-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
This amazing property added in #3620 for #3604 is extremely helpful and we could not be more appreciative of this feature!
I think it could be taken to the next level in our use cases by changing it to an array. In large, evolving code bases, elements might not have one single, consistent attribute to choose from and therefore it could be helpful to have a list.
For example,
dom: {
serializeAttribute: [
'data-testid', // all our good devs using react-testing library
'aria-label', // attempt to fallback on something recognizable
],
}
...
then something like,
// packages/utils/src/browser.ts
- const keyAttrValue = keyAttr ? elem.getAttribute(keyAttr) : null;
+ const keyAttrValue = Array.isArray(keyAttr) && keyAttr.length
+ ? elem.getAttribute(keyAttr.find(attr => elem.hasAttribute(attr)))
+ : null;
Thanks!