@@ -713,7 +713,7 @@ export class ShadowCss {
713713 // (ie: ".\fc ber" for ".über") is not a separator between 2 selectors
714714 // also keep in mind that backslashes are replaced by a placeholder by SafeSelector
715715 // These escaped selectors happen for example when esbuild runs with optimization.minify.
716- if ( part . match ( _placeholderRe ) && selector [ res . index + 1 ] ?. match ( / [ a - f A - F \d ] / ) ) {
716+ if ( part . match ( / _ _ e s c - p h - ( \d + ) _ _ / ) && selector [ res . index + 1 ] ?. match ( / [ a - f A - F \d ] / ) ) {
717717 continue ;
718718 }
719719
@@ -752,7 +752,13 @@ class SafeSelector {
752752 // pseudo-class, but writing `.foo\:blue` will match, because the colon was escaped.
753753 // Replace all escape sequences (`\` followed by a character) with a placeholder so
754754 // that our handling of pseudo-selectors doesn't mess with them.
755- selector = this . _escapeRegexMatches ( selector , / ( \\ .) / g) ;
755+ // Escaped characters have a specific placeholder so they can be detected separately.
756+ selector = selector . replace ( / ( \\ .) / g, ( _ , keep ) => {
757+ const replaceBy = `__esc-ph-${ this . index } __` ;
758+ this . placeholders . push ( keep ) ;
759+ this . index ++ ;
760+ return replaceBy ;
761+ } ) ;
756762
757763 // Replaces the expression in `:nth-child(2n + 1)` with a placeholder.
758764 // WS and "+" would otherwise be interpreted as selector separators.
@@ -765,7 +771,7 @@ class SafeSelector {
765771 }
766772
767773 restore ( content : string ) : string {
768- return content . replace ( _placeholderRe , ( _ph , index ) => this . placeholders [ + index ] ) ;
774+ return content . replace ( / _ _ (?: p h | e s c - p h ) - ( \d + ) _ _ / g , ( _ph , index ) => this . placeholders [ + index ] ) ;
769775 }
770776
771777 content ( ) : string {
@@ -825,8 +831,6 @@ const _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=/g;
825831const COMMENT_PLACEHOLDER = '%COMMENT%' ;
826832const _commentWithHashPlaceHolderRe = new RegExp ( COMMENT_PLACEHOLDER , 'g' ) ;
827833
828- const _placeholderRe = / _ _ p h - ( \d + ) _ _ / g;
829-
830834const BLOCK_PLACEHOLDER = '%BLOCK%' ;
831835const _ruleRe = new RegExp (
832836 `(\\s*(?:${ COMMENT_PLACEHOLDER } \\s*)*)([^;\\{\\}]+?)(\\s*)((?:{%BLOCK%}?\\s*;?)|(?:\\s*;))` ,
0 commit comments