-
Notifications
You must be signed in to change notification settings - Fork 423
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
Value defaults not committed to DOM #580
Comments
Just curious why you need this? I've always resolved that the defaults are there for when there is no explicit value set. This would potentially impact some performance for larger sets of default values. Also it would trigger false positives on valueChanged callbacks. |
Hey @adrianguenter, thanks for opening this issue! I remember thinking about this while implementing #350. The reason why I opted not to write the default Values to the DOM was to make sure that the What's your use case for this? Do you need to read the attributes from somewhere else? The thing we need to think about is "does having a default value mean that we have a value"? |
Thanks for the input! My use case is that I drive CSS with these attributes, and therefore need the default values to be reflected in the DOM. |
Even if you do set the value in JS on load - this approach could cause a flash of the unstyled (no data attribute) content. Hence you would be best to add the default styles case in your css (e.g. element Once you have default styles for when the value is not set - you don't need to worry about default attribute setting. |
@lb- That's a good approach I hadn't considered and should, in principle, suit my needs. Thank you! |
Would it make sense to always write value defaults to their respective DOM attributes when the controller loads, as is done on write to a value property? I currently have to remember to explicitly write them in
connect
withthis.someValue = this.constructor.values.some.default
for every such value to achieve this behavior.If this feature is desired I'd be happy to implement it. Thanks!
The text was updated successfully, but these errors were encountered: