[go: nahoru, domu]

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

Selectors in ::slotted don’t change specificity #728

Closed
surma opened this issue Feb 4, 2018 · 4 comments
Closed

Selectors in ::slotted don’t change specificity #728

surma opened this issue Feb 4, 2018 · 4 comments

Comments

@surma
Copy link
surma commented Feb 4, 2018

Let’s say I have a custom element <my-elem>, that has the following shadow root markup:

<style>
  /* ... */
  ::slotted(main) {
    background-color: blue;
  }
  ::slotted(*) {
    background-color: red;
  }
</style>
<slot></slot>
<my-elem>
  <div>DIV!</div>
  <main>MAIN!</main>
  <aside>ASIDE!</aside>
</my-elem>

I’d argue most authors would expect <main> to have a blue background color, but it is in fact red. It seems the selectors passed to ::slotted() don’t affect specificity. So precedence is defined by order of declaration.

Was this intentional? If so, why? If not, is it changeable?

(Live demo, code)

@emilio
Copy link
emilio commented Feb 4, 2018

I think per spec pseudo-elements are only counted when computing specificity (there's no special rule for ::slotted):

https://drafts.csswg.org/selectors-4/#specificity-rules

That being said there are already other issues with specificity css-scoping selectors, and also of selectors that allow more than one argument: w3c/csswg-drafts#2158, w3c/csswg-drafts#1027, w3c/csswg-drafts#1915.

It'd be nice to get this part of the spec properly defined to match both reality and / or what authors expect...

@annevk
Copy link
Collaborator
annevk commented Feb 4, 2018

It's probably best to file this against w3c/csswg-drafts, especially now Selectors is getting some editor attention. This is not really something that this repository can solve.

@surma
Copy link
Author
surma commented Feb 4, 2018

Understood.

@surma surma closed this as completed Feb 4, 2018
@surma
Copy link
Author
surma commented Feb 4, 2018

Continued in w3c/csswg-drafts#2271

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

No branches or pull requests

3 participants