Closed khrise closed 6 days ago
Hi @khrise,
This was a misinterpretation of the problem, as css vars in :root can penetrate the shadow DOM you can review this example. https://stackblitz.com/edit/stackblitz-starters-mynw5x?file=index.html
I if you can share an example, I can review your issue?
Thanks for your reply. Yes, if a variable is declared in the containing website, it's available in the shadow dom. However, a web component in a shadow dom seems not to be allowed to define things for the :root
scope.
I modified your stackblitz to reflect my situation. Note the :root
declaration is in the web component.
https://stackblitz.com/edit/stackblitz-starters-h9dgpl?file=index.html
This is true, but the question is why not to keep :root outside the web-component
Because I can't. In my case, the whole point of exposing a web component is to be able to embed it into an arbitrary website, like a widget. I don't control the surrounding website. Neither do I want to require the surrounding website to load an additional stylesheet in its root. I want (and need) the web component to be completely self-contained.
Alrighty I'll add a dedicated feature for this use case
Finally, I could take some time to add this feature, users now have the option to replace the injected CSS :root
to :host
you can see this example. https://stackblitz.com/~/github.com/EranGrin/bootstrap-demo-webcomponent?file=package.json
Hi @khrise I would like to close this issue, let me know if you have any thoughts
That's great news, thanks! I'm on vacation right now, I won't be able to check this out until next week. Cheers
Hi @khrise just flowing up on this, did you have a chance to check this, can we close the issue?
Sorry it took so long to respond. I checked the new flag and it works like a charm! Thanks a lot for your effort!
In this post, you introduced a mechanism to replace all occurrences of
:root
with:host
.You removed this feature later on with the comment
Rollback changes with :root replacement as most use cases are for css variables and this does work web components
. Could you elaborate on that, please? In my web components, I use a component library (telekom-scale), which provides css-variables in:root
-manner. I cannot access any of these variables in my web components when usingvue-web-component-wrapper
. If I monkey-patch the variable declaration from:root
to:host
, it works. So, I would really like this feature back. Or am I missing something?