Skip to content

Commit

Permalink
Add support for one-of attribute selector while not breaking support …
Browse files Browse the repository at this point in the history
…for general sibling combinator. Fixes #3023. Fix taken from #3067.
  • Loading branch information
Steven Orvell committed Feb 12, 2016
1 parent c00c47f commit 5a493d8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/style-transformer.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
var SCOPE_DOC_SELECTOR = ':not([' + SCOPE_NAME + '])' +
':not(.' + SCOPE_NAME + ')';
var COMPLEX_SELECTOR_SEP = ',';
var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)([^\s>+~]+)/g;
var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=\[])+)/g;
var HOST = ':host';
var ROOT = ':root';
// NOTE: this supports 1 nested () pair for things like
Expand Down
28 changes: 28 additions & 0 deletions test/unit/styling-scoped-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -505,3 +505,31 @@
is: 'x-overriding'
});
</script>

<dom-module id="x-attr-selector">
<template>
<style>
#foo1 ~ #bar1 {
border: 2px solid red;
}

#foo1 ~ #bar1 ~ #foo2[attr~=foo2] ~ #bar2[attr~=bar2] {
border: 4px solid red;
}

#foo1 ~ #bar1 ~ #foo2[attr~=foo2] ~ #bar2[attr~=bar2] ~ #foo3[attr~=foo3][a~=a] ~ #bar3[attr~=bar3][a~=a] {
border: 6px solid red;
}
</style>
<div id="foo1"></div>
<div id="bar1">bar1</div>
<div id="foo2" attr="foo2"></div>
<div id="bar2" attr="bar2">bar2</div>
<div id="foo3" attr="foo3" a="a"></div>
<div id="bar3" attr="bar3" a="a">bar3</div>

</template>
<script>
Polymer({is: 'x-attr-selector'});
</script>
</dom-module>
9 changes: 9 additions & 0 deletions test/unit/styling-scoped.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@
document.body.removeChild(el);
});

test('attribute inclusive selector and general sibling selectors', function() {
var e = document.createElement('x-attr-selector');
document.body.appendChild(e);
assertComputed(e.$.bar1, '2px');
assertComputed(e.$.bar2, '4px');
assertComputed(e.$.bar3, '6px');
});

suite('scoped-styling-shady-only', function() {

suiteSetup(function() {
Expand Down Expand Up @@ -333,6 +341,7 @@
computed = getComputedStyle(circle);
assert.equal(computed['fill-opacity'], '0.5');
});

});

</script>
Expand Down

0 comments on commit 5a493d8

Please sign in to comment.