Skip to content

Commit

Permalink
Merge 31d35e1 into 882d0f0
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Mar 10, 2020
2 parents 882d0f0 + 31d35e1 commit 5b0f732
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function parse (value, root, rule, rules, rulesets, points, declarations)
break
// \t \n \s
case 9: case 10: case 32:
characters += whitespace(previous)
characters += whitespace(previous, strlen(characters))
break
// /
case 47:
Expand Down
5 changes: 3 additions & 2 deletions src/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,17 @@ export function tokenize (value) {

/**
* @param {number} type
* @param {number} len
* @return {string}
*/
export function whitespace (type) {
export function whitespace (type, len) {
while (character = peek())
if (character < 33)
next()
else
break

return token(type) > 2 || token(type === 38 && character === 58 ? type : character) > 2 ? '' : ' '
return !len || character !== 58 && (token(type) > 2 || token(character) > 2) ? '' : ' '
}

/**
Expand Down
10 changes: 10 additions & 0 deletions test/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ describe('Parser', () => {
).to.equal(`.user :hover{color:blue;}`)
})

test('div :hover', () => {
expect(
stylis(`
div :hover {
color:blue;
}
`)
).to.equal(`.user div :hover{color:blue;}`)
})

test('@import', () => {
expect(stylis(`@import url('http://example.com');`)).to.equal(`@import url('http://example.com');`)
})
Expand Down

0 comments on commit 5b0f732

Please sign in to comment.