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
If render() returns undefined at the point where it is attached the static get styles() attribute is still called but never gets added to the shadow root.
If this control is attached to the DOM and then thingToRender is set render() calls as expected and populates the HTML, but the styles are never added.
Returning empty content appears to workaround this:
render() {
if(!this.thingToRender)
return html``;
So another option would be to update the documentation to state that render() should never return undefined.
Expected Results
Either the styles should be added on attach, or if skipped because no content it should be added after the first render() that contains content.
Actual Results
Styles are not added to the component.
Browsers Affected
I don't think this is browser specific.
Versions
lit-element: v2.0.1
webcomponents: v2.2.7
The text was updated successfully, but these errors were encountered:
Description
If
render()
returnsundefined
at the point where it is attached thestatic get styles()
attribute is still called but never gets added to the shadow root.Live Demo
https://stackblitz.com/edit/lit-element-example-debgxe?embed=1&file=index.js
Steps to Reproduce
The problem happens when you have a control that you don't want to render anything when properties are not set, for instance:
If this control is attached to the DOM and then
thingToRender
is setrender()
calls as expected and populates the HTML, but the styles are never added.Returning empty content appears to workaround this:
So another option would be to update the documentation to state that
render()
should never returnundefined
.Expected Results
Either the styles should be added on attach, or if skipped because no content it should be added after the first
render()
that contains content.Actual Results
Styles are not added to the component.
Browsers Affected
I don't think this is browser specific.
Versions
The text was updated successfully, but these errors were encountered: