webcomponents / polyfills

Web Components Polyfills
BSD 3-Clause "New" or "Revised" License
1.14k stars 165 forks source link

[ShadyCSS] Integration with Lit/HyperHtml - Dynamic Class Interpolation #18

Open egucciar opened 6 years ago

egucciar commented 6 years ago

We discovered an issue today in our application where we use hyperHtml and shadyCss extensively and successfully. We used a variable that changes dynamically over time to apply a class to a dom Element. When the class is updated, ShadyCSS styles are unfortunately cleared off.

My question here is - how do i force shadyCSS to re-apply styles to an element it thinks it has styled? I have tried the suspects - styleElement, styleSubtree and styleDocument but I believe there has to be some mechanism preventing shadyCSS from restyling certain elements. Any ideas what we could do better or differently here?

Our current workaround is not to use hyperHtml interpolation to set classes in the instance we discovered it, but we are wondering how this can be handled on a larger scale

haugthom commented 6 years ago

We have the same issue. We added an own helper method to re-apply "style-scope" and the tag name class "my-element" (e.g).

Example:

At the end this method returns the different class names plus "style-scope" and "my-element".

But this is not really a solution.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.