-
Notifications
You must be signed in to change notification settings - Fork 659
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
[css-shadow-parts][css-nesting] is & allowed after ::part() #10788
Comments
Based on this test: <!DOCTYPE HTML>
<style>
#host {
padding: 3px;
width: fit-content;
}
#host::part(p):hover {
color: green;
}
:hover {
#host& {
background: aqua;
}
#host::part(p)& {
background: lime;
}
}
</style>
<div id="host">
</div>
<script>
let shadow = document.getElementById("host").attachShadow({mode: "open"});
shadow.innerHTML = `<div part="p">this is the part, hover me</div>`;
</script> this currently doesn't work in any of Chromium, Gecko, or WebKit. |
According to this comment, |
Yeah, per grammar that's not currently allowed. I don't see a big reason to disallow it, tho, since it's morally equivalent to an |
The CSS Working Group just discussed
The full IRC log of that discussion<dholbert> dbaron: this is getting into fun stuff that I don't have strong opinions about, mixing multiple new features<dholbert> dbaron: is the & selector after ::part? <dholbert> dbaron: we have restrictions saying these selectors are allowed, these aren't (after ::part) <kbabbitt> s/selector after/selector allowed after/ <dholbert> dbaron: should we allow the nesting & selector after part, when it is a selector and is after part, or not <fantasai> https://github.com//issues/10788#issuecomment-2329279090 <dholbert> fantasai: I'd go with "no" per this comment^ <dholbert> fantasai: we do allow ::is but with restrictions, IIRC <dholbert> fantasai: the & is pulling in a whole type-selector ... Unless we're wanting to allow type-selector, I don't think it makes sense to allow & <dholbert> fantasai: proposed resolution: no change to spec, & is not allowed after ::part <dholbert> RESOLVED: No change to spec. & is not allowed after ::part |
I'd like to revisit this. I'm fine if we do end up keeping the resolution, but from the minutes it doesn't look like it was argued very well. The only real comment aside from dbaron's introduction was referring to a comment about the current state of the grammar, and didn't reference my response to that comment. My point is that |
I just ran into this. This works: sl-month-view::part(finish) {
background: var(--sl-color-success-plain);
border-radius: 50%;
color: var(--sl-color-text-inverted);
}
sl-month-view::part(finish):hover {
background: var(--sl-color-success-bold);
} This doesn't: sl-month-view::part(finish) {
background: var(--sl-color-success-plain);
border-radius: 50%;
color: var(--sl-color-text-inverted);
&:hover {
background: var(--sl-color-success-bold);
}
} This is totally not obvious to me (let alone a web dev who does not read csswg issues on github). |
@jpzwarte the example in #10788 (comment) is not what this issue is about. This issue is about whether you're allowed to write a single selector that contains |
I think your issue is #9702. |
(That said, there are some comments in #9702 that suggest that |
I don't think it's clear whether the
&
selector is allowed after the::part()
pseudo-element. At least, I read what I think are the relevant specs and I couldn't find any wording that gives me a clear answer.For example, is the following CSS:
equivalent to:
or is it invalid?
The text was updated successfully, but these errors were encountered: