Skip to content

Commit

Permalink
fix: various bugs (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
MKRhere authored Jan 23, 2024
1 parent 0c4d554 commit 4b8b861
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions parse-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class DelimToken extends CSSParserToken {
}
this.value = val;
}
toString() { return `DELIM(${this.val})`; }
toString() { return `DELIM(${this.value})`; }
toJSON() { return {type:this.type, value:this.value}; }
toSource() {
if(this.value == "\\") return "\\\n";
Expand Down Expand Up @@ -745,7 +745,7 @@ class DimensionToken extends CSSParserToken {
toJSON() { return {type:this.type, value:this.value, unit:this.unit}; }
toSource() {
let unit = escapeIdent(this.unit);
if(unit[0].toLowerCase() == "e" && (unit[1] == "-" || digit(unit[1]))) {
if(unit[0].toLowerCase() == "e" && (unit[1] == "-" || digit(unit[1].charCodeAt(0)))) {
// Unit is ambiguous with scinot
// Remove the leading "e", replace with escape.
unit = "\\65 " + unit.slice(1, unit.length);
Expand Down Expand Up @@ -880,7 +880,7 @@ class TokenStream {
}

function parseerror(s, msg) {
console.log("Parse error at token " + s.i + ": " + s.tokens[i] + ".\n" + msg);
console.log("Parse error at token " + s.i + ": " + s.tokens[s.i] + ".\n" + msg);
return true;
}

Expand All @@ -906,7 +906,7 @@ function consumeAStylesheetsContents(s) {

function consumeAnAtRule(s, nested=false) {
const token = s.consumeToken();
if(!token instanceof AtKeywordToken)
if(!(token instanceof AtKeywordToken))
throw new Error("consumeAnAtRule() called with an invalid token stream state.");
const rule = new AtRule(token.value);
while(1) {
Expand Down Expand Up @@ -972,7 +972,7 @@ function looksLikeACustomProperty(tokens) {
}

function consumeABlock(s) {
if(!s.nextToken() instanceof OpenCurlyToken) {
if(!(s.nextToken() instanceof OpenCurlyToken)) {
throw new Error("consumeABlock() called with an invalid token stream state.");
}
s.discardToken();
Expand Down Expand Up @@ -1110,7 +1110,7 @@ function consumeASimpleBlock(s) {
}

function consumeAFunction(s) {
if(!s.nextToken() instanceof FunctionToken) {
if(!(s.nextToken() instanceof FunctionToken)) {
throw new Error("consumeAFunction() called with an invalid token stream state.");
}
var func = new Func(s.consumeToken().value);
Expand Down

0 comments on commit 4b8b861

Please sign in to comment.