[csswg-drafts] [css-scoping-1] Matching of complex selectors containing host selectors is underspecified

bicknellr has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-scoping-1] Matching of complex selectors containing host selectors is underspecified ==
I was trying to determine why a host selector, when used in a complex selector such as `:host > *`, is able to match any element. Both Chrome and Safari (which have native Shadow DOM implementations) have the behavior that a complex selector containing a host selector matches elements as if the host element was at the root of the shadow tree, even though this is not the case because the host's ShadowRoot is the root of it's shadow tree.

Particularly, the host selectors are specified here as matching the 'shadow tree's shadow host':
https://www.w3.org/TR/css-scoping-1/#host-selector

Also, the combinators don't appear to reference Shadow DOM in any way:
https://drafts.csswg.org/selectors-4/#combinators
.. and the CSS Scoping spec doesn't include any extension to combinators as far as I'm aware.

Given those two things, it doesn't seem like a complex selector containing a host selector, as specified, could match anything: the combinators only describe relationships within in the same tree and the host selectors all only match the host element, which is outside of the tree that any other compound selector could match elements from. I think that the CSS Scoping spec needs additional text explaining this behavior. Maybe it would be sufficient to claim that the host specifiers, when used in a complex selector, match the ShadowRoot instead? (Without changing the behavior that the arguments to `:host()` and `:host-context()` are tested against the host itself.)

---
The reason I bring this up is because, if it is the case that Chrome and Safari's behavior is intended to be correct, then Chrome has a bug where this selector does not apply to `<svg>` elements that are children of ShadowRoots of hosts which are HTML elements:
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/css/svg.css?l=82&rcl=39f9c2980aef108b8602622e5a104b3c5ec567ae

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2242 using your GitHub account

Received on Tuesday, 30 January 2018 19:39:48 UTC