Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't camelize attributes for plain elements #3750

Merged
merged 4 commits into from Nov 29, 2023

Conversation

rchl
Copy link
Collaborator

@rchl rchl commented Nov 22, 2023

Plain (native) elements should not have their props camelized as then the attribute names won't match the type definition if the element has those. For example path element defines type for the stroke-width attribute but since Volar "camelizes" the attribute name by default, it triggers type error due to strokeWidth not matching the stroke-width key.

I suppose the ElementTypes.ELEMENT type does not necessarily mean "native element" but hopefully it's close enough and correct to not camelize attributes by default for those elements.

@johnsoncodehk
Copy link
Member

I found that the type definition for SVGAttributes still has many props that are camelized (allowReorder, attributeName, attributeType, autoReverse...), and the current changes will not recognize those props.

Maybe we need to set a whitelist for the default value of vueCompilerOptions.htmlAttributes to solve this problem.

@rchl
Copy link
Collaborator Author

rchl commented Nov 29, 2023

I found that the type definition for SVGAttributes still has many props that are camelized (allowReorder, attributeName, attributeType, autoReverse...), and the current changes will not recognize those props.

Seems like that's how the spec intended. Notice that those are listed like that in https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute so the user should write them literally like that and Vue Volar should not do any transformations.

@johnsoncodehk
Copy link
Member

@rchl that makes sense, thanks!

@johnsoncodehk johnsoncodehk merged commit 1789690 into vuejs:master Nov 29, 2023
3 checks passed
@rchl rchl deleted the fix/camel-case-attr branch November 29, 2023 08:56
so1ve added a commit to so1ve/language-tools that referenced this pull request Dec 4, 2023
Co-authored-by: Ray <i@mk1.io>
Co-authored-by: Johnson Chu <johnsoncodehk@gmail.com>
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.

None yet

3 participants