Skip to content

Commit

Permalink
Merge branch 'nazar-pc-fix-for-multiple-spaces'
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Nov 4, 2015
2 parents 174b77b + 51a4b2c commit 3378b4f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/css-parse.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
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);
Expand Down Expand Up @@ -175,6 +176,7 @@
mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
varApply: /[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,
keyframesRule: /^@[^\s]*keyframes/,
multipleSpaces: /\s+/g
},

VAR_START: '--',
Expand Down
16 changes: 16 additions & 0 deletions test/unit/css-parse.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@
border-top: 3px solid red;
}
</style>

<style id="multiple-spaces">
.foo .bar {}
.foo .bar {}
.foo


.bar {}
</style>
<script>

function sanitizeCss(text) {
Expand Down Expand Up @@ -157,6 +166,13 @@
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');
});

});
Expand Down

0 comments on commit 3378b4f

Please sign in to comment.