Skip to content

Commit ae32413

Browse files
committed
Fix special char representation for toString()
1 parent f2d9800 commit ae32413

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

parse-css.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class DelimToken extends CSSParserToken {
619619
}
620620
this.value = val;
621621
}
622-
toString() { return `DELIM(${this.value})`; }
622+
toString() { return `DELIM(${JSON.stringify(this.value)})`; }
623623
toJSON() { return {type:this.type, value:this.value}; }
624624
toSource() {
625625
if(this.value == "\\") return "\\\n";
@@ -632,7 +632,7 @@ class IdentToken extends CSSParserToken {
632632
super("IDENT");
633633
this.value = val;
634634
}
635-
toString() { return `IDENT(${this.value})`; }
635+
toString() { return `IDENT(${JSON.stringify(this.value)})`; }
636636
toJSON() { return {type:this.type, value:this.value}; }
637637
toSource() { return escapeIdent(this.value); }
638638
}
@@ -643,7 +643,7 @@ class FunctionToken extends CSSParserToken {
643643
this.value = val;
644644
this.mirror = CloseParenToken;
645645
}
646-
toString() { return `FUNCTION(${this.value})`; }
646+
toString() { return `FUNCTION(${JSON.stringify(this.value)})`; }
647647
toJSON() { return {type:this.type, value:this.value}; }
648648
toSource() { return escapeIdent(this.value) + "("; }
649649
}
@@ -653,7 +653,7 @@ class AtKeywordToken extends CSSParserToken {
653653
super("AT-KEYWORD");
654654
this.value = val;
655655
}
656-
toString() { return `AT(${this.value})`; }
656+
toString() { return `AT(${JSON.stringify(this.value)})`; }
657657
toJSON() { return {type:this.type, value:this.value }; }
658658
toSource() { return "@" + escapeIdent(this.value); }
659659
}
@@ -664,7 +664,7 @@ class HashToken extends CSSParserToken {
664664
this.value = val;
665665
this.isIdent = isIdent;
666666
}
667-
toString() { return `HASH(${this.value})`; }
667+
toString() { return `HASH(${JSON.stringify(this.value)})`; }
668668
toJSON() { return {type:this.type, value:this.value, isIdent:this.isIdent}; }
669669
toSource() {
670670
if(this.isIdent) {
@@ -679,7 +679,7 @@ class StringToken extends CSSParserToken {
679679
super("STRING");
680680
this.value = val;
681681
}
682-
toString() { return `STRING(${this.value})`; }
682+
toString() { return `STRING(${JSON.stringify(this.value)})`; }
683683
toJSON() { return {type:this.type, value:this.value}; }
684684
toSource() { return `"${escapeString(this.value)}"`; }
685685
}
@@ -689,7 +689,7 @@ class URLToken extends CSSParserToken {
689689
super("URL");
690690
this.value = val;
691691
}
692-
toString() { return `URL(${this.value})`; }
692+
toString() { return `URL(${JSON.stringify(this.value)})`; }
693693
toJSON() { return {type:this.type, value:this.value}; }
694694
toSource() { return `url("${escapeString(this.value)}")`; }
695695
}
@@ -732,7 +732,7 @@ class DimensionToken extends CSSParserToken {
732732
this.sign = sign;
733733
}
734734
toString() {
735-
return `DIM(${formatNumber(this.value, this.sign)}, ${this.unit})`;
735+
return `DIM(${formatNumber(this.value, this.sign)}, ${JSON.stringify(this.unit)})`;
736736
}
737737
toJSON() { return {type:this.type, value:this.value, isInteger:this.isInteger, unit:this.unit, sign:this.sign}; }
738738
toSource() {

0 commit comments

Comments
 (0)