-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Apply CSS reset inside shadow roots #1195
Comments
I have a better solution: This is my application in an actual project, and it works well on Reddit when used with Reference:https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/ |
Great links, thanks! I mentioned Warning note that setting Not sure what are considered "custom" properties in this case, but something to try and figure out. |
Yeah, so @molvqingtai In your case, However, I was able to find something that worked: Set const resetStylesheet = new CSSStyleSheet({});
resetStylesheet.replaceSync(`
/* WXT Shadow Root Reset */
body {
all: initial;
}
`);
shadow.adoptedStyleSheets = [resetStylesheet]; Can confirm it properly reset's Reddit's |
OK, this works for Chrome and Firefox: const resetCss = `/* WXT Shadow Root Reset */
body {
all: initial;
}`;
const resetStyle = document.createElement("style");
resetStyle.id = "wxt-shadow-root-reset";
resetStyle.innerHTML = resetCss;
shadow.querySelector("head")?.append(resetStyle); I could have sworn I tried this in the past... |
OK, so yeah, resets everything but REM units. We can leave that up to the postcss plugins. Also, order doesn't matter - I can add the style block before or after the content script's CSS 🤔 |
Feature Request
On discord, someone reported a general solution to resetting the few CSS properties that leak into shadow roots.
Is your feature request related to a bug?
https://discord.com/channels/1212416027611365476/1307764582969905295/1307764582969905295
What are the alternatives?
Manually setting the value of each style.
Additional context
Gonna get this added in v0.20 as a breaking change if it works.
The text was updated successfully, but these errors were encountered: