You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: selectors/Overview.bs
+47-45Lines changed: 47 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Abstract: <b>Selectors</b> are patterns that match against elements in a tree, a
20
20
Abstract: Selectors Level 4 describes the selectors that already exist in [[!SELECT]], and further introduces new selectors for CSS and other languages that may need them.
<em>This section is non-normative, as it merely summarizes the
80
80
following sections.</em>
81
81
82
-
A Selector represents a structure. This structure can be used as a
82
+
A selector represents a structure. This structure can be used as a
83
83
condition (e.g. in a CSS rule) that determines which elements a
84
84
selector matches in the document tree, or as a flat description of the
85
85
HTML or XML fragment corresponding to that structure.
@@ -506,7 +506,7 @@ Selectors Overview</h2>
506
506
<dt><dfn id='complete-profile'>complete</dfn>
507
507
<dd>
508
508
The <a>complete</a> profile is appropriate for contexts which aren't extremely performance sensitive.
509
-
For example, implementations of the Selectors API specification [[SELECTORS-API]] should use the ''complete'' profile.
509
+
For example, the <a method for=Element>query()</a> method defined in [[DOM]] should use the ''complete'' profile.
510
510
It includes all of the selectors defined in this document.
511
511
</dl>
512
512
@@ -530,16 +530,15 @@ Structure and Terminology</h3>
530
530
A <a>selector list</a> is a comma-separated list of <a>selectors</a>;
531
531
see <a href="#grouping">Selector Lists</a>.
532
532
533
-
A <dfn id="complex" export>complex selector</dfn> is a chain of one
534
-
or more <a>compound selectors</a>
533
+
A <dfn id="complex" export>complex selector</dfn> is a sequence of one or more <a>compound selectors</a>
535
534
separated by <a>combinators</a>.
536
535
537
536
A <dfn id="compound" export>compound selector</dfn>
538
-
is a chain of <a>simple selectors</a>
539
-
that are not separated by a <a>combinator</a>. It
540
-
always begins with a <a>type selector</a> or a
541
-
(possibly implied) <a>universal selector</a>.
542
-
No other type selector or universal selector is allowed in the sequence.
537
+
is a sequence of <a>simple selectors</a>
538
+
that are not separated by a <a>combinator</a>.
539
+
If it contains a <a>type selector</a> or <a>universal selector</a>,
540
+
that selector comes first in the sequence.
541
+
Only one type selector or universal selector is allowed in the sequence.
543
542
544
543
A <dfn id="simple" export>simple selector</dfn> is either a
545
544
<a>type selector</a>,
@@ -549,20 +548,24 @@ Structure and Terminology</h3>
549
548
<a>ID selector</a>,
550
549
or <a>pseudo-class</a>.
551
550
552
-
A <dfn export>combinator</dfn>is punctuation that represents a particular
553
-
kind of relationship between the <a>compound selectors</a> on either side.
551
+
A <dfn export>combinator</dfn> represents a particular kind of relationship
552
+
between the <a>compound selectors</a> on either side.
554
553
Combinators in Selectors level 4 include:
555
554
whitespace,
556
555
“greater-than sign” (U+003E, <code>></code>),
557
556
“plus sign” (U+002B, <code>+</code>),
558
557
and “tilde” (U+007E, <code>~</code>).
559
-
<a href="#whitespace">White space</a> may appear between a combinator
560
-
and the simple selectors around it.
558
+
559
+
Issue: Fill in more combinators.
561
560
562
561
An empty selector,
563
562
containing no <a>compound selector</a>,
564
563
is an <a href="#invalid">invalid selector</a>.
565
564
565
+
Note: As whitespace is a valid <a>combinator</a>,
566
+
no whitespace is allowed between the <a>simple selectors</a>
567
+
in a <a>compound selector</a>.
568
+
566
569
<h3 id='evaluating-selectors'>
567
570
Evaluating a Selector</h3>
568
571
@@ -656,8 +659,7 @@ Evaluating a Selector</h3>
656
659
must define the <dfn export>initial selector match list</dfn>,
657
660
the list of elements that every selector in that context begins with.
658
661
659
-
For HTML,
660
-
when evaluating a selector against a document,
662
+
When evaluating a selector against a DOM document,
661
663
the <a>initial selector match list</a>
662
664
is the root element and all of its descendants,
663
665
ordered by a pre-order traversal.
@@ -671,13 +673,13 @@ Evaluating a Selector</h3>
671
673
<h3 id='data-model'>
672
674
Data Model</h3>
673
675
674
-
Selectors are matched against an <dfn export>element tree</dfn>,
675
-
which is an abstract tree structure consisting of elements.
676
+
Selectors are matched against a <a>selector match list</a> of elements,
677
+
which is usually arranged in an abstract tree structure.
676
678
677
679
Each element may have any of:
678
680
679
681
<ul>
680
-
<li>A type, which is a string.
682
+
<li>A type, which is a pair of strings: a namespace and a local name.
681
683
<li>An ID, which is a string.
682
684
<li>Classes, which are strings.
683
685
<li>Attributes, which are pairs of strings consisting of an attribute name and an attribute value.
@@ -704,14 +706,14 @@ Data Model</h3>
704
706
(For example, the <a>host element</a> in a <a>shadow tree</a> is <a>featureless</a>,
705
707
and can't be matched by <em>any</em><a>pseudo-class</a> except for '':host'' and '':host-context()''.)
706
708
707
-
In HTML,
708
-
the DOM is used as the <a>element tree</a>.
709
-
Each DOM element is an element in the <a>element tree</a>,
709
+
In a DOM document,
710
+
the DOM is used as the <a>selector match list</a>.
711
+
Each DOM element is an element in the <a>selector match list</a>,
710
712
with the DOM element's tagname as the type,
711
713
and its ID, class list, attributes, and child elements
712
-
as the ID, classes, attributes, and child elements in the <a>element tree</a>.
714
+
as the ID, classes, attributes, and child elements in the <a>selector match list</a>.
713
715
The rest of the information in the DOM is also accessible
714
-
as the arbitrary additional information in the <a>element tree</a>.
716
+
as the arbitrary additional information in the <a>selector match list</a>.
715
717
716
718
717
719
<h3 id="scoping">
@@ -743,7 +745,7 @@ Scoped Selectors</h3>
743
745
744
746
<div class='example'>
745
747
For example,
746
-
the <code>element.querySelector()</code> function defined in [[SELECTORS-API2]]
748
+
the <code>element.querySelector()</code> function defined in [[DOM]]
747
749
allows the author to define a <a>scope-filtered</a> selector.
748
750
749
751
On the other hand, the selectors within an [[HTML5]] scoped stylesheet
@@ -810,15 +812,6 @@ Absolutizing a Relative Selector</h4>
810
812
Otherwise, the selector is already absolute.
811
813
</ol>
812
814
813
-
<p class='issue'>
814
-
The above algorithm is different from Selectors API: its step 2, which bailed if there were no :scope elements, has been removed.
815
-
This is because handling an explicitly empty list should return nothing;
816
-
if no :scope elements were given at all,
817
-
Selectors API 2 should be amended to say that the selector must be absolute already.
818
-
(Broken example: doing <code>document.query('img', [list-of-links]))</code> finds images that are descendants of links normally,
819
-
but instead finds all images in the document if the list-of-links is empty.)
820
-
821
-
822
815
To <dfn id='absolutize-list' export>absolutize a relative selector list</dfn>,
823
816
absolutize each relative selector in the list.
824
817
@@ -934,7 +927,7 @@ Pseudo-classes</h3>
934
927
<a>Pseudo-elements</a> may have children,
935
928
as defined by the specification defining them.
936
929
Their children can be children of other elements, too,
937
-
turning the <a>element tree</a> into a directed acyclic graph,
930
+
turning the <a>selector match list</a> into a directed acyclic graph,
938
931
but their rendering must be defined so as to maintain the tree-ness of the <a>box tree</a>.
939
932
940
933
<div class='example'>
@@ -2106,7 +2099,7 @@ The reference element pseudo-class '':scope''</h3>
2106
2099
In some contexts, selectors can be matched with an explicit set of <dfn dfn export title=":scope element">:scope elements</dfn>.
2107
2100
This is is a (potentially empty) set of elements
2108
2101
that provide a reference point for selectors to match against,
2109
-
such as that specified by the <code>querySelector()</code> call in [[SELECTORS-API2]],
2102
+
such as that specified by the <code>querySelector()</code> call in [[DOM]],
2110
2103
or the parent element of a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-style-element">scoped <code><style></code> element</a> in [[HTML5]].
2111
2104
2112
2105
The <dfn id='scope-pseudo'>:scope</dfn> pseudo-class represents any element that is a <a>:scope element</a>.
@@ -2150,6 +2143,11 @@ User Action Pseudo-classes</h2>
2150
2143
the pseudo-class :focus and in the pseudo-class :hover.
2151
2144
</div>
2152
2145
2146
+
Note: The specifics of hit-testing,
2147
+
necessary to know when several of the pseudo-classes defined in this section apply,
0 commit comments