@@ -156,8 +156,8 @@ function tokenize(str) {
156
156
else if ( code == 0x22 ) return consumeAStringToken ( ) ;
157
157
else if ( code == 0x23 ) {
158
158
if ( namechar ( next ( ) ) || areAValidEscape ( next ( 1 ) , next ( 2 ) ) ) {
159
- const isIdent = wouldStartAnIdentifier ( next ( 1 ) , next ( 2 ) , next ( 3 ) ) ;
160
- return new HashToken ( consumeAName ( ) , isIdent ) ;
159
+ const type = wouldStartAnIdentifier ( next ( 1 ) , next ( 2 ) , next ( 3 ) ) ? 'id' : 'unrestricted' ;
160
+ return new HashToken ( consumeAName ( ) , type ) ;
161
161
} else {
162
162
return new DelimToken ( code ) ;
163
163
}
@@ -255,15 +255,15 @@ function tokenize(str) {
255
255
} ;
256
256
257
257
var consumeANumericToken = function ( ) {
258
- var { value, isInteger , sign} = consumeANumber ( ) ;
258
+ var { value, type , sign} = consumeANumber ( ) ;
259
259
if ( wouldStartAnIdentifier ( next ( 1 ) , next ( 2 ) , next ( 3 ) ) ) {
260
260
const unit = consumeAName ( ) ;
261
- return new DimensionToken ( value , isInteger , unit , sign ) ;
261
+ return new DimensionToken ( value , type , unit , sign ) ;
262
262
} else if ( next ( ) == 0x25 ) {
263
263
consume ( ) ;
264
264
return new PercentageToken ( value , sign ) ;
265
265
} else {
266
- return new NumberToken ( value , isInteger , sign ) ;
266
+ return new NumberToken ( value , type , sign ) ;
267
267
}
268
268
} ;
269
269
@@ -428,7 +428,7 @@ function tokenize(str) {
428
428
} ;
429
429
430
430
var consumeANumber = function ( ) {
431
- let isInteger = true ;
431
+ let type = 'integer' ;
432
432
let sign ;
433
433
let numberPart = "" ;
434
434
let exponentPart = "" ;
@@ -448,7 +448,7 @@ function tokenize(str) {
448
448
consume ( ) ;
449
449
numberPart += String . fromCodePoint ( code ) ;
450
450
}
451
- isInteger = false ;
451
+ type = 'number' ;
452
452
}
453
453
var c1 = next ( 1 ) , c2 = next ( 2 ) , c3 = next ( 3 ) ;
454
454
const eDigit = ( c1 == 0x45 || c1 == 0x65 ) && digit ( c2 ) ;
@@ -463,7 +463,7 @@ function tokenize(str) {
463
463
consume ( ) ;
464
464
exponentPart += String . fromCodePoint ( code ) ;
465
465
}
466
- isInteger = false ;
466
+ type = 'number' ;
467
467
}
468
468
469
469
// parse with native engine to prevent a precision issue
@@ -472,7 +472,7 @@ function tokenize(str) {
472
472
// let value = +numberPart;
473
473
// if(exponentPart) value = value * Math.pow(10, +exponentPart);
474
474
475
- return { value, isInteger , sign} ;
475
+ return { value, type , sign} ;
476
476
} ;
477
477
478
478
var consumeTheRemnantsOfABadURL = function ( ) {
@@ -504,12 +504,12 @@ function tokenize(str) {
504
504
}
505
505
506
506
class CSSParserToken {
507
- constructor ( type ) {
508
- this . type = type ;
507
+ constructor ( TYPE ) {
508
+ this . TYPE = TYPE ;
509
509
}
510
510
511
- toJSON ( ) { return { type :this . type } ; }
512
- toString ( ) { return this . type ; }
511
+ toJSON ( ) { return { TYPE :this . TYPE } ; }
512
+ toString ( ) { return this . TYPE ; }
513
513
toSource ( ) { throw new Error ( "Not implemented." ) ; }
514
514
}
515
515
//toJSON()
@@ -639,7 +639,7 @@ class DelimToken extends CSSParserToken {
639
639
this . value = val ;
640
640
}
641
641
toString ( ) { return `DELIM(${ this . value } )` ; }
642
- toJSON ( ) { return { type :this . type , value :this . value } ; }
642
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value } ; }
643
643
toSource ( ) {
644
644
if ( this . value == "\\" ) return "\\\n" ;
645
645
return this . value ;
@@ -652,7 +652,7 @@ class IdentToken extends CSSParserToken {
652
652
this . value = val ;
653
653
}
654
654
toString ( ) { return `IDENT(${ this . value } )` ; }
655
- toJSON ( ) { return { type :this . type , value :this . value } ; }
655
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value } ; }
656
656
toSource ( ) { return escapeIdent ( this . value ) ; }
657
657
}
658
658
@@ -663,7 +663,7 @@ class FunctionToken extends CSSParserToken {
663
663
this . mirror = CloseParenToken ;
664
664
}
665
665
toString ( ) { return `FUNCTION(${ this . value } )` ; }
666
- toJSON ( ) { return { type :this . type , value :this . value } ; }
666
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value } ; }
667
667
toSource ( ) { return escapeIdent ( this . value ) + "(" ; }
668
668
}
669
669
@@ -673,20 +673,20 @@ class AtKeywordToken extends CSSParserToken {
673
673
this . value = val ;
674
674
}
675
675
toString ( ) { return `AT(${ this . value } )` ; }
676
- toJSON ( ) { return { type :this . type , value :this . value } ; }
676
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value } ; }
677
677
toSource ( ) { return "@" + escapeIdent ( this . value ) ; }
678
678
}
679
679
680
680
class HashToken extends CSSParserToken {
681
- constructor ( val , isIdent ) {
681
+ constructor ( val , type ) {
682
682
super ( "HASH" ) ;
683
683
this . value = val ;
684
- this . isIdent = isIdent ;
684
+ this . type = type ;
685
685
}
686
686
toString ( ) { return `HASH(${ this . value } )` ; }
687
- toJSON ( ) { return { type :this . type , value :this . value , isIdent :this . isIdent } ; }
687
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value , type :this . type } ; }
688
688
toSource ( ) {
689
- if ( this . isIdent ) {
689
+ if ( this . type === 'id' ) {
690
690
return "#" + escapeIdent ( this . value ) ;
691
691
}
692
692
return "#" + escapeHash ( this . value ) ;
@@ -699,7 +699,7 @@ class StringToken extends CSSParserToken {
699
699
this . value = val ;
700
700
}
701
701
toString ( ) { return `STRING(${ this . value } )` ; }
702
- toJSON ( ) { return { type :this . type , value :this . value } ; }
702
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value } ; }
703
703
toSource ( ) { return `"${ escapeString ( this . value ) } "` ; }
704
704
}
705
705
@@ -709,23 +709,23 @@ class URLToken extends CSSParserToken {
709
709
this . value = val ;
710
710
}
711
711
toString ( ) { return `URL(${ this . value } )` ; }
712
- toJSON ( ) { return { type :this . type , value :this . value } ; }
712
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value } ; }
713
713
toSource ( ) { return `url("${ escapeString ( this . value ) } ")` ; }
714
714
}
715
715
716
716
class NumberToken extends CSSParserToken {
717
- constructor ( val , isInteger , sign = undefined ) {
717
+ constructor ( val , type , sign = undefined ) {
718
718
super ( "NUMBER" ) ;
719
719
this . value = val ;
720
- this . isInteger = isInteger ;
720
+ this . type = type ;
721
721
this . sign = sign ;
722
722
}
723
723
toString ( ) {
724
- const name = this . isInteger ? "INT" : "NUMBER" ;
724
+ const name = this . type === 'integer' ? "INT" : "NUMBER" ;
725
725
const sign = this . sign == "+" ? "+" : "" ;
726
726
return `${ name } (${ sign } ${ this . value } )` ;
727
727
}
728
- toJSON ( ) { return { type :this . type , value :this . value , isInteger :this . isInteger , sign :this . sign } ; }
728
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value , type :this . type , sign :this . sign } ; }
729
729
toSource ( ) { return formatNumber ( this . value , this . sign ) ; }
730
730
}
731
731
@@ -739,23 +739,23 @@ class PercentageToken extends CSSParserToken {
739
739
const sign = this . sign == "+" ? "+" : "" ;
740
740
return `PERCENTAGE(${ sign } ${ this . value } )` ;
741
741
}
742
- toJSON ( ) { return { type :this . type , value :this . value , sign :this . sign } ; }
742
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value , sign :this . sign } ; }
743
743
toSource ( ) { return `${ formatNumber ( this . value , this . sign ) } %` ; }
744
744
}
745
745
746
746
class DimensionToken extends CSSParserToken {
747
- constructor ( val , isInteger , unit , sign = undefined ) {
747
+ constructor ( val , type , unit , sign = undefined ) {
748
748
super ( "DIMENSION" ) ;
749
749
this . value = val ;
750
- this . isInteger = isInteger ;
750
+ this . type = type ;
751
751
this . unit = unit ;
752
752
this . sign = sign ;
753
753
}
754
754
toString ( ) {
755
755
const sign = this . sign == "+" ? "+" : "" ;
756
756
return `DIM(${ sign } ${ this . value } , ${ this . unit } )` ;
757
757
}
758
- toJSON ( ) { return { type :this . type , value :this . value , isInteger :this . isInteger , unit :this . unit , sign :this . sign } ; }
758
+ toJSON ( ) { return { TYPE :this . TYPE , value :this . value , type :this . type , unit :this . unit , sign :this . sign } ; }
759
759
toSource ( ) {
760
760
let unit = escapeIdent ( this . unit ) ;
761
761
if ( unit [ 0 ] . toLowerCase ( ) == "e" && ( unit [ 1 ] == "-" || digit ( unit [ 1 ] . charCodeAt ( 0 ) ) ) ) {
@@ -1142,24 +1142,24 @@ function isValidInContext(construct, context) {
1142
1142
// Trivial validator, without any special CSS knowledge.
1143
1143
1144
1144
// All at-rules are valid, who cares.
1145
- if ( construct . type == "AT-RULE" ) return true ;
1145
+ if ( construct . TYPE == "AT-RULE" ) return true ;
1146
1146
1147
1147
// Exclude qualified rules that ended up with a semicolon
1148
1148
// in their prelude.
1149
1149
// (Can only happen at the top level of a stylesheet.)
1150
- if ( construct . type == "QUALIFIED-RULE" ) {
1150
+ if ( construct . TYPE == "QUALIFIED-RULE" ) {
1151
1151
for ( const val of construct . prelude ) {
1152
- if ( val . type == "SEMICOLON" ) return false ;
1152
+ if ( val . TYPE == "SEMICOLON" ) return false ;
1153
1153
}
1154
1154
return true ;
1155
1155
}
1156
1156
1157
1157
// Exclude properties that ended up with a {}-block
1158
1158
// in their value, unless they're custom.
1159
- if ( construct . type == "DECLARATION" ) {
1159
+ if ( construct . TYPE == "DECLARATION" ) {
1160
1160
if ( construct . name . slice ( 0 , 2 ) == "--" ) return true ;
1161
1161
for ( const val of construct . value ) {
1162
- if ( val . type == "BLOCK" && val . name == "{" ) return false ;
1162
+ if ( val . TYPE == "BLOCK" && val . name == "{" ) return false ;
1163
1163
}
1164
1164
return true ;
1165
1165
}
@@ -1248,7 +1248,7 @@ function parseACommaSeparatedListOfComponentValues(s) {
1248
1248
1249
1249
1250
1250
class CSSParserRule {
1251
- constructor ( type ) { this . type = type ; }
1251
+ constructor ( TYPE ) { this . TYPE = TYPE ; }
1252
1252
toString ( indent ) {
1253
1253
return JSON . stringify ( this , null , indent ) ;
1254
1254
}
@@ -1262,7 +1262,7 @@ class Stylesheet extends CSSParserRule {
1262
1262
}
1263
1263
toJSON ( ) {
1264
1264
return {
1265
- type : this . type ,
1265
+ TYPE : this . TYPE ,
1266
1266
rules : this . rules ,
1267
1267
}
1268
1268
}
@@ -1282,7 +1282,7 @@ class AtRule extends CSSParserRule {
1282
1282
}
1283
1283
toJSON ( ) {
1284
1284
return {
1285
- type : this . type ,
1285
+ TYPE : this . TYPE ,
1286
1286
name : this . name ,
1287
1287
prelude : this . prelude ,
1288
1288
declarations : this . declarations ,
@@ -1318,7 +1318,7 @@ class QualifiedRule extends CSSParserRule {
1318
1318
}
1319
1319
toJSON ( ) {
1320
1320
return {
1321
- type : this . type ,
1321
+ TYPE : this . TYPE ,
1322
1322
prelude : this . prelude ,
1323
1323
declarations : this . declarations ,
1324
1324
rules : this . rules ,
@@ -1349,7 +1349,7 @@ class Declaration extends CSSParserRule {
1349
1349
}
1350
1350
toJSON ( ) {
1351
1351
return {
1352
- type : this . type ,
1352
+ TYPE : this . TYPE ,
1353
1353
name : this . name ,
1354
1354
value : this . value ,
1355
1355
important : this . important ,
@@ -1367,15 +1367,15 @@ class Declaration extends CSSParserRule {
1367
1367
}
1368
1368
1369
1369
class SimpleBlock extends CSSParserRule {
1370
- constructor ( type ) {
1370
+ constructor ( TYPE ) {
1371
1371
super ( "BLOCK" ) ;
1372
- this . name = type ;
1372
+ this . name = TYPE ;
1373
1373
this . value = [ ] ;
1374
1374
return this ;
1375
1375
}
1376
1376
toJSON ( ) {
1377
1377
return {
1378
- type : this . type ,
1378
+ TYPE : this . TYPE ,
1379
1379
name : this . name ,
1380
1380
value : this . value ,
1381
1381
}
@@ -1395,7 +1395,7 @@ class Func extends CSSParserRule {
1395
1395
}
1396
1396
toJSON ( ) {
1397
1397
return {
1398
- type : this . type ,
1398
+ TYPE : this . TYPE ,
1399
1399
name : this . name ,
1400
1400
value : this . value ,
1401
1401
}
0 commit comments