question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Value defaults not committed to DOM

See original GitHub issue

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 with this.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!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lb-commented, Sep 2, 2022

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 :not([data-my-foo-value])).

Once you have default styles for when the value is not set - you don’t need to worry about default attribute setting.

0reactions
adrianguentercommented, Sep 2, 2022

@lb- That’s a good approach I hadn’t considered and should, in principle, suit my needs. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default value of state is not updated between renders
The default value is intentionally only used when the component mounts. That's what's meant by "default". After that, the only way to change ......
Read more >
Default properties values are not working · Issue #114 - GitHub
Description Default values are not being applied when a property has one specified and its corresponding attribute is not defined.
Read more >
Using CSS custom properties (variables) - MDN Web Docs
Custom property fallback values ... Using the var() function, you can define multiple fallback values when the given variable is not yet defined; ......
Read more >
Refs and the DOM - React
Refs provide a way to access DOM nodes or React elements created in the render ... By default, you may not use the...
Read more >
Lifecycle - Lit.dev
Use the element constructor for initializing LitElement properties with default values. (Attribute values from the DOM are not available when the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found