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

Encapsulated CSS specificity bug #1277

Closed
Rich-Harris opened this issue Mar 26, 2018 · 1 comment · Fixed by #4146
Closed

Encapsulated CSS specificity bug #1277

Rich-Harris opened this issue Mar 26, 2018 · 1 comment · Fixed by #4146
Labels

Comments

@Rich-Harris
Copy link
Member

This is possibly a bit of an edge case, and it's something that can easily be worked around, but it's a bug nonetheless:

https://gist.github.com/giuseppeg/d37644d8d9d5004b15c5c48e66f632aa

<div>
  <div>
    <div>
      <span>
        Big red Comic Sans
      </span>
      <span class='foo'>
        Big red Comic Sans
      </span>
    </div>
  </div>
</div>

<style>
  div div div span {
    color: red;
    font-size: 2em;
    font-family: 'Comic Sans MS';
  }
  .foo {
    color: green;
  }
</style>

In this example, the second span should be green (because classes override element selectors), but because Svelte transforms it to...

<style>
  div.svelte-xyz div div span.svelte-xyz {
    color: red;
    font-size: 2em;
    font-family: 'Comic Sans MS';
  }
  .foo.svelte-xyz {
    color: green;
  }
</style>

...the first declaration defeats the second one.

One possible solution is to double up single selectors:

.foo.svelte-xyz.svelte-xyz {
  color: green;
}

See thysultan/stylis#101. Thanks to @giuseppeg for flagging this up

@arxpoetica
Copy link
Member

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

Successfully merging a pull request may close this issue.

3 participants