Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit f104b0d

Browse files
committed
Merge pull request #486 from arv/content-not
Allow :not() selector for the content select attribute
2 parents 5f8e4a0 + d565a12 commit f104b0d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/ShadowRenderer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@
539539
// ClassSelector
540540
// IDSelector
541541
// AttributeSelector
542-
var selectorStartCharRe = /^[*.#[a-zA-Z_|]/;
542+
// negation
543+
var selectorStartCharRe = /^(:not\()?[*.#[a-zA-Z_|]/;
543544

544545
function matches(node, contentElement) {
545546
var select = contentElement.getAttribute('select');

test/js/test.js

+23
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,29 @@ suite('Shadow DOM', function() {
193193
'<a data-test="a b c"></a>');
194194
});
195195

196+
suite('Not selector', function() {
197+
testRender('Type',
198+
'<a></a><b></b>',
199+
'<content select=":not(a)"></content>',
200+
'<b></b>');
201+
testRender('ID',
202+
'<a id="a"></a><a id="b"></a>',
203+
'<content select=":not(#a)"></content>',
204+
'<a id="b"></a>');
205+
testRender('Class',
206+
'<a class="a"></a><a class="b"></a>',
207+
'<content select=":not(.a)"></content>',
208+
'<a class="b"></a>');
209+
testRender('Attribute',
210+
'<a a="a"></a><a b="b"></a>',
211+
'<content select=":not([a])"></content>',
212+
'<a b="b"></a>');
213+
testRender('Attribute Value',
214+
'<a x="a"></a><a x="b"></a>',
215+
'<content select=":not([x=a])"></content>',
216+
'<a x="b"></a>');
217+
});
218+
196219
});
197220

198221
suite('Nested shadow hosts', function() {

0 commit comments

Comments
 (0)