@@ -13,7 +13,7 @@ export function modernizeArbitraryValues(
1313 let clone = structuredClone ( candidate )
1414 let changed = false
1515
16- for ( let [ variant , parent ] of variants ( clone ) ) {
16+ for ( let variant of variants ( clone ) ) {
1717 // Expecting an arbitrary variant
1818 if ( variant . kind !== 'arbitrary' ) continue
1919
@@ -25,26 +25,6 @@ export function modernizeArbitraryValues(
2525 // Expecting a single selector node
2626 if ( ast . nodes . length !== 1 ) continue
2727
28- // Track whether we need to add a `*:` variant
29- let addChildVariant = false
30-
31- // Handling a child combinator. E.g.: `[&>[data-visible]]` => `*:data-visible`
32- if (
33- // Only top-level, so `has-[&>[data-visible]]` is not supported
34- parent === null &&
35- // [&_>_[data-visible]]:flex
36- // ^ ^ ^^^^^^^^^^^^^^
37- ast . nodes [ 0 ] . length === 3 &&
38- ast . nodes [ 0 ] . nodes [ 0 ] . type === 'nesting' &&
39- ast . nodes [ 0 ] . nodes [ 0 ] . value === '&' &&
40- ast . nodes [ 0 ] . nodes [ 1 ] . type === 'combinator' &&
41- ast . nodes [ 0 ] . nodes [ 1 ] . value === '>' &&
42- ast . nodes [ 0 ] . nodes [ 2 ] . type === 'attribute'
43- ) {
44- ast . nodes [ 0 ] . nodes = [ ast . nodes [ 0 ] . nodes [ 2 ] ]
45- addChildVariant = true
46- }
47-
4828 // Filter out `&`. E.g.: `&[data-foo]` => `[data-foo]`
4929 let selectorNodes = ast . nodes [ 0 ] . filter ( ( node ) => node . type !== 'nesting' )
5030
@@ -113,14 +93,6 @@ export function modernizeArbitraryValues(
11393 : { kind : 'arbitrary' , value : `${ attributeKey } ${ operator } ${ attributeValue } ` } , // aria-[foo~="true"], aria-[foo|="true"], …
11494 } satisfies Variant )
11595 }
116-
117- if ( addChildVariant ) {
118- let idx = clone . variants . indexOf ( variant )
119- if ( idx === - 1 ) continue
120-
121- // Ensure we have the `*:` variant
122- clone . variants . splice ( idx , 1 , variant , { kind : 'static' , root : '*' } )
123- }
12496 }
12597
12698 return changed ? printCandidate ( designSystem , clone ) : rawCandidate
@@ -130,18 +102,15 @@ export function modernizeArbitraryValues(
130102}
131103
132104function * variants ( candidate : Candidate ) {
133- function * inner (
134- variant : Variant ,
135- parent : Extract < Variant , { kind : 'compound' } > | null = null ,
136- ) : Iterable < [ Variant , Extract < Variant , { kind : 'compound' } > | null ] > {
137- yield [ variant , parent ]
105+ function * inner ( variant : Variant ) : Iterable < Variant > {
106+ yield variant
138107
139108 if ( variant . kind === 'compound' ) {
140- yield * inner ( variant . variant , variant )
109+ yield * inner ( variant . variant )
141110 }
142111 }
143112
144113 for ( let variant of candidate . variants ) {
145- yield * inner ( variant , null )
114+ yield * inner ( variant )
146115 }
147116}
0 commit comments