Elements with styled shadowRoots are rendered incorrectly when prepareTemplate is called lazily
sorvell opened this issue · 0 comments
sorvell commented
The setup is a little arcane but this can happen when:
- a custom element
x-foo
is defined and creates a shadowRoot but doesn't render anything to it and does not yet callShadyCSS.prepareTemplate
(e.g. a LitElement initially hasshouldRender: false
). - another element up the tree calls
ShadyCSS.styleSubtree()
. This will create style information forx-foo
that references no styles. - then
ShadyCSS.prepareTemplate
is called forx-foo
(e.g. itsshouldRender
becomes true and it renders the first time) - then any call to
ShadyCSS.styleElement
forx-foo
will not contain this new styling.
To address this, perhaps at https://github.com/webcomponents/shadycss/blob/master/src/scoping-shim.js#L151 we can only actually store the styleInfo
if prepareTemplate
has been called for this scope.