Add support for one-of attribute selector while not breaking support for general sibling combinator. Fixes #3023. Fix taken from #3067.

This commit is contained in:
Steven Orvell 2016-02-12 11:42:59 -08:00
parent c00c47f40e
commit 5a493d84ad
3 changed files with 38 additions and 1 deletions

View File

@ -253,7 +253,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var SCOPE_DOC_SELECTOR = ':not([' + SCOPE_NAME + '])' + var SCOPE_DOC_SELECTOR = ':not([' + SCOPE_NAME + '])' +
':not(.' + SCOPE_NAME + ')'; ':not(.' + SCOPE_NAME + ')';
var COMPLEX_SELECTOR_SEP = ','; var COMPLEX_SELECTOR_SEP = ',';
var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)([^\s>+~]+)/g; var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=\[])+)/g;
var HOST = ':host'; var HOST = ':host';
var ROOT = ':root'; var ROOT = ':root';
// NOTE: this supports 1 nested () pair for things like // NOTE: this supports 1 nested () pair for things like

View File

@ -505,3 +505,31 @@
is: 'x-overriding' is: 'x-overriding'
}); });
</script> </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>

View File

@ -236,6 +236,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
document.body.removeChild(el); 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() { suite('scoped-styling-shady-only', function() {
suiteSetup(function() { suiteSetup(function() {
@ -333,6 +341,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
computed = getComputedStyle(circle); computed = getComputedStyle(circle);
assert.equal(computed['fill-opacity'], '0.5'); assert.equal(computed['fill-opacity'], '0.5');
}); });
}); });
</script> </script>