@@ -151,10 +151,8 @@ function tokenize(str) {
151
151
else if ( code == 0x22 ) return consumeAStringToken ( ) ;
152
152
else if ( code == 0x23 ) {
153
153
if ( namechar ( next ( ) ) || areAValidEscape ( next ( 1 ) , next ( 2 ) ) ) {
154
- var token = new HashToken ( ) ;
155
- if ( wouldStartAnIdentifier ( next ( 1 ) , next ( 2 ) , next ( 3 ) ) ) token . type = "id" ;
156
- token . value = consumeAName ( ) ;
157
- return token ;
154
+ const isIdent = wouldStartAnIdentifier ( next ( 1 ) , next ( 2 ) , next ( 3 ) ) ;
155
+ return new HashToken ( consumeAName ( ) , isIdent ) ;
158
156
} else {
159
157
return new DelimToken ( code ) ;
160
158
}
@@ -722,13 +720,19 @@ class AtKeywordToken extends CSSParserToken {
722
720
}
723
721
724
722
class HashToken extends CSSParserToken {
725
- constructor ( val ) {
723
+ constructor ( val , isIdent ) {
726
724
super ( "HASH" ) ;
727
725
this . value = val ;
726
+ this . isIdent = isIdent ;
728
727
}
729
728
toString ( ) { return `HASH(${ this . value } )` ; }
730
- toJSON ( ) { return { type :this . type , value :this . value } ; }
731
- toSource ( ) { return "#" + escapeHash ( this . value ) ; }
729
+ toJSON ( ) { return { type :this . type , value :this . value , isIdent :this . isIdent } ; }
730
+ toSource ( ) {
731
+ if ( this . isIdent ) {
732
+ return "#" + escapeIdent ( this . value ) ;
733
+ }
734
+ return "#" + escapeHash ( this . value ) ;
735
+ }
732
736
}
733
737
734
738
class StringToken extends CSSParserToken {
0 commit comments