Skip to content

Commit 48d8984

Browse files
committed
[selectors-3] Fold in erratum about :nth-child() etc applying to root element, per WG resolution.
1 parent a9ffafe commit 48d8984

2 files changed

Lines changed: 73 additions & 53 deletions

File tree

selectors-3/Overview.html

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
rel=dcterms.rights>
1414
<meta content="Selectors Level 3" name=dcterms.title>
1515
<meta content=text name=dcterms.type>
16-
<meta content=2017-05-16 name=dcterms.date>
16+
<meta content=2017-05-17 name=dcterms.date>
1717
<meta content="" name=dcterms.creator>
1818
<meta content=W3C name=dcterms.publisher>
1919
<meta content="https://dev.w3.org/csswg/css3-selectors/"
@@ -30,13 +30,13 @@
3030

3131
<h1 id=title>Selectors Level 3</h1>
3232

33-
<h2 class="no-num no-toc">Editor's Draft 16 May 2017</h2>
33+
<h2 class="no-num no-toc">Editor's Draft 17 May 2017</h2>
3434

3535
<dl>
3636
<dt>This version:
3737

3838
<dd> <!-- <a href="https://dev.w3.org/csswg/css3-selectors/">
39-
https://www.w3.org/TR/2017/REC-css3-selectors-20170516</a> -->
39+
https://www.w3.org/TR/2017/REC-css3-selectors-20170517</a> -->
4040
<a href="https://drafts.csswg.org/selectors3">
4141
https://drafts.csswg.org/selectors3</a>
4242

@@ -396,6 +396,8 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
396396

397397
<li><a href="#informative-references"><span class=secno>15.2.
398398
</span>Informative References</a>
399+
400+
<li><a href="#changes"><span class=secno>15.3. </span>Changes</a>
399401
</ul>
400402
</ul>
401403
<!--end-toc--> </nav>
@@ -1888,9 +1890,8 @@ <h4 id=structural-pseudos><span class=secno>6.6.5. </span>Structural
18881890
cannot be represented by other simple selectors or combinators.
18891891

18901892
<p>Standalone text and other non-element nodes are not counted when
1891-
calculating the position of an element in the list of children of its
1892-
parent. When calculating the position of an element in the list of
1893-
children of its parent, the index numbering starts at 1.
1893+
calculating the position of an element in its list of siblings; index
1894+
numbering starts at 1.
18941895

18951896
<h5 id=root-pseudo><span class=secno>6.6.5.1. </span>:root pseudo-class</h5>
18961897

@@ -1908,15 +1909,15 @@ <h5 id=nth-child-pseudo><span class=secno>6.6.5.2. </span>:nth-child()
19081909
pseudo-class notation represents an element that has
19091910
<var>a</var><code>n</code>+<var>b</var>-1 siblings <a
19101911
href="#sel-before"><strong>before</strong></a> it in the document tree,
1911-
for any positive integer or zero value of <code>n</code>, and has a parent
1912-
element. For values of <var>a</var> and <var>b</var> greater than zero,
1913-
this effectively divides the element's children into groups of
1914-
<var>a</var> elements (the last group taking the remainder), and selecting
1915-
the <var>b</var>th element of each group. For example, this allows the
1916-
selectors to address every other row in a table, and could be used to
1917-
alternate the color of paragraph text in a cycle of four. The <var>a</var>
1918-
and <var>b</var> values must be integers (positive, negative, or zero).
1919-
The index of the first child of an element is 1.
1912+
for any positive integer or zero value of <code>n</code>. It is not
1913+
required to have a parent. For values of <var>a</var> and <var>b</var>
1914+
greater than zero, this effectively divides the element's children into
1915+
groups of <var>a</var> elements (the last group taking the remainder), and
1916+
selecting the <var>b</var>th element of each group. For example, this
1917+
allows the selectors to address every other row in a table, and could be
1918+
used to alternate the color of paragraph text in a cycle of four. The
1919+
<var>a</var> and <var>b</var> values must be integers (positive, negative,
1920+
or zero). The index of the first child of an element is 1.
19201921

19211922
<p>In addition to this, <code>:nth-child()</code> can take ‘<code
19221923
class=css><code>odd</code></code>’ and ‘<code
@@ -2047,9 +2048,10 @@ <h5 id=nth-last-child-pseudo><span class=secno>6.6.5.3.
20472048
pseudo-class notation represents an element that has
20482049
<var>a</var><code>n</code>+<var>b</var>-1 siblings <a
20492050
href="#sel-after"><strong>after</strong></a> it in the document tree, for
2050-
any positive integer or zero value of <code>n</code>, and has a parent
2051-
element. See <a href="#nth-child-pseudo"><code>:nth-child()</code></a>
2052-
pseudo-class for the syntax of its argument. It also accepts the ‘<code
2051+
any positive integer or zero value of <code>n</code>. It is not required
2052+
to have a parent. See <a
2053+
href="#nth-child-pseudo"><code>:nth-child()</code></a> pseudo-class for
2054+
the syntax of its argument. It also accepts the ‘<code
20532055
class=css><code>even</code></code>’ and ‘<code
20542056
class=css><code>odd</code></code>’ values as arguments.
20552057

