@@ -54,7 +54,7 @@ export function parseSelector(selector: string, customNames: Set<string>): Parse
5454 } ;
5555 }
5656
57- const chain = ( from : number , to : number ) : CSSComplexSelector => {
57+ const chain = ( from : number , to : number , turnFirstTextIntoScope : boolean ) : CSSComplexSelector => {
5858 const result : CSSComplexSelector = { simples : [ ] } ;
5959 for ( const part of v1 . parts . slice ( from , to ) ) {
6060 let name = part . name ;
@@ -76,6 +76,8 @@ export function parseSelector(selector: string, customNames: Set<string>): Parse
7676 }
7777 } else if ( name === 'text' ) {
7878 let simple = textSelectorToSimple ( part . body ) ;
79+ if ( turnFirstTextIntoScope )
80+ simple . functions . push ( { name : 'is' , args : [ simpleToComplex ( callWith ( 'scope' , [ ] ) ) , simpleToComplex ( { css : '*' , functions : [ ] } ) ] } ) ;
7981 if ( result . simples . length )
8082 result . simples [ result . simples . length - 1 ] . combinator = '>=' ;
8183 if ( wrapInLight )
@@ -87,14 +89,16 @@ export function parseSelector(selector: string, customNames: Set<string>): Parse
8789 simple = callWith ( 'light' , [ simpleToComplex ( simple ) ] ) ;
8890 result . simples . push ( { selector : simple , combinator : '' } ) ;
8991 }
92+ if ( name !== 'text' )
93+ turnFirstTextIntoScope = false ;
9094 }
9195 return result ;
9296 } ;
9397
9498 const capture = v1 . capture === undefined ? v1 . parts . length - 1 : v1 . capture ;
95- const result = chain ( 0 , capture + 1 ) ;
99+ const result = chain ( 0 , capture + 1 , false ) ;
96100 if ( capture + 1 < v1 . parts . length ) {
97- const has = chain ( capture + 1 , v1 . parts . length ) ;
101+ const has = chain ( capture + 1 , v1 . parts . length , true ) ;
98102 const last = result . simples [ result . simples . length - 1 ] ;
99103 last . selector . functions . push ( { name : 'has' , args : [ has ] } ) ;
100104 }
0 commit comments