Merge branch 'fix-for-multiple-spaces' of https://github.com/nazar-pc/polymer into nazar-pc-fix-for-multiple-spaces

This commit is contained in:
Daniel Freedman 2015-11-04 14:40:45 -08:00
commit 51a4b2c9b5
2 changed files with 18 additions and 0 deletions

View File

@ -61,6 +61,7 @@ Polymer.CssParse = (function() {
var ss = node.previous ? node.previous.end : node.parent.start;
t = text.substring(ss, node.start-1);
t = this._expandUnicodeEscapes(t);
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);
@ -175,6 +176,7 @@ Polymer.CssParse = (function() {
mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
varApply: /[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,
keyframesRule: /^@[^\s]*keyframes/,
multipleSpaces: /\s+/g
},
VAR_START: '--',

View File

@ -89,6 +89,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
border-top: 3px solid red;
}
</style>
<style id="multiple-spaces">
.foo .bar {}
.foo .bar {}
.foo
.bar {}
</style>
<script>
function sanitizeCss(text) {
@ -157,6 +166,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(t.rules[3].selector, '.\\0c3333d-model');
assert.equal(t.rules[4].selector, '.\\d33333d-model');
assert.equal(t.rules[5].selector, '.\\e33333d-model');
});
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');
});
});