@@ -2071,8 +2073,8 @@ <h5 id=nth-of-type-pseudo><span class=secno>6.6.5.4. </span>:nth-of-type()
20712073
pseudo-class notation represents an element that has
20722074
<var>a</var><code>n</code>+<var>b</var>-1 siblings with the same expanded
20732075
element name <a href="#sel-before"><strong>before</strong></a> it in the
2074-
document tree, for any zero or positive integer value of <code>n</code>,
2075-
and has a parent element. See <a
2076+
document tree, for any zero or positive integer value of <code>n</code>.
2077+
It is not required to have a parent. See <a
20762078
href="#nth-child-pseudo"><code>:nth-child()</code></a> pseudo-class for
20772079
the syntax of its argument. It also accepts the ‘<code
20782080
class=css><code>even</code></code>’ and ‘<code
@@ -2096,8 +2098,8 @@ <h5 id=nth-last-of-type-pseudo><span class=secno>6.6.5.5.
20962098
pseudo-class notation represents an element that has
20972099
<var>a</var><code>n</code>+<var>b</var>-1 siblings with the same expanded
20982100
element name <a href="#sel-after"><strong>after</strong></a> it in the
2099-
document tree, for any zero or positive integer value of <code>n</code>,
2100-
and has a parent element. See <a
2101+
document tree, for any zero or positive integer value of <code>n</code>.
2102+
It is not required to have a parent. See <a
21012103
href="#nth-child-pseudo"><code>:nth-child()</code></a> pseudo-class for
21022104
the syntax of its argument. It also accepts the ‘<code
21032105
class=css><code>even</code></code>’ and ‘<code
@@ -2122,7 +2124,7 @@ <h5 id=first-child-pseudo><span class=secno>6.6.5.6. </span>:first-child
21222124

21232125
<p>Same as <code>:nth-child(1)</code>. The <dfn data-dfn-type=selector
21242126
data-export=data-export id=sel-first-child>:first-child</dfn> pseudo-class
2125-
represents an element that is the first child of some other element.
2127+
represents an element that is first in a list of siblings.
21262128

21272129
<div class=example>
21282130
<p>Examples:
@@ -2157,7 +2159,7 @@ <h5 id=last-child-pseudo><span class=secno>6.6.5.7. </span>:last-child
21572159

21582160
<p>Same as <code>:nth-last-child(1)</code>. The <dfn data-dfn-type=selector
21592161
data-export=data-export id=sel-last-child>:last-child</dfn> pseudo-class
2160-
represents an element that is the last child of some other element.
2162+
represents an element that is last in a list of siblings.
21612163

21622164
<div class=example>
21632165
<p>Example:
@@ -2173,8 +2175,7 @@ <h5 id=first-of-type-pseudo><span class=secno>6.6.5.8.
21732175

21742176
<p>Same as <code>:nth-of-type(1)</code>. The <dfn data-dfn-type=selector
21752177
data-export=data-export id=sel-first-of-type>:first-of-type</dfn>
2176-
pseudo-class represents an element that is the first sibling of its type
2177-
in the list of children of its parent element.
2178+
pseudo-class represents an element that is the first sibling of its type.
21782179

21792180
<div class=example>
21802181
<p>Example:
@@ -2207,8 +2208,7 @@ <h5 id=last-of-type-pseudo><span class=secno>6.6.5.9. </span>:last-of-type
22072208
<p>Same as <code>:nth-last-of-type(1)</code>. The <dfn
22082209
data-dfn-type=selector data-export=data-export
22092210
id=sel-last-of-type>:last-of-type</dfn> pseudo-class represents an element
2210-
that is the last sibling of its type in the list of children of its parent
2211-
element.
2211+
that is the last sibling of its type.
22122212

22132213
<div class=example>
22142214
<p>Example:
@@ -2224,8 +2224,7 @@ <h5 id=only-child-pseudo><span class=secno>6.6.5.10. </span>:only-child
22242224

22252225
<p>The <dfn data-dfn-type=selector data-export=data-export
22262226
id=sel-only-child>:only-child</dfn> pseudo-class represents an element
2227-
that has a parent element and whose parent element has no other element
2228-
children. Same as <code>:first-child:last-child</code> or
2227+
that has no siblings. Same as <code>:first-child:last-child</code> or
22292228
<code>:nth-child(1):nth-last-child(1)</code>, but with a lower
22302229
specificity.
22312230

