-
Notifications
You must be signed in to change notification settings - Fork 47
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
Styles bleed through #78
Comments
Oops, yeah - good point, thanks for finding this and reporting it. Bit swamped with work right now, so don't quite have time to fix this. What do you propose the solution is to this? |
The simplest solution I can think of is following the Vue approach with a slight change:
<article class="${articleHash}">
<h1 class="${articleHash} header">Article title</h1>
<section class="${articleHash} comments">
<article class="${commentHash}">
<h2 class="${commentHash} header">Comment title</h2>
</article>
<section>
</article> This way whenever you reference a "local" class, you need to add the hash. But to do this manually is still cumbersome and error-prone. Another solution is following the CSS Modules approach and rewriting classes:
<article class="${article.$host}">
<h1 class="${article.header}">Article title</h1>
<section class="${article.comments}">
<article class="${comment.$host}">
<h2 class="${comment.header}">Comment title</h2>
</article>
<section>
</article> With this approach the library needs to worry about case, because JavaScript does not support the
|
Example:
Comment header will be either red or blue, depending on the order of file inclusion. You can guard with
>
selectors, but this makes your CSS dependent on the exact DOM structure.Shadow DOM naturally does not suffer from this.
BEM does not suffer from this, due to using unique names.
CSS Modules does not suffer from this, due to rewriting all class names.
Vue implementation of scoped styles does not suffer from this, due to rewriting HTML too and using different prefixing technique (
<div class="header" _article-hash>
and.header[_article-hash]
).The text was updated successfully, but these errors were encountered: