Skip to content

Commit 2a2e99e

Browse files
committed
fixes #31: values after empty url() func
1 parent d3ecad2 commit 2a2e99e

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

lib/parser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ module.exports = class Parser {
293293
// url functions get special treatment, and anything between the function
294294
// parens get treated as one word, if the contents aren't not a string.
295295
if (this.current.type === 'func' && this.current.unbalanced &&
296-
this.current.value === 'url' && this.currToken[0] !== 'string') {
296+
this.current.value === 'url' && this.currToken[0] !== 'string' &&
297+
this.currToken[0] !== ')') {
298+
297299
let nextToken = this.nextToken,
298300
value = this.currToken[1],
299301
start = {

test/function.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ describe('Parser → Function', () => {
2323
{ type: 'paren', value: ')' }
2424
]
2525
},
26+
{
27+
it: 'should parse empty url function with values following',
28+
test: 'url() foo bar baz',
29+
expected: [
30+
{ type: 'func', value: 'url' },
31+
{ type: 'paren', value: '(' },
32+
{ type: 'paren', value: ')' },
33+
{ type: 'word', value: 'foo' },
34+
{ type: 'word', value: 'bar' },
35+
{ type: 'word', value: 'baz' }
36+
]
37+
},
2638
{
2739
it: 'should parse url function',
2840
test: 'url( /gfx/img/bg.jpg )',
@@ -131,8 +143,6 @@ describe('Parser → Function', () => {
131143
let ast = new Parser(fixture.test).parse(),
132144
index = 0;
133145

134-
// console.log(ast.first.first.nodes);
135-
136146
ast.first.walk((node) => {
137147
let expected = fixture.expected[index];
138148
index ++;

test/tokenize.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ describe('Tokenize', () => {
2121
fixtures.forEach((fixture) => {
2222
it('should tokenize ' + fixture.value.replace(/\n/g, '\\n').replace(/\t/g, '\\t'), () => {
2323
let tokens = tokenize(fixture.value);
24-
console.log(tokens);
2524
expect(tokens.length).to.equal(fixture.expectedLength);
2625
});
2726
});

0 commit comments

Comments
 (0)