Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for shadowDom.adoptedStylesheets #3057

Closed
3 tasks done
Arvind6353 opened this issue Sep 13, 2021 · 3 comments
Closed
3 tasks done

feat: Add support for shadowDom.adoptedStylesheets #3057

Arvind6353 opened this issue Sep 13, 2021 · 3 comments
Labels

Comments

@Arvind6353
Copy link

Prequisites

Describe the Feature Request

Hi Team,

Add support for shadowDom.adoptedStylesheets

https://wicg.github.io/construct-stylesheets/

const shadowRoot = this.attachShadow({ mode: "open" });
shadowRoot.adoptedStyleSheets = [myElementSheet];

This gives an option to avoid duplicating css .

Describe the Use Case

In stencil, css is used as a string inside each component bundle. For css that gets reused across components, this css string is repeated in each component.

Using the https://wicg.github.io/construct-stylesheets/ approach , we can avoid duplicating the css if multiple components reuse some css.

Describe Preferred Solution

No response

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Sep 13, 2021
@dmartinjs
Copy link

I think it's already the case 🤔

For example, the CSS of my component rendered in shadowDOM
is showing constructed stylesheet in the devtools.

Capture d’écran 2021-09-13 à 14 24 48

more explanation about the information in chrome DevTools: https://developer.chrome.com/blog/css-in-js/

@johnjenkins
Copy link
Contributor

it's only a string in dev / unsupported browsers. In a prod build, it'll use constructed stylesheets

@Arvind6353
Copy link
Author

@johnjenkins @dmartinjs Thank you. I could see thats the case in the prod build. I was looking at the dev build.

https://wicg.github.io/construct-stylesheets/

Its working fine in Chrome browser. I suppose it is not supported yet in firefox. Do we have any pollyfills for that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants