From accec31c4e720adf057f8494466762c462da82cb Mon Sep 17 00:00:00 2001 From: Ian Prest Date: Wed, 5 Aug 2015 20:53:19 -0400 Subject: [PATCH] Fixed a problem parsing CSS comments -- The WS rule was incorrect, so two WHITESPACE tokens in a row wouldn't work. --- cssparser.y | 3 +-- spec/kb-css-spec.js | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cssparser.y b/cssparser.y index d2fe4e7..bb656f1 100644 --- a/cssparser.y +++ b/cssparser.y @@ -186,7 +186,6 @@ unquoted_attribute_value_char WS : /*empty*/ { $$ = ''; } - | WHITESPACE { $$ = ''; } - | ws WHITESPACE { $$ = ''; } + | WHITESPACE+ { $$ = ''; } ; diff --git a/spec/kb-css-spec.js b/spec/kb-css-spec.js index ede8d77..7489141 100644 --- a/spec/kb-css-spec.js +++ b/spec/kb-css-spec.js @@ -116,5 +116,10 @@ describe('css parser', function() { expect(css.parse('@foo { nested { arbitrary-stuff; } here(); }')).toEqual([ {name: '@foo', content: "nested { arbitrary-stuff; } here();"} ]); }); + it('should ignore CSS comments', function() { + expect(css.parse('/*foo*/\n')).toEqual([]); + expect(css.parse('/*foo*/foo{}')).toEqual([ {selector: ["foo"]} ]); + expect(css.parse('foo{}/*foo*/')).toEqual([ {selector: ["foo"]} ]); + }); });