@@ -6,6 +6,7 @@ import { platform, tmpdir } from 'node:os'
66import path from 'node:path'
77import { stripVTControlCharacters } from 'node:util'
88import { test as defaultTest , type ExpectStatic } from 'vitest'
9+ import { escape } from '../packages/tailwindcss/src/utils/escape'
910
1011const REPO_ROOT = path . join ( __dirname , '..' )
1112const PUBLIC_PACKAGES = ( await fs . readdir ( path . join ( REPO_ROOT , 'dist' ) ) ) . map ( ( name ) =>
@@ -521,80 +522,6 @@ export function candidate(strings: TemplateStringsArray, ...values: any[]) {
521522 return `.${ escape ( output . join ( '' ) . trim ( ) ) } `
522523}
523524
524- // https://drafts.csswg.org/cssom/#serialize-an-identifier
525- export function escape ( value : string ) {
526- if ( arguments . length == 0 ) {
527- throw new TypeError ( '`CSS.escape` requires an argument.' )
528- }
529- var string = String ( value )
530- var length = string . length
531- var index = - 1
532- var codeUnit
533- var result = ''
534- var firstCodeUnit = string . charCodeAt ( 0 )
535-
536- if (
537- // If the character is the first character and is a `-` (U+002D), and
538- // there is no second character, […]
539- length == 1 &&
540- firstCodeUnit == 0x002d
541- ) {
542- return '\\' + string
543- }
544-
545- while ( ++ index < length ) {
546- codeUnit = string . charCodeAt ( index )
547- // Note: there’s no need to special-case astral symbols, surrogate
548- // pairs, or lone surrogates.
549-
550- // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
551- // (U+FFFD).
552- if ( codeUnit == 0x0000 ) {
553- result += '\uFFFD'
554- continue
555- }
556-
557- if (
558- // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
559- // U+007F, […]
560- ( codeUnit >= 0x0001 && codeUnit <= 0x001f ) ||
561- codeUnit == 0x007f ||
562- // If the character is the first character and is in the range [0-9]
563- // (U+0030 to U+0039), […]
564- ( index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 ) ||
565- // If the character is the second character and is in the range [0-9]
566- // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
567- ( index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002d )
568- ) {
569- // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
570- result += '\\' + codeUnit . toString ( 16 ) + ' '
571- continue
572- }
573-
574- // If the character is not handled by one of the above rules and is
575- // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
576- // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
577- // U+005A), or [a-z] (U+0061 to U+007A), […]
578- if (
579- codeUnit >= 0x0080 ||
580- codeUnit == 0x002d ||
581- codeUnit == 0x005f ||
582- ( codeUnit >= 0x0030 && codeUnit <= 0x0039 ) ||
583- ( codeUnit >= 0x0041 && codeUnit <= 0x005a ) ||
584- ( codeUnit >= 0x0061 && codeUnit <= 0x007a )
585- ) {
586- // the character itself
587- result += string . charAt ( index )
588- continue
589- }
590-
591- // Otherwise, the escaped character.
592- // https://drafts.csswg.org/cssom/#escape-a-character
593- result += '\\' + string . charAt ( index )
594- }
595- return result
596- }
597-
598525export async function retryAssertion < T > (
599526 fn : ( ) => Promise < T > ,
600527 { timeout = ASSERTION_TIMEOUT , delay = 5 } : { timeout ?: number ; delay ?: number } = { } ,
0 commit comments