@@ -209,7 +209,7 @@ <h2 class="no-num no-toc" id=contents>Table of Contents</h2>
209209 Selectors</ a >
210210 < ul class =toc >
211211 < li > < a href ="#absolutizing "> < span class =secno > 3.4.1. </ span >
212- Absolutizing a Scope-relative Selector</ a >
212+ Absolutizing a Relative Selector</ a >
213213 </ ul >
214214
215215 < li > < a href ="#pseudo-classes "> < span class =secno > 3.5. </ span >
@@ -1407,12 +1407,12 @@ <h3 id=relative><span class=secno>3.4. </span> Relative Selectors</h3>
14071407 href ="#scope-filtered "> < i > scope-filtered</ i > </ a > .
14081408
14091409 < h4 id =absolutizing > < span class =secno > 3.4.1. </ span > Absolutizing a
1410- Scope-relative Selector</ h4 >
1410+ Relative Selector</ h4 >
14111411
14121412 < p > To < dfn id =absolutize > absolutize a relative selector</ dfn > :
14131413
14141414 < p > If the < a href ="#reference-element-set "> < i > reference element
1415- set</ i > </ a > is non- empty,
1415+ set</ i > </ a > is empty or consists of one or more elements:
14161416
14171417 < ol >
14181418 < li > If the selector starts with a < a
@@ -1421,9 +1421,6 @@ <h4 id=absolutizing><span class=secno>3.4.1. </span> Absolutizing a
14211421 < a href ="#scope-pseudo "> < code > :scope</ code > </ a > as the initial < a
14221422 href ="#compound "> < i > compound selector</ i > </ a > .
14231423
1424- < li > Otherwise, if the < a href ="#reference-element-set "> < i > reference
1425- element set</ i > </ a > is empty, the selector is already absolute.
1426-
14271424 < li > Otherwise, if the selector does not contain any instance of the < a
14281425 href ="#scope-pseudo "> < code > :scope</ code > </ a > pseudo-class (either at the
14291426 top-level or as an argument to a functional pseudo-class), prepend < a
@@ -1433,22 +1430,37 @@ <h4 id=absolutizing><span class=secno>3.4.1. </span> Absolutizing a
14331430 < li > Otherwise, the selector is already absolute.
14341431 </ ol >
14351432
1433+ < p class =issue > The above algorithm is different from Selectors API: its
1434+ step 2, which bailed if the reference element set was empty, has been
1435+ removed. This is because handling an explicitly empty list should return
1436+ nothing; if a reference element set was not given at all, Selectors API 2
1437+ should be amended to say that the selector must be absolute already.
1438+ (Broken example: doing < code > document.find('img', [list-of-links]))</ code >
1439+ finds images that are descendants of links normally, but instead finds all
1440+ images in the document if the list-of-links is empty.)
1441+
14361442 < p > Otherwise, if the < a href ="#reference-element-set "> < i > reference element
1437- set</ i > </ a > is empty,
1443+ set</ i > </ a > consists of only a < a href ="#virtual "> < i > virtual scoping
1444+ root</ i > </ a > :
14381445
14391446 < ol >
14401447 < li > If the selector starts with a < a href ="#child-combinator "> < i > child
14411448 combinator</ i > </ a > , remove the child combinator. The selector is now
14421449 absolute, with the additional constraint that the first compound selector
14431450 in the selector only matches elements without a parent.
14441451
1445- < li > If the selectors starts with any other combinator other than the < a
1446- href ="#descendant-combinator "> < i > descendant combinator</ i > </ a > , the
1447- selector represents nothing.
1452+ < li > Otherwise, if the selector starts with any combinator other than the
1453+ < a href ="#descendant-combinator "> < i > descendant combinator</ i > </ a > , change
1454+ the selector to ‘< a href ="#negation-pseudo "> < code
1455+ class =css > :not(*)</ code > </ a > ’. < span class =note > This is the shortest
1456+ selector that is valid, but guaranteed to match nothing.</ span >
14481457
14491458 < li > Otherwise, the selector is already absolute.
14501459 </ ol >
14511460
1461+ < p > Otherwise, this is a spec error. Please report it to the relevant
1462+ standards body.
1463+
14521464 < p > To < dfn id =absolutize-list > absolutize a relative selector list</ dfn > ,
14531465 absolutize each relative selector in the list.
14541466
0 commit comments