@@ -107,8 +107,21 @@ class CSSParser {
107107 * 6. :where(.a, .b, .c) a {}
108108 * should be ==> micro-app[name=xxx] :where(.a, .b, .c) a {}
109109 */
110- return m [ 0 ] . replace ( / ( ^ | , [ \n \s ] * ) ( [ ^ , ] + ) / g, ( _ , separator , selector ) => {
110+ const attributeValues : { [ key : string ] : any } = { }
111+ const matchRes = m [ 0 ] . replace ( / \[ ( [ ^ = ] + ) = ? ( .+ ?) \] / g, ( match , p1 , p2 ) => {
112+ const mock = `__mock_${ p1 } Value__`
113+ attributeValues [ mock ] = p2
114+ return match . replace ( p2 , mock )
115+ } )
116+
117+ return matchRes . replace ( / ( ^ | , [ \n \s ] * ) ( [ ^ , ] + ) / g, ( _ , separator , selector ) => {
111118 selector = trim ( selector )
119+ selector = selector . replace ( / \[ [ ^ = ] + = ? ( .+ ?) \] / g, ( match :string , p1 : string ) => {
120+ if ( attributeValues [ p1 ] ) {
121+ return match . replace ( p1 , attributeValues [ p1 ] )
122+ }
123+ return match
124+ } )
112125 if ( selector && ! (
113126 this . scopecssDisableNextLine ||
114127 (
@@ -149,7 +162,7 @@ class CSSParser {
149162 ! this . scopecssDisableNextLine &&
150163 ( ! this . scopecssDisable || this . scopecssDisableSelectors . length )
151164 ) {
152- cssValue = cssValue . replace ( / u r l \( [ " ' ] ? ( [ ^ ) " ' ] + ) [ " ' ] ? \ )/ gm, ( all , $1 ) => {
165+ cssValue = cssValue . replace ( / u r l \( ( [ " ' ] ? ) ( . * ? ) \1 \ )/ gm, ( all , _ , $1 ) => {
153166 if ( / ^ ( ( d a t a | b l o b ) : | # | % 2 3 ) / . test ( $1 ) || / ^ ( h t t p s ? : ) ? \/ \/ / . test ( $1 ) ) {
154167 return all
155168 }
0 commit comments