Skip to content

[Feature] Change new serializeAttribute option in breadcrumbs to an array #3738

@CopyJosh

Description

@CopyJosh

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!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions