Skip to content

Commit cedf942

Browse files
committed
[selectors] Remove the restriction on nesting :not() and :matches() inside of not, as it's easily bypassable by just using a selector list.
1 parent 131d277 commit cedf942

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

selectors/Overview.bs

+8-13
Original file line numberDiff line numberDiff line change
@@ -1231,17 +1231,14 @@ The Matches-Any Pseudo-class: '':matches()''</h3>
12311231
<h3 id="negation">
12321232
The Negation Pseudo-class: '':not()''</h3>
12331233

1234-
The negation pseudo-class, <dfn id='negation-pseudo'>:not()</dfn>, is a
1235-
functional pseudo-class taking a <a href="#grouping">selector list</a>
1236-
as an argument. It represents an element that is not represented
1237-
by its argument.
1234+
The negation pseudo-class, <dfn id='negation-pseudo'>:not()</dfn>,
1235+
is a functional pseudo-class taking a <a>selector list</a> as an argument.
1236+
It represents an element that is not represented by its argument.
12381237

12391238
Note: In Selectors Level 3,
12401239
only a single <a>simple selector</a> was allowed as the argument to '':not()''.
12411240

1242-
A negation may not be nested within itself or within '':matches()'':
1243-
'':not(:not(...))'' and '':matches(:not(...))'' are invalid.
1244-
Additionally, pseudo-elements cannot be represented by the negation pseudo-class;
1241+
Pseudo-elements cannot be represented by the negation pseudo-class;
12451242
they are not valid within '':not()''.
12461243

12471244
<div class="example">
@@ -1250,7 +1247,7 @@ The Negation Pseudo-class: '':not()''</h3>
12501247

12511248
<pre>button:not([DISABLED]) </pre>
12521249

1253-
The following selector represents all but <a element title=''>FOO</a> elements.
1250+
The following selector represents all but <a element title>FOO</a> elements.
12541251

12551252
<pre>*:not(FOO)</pre>
12561253

@@ -1264,11 +1261,9 @@ The Negation Pseudo-class: '':not()''</h3>
12641261
within a negation pseudo-class unless the argument is an explicit universal
12651262
selector or a type selector. (See '':matches()''for examples.)
12661263

1267-
Note: The '':not()'' pseudo allows
1268-
useless selectors to be written. For instance '':not(*|*)'',
1269-
which represents no element at all, or ''foo:not(bar)'',
1270-
which is equivalent to ''foo'' but with a higher
1271-
specificity.
1264+
Note: The '':not()'' pseudo-class allows useless selectors to be written.
1265+
For instance '':not(*|*)'', which represents no element at all,
1266+
or ''div:not(span)'', which is equivalent to ''div'' but with a higher specificity.
12721267

12731268
<h3 id='relational'>
12741269
The Relational Pseudo-class: '':has()''</h3>

selectors/Overview.html

+7-12
Original file line numberDiff line numberDiff line change
@@ -1473,17 +1473,14 @@ <h3 class="heading settled heading" data-level=4.2 id=matches><span class=secno>
14731473
<h3 class="heading settled heading" data-level=4.3 id=negation><span class=secno>4.3 </span><span class=content>
14741474
The Negation Pseudo-class: <a class=css data-link-type=maybe href=#negation-pseudo title=:not()>:not()</a></span><a class=self-link href=#negation></a></h3>
14751475

1476-
<p>The negation pseudo-class, <dfn class=css-code data-dfn-type=selector data-export="" id=negation-pseudo>:not()<a class=self-link href=#negation-pseudo></a></dfn>, is a
1477-
functional pseudo-class taking a <a href=#grouping>selector list</a>
1478-
as an argument. It represents an element that is not represented
1479-
by its argument.</p>
1476+
<p>The negation pseudo-class, <dfn class=css-code data-dfn-type=selector data-export="" id=negation-pseudo>:not()<a class=self-link href=#negation-pseudo></a></dfn>,
1477+
is a functional pseudo-class taking a <a data-link-type=dfn href=#selector-list title="selector list">selector list</a> as an argument.
1478+
It represents an element that is not represented by its argument.</p>
14801479

14811480
<p class=note>Note: In Selectors Level 3,
14821481
only a single <a data-link-type=dfn href=#simple title="simple selector">simple selector</a> was allowed as the argument to <a class=css data-link-type=maybe href=#negation-pseudo title=:not()>:not()</a>.</p>
14831482

1484-
<p>A negation may not be nested within itself or within <a class=css data-link-type=maybe href=#matches-pseudo title=:matches()>:matches()</a>:
1485-
<span class=css data-link-type=maybe title=:not(:not(...))>:not(:not(...))</span> and <span class=css data-link-type=maybe title=:matches(:not(...))>:matches(:not(...))</span> are invalid.
1486-
Additionally, pseudo-elements cannot be represented by the negation pseudo-class;
1483+
<p>Pseudo-elements cannot be represented by the negation pseudo-class;
14871484
they are not valid within <a class=css data-link-type=maybe href=#negation-pseudo title=:not()>:not()</a>.</p>
14881485

14891486
<div class=example>
@@ -1506,11 +1503,9 @@ <h3 class="heading settled heading" data-level=4.3 id=negation><span class=secno
15061503
within a negation pseudo-class unless the argument is an explicit universal
15071504
selector or a type selector. (See <a class=css data-link-type=maybe href=#matches-pseudo title=:matches()>:matches()</a>for examples.)</p>
15081505

1509-
<p class=note>Note: The <a class=css data-link-type=maybe href=#negation-pseudo title=:not()>:not()</a> pseudo allows
1510-
useless selectors to be written. For instance <span class=css data-link-type=maybe title=:not(*|*)>:not(*|*)</span>,
1511-
which represents no element at all, or <span class=css data-link-type=maybe title=foo:not(bar)>foo:not(bar)</span>,
1512-
which is equivalent to <span class=css data-link-type=maybe title=foo>foo</span> but with a higher
1513-
specificity.</p>
1506+
<p class=note>Note: The <a class=css data-link-type=maybe href=#negation-pseudo title=:not()>:not()</a> pseudo-class allows useless selectors to be written.
1507+
For instance <span class=css data-link-type=maybe title=:not(*|*)>:not(*|*)</span>, which represents no element at all,
1508+
or <span class=css data-link-type=maybe title=div:not(span)>div:not(span)</span>, which is equivalent to <span class=css data-link-type=maybe title=div>div</span> but with a higher specificity.</p>
15141509

15151510
<h3 class="heading settled heading" data-level=4.4 id=relational><span class=secno>4.4 </span><span class=content>
15161511
The Relational Pseudo-class: <a class=css data-link-type=maybe href=#has-pseudo title=:has()>:has()</a></span><a class=self-link href=#relational></a></h3>

0 commit comments

Comments
 (0)