Skip to content

Commit 4b8b861

Browse files
authored
fix: various bugs (#51)
1 parent 0c4d554 commit 4b8b861

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

parse-css.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ class DelimToken extends CSSParserToken {
626626
}
627627
this.value = val;
628628
}
629-
toString() { return `DELIM(${this.val})`; }
629+
toString() { return `DELIM(${this.value})`; }
630630
toJSON() { return {type:this.type, value:this.value}; }
631631
toSource() {
632632
if(this.value == "\\") return "\\\n";
@@ -745,7 +745,7 @@ class DimensionToken extends CSSParserToken {
745745
toJSON() { return {type:this.type, value:this.value, unit:this.unit}; }
746746
toSource() {
747747
let unit = escapeIdent(this.unit);
748-
if(unit[0].toLowerCase() == "e" && (unit[1] == "-" || digit(unit[1]))) {
748+
if(unit[0].toLowerCase() == "e" && (unit[1] == "-" || digit(unit[1].charCodeAt(0)))) {
749749
// Unit is ambiguous with scinot
750750
// Remove the leading "e", replace with escape.
751751
unit = "\\65 " + unit.slice(1, unit.length);
@@ -880,7 +880,7 @@ class TokenStream {
880880
}
881881

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

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

907907
function consumeAnAtRule(s, nested=false) {
908908
const token = s.consumeToken();
909-
if(!token instanceof AtKeywordToken)
909+
if(!(token instanceof AtKeywordToken))
910910
throw new Error("consumeAnAtRule() called with an invalid token stream state.");
911911
const rule = new AtRule(token.value);
912912
while(1) {
@@ -972,7 +972,7 @@ function looksLikeACustomProperty(tokens) {
972972
}
973973

974974
function consumeABlock(s) {
975-
if(!s.nextToken() instanceof OpenCurlyToken) {
975+
if(!(s.nextToken() instanceof OpenCurlyToken)) {
976976
throw new Error("consumeABlock() called with an invalid token stream state.");
977977
}
978978
s.discardToken();
@@ -1110,7 +1110,7 @@ function consumeASimpleBlock(s) {
11101110
}
11111111

11121112
function consumeAFunction(s) {
1113-
if(!s.nextToken() instanceof FunctionToken) {
1113+
if(!(s.nextToken() instanceof FunctionToken)) {
11141114
throw new Error("consumeAFunction() called with an invalid token stream state.");
11151115
}
11161116
var func = new Func(s.consumeToken().value);

0 commit comments

Comments
 (0)