You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
defineCustomElement can accidentally override members of the Element prototype #12124
I defined a Vue component with tagName as a property, and used that, together with defineCustomElement to define the hello-world webcomponent.
tagName is obviously already defined in the Element prototype.
What is expected?
I expected to maybe be able to create only the tag-name attribute (and no matching tagName property), or a warning that I'm accidentally overwriting important Element properties. Or a way to remap the tag-name attribute to a different property.
What is actually happening?
Vue's defineCustomElement happily overwrites the tagName property of the Element prototype without warning.
I know this is user error, but I was surprised that Vue let me.
System Info
No response
Any additional comments?
In Lit, you can be explicit about what property/attribute something maps to, that would be super cool here too:
We managed to put us in a situation where the attribute (which is not problematic) is causing issues because Vue generated an override for the tagName property (which is problematic), while we don't use that often.
Activity
edison1105 commentedon Oct 8, 2024
If your code relies on
tagName, maybe you can usenodeNameinsteadfix(custom-element): warn when props override native properties (vuej…