@@ -183,6 +183,9 @@ <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 >
186189 </ ul >
187190
188191 < li > < a href ="#logical-combination "> < span class =secno > 4. </ span > Logical
@@ -1367,6 +1370,50 @@ <h3 id=invalid><span class=secno>3.8. </span> Invalid Selectors and Error
13671370 that the last rule be dropped in favor of Media Queries-style
13681371 error-handling.
13691372
1373+ < h3 id =selector-scoping > < span class =secno > 3.9. </ span > Selector Scoping</ h3 >
1374+
1375+ < p > In some instances, selectors may be "scoped", or limited in some way to
1376+ apply only within a section of the document.
1377+
1378+ < p > There are two distinct ways in which selectors can be scoped:
1379+
1380+ < dl >
1381+ < dt > < dfn id =scope-contained0 > scope-contained</ dfn >
1382+
1383+ < dd > When a selector is < a
1384+ href ="#scope-contained0 "> < i > scope-contained</ i > </ a > , it matches as if the
1385+ elements outside of its scope did not exist. In other words, it acts like
1386+ the scope defines a sub-document within which the selector is matched.
1387+
1388+ < dt > < dfn id =scope-limited > scope-limited</ dfn >
1389+
1390+ < dd > When a selector is < a href ="#scope-limited "> < i > scope-limited</ i > </ a > ,
1391+ it only matches if the target is within the scope. The rest of the
1392+ document is still acknowledged and can match all but the last part of the
1393+ selector; only the target (the element matched by the last compound
1394+ selector in the selector) is required to be within the scope.
1395+ </ dl >
1396+
1397+ < div class =example >
1398+ < p > The < code > document.querySelector()</ code > function defined in < a
1399+ href ="#SELECTORS-API2 "
1400+ rel =biblioentry > [SELECTORS-API2]<!--{{SELECTORS-API2}}--> </ a > allows the
1401+ author to define a < a href ="#scope-limited "> < i > scope-limited</ i > </ a >
1402+ selector.
1403+
1404+ < p > On the other hand, the < code > document.find()</ code > function defined
1405+ in < a href ="#SELECTORS-API2 "
1406+ rel =biblioentry > [SELECTORS-API2]<!--{{SELECTORS-API2}}--> </ a > and the
1407+ selectors within a scoped stylesheet, defined in < a href ="#HTML5 "
1408+ rel =biblioentry > [HTML5]<!--{{HTML5}}--> </ a > , define < a
1409+ href ="#scope-contained0 "> < i > scope-contained</ i > </ a > selectors.
1410+ </ div >
1411+
1412+ < p > Both kinds of scoping define a < a
1413+ href ="#contextual-reference-element-set "> < i > contextual reference element
1414+ set</ i > </ a > , which can be matched with the < a
1415+ href ="#scope "> < code > :scope</ code > </ a > pseudo-class selector.
1416+
13701417 < h2 id =logical-combination > < span class =secno > 4. </ span > Logical
13711418 Combinations</ h2 >
13721419
@@ -1847,10 +1894,7 @@ <h3 id=attribute-case><span class=secno>6.3. </span> Case-sensitivity</h3>
18471894 has a value of < code > hsides</ code > , whether that value is represented as
18481895 < code > hsides</ code > , < code > HSIDES</ code > , < code > hSides</ code > , etc. even
18491896 in an XML environment where attribute values are case-sensitive.
1850-
1851- < pre >
1852- <!-- --> [frame=hsides i] { border-style: solid none; }
1853- </ pre >
1897+ f<!-- --> [frame=hsides i] { border-style: solid none; }
18541898 </ div >
18551899 <!-- plinss notes we may eventually want to choose other normalizations
18561900 for attribute matching; but since there's no normalization scheme
0 commit comments