-
Notifications
You must be signed in to change notification settings - Fork 228
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
Web component host reset #56
Comments
If I am reading this correctly, the issue descried above is discussing the use of the-new-css-reset within a component. It appears that it also can occur when using it in a page that is consuming a web component. For example, <script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js" />
<ion-icon name="heart" /> displays a heart inline, where as <link rel="stylesheet" href="https://unpkg.com/[email protected]/css/reset.css" />
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js" />
<ion-icon name="heart" /> displays a huge heart. |
Yep. Because use of the |
I too am running into this problem and its making it very difficult to even consider using this reset as a result. I wish there was a way to include the Anyone else find a way around this? The reset does a 90% good job for my design system needs but this is a big 10% problem |
This is also my experience. My workaround was to reset the relevant properties manually, e.g: ion-icon {
fill: currentcolor;
height: 1em;
width: 1em;
} |
I've been using this reset with web components (via LitElement). In doing so, I've found that the reset (both
unset: all
anddisplay: revert
) causes a lot of problems related to styling the:host
(shadow root) selector.Problem
Research suggests that the specificity for the
:host
selector is intended to make it act as the default style for a custom element. Therefore, it is expected to be overridden by any other styles.That places the shadow root in quite an awkward position following a reset. After all, the purpose of a reset is to strip browser styling. After that, any user-authored styling (including the defaults of custom elements) should be respected.
Solution
My solution is to add
display: contents !important
to the:host
selector in each component. Then, if a custom root is desired, it can be implemented as a separate class, applied to a container element (like adiv
).This solution is ideal in my case, because I don't like that shadow roots participate in the document layout in the first place; I prefer the pass-through behavior of React fragments (
<></>
).Related
Related external links:
The text was updated successfully, but these errors were encountered: