@@ -1569,10 +1569,10 @@ <h3 id=scoping><span class=secno>3.5. </span> Scoped Selectors</h3>
15691569 href ="#scope-contained "> < i > scope-contained</ i > </ a > selectors.
15701570 </ div >
15711571
1572- < p > Unless otherwise specified, the < a href =" #scoping-root " > < i > scoping
1573- root < /i > </ a > also forms the < a href =" #reference-element-set " > < i > reference
1574- element set < /i > </ a > and matches the < a
1575- href ="#scope-pseudo "> < code > :scope</ code > </ a > pseudo-class .
1572+ < p class = note > Note that if there are no < a
1573+ href =" #scope-elements " > < i > :scope elements < /i > </ a > when a selector is
1574+ evaluated, the < a href =" #scoping-root " > < i > scoping root < /i > </ a > acts like a
1575+ < a href ="#scope-elements "> < i > :scope element </ i > </ a > .
15761576
15771577 < h3 id =relative > < span class =secno > 3.6. </ span > Relative Selectors</ h3 >
15781578
@@ -1601,8 +1601,26 @@ <h4 id=absolutizing><span class=secno>3.6.1. </span> Absolutizing a
16011601
16021602 < p > To < dfn id =absolutize > absolutize a relative selector</ dfn > :
16031603
1604- < p > If the < a href ="#reference-element-set "> < i > reference element
1605- set</ i > </ a > is empty or consists of one or more elements:
1604+ < p > If there are no < a href ="#scope-elements "> < i > :scope elements</ i > </ a >
1605+ and the selector is < i > scoped</ i > to a < a href ="#virtual "> < i > virtual
1606+ scoping root</ i > </ a > :
1607+
1608+ < ol >
1609+ < li > If the selector starts with a < a href ="#child-combinator "> < i > child
1610+ combinator</ i > </ a > , remove the child combinator. The selector is now
1611+ absolute, with the additional constraint that the first compound selector
1612+ in the selector only matches elements without a parent.
1613+
1614+ < li > Otherwise, if the selector starts with any combinator other than the
1615+ < a href ="#descendant-combinator "> < i > descendant combinator</ i > </ a > , change
1616+ the selector to ‘< a href ="#negation-pseudo "> < code
1617+ class =css > :not(*)</ code > </ a > ’. < span class =note > This is the shortest
1618+ selector that is valid, but guaranteed to match nothing.</ span >
1619+
1620+ < li > Otherwise, the selector is already absolute.
1621+ </ ol >
1622+
1623+ < p > Otherwise:
16061624
16071625 < ol >
16081626 < li > If the selector starts with a < a
@@ -1621,35 +1639,13 @@ <h4 id=absolutizing><span class=secno>3.6.1. </span> Absolutizing a
16211639 </ ol >
16221640
16231641 < p class =issue > The above algorithm is different from Selectors API: its
1624- step 2, which bailed if the reference element set was empty, has been
1625- removed. This is because handling an explicitly empty list should return
1626- nothing; if a reference element set was not given at all, Selectors API 2
1627- should be amended to say that the selector must be absolute already.
1628- (Broken example: doing < code > document.find('img', [list-of-links]))</ code >
1629- finds images that are descendants of links normally, but instead finds all
1630- images in the document if the list-of-links is empty.)
1631-
1632- < p > Otherwise, if the < a href ="#reference-element-set "> < i > reference element
1633- set</ i > </ a > consists of only a < a href ="#virtual "> < i > virtual scoping
1634- root</ i > </ a > :
1635-
1636- < ol >
1637- < li > If the selector starts with a < a href ="#child-combinator "> < i > child
1638- combinator</ i > </ a > , remove the child combinator. The selector is now
1639- absolute, with the additional constraint that the first compound selector
1640- in the selector only matches elements without a parent.
1641-
1642- < li > Otherwise, if the selector starts with any combinator other than the
1643- < a href ="#descendant-combinator "> < i > descendant combinator</ i > </ a > , change
1644- the selector to ‘< a href ="#negation-pseudo "> < code
1645- class =css > :not(*)</ code > </ a > ’. < span class =note > This is the shortest
1646- selector that is valid, but guaranteed to match nothing.</ span >
1647-
1648- < li > Otherwise, the selector is already absolute.
1649- </ ol >
1650-
1651- < p > Otherwise, this is a spec error. Please report it to the relevant
1652- standards body.
1642+ step 2, which bailed if there were no :scope elements, has been removed.
1643+ This is because handling an explicitly empty list should return nothing;
1644+ if no :scope elements were given at all, Selectors API 2 should be amended
1645+ to say that the selector must be absolute already. (Broken example: doing
1646+ < code > document.find('img', [list-of-links]))</ code > finds images that are
1647+ descendants of links normally, but instead finds all images in the
1648+ document if the list-of-links is empty.)
16531649
16541650 < p > To < dfn id =absolutize-list > absolutize a relative selector list</ dfn > ,
16551651 absolutize each relative selector in the list.
@@ -2961,31 +2957,31 @@ <h3 id=the-target-pseudo><span class=secno>8.4. </span> The target
29612957 < h3 id =the-scope-pseudo > < span class =secno > 8.5. </ span > The reference
29622958 element pseudo-class < a href ="#scope-pseudo "> < code > :scope</ code > </ a > </ h3 >
29632959
2964- < p > The < dfn id =scope-pseudo > :scope</ dfn > pseudo-class represents any
2965- element that is in the < dfn id =reference-element-set > reference element
2966- set</ dfn > . This is is a (potentially empty) set of elements that provide a
2967- reference point for selectors to match against, such as that specified by
2968- the < code > querySelector()</ code > call in < a href ="#ref-SELECTORS-API2 "
2960+ < p > In some contexts, selectors can be matched with an explicit set of < dfn
2961+ data-export =data-export id =scope-elements title =":scope element "> :scope
2962+ elements</ dfn > . This is is a (potentially empty) set of elements that
2963+ provide a reference point for selectors to match against, such as that
2964+ specified by the < code > querySelector()</ code > call in < a
2965+ href ="#ref-SELECTORS-API2 "
29692966 rel =biblioentry > [SELECTORS-API2]<!--{{SELECTORS-API2}}--> </ a > , or the
29702967 parent element of a < a
29712968 href ="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-style-element "> scoped
29722969 < code > <style> </ code > element</ a > in < a href ="#ref-HTML5 "
29732970 rel =biblioentry > [HTML5]<!--{{HTML5}}--> </ a > .
29742971
2975- < p > If the < a href ="#reference-element-set "> < i > reference element
2976- set</ i > </ a > is not explicitly specified, it defaults to representing the
2977- < a href ="#scoping-root "> < i > scoping root</ i > </ a > (if any), else represents
2978- the root of the document (i.e. matches < a
2979- href ="#roo-pseudo "> < code > :root</ code > </ a > ). Specifications intending for
2980- this pseudo-class to match specific elements rather than the document's
2981- root element must define either a < a href ="#scoping-root "> < i > scoping
2972+ < p > The < dfn id =scope-pseudo > :scope</ dfn > pseudo-class represents any
2973+ element that is a < a href ="#scope-elements "> < i > :scope element</ i > </ a > . If
2974+ the < a href ="#scope-elements "> < i > :scope elements</ i > </ a > are not
2975+ explicitly specified, but the selector is < i > scoped</ i > and the < a
2976+ href ="#scoping-root "> < i > scoping root</ i > </ a > is an element, then ‘< a
2977+ href ="#scope-pseudo "> < code class =css > :scope</ code > </ a > ’ represents the
2978+ < a href ="#scoping-root "> < i > scoping root</ i > </ a > ; otherwise, it represents
2979+ the root of the document (equivalent to ‘< a href ="#roo-pseudo "> < code
2980+ class =css > :root</ code > </ a > ’). Specifications intending for this
2981+ pseudo-class to match specific elements rather than the document's root
2982+ element must define either a < a href ="#scoping-root "> < i > scoping
29822983 root</ i > </ a > (if using < a href ="#scope "> < i > scoped selectors</ i > </ a > ) or an
2983- explicit < a href ="#reference-element-set "> < i > reference element
2984- set</ i > </ a > .
2985-
2986- < p class =note > Note that since this pseudo-class only represents elements,
2987- a virtual < a href ="#scoping-root "> < i > scoping root</ i > </ a > cannot be the
2988- subject of a selector; such a selector effectively represents nothing.
2984+ explicit set of < a href ="#scope-elements "> < i > :scope elements</ i > </ a > .
29892985
29902986 < h2 id =useraction-pseudos > < span class =secno > 9. </ span > User Action
29912987 Pseudo-classes</ h2 >
@@ -4375,12 +4371,9 @@ <h3 id=parse-a-relative-selector><span class=secno>17.2. </span> Parse A
43754371 Relative Selector</ h3 >
43764372
43774373 < p > This section defines how to < dfn id =parse-a-relative-selector0 > parse a
4378- relative selector</ dfn > from a string < var > source</ var > , against a < a
4379- href ="#reference-element-set "> < i > reference element set</ i > </ a >
4380- < var > refs</ var > . The reference element set must contain zero or more
4381- elements, or a single virtual scoping root, such as a
4382- < code > Document</ code > or < code > Document Fragment</ code > . It returns either
4383- a complex selector list, or failure.
4374+ relative selector</ dfn > from a string < var > source</ var > , against < a
4375+ href ="#scope-elements "> < i > :scope elements</ i > </ a > < var > refs</ var > . It
4376+ returns either a complex selector list, or failure.
43844377
43854378 < ol >
43864379 < li > Let < var title =""> selector</ var > be the result of parsing
@@ -4396,7 +4389,7 @@ <h3 id=parse-a-relative-selector><span class=secno>17.2. </span> Parse A
43964389 < li > Otherwise, < a href ="#absolutize-list "> < i
43974390 title ="absolutize a relative selector list "> absolutize < var
43984391 title =""> selector</ var > </ i > </ a > with < var > refs</ var > as the < a
4399- href ="#reference-element-set "> < i > reference element set </ i > </ a > .
4392+ href ="#scope-elements "> < i > :scope elements </ i > </ a > .
44004393
44014394 < li > Return < var title =""> selector</ var > .
44024395 </ ol >
@@ -4412,17 +4405,17 @@ <h3 id=match-a-selector><span class=secno>17.3. </span> Match A Selector</h3>
44124405 root</ i > </ a > and < a href ="#scoping-methods "> < i > scoping method</ i > </ a > (< a
44134406 href ="#scope-contained "> < i > scope-contained</ i > </ a > or < a
44144407 href ="#scope-filtered "> < i > scope-filtered</ i > </ a > ) may be provided.
4415- Optionally, an explicit < a href ="#reference-element-set "> < i > reference
4416- element set </ i > </ a > < var > element set</ var > (which may be empty) may be
4408+ Optionally, an explicit < a href ="#scope-elements "> < i > :scope
4409+ elements </ i > </ a > < var > element set</ var > (which may be empty) may be
44174410 provided. It returns a list of zero or more elements.
44184411
44194412 < p > < a href ="#evaluate-a-selector "> < i > Evaluate a selector</ i > </ a > < var
44204413 title =""> selector</ var > against < var > nodes</ var > with the < a
44214414 href ="#scoping-root "> < i > scoping root</ i > </ a > , < a
44224415 href ="#scoping-methods "> < i > scoping method</ i > </ a > , and < a
4423- href ="#reference-element-set "> < i > reference element set </ i > </ a > if they
4424- were provided, and return the elements that match the selector. Return the
4425- nodes matched by the selector.
4416+ href ="#scope-elements "> < i > :scope elements </ i > </ a > if they were provided,
4417+ and return the elements that match the selector. Return the nodes matched
4418+ by the selector.
44264419
44274420 < h2 id =changes > < span class =secno > 18. </ span > Changes</ h2 >
44284421
0 commit comments