@@ -48,8 +48,10 @@ function preprocess(str: string): number[] {
4848 if ( code === 0xd && str . charCodeAt ( i + 1 ) === 0xa ) {
4949 code = 0xa ; i ++ ;
5050 }
51- if ( code === 0xd || code === 0xc ) code = 0xa ;
52- if ( code === 0x0 ) code = 0xfffd ;
51+ if ( code === 0xd || code === 0xc )
52+ code = 0xa ;
53+ if ( code === 0x0 )
54+ code = 0xfffd ;
5355 if ( between ( code , 0xd800 , 0xdbff ) && between ( str . charCodeAt ( i + 1 ) , 0xdc00 , 0xdfff ) ) {
5456 // Decode a surrogate pair into an astral codepoint.
5557 const lead = code - 0xd800 ;
@@ -63,7 +65,8 @@ function preprocess(str: string): number[] {
6365}
6466
6567function stringFromCode ( code : number ) {
66- if ( code <= 0xffff ) return String . fromCharCode ( code ) ;
68+ if ( code <= 0xffff )
69+ return String . fromCharCode ( code ) ;
6770 // Otherwise, encode astral char as surrogate pair.
6871 code -= Math . pow ( 2 , 16 ) ;
6972 const lead = Math . floor ( code / Math . pow ( 2 , 10 ) ) + 0xd800 ;
@@ -107,8 +110,10 @@ export function tokenize(str1: string): CSSTokenInterface[] {
107110 num = 1 ;
108111 i += num ;
109112 code = codepoint ( i ) ;
110- if ( newline ( code ) ) incrLineno ( ) ;
111- else column += num ;
113+ if ( newline ( code ) )
114+ incrLineno ( ) ;
115+ else
116+ column += num ;
112117 // console.log('Consume '+i+' '+String.fromCharCode(code) + ' 0x' + code.toString(16));
113118 return true ;
114119 } ;
@@ -125,7 +130,8 @@ export function tokenize(str1: string): CSSTokenInterface[] {
125130 return true ;
126131 } ;
127132 const eof = function ( codepoint ?: number ) : boolean {
128- if ( codepoint === undefined ) codepoint = code ;
133+ if ( codepoint === undefined )
134+ codepoint = code ;
129135 return codepoint === - 1 ;
130136 } ;
131137 const donothing = function ( ) { } ;
@@ -138,12 +144,14 @@ export function tokenize(str1: string): CSSTokenInterface[] {
138144 consumeComments ( ) ;
139145 consume ( ) ;
140146 if ( whitespace ( code ) ) {
141- while ( whitespace ( next ( ) ) ) consume ( ) ;
147+ while ( whitespace ( next ( ) ) )
148+ consume ( ) ;
142149 return new WhitespaceToken ( ) ;
143150 } else if ( code === 0x22 ) { return consumeAStringToken ( ) ; } else if ( code === 0x23 ) {
144151 if ( namechar ( next ( ) ) || areAValidEscape ( next ( 1 ) , next ( 2 ) ) ) {
145152 const token = new HashToken ( '' ) ;
146- if ( wouldStartAnIdentifier ( next ( 1 ) , next ( 2 ) , next ( 3 ) ) ) token . type = 'id' ;
153+ if ( wouldStartAnIdentifier ( next ( 1 ) , next ( 2 ) , next ( 3 ) ) )
154+ token . type = 'id' ;
147155 token . value = consumeAName ( ) ;
148156 return token ;
149157 } else {
@@ -288,7 +296,8 @@ export function tokenize(str1: string): CSSTokenInterface[] {
288296 const str = consumeAName ( ) ;
289297 if ( str . toLowerCase ( ) === 'url' && next ( ) === 0x28 ) {
290298 consume ( ) ;
291- while ( whitespace ( next ( 1 ) ) && whitespace ( next ( 2 ) ) ) consume ( ) ;
299+ while ( whitespace ( next ( 1 ) ) && whitespace ( next ( 2 ) ) )
300+ consume ( ) ;
292301 if ( next ( ) === 0x22 || next ( ) === 0x27 )
293302 return new FunctionToken ( str ) ;
294303 else if ( whitespace ( next ( ) ) && ( next ( 2 ) === 0x22 || next ( 2 ) === 0x27 ) )
@@ -305,7 +314,8 @@ export function tokenize(str1: string): CSSTokenInterface[] {
305314 } ;
306315
307316 const consumeAStringToken = function ( endingCodePoint ?: number ) : CSSParserToken {
308- if ( endingCodePoint === undefined ) endingCodePoint = code ;
317+ if ( endingCodePoint === undefined )
318+ endingCodePoint = code ;
309319 let string = '' ;
310320 while ( consume ( ) ) {
311321 if ( code === endingCodePoint || eof ( ) ) {
@@ -331,13 +341,16 @@ export function tokenize(str1: string): CSSTokenInterface[] {
331341
332342 const consumeAURLToken = function ( ) : CSSTokenInterface {
333343 const token = new URLToken ( '' ) ;
334- while ( whitespace ( next ( ) ) ) consume ( ) ;
335- if ( eof ( next ( ) ) ) return token ;
344+ while ( whitespace ( next ( ) ) )
345+ consume ( ) ;
346+ if ( eof ( next ( ) ) )
347+ return token ;
336348 while ( consume ( ) ) {
337349 if ( code === 0x29 || eof ( ) ) {
338350 return token ;
339351 } else if ( whitespace ( code ) ) {
340- while ( whitespace ( next ( ) ) ) consume ( ) ;
352+ while ( whitespace ( next ( ) ) )
353+ consume ( ) ;
341354 if ( next ( ) === 0x29 || eof ( next ( ) ) ) {
342355 consume ( ) ;
343356 return token ;
@@ -379,9 +392,11 @@ export function tokenize(str1: string): CSSTokenInterface[] {
379392 break ;
380393 }
381394 }
382- if ( whitespace ( next ( ) ) ) consume ( ) ;
395+ if ( whitespace ( next ( ) ) )
396+ consume ( ) ;
383397 let value = parseInt ( digits . map ( function ( x ) { return String . fromCharCode ( x ) ; } ) . join ( '' ) , 16 ) ;
384- if ( value > maximumallowedcodepoint ) value = 0xfffd ;
398+ if ( value > maximumallowedcodepoint )
399+ value = 0xfffd ;
385400 return value ;
386401 } else if ( eof ( ) ) {
387402 return 0xfffd ;
@@ -391,8 +406,10 @@ export function tokenize(str1: string): CSSTokenInterface[] {
391406 } ;
392407
393408 const areAValidEscape = function ( c1 : number , c2 : number ) {
394- if ( c1 !== 0x5c ) return false ;
395- if ( newline ( c2 ) ) return false ;
409+ if ( c1 !== 0x5c )
410+ return false ;
411+ if ( newline ( c2 ) )
412+ return false ;
396413 return true ;
397414 } ;
398415 const startsWithAValidEscape = function ( ) {
@@ -416,11 +433,14 @@ export function tokenize(str1: string): CSSTokenInterface[] {
416433
417434 const wouldStartANumber = function ( c1 : number , c2 : number , c3 : number ) {
418435 if ( c1 === 0x2b || c1 === 0x2d ) {
419- if ( digit ( c2 ) ) return true ;
420- if ( c2 === 0x2e && digit ( c3 ) ) return true ;
436+ if ( digit ( c2 ) )
437+ return true ;
438+ if ( c2 === 0x2e && digit ( c3 ) )
439+ return true ;
421440 return false ;
422441 } else if ( c1 === 0x2e ) {
423- if ( digit ( c2 ) ) return true ;
442+ if ( digit ( c2 ) )
443+ return true ;
424444 return false ;
425445 } else if ( digit ( c1 ) ) {
426446 return true ;
@@ -519,7 +539,8 @@ export function tokenize(str1: string): CSSTokenInterface[] {
519539 while ( ! eof ( next ( ) ) ) {
520540 tokens . push ( consumeAToken ( ) ) ;
521541 iterationCount ++ ;
522- if ( iterationCount > str . length * 2 ) throw new Error ( "I'm infinite-looping!" ) ;
542+ if ( iterationCount > str . length * 2 )
543+ throw new Error ( "I'm infinite-looping!" ) ;
523544 }
524545 return tokens ;
525546}
0 commit comments