@@ -75,7 +75,7 @@ export function isSelector(key: string): boolean {
7575/**
7676 * Get the selector suffix for a key
7777 */
78- function getSelector ( key : string ) : string | null {
78+ function getSelector ( key : string , styles ?: Styles ) : string | null {
7979 if ( key . startsWith ( '&' ) ) {
8080 return key . slice ( 1 ) ;
8181 }
@@ -85,7 +85,9 @@ function getSelector(key: string): string | null {
8585 }
8686
8787 if ( key . match ( / ^ [ A - Z ] / ) ) {
88- return ` [data-element="${ key } "]` ;
88+ // Check if styles object has $: '>' for direct child selector
89+ const combinator = styles && ( styles as any ) . $ === '>' ? ' > ' : ' ' ;
90+ return `${ combinator } [data-element="${ key } "]` ;
8991 }
9092
9193 return null ;
@@ -613,9 +615,11 @@ function generateLogicalRules(
613615
614616 // Recurse into nested selectors first to compute proper suffix chaining
615617 for ( const key of selectorKeys ) {
616- const suffix = getSelector ( key ) ;
618+ const suffix = getSelector ( key , currentStyles [ key ] as Styles ) ;
617619 if ( suffix && currentStyles [ key ] ) {
618- processStyles ( currentStyles [ key ] as Styles , `${ parentSuffix } ${ suffix } ` ) ;
620+ // Remove $ key to prevent it from being processed as a style property
621+ const { $ : _omit , ...cleanedStyles } = currentStyles [ key ] as any ;
622+ processStyles ( cleanedStyles as Styles , `${ parentSuffix } ${ suffix } ` ) ;
619623 }
620624 }
621625
0 commit comments