Skip to content

Commit f666d84

Browse files
committed
[selectors] Address anne's comments.
1 parent 5b913a8 commit f666d84

2 files changed

Lines changed: 145 additions & 149 deletions

File tree

selectors/Overview.bs

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Abstract: <b>Selectors</b> are patterns that match against elements in a tree, a
2020
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.
2121
At Risk: the column combinator
2222
At Risk: The '':drop()'' pseudo-class
23-
Ignored Terms: DocumentFragment, math, h1, host element, shadow tree, box tree
23+
Ignored Terms: DocumentFragment, math, h1, shadow tree, box tree, query()
2424
Link Defaults: html5 (element) a
2525
</pre>
2626
<style>
@@ -79,7 +79,7 @@ Selectors Overview</h2>
7979
<em>This section is non-normative, as it merely summarizes the
8080
following sections.</em>
8181

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
8383
condition (e.g. in a CSS rule) that determines which elements a
8484
selector matches in the document tree, or as a flat description of the
8585
HTML or XML fragment corresponding to that structure.
@@ -506,7 +506,7 @@ Selectors Overview</h2>
506506
<dt><dfn id='complete-profile'>complete</dfn>
507507
<dd>
508508
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.
510510
It includes all of the selectors defined in this document.
511511
</dl>
512512

@@ -530,16 +530,15 @@ Structure and Terminology</h3>
530530
A <a>selector list</a> is a comma-separated list of <a>selectors</a>;
531531
see <a href="#grouping">Selector Lists</a>.
532532

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>
535534
separated by <a>combinators</a>.
536535

537536
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.
543542

544543
A <dfn id="simple" export>simple selector</dfn> is either a
545544
<a>type selector</a>,
@@ -549,20 +548,24 @@ Structure and Terminology</h3>
549548
<a>ID selector</a>,
550549
or <a>pseudo-class</a>.
551550

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.
554553
Combinators in Selectors level 4 include:
555554
whitespace,
556555
“greater-than sign” (U+003E, <code>></code>),
557556
“plus sign” (U+002B, <code>+</code>),
558557
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.
561560

562561
An empty selector,
563562
containing no <a>compound selector</a>,
564563
is an <a href="#invalid">invalid selector</a>.
565564

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+
566569
<h3 id='evaluating-selectors'>
567570
Evaluating a Selector</h3>
568571

@@ -656,8 +659,7 @@ Evaluating a Selector</h3>
656659
must define the <dfn export>initial selector match list</dfn>,
657660
the list of elements that every selector in that context begins with.
658661

659-
For HTML,
660-
when evaluating a selector against a document,
662+
When evaluating a selector against a DOM document,
661663
the <a>initial selector match list</a>
662664
is the root element and all of its descendants,
663665
ordered by a pre-order traversal.
@@ -671,13 +673,13 @@ Evaluating a Selector</h3>
671673
<h3 id='data-model'>
672674
Data Model</h3>
673675

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.
676678

677679
Each element may have any of:
678680

679681
<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.
681683
<li>An ID, which is a string.
682684
<li>Classes, which are strings.
683685
<li>Attributes, which are pairs of strings consisting of an attribute name and an attribute value.
@@ -704,14 +706,14 @@ Data Model</h3>
704706
(For example, the <a>host element</a> in a <a>shadow tree</a> is <a>featureless</a>,
705707
and can't be matched by <em>any</em> <a>pseudo-class</a> except for '':host'' and '':host-context()''.)
706708

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>,
710712
with the DOM element's tagname as the type,
711713
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>.
713715
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>.
715717

716718

717719
<h3 id="scoping">
@@ -743,7 +745,7 @@ Scoped Selectors</h3>
743745

744746
<div class='example'>
745747
For example,
746-
the <code>element.querySelector()</code> function defined in [[SELECTORS-API2]]
748+
the <code>element.querySelector()</code> function defined in [[DOM]]
747749
allows the author to define a <a>scope-filtered</a> selector.
748750

749751
On the other hand, the selectors within an [[HTML5]] scoped stylesheet
@@ -810,15 +812,6 @@ Absolutizing a Relative Selector</h4>
810812
Otherwise, the selector is already absolute.
811813
</ol>
812814

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-
822815
To <dfn id='absolutize-list' export>absolutize a relative selector list</dfn>,
823816
absolutize each relative selector in the list.
824817

@@ -934,7 +927,7 @@ Pseudo-classes</h3>
934927
<a>Pseudo-elements</a> may have children,
935928
as defined by the specification defining them.
936929
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,
938931
but their rendering must be defined so as to maintain the tree-ness of the <a>box tree</a>.
939932

940933
<div class='example'>
@@ -2106,7 +2099,7 @@ The reference element pseudo-class '':scope''</h3>
21062099
In some contexts, selectors can be matched with an explicit set of <dfn dfn export title=":scope element">:scope elements</dfn>.
21072100
This is is a (potentially empty) set of elements
21082101
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]],
21102103
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>&lt;style></code> element</a> in [[HTML5]].
21112104

21122105
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>
21502143
the pseudo-class :focus and in the pseudo-class :hover.
21512144
</div>
21522145

2146+
Note: The specifics of hit-testing,
2147+
necessary to know when several of the pseudo-classes defined in this section apply,
2148+
are not yet defined,
2149+
but should be in the future.
2150+
21532151
<h3 id="the-hover-pseudo">
21542152
The pointer hover pseudo-class '':hover''</h3>
21552153

@@ -2525,19 +2523,23 @@ Tree-Structural pseudo-classes</h2>
25252523
'':root'' pseudo-class</h3>
25262524

25272525
The <dfn id='root-pseudo'>:root</dfn> pseudo-class represents an element that is
2528-
the root of the document. In HTML 4, this is always the
2529-
<a element>HTML</a> element.
2526+
the root of the document.
2527+
2528+
For example, in a DOM document,
2529+
the '':root'' pseudo-class matches the root element of the <a interface>Document</a> object.
2530+
In HTML, this would be the <a element>html</a> element
2531+
(unless scripting has been used to modify the document).
25302532

25312533
<h3 id="the-empty-pseudo">
25322534
'':empty'' pseudo-class</h3>
25332535

2534-
The <dfn id='empty-pseudo'>:empty</dfn> pseudo-class represents an element that has
2535-
no children at all. In terms of the document tree, only element nodes and
2536-
content nodes (such as DOM [[DOM-LEVEL-3-CORE]] text nodes, CDATA
2537-
nodes, and entity references) whose data has a non-zero length must be
2538-
considered as affecting emptiness;
2539-
comments, processing instructions, and other nodes must not affect whether
2540-
an element is considered empty or not.
2536+
The <dfn id='empty-pseudo'>:empty</dfn> pseudo-class represents an element that has no children at all.
2537+
In terms of the document tree,
2538+
only element nodes and content nodes
2539+
(such as [[DOM]] text nodes, and entity references)
2540+
whose data has a non-zero length must be considered as affecting emptiness;
2541+
comments, processing instructions, and other nodes
2542+
must not affect whether an element is considered empty or not.
25412543

25422544
<div class="example">
25432545
Examples:

0 commit comments

Comments
 (0)