@@ -2234,8 +2233,7 @@ <h5 id=only-of-type-pseudo><span class=secno>6.6.5.11. </span>:only-of-type
22342233

22352234
<p>The <dfn data-dfn-type=selector data-export=data-export
22362235
id=sel-only-of-type>:only-of-type</dfn> pseudo-class represents an element
2237-
that has a parent element and whose parent element has no other element
2238-
children with the same expanded element name. Same as
2236+
that has no siblings with the same expanded element name. Same as
22392237
<code>:first-of-type:last-of-type</code> or
22402238
<code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
22412239
specificity.
@@ -3532,5 +3530,17 @@ <h3 id=informative-references><span class=secno>15.2. </span>Informative
35323530
</dl>
35333531
<!--end-informative-->
35343532

3533+
<h3 id=changes><span class=secno>15.3. </span>Changes</h3>
3534+
3535+
<p>Substantive since the previous Recommendation are:
3536+
3537+
<ul>
3538+
<li>Allowing the <a href="#structural-pseudos">Structural
3539+
pseudo-classes</a> to match the root element. See <a
3540+
href="http://lists.w3.org/Archives/Public/www-style/2013Apr/0246.html">minutes</a>
3541+
and <a
3542+
href="https://software.hixie.ch/utilities/js/live-dom-viewer/saved/5188">testcase</a>.
3543+
</ul>
3544+
35353545
<script src="//www.w3.org/scripts/TR/2016/fixup.js"
35363546
type="application/javascript"></script>

selectors-3/Overview.src.html

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,10 +1390,10 @@ <h4 id="structural-pseudos">Structural pseudo-classes</h4>
13901390
the document tree but cannot be represented by other simple selectors or
13911391
combinators.
13921392

1393-
<p>Standalone text and other non-element
1394-
nodes are not counted when calculating the position of an element in the list
1395-
of children of its parent. When calculating the position of an element in
1396-
the list of children of its parent, the index numbering starts at 1.
1393+
<p>Standalone text and other non-element nodes
1394+
are not counted when calculating the position of an element
1395+
in its list of siblings;
1396+
index numbering starts at 1.
13971397

13981398

13991399
<h5 id="root-pseudo">:root pseudo-class</h5>
@@ -1410,7 +1410,8 @@ <h5 id="nth-child-pseudo">:nth-child() pseudo-class</h5>
14101410
pseudo-class notation represents an element that has
14111411
<var>a</var><code>n</code>+<var>b</var>-1 siblings
14121412
<strong>before</strong> it in the document tree, for any positive
1413-
integer or zero value of <code>n</code>, and has a parent element.
1413+
integer or zero value of <code>n</code>.
1414+
It is not required to have a parent.
14141415
For values of <var>a</var> and <var>b</var> greater than zero, this
14151416
effectively divides the element's children into groups of <var>a</var>
14161417
elements (the last group taking the remainder), and selecting the
@@ -1536,8 +1537,9 @@ <h5 id="nth-last-child-pseudo">:nth-last-child() pseudo-class</h5>
15361537
pseudo-class notation represents an element that has
15371538
<var>a</var><code>n</code>+<var>b</var>-1 siblings
15381539
<strong>after</strong> it in the document tree, for any positive
1539-
integer or zero value of <code>n</code>, and has a parent element. See
1540-
<a href="#nth-child-pseudo"><code>:nth-child()</code></a> pseudo-class for
1540+
integer or zero value of <code>n</code>.
1541+
It is not required to have a parent.
1542+
See <a href="#nth-child-pseudo"><code>:nth-child()</code></a> pseudo-class for
15411543
the syntax of its argument.
15421544
It also accepts the '<code>even</code>' and '<code>odd</code>' values
15431545
as arguments.
@@ -1558,8 +1560,9 @@ <h5 id="nth-of-type-pseudo">:nth-of-type() pseudo-class</h5>
15581560
pseudo-class notation represents an element that has
15591561
<var>a</var><code>n</code>+<var>b</var>-1 siblings with the same expanded
15601562
element name <strong>before</strong> it in the document tree, for any
1561-
zero or positive integer value of <code>n</code>, and has a
1562-
parent element. See <a href="#nth-child-pseudo"><code>:nth-child()</code></a>
1563+
zero or positive integer value of <code>n</code>.
1564+
It is not required to have a parent.
1565+
See <a href="#nth-child-pseudo"><code>:nth-child()</code></a>
15631566
pseudo-class for the syntax of its argument. It also accepts the
15641567
'<code>even</code>' and '<code>odd</code>' values.
15651568

