Skip to content

Conversation

@thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Oct 16, 2025

Fixes #409

A regex like /.*-class/ was matching :custom-class in Vue files but considered it a static attribute. This is incorrect.

The current implementation was based on a previous version where it built up attribute lists for fast Set-based matching. But really the rules for the parser should just be encoded directly as Vue and Angular have fairly specific rules about which attributes are dynamic vs. static.

This tweaks things to encode those rules directly and fixes the above as a result.

Some of these would’ve caught a bug if written correctly 🤦‍♂️
Dynamic attribute names have definite rules in Vue and Angular. Testing those rules directly and matching the actual “name” portion against the regex is a better option.
if (parser === 'vue') {
if (name.startsWith(':')) return name.slice(1)
if (name.startsWith('v-bind:')) return name.slice(7)
if (name.startsWith('v-')) return name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to slice until the = or :?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, the parser has already split the name and value and this only matches against the name.

As for the : I think that is only useful with v-bind. Can always change this in the future if we need to.

@thecrypticace thecrypticace merged commit 42aca0c into main Oct 16, 2025
1 check passed
@thecrypticace thecrypticace deleted the fix/issue-409 branch October 16, 2025 16:05
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.

Attribute regex breaks prettier linting

3 participants