@@ -151,10 +151,8 @@ function tokenize(str) {
151151 else if ( code == 0x22 ) return consumeAStringToken ( ) ;
152152 else if ( code == 0x23 ) {
153153 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 ) ;
158156 } else {
159157 return new DelimToken ( code ) ;
160158 }
@@ -722,13 +720,19 @@ class AtKeywordToken extends CSSParserToken {
722720}
723721
724722class HashToken extends CSSParserToken {
725- constructor ( val ) {
723+ constructor ( val , isIdent ) {
726724 super ( "HASH" ) ;
727725 this . value = val ;
726+ this . isIdent = isIdent ;
728727 }
729728 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+ }
732736}
733737
734738class StringToken extends CSSParserToken {
0 commit comments