Commit 1c69ab8
Support no-pseudo reverse and cross-component sibling selectors (#352)
* feat: support cross-component sibling and no-pseudo ancestor selectors
Implement two previously unimplemented selector patterns:
- `${Link}:focus-visible + &` (cross-component sibling combinator)
→ stylex.when.siblingBefore(":focus-visible", LinkMarker)
- `${Other} &` (component as ancestor without pseudo)
→ stylex.when.ancestor(":is(*)", OtherMarker)
Both use defineMarker() for the referenced component, reusing the
existing siblingMarkerNames/siblingMarkerParents → crossFileMarkers
pipeline for sidecar generation and JSX marker injection.
Move _unimplemented.selector-componentDescendant (uses CSS class
selectors) to _unsupported and create new implementable test case.
https://claude.ai/code/session_01X1Gxfz4reNWtojK37AJpsT
* fix: address PR review comments for cross-component selectors
- Bail on cross-file cross-component sibling selectors instead of silently proceeding
- Preserve media query context in cross-component sibling handler
- Fix marker assignment on pre-existing relation overrides
- Add eslint override for stylex.when.siblingBefore() computed keys
- Extend test cases to cover media queries and combined pseudo/no-pseudo patterns
https://claude.ai/code/session_01X1Gxfz4reNWtojK37AJpsT
* fix: bail on computed media queries inside sibling selectors
When resolveMediaAtRulePlaceholders() returns a computed media key (e.g.
from an imported breakpoint constant), both the cross-component sibling
handler and handleSiblingSelector were silently dropping the media guard
by setting media = undefined. This could cause styles to apply
unconditionally instead of respecting viewport constraints.
Now both handlers bail with a descriptive warning instead of silently
dropping the computed media condition.
https://claude.ai/code/session_01X1Gxfz4reNWtojK37AJpsT
* fix: always emit defaultMarker() alongside scoped markers
Scoped markers (from defineMarker) and defaultMarker() must coexist:
- Scoped markers enable targeted sibling/no-pseudo matching
- defaultMarker() enables regular pseudo-reverse selectors like
stylex.when.ancestor(':hover') without an explicit marker arg
Previously, components registered in siblingMarkerKeys had their
defaultMarker() suppressed, breaking mixed scenarios where the same
component was both a sibling target and an ancestor reverse target.
Fixes both rewrite-jsx.ts (JSX marker injection) and style-merger.ts
(wrapper emission) to always include defaultMarker() for ancestor
selector parents.
https://claude.ai/code/session_01X1Gxfz4reNWtojK37AJpsT
* fix: only emit defaultMarker() when parent has non-scoped overrides
Parents that only have scoped marker overrides (sibling selectors,
no-pseudo ancestor with defineMarker) don't need defaultMarker() —
it would be unnecessary overhead. Only emit defaultMarker() when the
parent has at least one override without a markerVarName, which means
it uses stylex.when.ancestor(':pseudo') with no marker argument.
Introduces parentsNeedingDefaultMarker set computed in lower-rules.ts
and plumbed through the pipeline to both JSX emission paths
(rewrite-jsx.ts for inlined components, style-merger.ts for wrappers).
https://claude.ai/code/session_01X1Gxfz4reNWtojK37AJpsT
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3a9357f commit 1c69ab8
22 files changed
Lines changed: 491 additions & 52 deletions
File tree
- src/internal
- emit-wrappers
- lower-rules
- transform-steps
- test-cases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
137 | | - | |
138 | | - | |
139 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
97 | 98 | | |
| 99 | + | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
| 107 | + | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
142 | 154 | | |
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
| 161 | + | |
149 | 162 | | |
150 | 163 | | |
151 | 164 | | |
0 commit comments