Skip to content

Commit 5b26007

Browse files
committed
Whoops, didn't realize fantasai had already added a scoped selector section, and it's better. Moved the example I wrote up into it, and deleted the rest of my section.
--HG-- extra : rebase_source : 29e77465aac1d3495ba20cff1b385a06d2d4c55f
1 parent 0681ac7 commit 5b26007

2 files changed

Lines changed: 30 additions & 93 deletions

File tree

selectors4/Overview.html

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ <h2 class="no-num no-toc" id=contents>Table of Contents</h2>
183183

184184
<li><a href="#invalid"><span class=secno>3.8. </span> Invalid Selectors
185185
and Error Handling</a>
186-
187-
<li><a href="#selector-scoping"><span class=secno>3.9. </span> Selector
188-
Scoping</a>
189186
</ul>
190187

191188
<li><a href="#logical-combination"><span class=secno>4. </span> Logical
@@ -1236,6 +1233,21 @@ <h3 id=scoping><span class=secno>3.3. </span> Scoped Selectors</h3>
12361233
set</i></a> and can be selected with the <a
12371234
href="#scope-pseudo"><code>:scope</code></a> pseudo-class.
12381235

1236+
<div class=example>
1237+
<p> The <code>document.querySelector()</code> function defined in <a
1238+
href="#SELECTORS-API2"
1239+
rel=biblioentry>[SELECTORS-API2]<!--{{SELECTORS-API2}}--></a> allows the
1240+
author to define a <a
1241+
href="#scope-constrained"><i>scope-constrained</i></a> selector.
1242+
1243+
<p> On the other hand, the <code>document.find()</code> function defined
1244+
in <a href="#SELECTORS-API2"
1245+
rel=biblioentry>[SELECTORS-API2]<!--{{SELECTORS-API2}}--></a> and the
1246+
selectors within a scoped stylesheet, defined in <a href="#HTML5"
1247+
rel=biblioentry>[HTML5]<!--{{HTML5}}--></a>, define <a
1248+
href="#scope-contained"><i>scope-contained</i></a> selectors.
1249+
</div>
1250+
12391251
<h3 id=pseudo-classes><span class=secno>3.4. </span> Pseudo-classes</h3>
12401252

12411253
<p>The <dfn id=pseudo-class>pseudo-class</dfn> concept is introduced to
@@ -1374,50 +1386,6 @@ <h3 id=invalid><span class=secno>3.8. </span> Invalid Selectors and Error
13741386
that the last rule be dropped in favor of Media Queries-style
13751387
error-handling.
13761388

1377-
<h3 id=selector-scoping><span class=secno>3.9. </span> Selector Scoping</h3>
1378-
1379-
<p> In some instances, selectors may be "scoped", or limited in some way to
1380-
apply only within a section of the document.
1381-
1382-
<p> There are two distinct ways in which selectors can be scoped:
1383-
1384-
<dl>
1385-
<dt><dfn id=scope-contained0>scope-contained</dfn>
1386-
1387-
<dd> When a selector is <a
1388-
href="#scope-contained0"><i>scope-contained</i></a>, it matches as if the
1389-
elements outside of its scope did not exist. In other words, it acts like
1390-
the scope defines a sub-document within which the selector is matched.
1391-
1392-
<dt><dfn id=scope-limited>scope-limited</dfn>
1393-
1394-
<dd> When a selector is <a href="#scope-limited"><i>scope-limited</i></a>,
1395-
it only matches if the target is within the scope. The rest of the
1396-
document is still acknowledged and can match all but the last part of the
1397-
selector; only the target (the element matched by the last compound
1398-
selector in the selector) is required to be within the scope.
1399-
</dl>
1400-
1401-
<div class=example>
1402-
<p> The <code>document.querySelector()</code> function defined in <a
1403-
href="#SELECTORS-API2"
1404-
rel=biblioentry>[SELECTORS-API2]<!--{{SELECTORS-API2}}--></a> allows the
1405-
author to define a <a href="#scope-limited"><i>scope-limited</i></a>
1406-
selector.
1407-
1408-
<p> On the other hand, the <code>document.find()</code> function defined
1409-
in <a href="#SELECTORS-API2"
1410-
rel=biblioentry>[SELECTORS-API2]<!--{{SELECTORS-API2}}--></a> and the
1411-
selectors within a scoped stylesheet, defined in <a href="#HTML5"
1412-
rel=biblioentry>[HTML5]<!--{{HTML5}}--></a>, define <a
1413-
href="#scope-contained0"><i>scope-contained</i></a> selectors.
1414-
</div>
1415-
1416-
<p> Both kinds of scoping define a <a
1417-
href="#contextual-reference-element-set"><i>contextual reference element
1418-
set</i></a>, which can be matched with the <a
1419-
href="#scope-pseudo"><code>:scope</code></a> pseudo-class selector.
1420-
14211389
<h2 id=logical-combination><span class=secno>4. </span> Logical
14221390
Combinations</h2>
14231391

selectors4/Overview.src.html

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ <h3 id="scoping">
580580
<p>Some host applications may choose to <dfn>scope</dfn> selectors
581581
to a particular subtree of the document.
582582
There are two methods of doing this:
583+
583584
<dl>
584585
<dt><dfn>scope-contained</dfn> selectors
585586
<dd>
@@ -588,17 +589,31 @@ <h3 id="scoping">
588589
all <i>compound selectors</i> must match elements within the scope.
589590
(The <code>:root</code> pseudo-class, however,
590591
still only matches the actual root of the document.)
592+
591593
<dt><dfn>scope-constrained</dfn> selectors
592594
<dd>
593595
With this method of scoping, a selector matches if
594596
the <i>subject</i> of the selector is within the scope,
595597
even if other components of the selector are outside the scope.
596598
</dl>
599+
597600
<p>The root of the scoping subtree is called the <dfn>scoping element</dfn>
598601
and is in-scope.
599602
When scoped selectors are used, it forms the <i>contextual reference element set</i>
600603
and can be selected with the <code>:scope</code> pseudo-class.
601604

605+
<div class='example'>
606+
<p>
607+
The <code>document.querySelector()</code> function defined in [[SELECTORS-API2]]
608+
allows the author to define a <i>scope-constrained</i> selector.
609+
610+
<p>
611+
On the other hand, the <code>document.find()</code> function defined in [[SELECTORS-API2]]
612+
and the selectors within a scoped stylesheet, defined in [[HTML5]],
613+
define <i>scope-contained</i> selectors.
614+
</div>
615+
616+
602617
<h3 id="pseudo-classes">
603618
Pseudo-classes</h3>
604619

@@ -732,52 +747,6 @@ <h3 id="invalid">
732747
that the last rule be dropped in favor of Media Queries-style error-handling.</p>
733748

734749

735-
<h3 id='selector-scoping'>
736-
Selector Scoping</h3>
737-
738-
<p>
739-
In some instances,
740-
selectors may be "scoped",
741-
or limited in some way to apply only within a section of the document.
742-
743-
<p>
744-
There are two distinct ways in which selectors can be scoped:
745-
746-
<dl>
747-
<dt><dfn>scope-contained</dfn>
748-
<dd>
749-
When a selector is <i>scope-contained</i>,
750-
it matches as if the elements outside of its scope did not exist.
751-
In other words,
752-
it acts like the scope defines a sub-document within which the selector is matched.
753-
754-
<dt><dfn>scope-limited</dfn>
755-
<dd>
756-
When a selector is <i>scope-limited</i>,
757-
it only matches if the target is within the scope.
758-
The rest of the document is still acknowledged
759-
and can match all but the last part of the selector;
760-
only the target
761-
(the element matched by the last compound selector in the selector)
762-
is required to be within the scope.
763-
</dl>
764-
765-
<div class='example'>
766-
<p>
767-
The <code>document.querySelector()</code> function defined in [[SELECTORS-API2]]
768-
allows the author to define a <i>scope-limited</i> selector.
769-
770-
<p>
771-
On the other hand, the <code>document.find()</code> function defined in [[SELECTORS-API2]]
772-
and the selectors within a scoped stylesheet, defined in [[HTML5]],
773-
define <i>scope-contained</i> selectors.
774-
</div>
775-
776-
<p>
777-
Both kinds of scoping define a <i>contextual reference element set</i>,
778-
which can be matched with the <code>:scope</code> pseudo-class selector.
779-
780-
781750

782751
<h2 id="logical-combination">
783752
Logical Combinations</h2>

0 commit comments

Comments
 (0)