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

Commit

Permalink
Allow :not() selector for the content select attribute
Browse files Browse the repository at this point in the history
Fixes #485
  • Loading branch information
arv committed Aug 6, 2014
1 parent c4da637 commit d565a12
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ShadowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@
// ClassSelector
// IDSelector
// AttributeSelector
var selectorStartCharRe = /^[*.#[a-zA-Z_|]/;
// negation
var selectorStartCharRe = /^(:not\()?[*.#[a-zA-Z_|]/;

function matches(node, contentElement) {
var select = contentElement.getAttribute('select');
Expand Down
23 changes: 23 additions & 0 deletions test/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,29 @@ suite('Shadow DOM', function() {
'<a data-test="a b c"></a>');
});

suite('Not selector', function() {
testRender('Type',
'<a></a><b></b>',
'<content select=":not(a)"></content>',
'<b></b>');
testRender('ID',
'<a id="a"></a><a id="b"></a>',
'<content select=":not(#a)"></content>',
'<a id="b"></a>');
testRender('Class',
'<a class="a"></a><a class="b"></a>',
'<content select=":not(.a)"></content>',
'<a class="b"></a>');
testRender('Attribute',
'<a a="a"></a><a b="b"></a>',
'<content select=":not([a])"></content>',
'<a b="b"></a>');
testRender('Attribute Value',
'<a x="a"></a><a x="b"></a>',
'<content select=":not([x=a])"></content>',
'<a x="b"></a>');
});

});

suite('Nested shadow hosts', function() {
Expand Down

0 comments on commit d565a12

Please sign in to comment.