mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Fix for multiple consequent spaces present in CSS selectors, fixes #2670
This commit is contained in:
parent
0dc69dfbe5
commit
ecddb56bc1
@ -60,6 +60,7 @@ Polymer.CssParse = (function() {
|
||||
if (node.parent) {
|
||||
var ss = node.previous ? node.previous.end : node.parent.start;
|
||||
t = text.substring(ss, node.start-1);
|
||||
t = t.replace(this._rx.multipleSpaces, ' ');
|
||||
// TODO(sorvell): ad hoc; make selector include only after last ;
|
||||
// helps with mixin syntax
|
||||
t = t.substring(t.lastIndexOf(';')+1);
|
||||
@ -162,6 +163,7 @@ Polymer.CssParse = (function() {
|
||||
mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
|
||||
varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim,
|
||||
keyframesRule: /^@[^\s]*keyframes/,
|
||||
multipleSpaces: /\s+/g
|
||||
},
|
||||
|
||||
VAR_START: '--',
|
||||
|
@ -60,6 +60,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
/* comment */
|
||||
</style>
|
||||
|
||||
<style id="multiple-spaces">
|
||||
.foo .bar {}
|
||||
.foo .bar {}
|
||||
.foo
|
||||
|
||||
|
||||
.bar {}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
function sanitizeCss(text) {
|
||||
@ -119,6 +128,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
assert.equal(result, '.stuff { background: red; }', 'unexpected stringified output');
|
||||
});
|
||||
|
||||
test('multiple consequent spaces in CSS selector', function() {
|
||||
var s4 = document.querySelector('#multiple-spaces');
|
||||
var t = css.parse(s4.textContent);
|
||||
assert.equal(t.rules[0].selector, '.foo .bar');
|
||||
assert.equal(t.rules[1].selector, '.foo .bar');
|
||||
assert.equal(t.rules[2].selector, '.foo .bar');
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user