jscssp icon indicating copy to clipboard operation
jscssp copied to clipboard

Issue with expanding the font shorthand property

Open kapetan opened this issue 9 years ago • 0 comments

I've encountered an error when trying parse the font shorthand property. E.g.

var source = 'body { font: 14px sans-serif; }';

var parser = new CSSParser();
var ast = parser.parse(source, false, true);

console.log(ast.cssText());

This outputs and empty body rule in the console.

body {
}

Even though this is a valid font declaration. But when the line-height is present the output is correct. So using body { font: 14px/28px sans-serif; } as source the property is expanded correctly.

This seems to be a general problem with the getToken and ungetToken methods.

var token = this.getToken(false, false);
this.ungetToken();
token = this.getToken(true, true);

The last call might return whitespace even though the skip whitespace argument is set to true, because it reads this.mLookAhead.

This seems to be causing the error when trying to parse the font property.

Is also seems that the code on github is older than that on npm. Is it possible to sync these?

kapetan avatar Mar 01 '15 11:03 kapetan