@@ -86,7 +86,7 @@ export class StyleInjector {
8686 if ( rules . length === 0 ) {
8787 return {
8888 className : '' ,
89- dispose : ( ) => { } ,
89+ dispose : ( ) => { } ,
9090 } ;
9191 }
9292
@@ -223,36 +223,36 @@ export class StyleInjector {
223223 const rulesToInsert =
224224 generatedClass && generatedClass !== className
225225 ? rules . map ( ( r ) => {
226- if ( r . selector . startsWith ( '.' + generatedClass ) ) {
227- const newSelector =
228- '.' + className + r . selector . slice ( generatedClass . length + 1 ) ;
229- // Increase specificity by duplicating the class for class-based selectors
230- const specificSelector =
231- newSelector . startsWith ( '.' + className ) &&
226+ if ( r . selector . startsWith ( '.' + generatedClass ) ) {
227+ const newSelector =
228+ '.' + className + r . selector . slice ( generatedClass . length + 1 ) ;
229+ // Increase specificity by duplicating the class for class-based selectors
230+ const specificSelector =
231+ newSelector . startsWith ( '.' + className ) &&
232232 / ^ \. t \d + / . test ( newSelector )
233- ? '.' + className + newSelector
234- : newSelector ;
235- return {
236- ...r ,
237- selector : specificSelector ,
238- } as StyleRule ;
239- }
240- return r ;
241- } )
242- : rules . map ( ( r ) => {
243- // Increase specificity for class-based selectors by duplicating the class
244- if ( r . selector . startsWith ( '.' ) && / ^ \. t \d + / . test ( r . selector ) ) {
245- const classMatch = r . selector . match ( / ^ \. t \d + / ) ;
246- if ( classMatch ) {
247- const baseClass = classMatch [ 0 ] ;
233+ ? '.' + className + newSelector
234+ : newSelector ;
248235 return {
249236 ...r ,
250- selector : baseClass + r . selector ,
237+ selector : specificSelector ,
251238 } as StyleRule ;
252239 }
253- }
254- return r ;
255- } ) ;
240+ return r ;
241+ } )
242+ : rules . map ( ( r ) => {
243+ // Increase specificity for class-based selectors by duplicating the class
244+ if ( r . selector . startsWith ( '.' ) && / ^ \. t \d + / . test ( r . selector ) ) {
245+ const classMatch = r . selector . match ( / ^ \. t \d + / ) ;
246+ if ( classMatch ) {
247+ const baseClass = classMatch [ 0 ] ;
248+ return {
249+ ...r ,
250+ selector : baseClass + r . selector ,
251+ } as StyleRule ;
252+ }
253+ }
254+ return r ;
255+ } ) ;
256256
257257 // Before inserting, auto-register @property for any color custom properties being defined.
258258 // Fast parse: split declarations by ';' and match "--*-color:"
@@ -295,7 +295,7 @@ export class StyleInjector {
295295
296296 return {
297297 className,
298- dispose : ( ) => { } ,
298+ dispose : ( ) => { } ,
299299 } ;
300300 }
301301
@@ -328,7 +328,7 @@ export class StyleInjector {
328328 const registry = this . sheetManager . getRegistry ( root ) ;
329329
330330 if ( ! rules || rules . length === 0 ) {
331- return { dispose : ( ) => { } } ;
331+ return { dispose : ( ) => { } } ;
332332 }
333333
334334 // Use a non-tasty identifier to avoid any collisions with .t{number} classes
@@ -546,7 +546,7 @@ export class StyleInjector {
546546 if ( Object . keys ( steps ) . length === 0 ) {
547547 return {
548548 toString : ( ) => '' ,
549- dispose : ( ) => { } ,
549+ dispose : ( ) => { } ,
550550 } ;
551551 }
552552
@@ -573,7 +573,7 @@ export class StyleInjector {
573573 if ( ! info ) {
574574 return {
575575 toString : ( ) => '' ,
576- dispose : ( ) => { } ,
576+ dispose : ( ) => { } ,
577577 } ;
578578 }
579579
0 commit comments