Skip to content

Commit ca0d37e

Browse files
committed
[selectors] Define proper absolutizing rules for scope-relative selectors.
1 parent a7e4754 commit ca0d37e

2 files changed

Lines changed: 63 additions & 3 deletions

File tree

selectors/Overview.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ <h2 class="no-num no-toc" id=contents>Table of Contents</h2>
197197

198198
<li><a href="#scoping"><span class=secno>3.3. </span> Scoped
199199
Selectors</a>
200+
<ul class=toc>
201+
<li><a href="#absolutizing"><span class=secno>3.3.1. </span>
202+
Absolutizing a Scope-relative Selector</a>
203+
</ul>
200204

201205
<li><a href="#pseudo-classes"><span class=secno>3.4. </span>
202206
Pseudo-classes</a>
@@ -1334,10 +1338,14 @@ <h3 id=scoping><span class=secno>3.3. </span> Scoped Selectors</h3>
13341338
href="#scope-pseudo"><code>:scope</code></a> " (the <a
13351339
href="#scope-pseudo"><code>:scope</code></a> pseudo-class followed by a
13361340
space) is implied at the beginning of each <a href="#complex"><i>complex
1337-
selector</i></a>, allowing them to begin syntactically with a <a
1341+
selector</i></a> that does not already contain the <a
1342+
href="#scope-pseudo"><code>:scope</code></a> pseudo-class. This allows
1343+
the selector to begin syntactically with a <a
13381344
href="#combinator"><i>combinator</i></a>. The scoping element matches
13391345
this implied <a href="#scope-pseudo"><code>:scope</code></a> selector,
13401346
but does not limit which elements match.
1347+
<p> Scope-relative selectors must be <a href=absolutize>absolutized</a>
1348+
before using them for matching.
13411349
</dl>
13421350

13431351
<div class=example>
@@ -1354,6 +1362,30 @@ <h3 id=scoping><span class=secno>3.3. </span> Scoped Selectors</h3>
13541362
href="#scope-contained"><i>scope-contained</i></a> selectors.
13551363
</div>
13561364

1365+
<h4 id=absolutizing><span class=secno>3.3.1. </span> Absolutizing a
1366+
Scope-relative Selector</h4>
1367+
1368+
<p> To <dfn id=absolutize>absolutize a scope-relative selector</dfn>:
1369+
1370+
<ol>
1371+
<li> If the selector starts with a <a
1372+
href="#combinator"><i>combinator</i></a> other than the <a
1373+
href="#descendant-combinator"><i>descendant combinator</i></a>, prepend
1374+
<a href="#scope-pseudo"><code>:scope</code></a> as the initial <a
1375+
href="#compound"><i>compound selector</i></a>.
1376+
1377+
<li> Otherwise, if the selector does not contain any instance of the <a
1378+
href="#scope-pseudo"><code>:scope</code></a> pseudo-class (either at the
1379+
top-level or as an argument to a functional pseudo-class), prepend <a
1380+
href="#scope-pseudo"><code>:scope</code></a> followed by the <a
1381+
href="#descendant-combinator"><i>descendant combinator</i></a>.
1382+
1383+
<li> Otherwise, the selector is already absolute.
1384+
</ol>
1385+
1386+
<p> To <dfn id=absolutize-list>absolutize a scope-relative selector
1387+
list</dfn>, absolutize each scope-relative selector in the list.
1388+
13571389
<h3 id=pseudo-classes><span class=secno>3.4. </span> Pseudo-classes</h3>
13581390

13591391
<p>The <dfn id=pseudo-class>pseudo-class</dfn> concept is introduced to

selectors/Overview.src.html

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,14 @@ <h3 id="scoping">
659659
<dd>
660660
With this method of scoping,
661661
"<code>:scope</code> " (the <code>:scope</code> pseudo-class followed by a space)
662-
is implied at the beginning of each <i>complex selector</i>,
663-
allowing them to begin syntactically with a <i>combinator</i>.
662+
is implied at the beginning of each <i>complex selector</i>
663+
that does not already contain the <code>:scope</code> pseudo-class.
664+
This allows the selector to begin syntactically with a <i>combinator</i>.
664665
The scoping element matches this implied <code>:scope</code> selector,
665666
but does not limit which elements match.
667+
668+
<p>
669+
Scope-relative selectors must be <a href="absolutize">absolutized</a> before using them for matching.
666670
</dl>
667671

668672
<div class='example'>
@@ -678,6 +682,30 @@ <h3 id="scoping">
678682
define <i>scope-contained</i> selectors.
679683
</div>
680684

685+
<h4 id='absolutizing'>
686+
Absolutizing a Scope-relative Selector</h4>
687+
688+
<p>
689+
To <dfn id='absolutize'>absolutize a scope-relative selector</dfn>:
690+
691+
<ol>
692+
<li>
693+
If the selector starts with a <i>combinator</i> other than the <i>descendant combinator</i>,
694+
prepend <code>:scope</code> as the initial <i>compound selector</i>.
695+
696+
<li>
697+
Otherwise, if the selector does not contain any instance of the <code>:scope</code> pseudo-class
698+
(either at the top-level or as an argument to a functional pseudo-class),
699+
prepend <code>:scope</code> followed by the <i>descendant combinator</i>.
700+
701+
<li>
702+
Otherwise, the selector is already absolute.
703+
</ol>
704+
705+
<p>
706+
To <dfn id='absolutize-list'>absolutize a scope-relative selector list</dfn>,
707+
absolutize each scope-relative selector in the list.
708+
681709

682710
<h3 id="pseudo-classes">
683711
Pseudo-classes</h3>

0 commit comments

Comments
 (0)