shadycss
shadycss copied to clipboard
Elements with styled shadowRoots are rendered incorrectly when prepareTemplate is called lazily
The setup is a little arcane but this can happen when:
- a custom element
x-foois 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-foothat references no styles. - then
ShadyCSS.prepareTemplateis called forx-foo(e.g. itsshouldRenderbecomes true and it renders the first time) - then any call to
ShadyCSS.styleElementforx-foowill 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.