Skip to content

TypeError: Cannot read property 'start' of null #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
maribezler opened this issue Dec 5, 2017 · 0 comments
Open

TypeError: Cannot read property 'start' of null #22

maribezler opened this issue Dec 5, 2017 · 0 comments

Comments

@maribezler
Copy link

The Parse is unable to gracefully recover css with incomplete @ rule. I'm getting an error on parsing css from the user input:

TypeError: Cannot read property 'start' of null
at Tokenizer.getRange (shady-css-parser/src/shady-css/tokenizer.js:88:36)
at Parser.parseAtRule (shady-css-parser/src/shady-css/parser.js:148:39)
at Parser.parseRule (shady-css-parser/src/shady-css/parser.js:86:25)
at Parser.parseRules (shady-css-parser/src/shady-css/parser.js:53:31)
at Parser.parseStylesheet (shady-css-parser/src/shady-css/parser.js:41:49)
at Parser.parse (shady-css-parser/src/shady-css/parser.js:34:21)

The minimal css input string example : ul {list-style: square); @. The following code is going to fail in Parser.parseAtRule:

    tokenizer.advance();
    const start = tokenizer.currentToken;
    nameRange = tokenizer.getRange(start, end);

The token.advance() function discards the first @ for media rule and nulls tokenizer.currentToken (start) as nothing left in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant