-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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(custom-element): reflect prop default value #10537
Conversation
Size ReportBundles
Usages
|
I’m pretty sure if you’ll set an attribute (setProp-> reflect attr) inside of the constructor, real browser will throw an exception :( |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
I think we may need to make a distinction between properties and attributes here. The original issue was specifically about properties, not attributes. I think having default prop values reflected in the properties of the element make sense, but I'm not so sure about the attributes. I've had a look through some resources about custom elements, but I can't find anything that describes what's expected for property defaults. There's a recommendation that calls to For native elements, a default value for a property doesn't lead to an attribute being set. For example, consider a I suspect exposing the defaults as attributes could cause problems for SSR too. The hydration process won't be expecting those extra attributes to be present. I haven't actually verified whether this is problem in practice, as there's a lot of stuff that needs setting up to test it, but it isn't just Vue's hydration process that might be impacted, it could also impact hydration in other frameworks that are trying to use a Vue-based custom element. |
Superseded by 63689ed @skirtles-code that seems to be a separate topic from this PR - the current behavior of Vue custom elements always reflect declared props as attribute if it has a value, so this PR (and by extension 63689ed) just aligns default values with that behavior. |
close #9006