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

Commit d565a12

Browse files
committed
Allow :not() selector for the content select attribute
Fixes #485
1 parent c4da637 commit d565a12

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
@@ -538,7 +538,8 @@
538538
// ClassSelector
539539
// IDSelector
540540
// AttributeSelector
541-
var selectorStartCharRe = /^[*.#[a-zA-Z_|]/;
541+
// negation
542+
var selectorStartCharRe = /^(:not\()?[*.#[a-zA-Z_|]/;
542543

543544
function matches(node, contentElement) {
544545
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)