Skip to content

Commit c4b82a8

Browse files
committed
[css-scoping-1] Define the specificity of :host/etc, per WG resolution. Closes w3c#1915.
1 parent 38653b9 commit c4b82a8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

css-scoping-1/Overview.bs

+21-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:html; type:element; text:style
2525
spec:selectors-4; type:dfn;
2626
text: static profile
2727
text: dynamic profile
28-
spec:css-pseudo-4; type:selector;
28+
spec:css-pseudo-4; type:selector;
2929
text:::before
3030
text:::after
3131
spec:cascade-4; type:dfn; text: inherit
@@ -263,6 +263,20 @@ Selecting Into the Light: the '':host'', '':host()'', and '':host-context()'' ps
263263
In any other context,
264264
it matches nothing.
265265

266+
The [=specificity=] of '':host'' is that of a pseudo-class.
267+
The [=specificity=] of '':host()'' is that of a pseudo-class,
268+
plus the [=specificity=] of its argument.
269+
270+
Note: This is different from the specificity of similar pseudo-classes,
271+
like '':matches()'' or '':not()'',
272+
which <em>only</em> take the specificity of their argument.
273+
This is because '':host'' is affirmatively selecting an element all by itself,
274+
like a "normal" pseudo-class;
275+
it takes a selector argument for syntactic reasons
276+
(we can't say that '':host.foo'' matches but ''.foo'' doesn't),
277+
but is otherwise identical
278+
to just using '':host'' followed by a selector.
279+
266280
<div class='example'>
267281
For example, say you had a component with a <a>shadow tree</a> like the following:
268282

@@ -310,6 +324,9 @@ Selecting Into the Light: the '':host'', '':host()'', and '':host-context()'' ps
310324
In any other context,
311325
it matches nothing.
312326

327+
The [=specificity=] of '':host-context()'' is that of a pseudo-class,
328+
plus the [=specificity=] of its argument.
329+
313330
Note: This means that the selector pierces through shadow boundaries on the way up,
314331
looking for elements that match its argument,
315332
until it reaches the document root.
@@ -348,6 +365,9 @@ Selecting Slot-Assigned Content: the ''::slotted()'' pseudo-element</h4>
348365
like ''::slotted()::before'',
349366
representing the appropriate pseudo-element of the elements represented by the ''::slotted()'' pseudo-element.
350367

368+
The [=specificity=] of ''::slotted()'' is that of a pseudo-element,
369+
plus the [=specificity=] of its argument.
370+
351371
<div class="example">
352372
For example, say you had a component with both children and a shadow tree,
353373
like the following:

0 commit comments

Comments
 (0)