@@ -1578,8 +1581,9 @@ <h5 id="nth-last-of-type-pseudo">:nth-last-of-type() pseudo-class</h5>
15781581
pseudo-class notation represents an element that has
15791582
<var>a</var><code>n</code>+<var>b</var>-1 siblings with the same expanded
15801583
element name <strong>after</strong> it in the document tree, for any
1581-
zero or positive integer value of <code>n</code>, and has a
1582-
parent element. See <a href="#nth-child-pseudo"><code>:nth-child()</code></a>
1584+
zero or positive integer value of <code>n</code>.
1585+
It is not required to have a parent.
1586+
See <a href="#nth-child-pseudo"><code>:nth-child()</code></a>
15831587
pseudo-class for the syntax of its argument. It also accepts the
15841588
'<code>even</code>' and '<code>odd</code>' values.
15851589

@@ -1599,7 +1603,7 @@ <h5 id="nth-last-of-type-pseudo">:nth-last-of-type() pseudo-class</h5>
15991603
<h5 id="first-child-pseudo">:first-child pseudo-class</h5>
16001604

16011605
<p>Same as <code>:nth-child(1)</code>. The <dfn data-dfn-type=selector data-export id="sel-first-child">:first-child</dfn> pseudo-class
1602-
represents an element that is the first child of some other element.
1606+
represents an element that is first in a list of siblings.
16031607

16041608

16051609
<div class="example">
@@ -1627,7 +1631,7 @@ <h5 id="first-child-pseudo">:first-child pseudo-class</h5>
16271631
<h5 id="last-child-pseudo">:last-child pseudo-class</h5>
16281632

16291633
<p>Same as <code>:nth-last-child(1)</code>. The <dfn data-dfn-type=selector data-export id="sel-last-child">:last-child</dfn> pseudo-class
1630-
represents an element that is the last child of some other element.
1634+
represents an element that is last in a list of siblings.
16311635

16321636
<div class="example">
16331637
<p>Example:</p>
@@ -1639,8 +1643,7 @@ <h5 id="last-child-pseudo">:last-child pseudo-class</h5>
16391643
<h5 id="first-of-type-pseudo">:first-of-type pseudo-class</h5>
16401644

16411645
<p>Same as <code>:nth-of-type(1)</code>. The <dfn data-dfn-type=selector data-export id="sel-first-of-type">:first-of-type</dfn> pseudo-class
1642-
represents an element that is the first sibling of its type in the list of
1643-
children of its parent element.
1646+
represents an element that is the first sibling of its type.
16441647

16451648
<div class="example">
16461649
<p>Example:</p>
@@ -1668,8 +1671,7 @@ <h5 id="last-of-type-pseudo">:last-of-type pseudo-class</h5>
16681671

16691672
<p>Same as <code>:nth-last-of-type(1)</code>. The
16701673
<dfn data-dfn-type=selector data-export id="sel-last-of-type">:last-of-type</dfn> pseudo-class represents an element that is
1671-
the last sibling of its type in the list of children of its parent
1672-
element.</p>
1674+
the last sibling of its type.
16731675

16741676
<div class="example">
16751677
<p>Example:</p>
@@ -1681,17 +1683,15 @@ <h5 id="last-of-type-pseudo">:last-of-type pseudo-class</h5>
16811683
<h5 id="only-child-pseudo">:only-child pseudo-class</h5>
16821684

16831685
<p>The <dfn data-dfn-type=selector data-export id="sel-only-child">:only-child</dfn> pseudo-class
1684-
represents an element that has a parent element and whose parent
1685-
element has no other element children. Same as
1686+
represents an element that has no siblings. Same as
16861687
<code>:first-child:last-child</code> or
16871688
<code>:nth-child(1):nth-last-child(1)</code>, but with a lower
16881689
specificity.</p>
16891690

16901691
<h5 id="only-of-type-pseudo">:only-of-type pseudo-class</h5>
16911692

16921693
<p>The <dfn data-dfn-type=selector data-export id="sel-only-of-type">:only-of-type</dfn> pseudo-class
1693-
represents an element that has a parent element and whose parent
1694-
element has no other element children with the same expanded element
1694+
represents an element that has no siblings with the same expanded element
16951695
name. Same as <code>:first-of-type:last-of-type</code> or
16961696
<code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
16971697
specificity.</p>
@@ -2664,5 +2664,15 @@ <h3 id=normative-references>Normative References</h3>
26642664
<h3 id=informative-references>Informative References</h3>
26652665
<!--informative-->
26662666

2667+
<h3 id=changes>Changes</h3>
2668+
2669+
<p>Substantive since the previous Recommendation are:
2670+
2671+
<ul>
2672+
<li>Allowing the <a href=#structural-pseudos>Structural pseudo-classes</a> to match the root element.
2673+
See <a href="http://lists.w3.org/Archives/Public/www-style/2013Apr/0246.html">minutes</a> and
2674+
<a href="https://software.hixie.ch/utilities/js/live-dom-viewer/saved/5188">testcase</a>.
2675+
</ul>
2676+
26672677
</body>
26682678
</html>

0 commit comments

Comments
 (0)