Skip to content

Feat: Include data attributes in element path#177

Open
panrafal wants to merge 1 commit intobenjitaylor:mainfrom
panrafal:feat/data-path
Open

Feat: Include data attributes in element path#177
panrafal wants to merge 1 commit intobenjitaylor:mainfrom
panrafal:feat/data-path

Conversation

@panrafal
Copy link
Copy Markdown

Enhanced getElementPath() in package/src/utils/element-identification.ts to include data-* attributes when building the readable element path.

Many applications use data-testid, data-component or similar attributes to identify components. This is very often an easily grepable static text, so it's a good candidate for element locator, contrary to minified classes and tailwind markup.

As both user and a used UI library can add their data-* attributes, we're using the first and last one - to cover {...props} splats that are done before, or after lowe-level attributes.

Behavior

  • If an element has one data-* attribute, append it as [data-name="value"]
  • If an element has more than one, append the first and last as [data-first="v1"][data-last="v2"]
  • Elements with no data-* attributes are unchanged

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

@panrafal is attempting to deploy a commit to the Benji Taylor's Projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant