Commit 1ac48ad
Support dynamic indexed values in pseudo-element selectors (#353)
* feat: support indexed theme lookup in pseudo-element selectors
Extend tryHandleThemeIndexedLookup in value-patterns.ts to handle
pseudo-element contexts (::placeholder, ::after, ::before). Previously,
indexed theme lookups like `props.theme.color[props.$placeholderColor]`
inside pseudo-element selectors were explicitly skipped, producing a
bail warning. Now the style function body is wrapped in pseudo-element
nesting (e.g., `"::placeholder": { color: $colors[param] }`).
Promotes _unimplemented.selector-dynamicPlaceholderIndexed to a
supported test case and extends selector-dynamicPseudoElement with
an indexed theme variant.
https://claude.ai/code/session_019qihykXE8bykukYa1Zefe3
* fix: bail on indexed theme lookup when static prefix/suffix exists
Prevents silent data loss when an interpolated value has surrounding
static text (e.g., `box-shadow: 0 0 4px ${indexed_theme}`). The indexed
expression cannot be concatenated with a prefix in StyleX, so we bail
and let downstream handlers deal with it.
Addresses PR #353 review feedback.
https://claude.ai/code/session_019qihykXE8bykukYa1Zefe3
* fix: guard indexed theme lookups against CSS shorthand properties
Adds isCssShorthandProperty() check to tryHandleThemeIndexedLookup so it
bails on properties like padding, margin, border, background. These
shorthands cannot be emitted directly in StyleX and the indexed theme
expression produces a single value that cannot be expanded to longhands.
Addresses PR #353 review feedback about shorthand safety.
https://claude.ai/code/session_019qihykXE8bykukYa1Zefe3
* refactor: merge indexed theme lookups into pseudo-element style functions
Move indexed theme resolution into tryHandleDynamicPseudoElementStyleFunction
so that static and dynamic properties produce a single merged StyleX function
(e.g., `styles.input({ placeholderColor })`) instead of separate entries
(`[styles.input, styles.inputPlaceholderColor(placeholderColor)]`).
- Extend isPseudoElementSelector to include ::placeholder
- Add tryResolveIndexedThemeForPseudoElement helper for theme resolution
- Revert pseudo-element handling from tryHandleThemeIndexedLookup
- Fix selector-dynamicPseudoElement test case CSS that blocked playground
interaction (replaced absolute-positioned overlays with block-level elements)
https://claude.ai/code/session_019qihykXE8bykukYa1Zefe3
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 568eb47 commit 1ac48ad
File tree
8 files changed
+403
-73
lines changed- src
- __tests__
- internal
- lower-rules
- test-cases
8 files changed
+403
-73
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5210 | 5210 | | |
5211 | 5211 | | |
5212 | 5212 | | |
| 5213 | + | |
| 5214 | + | |
| 5215 | + | |
| 5216 | + | |
| 5217 | + | |
| 5218 | + | |
| 5219 | + | |
| 5220 | + | |
| 5221 | + | |
| 5222 | + | |
| 5223 | + | |
| 5224 | + | |
| 5225 | + | |
| 5226 | + | |
| 5227 | + | |
| 5228 | + | |
| 5229 | + | |
| 5230 | + | |
| 5231 | + | |
| 5232 | + | |
| 5233 | + | |
| 5234 | + | |
| 5235 | + | |
| 5236 | + | |
| 5237 | + | |
| 5238 | + | |
| 5239 | + | |
| 5240 | + | |
| 5241 | + | |
| 5242 | + | |
| 5243 | + | |
| 5244 | + | |
| 5245 | + | |
| 5246 | + | |
| 5247 | + | |
| 5248 | + | |
| 5249 | + | |
| 5250 | + | |
| 5251 | + | |
| 5252 | + | |
| 5253 | + | |
| 5254 | + | |
| 5255 | + | |
| 5256 | + | |
| 5257 | + | |
| 5258 | + | |
| 5259 | + | |
| 5260 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
20 | 35 | | |
21 | 36 | | |
22 | 37 | | |
| |||
Lines changed: 167 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
2283 | 2285 | | |
2284 | 2286 | | |
2285 | 2287 | | |
2286 | | - | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
2287 | 2381 | | |
2288 | 2382 | | |
2289 | 2383 | | |
2290 | | - | |
2291 | | - | |
2292 | | - | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
2293 | 2387 | | |
2294 | 2388 | | |
2295 | 2389 | | |
| |||
2325 | 2419 | | |
2326 | 2420 | | |
2327 | 2421 | | |
2328 | | - | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
2329 | 2430 | | |
2330 | 2431 | | |
2331 | 2432 | | |
2332 | | - | |
2333 | | - | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
2334 | 2436 | | |
2335 | 2437 | | |
2336 | 2438 | | |
2337 | | - | |
2338 | | - | |
| 2439 | + | |
| 2440 | + | |
2339 | 2441 | | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
2340 | 2475 | | |
2341 | 2476 | | |
2342 | 2477 | | |
2343 | | - | |
2344 | | - | |
2345 | | - | |
2346 | | - | |
2347 | | - | |
2348 | | - | |
2349 | | - | |
2350 | | - | |
2351 | | - | |
2352 | | - | |
2353 | | - | |
2354 | 2478 | | |
2355 | 2479 | | |
2356 | | - | |
2357 | 2480 | | |
2358 | 2481 | | |
2359 | 2482 | | |
2360 | 2483 | | |
2361 | 2484 | | |
2362 | 2485 | | |
2363 | 2486 | | |
2364 | | - | |
2365 | | - | |
2366 | | - | |
2367 | | - | |
2368 | | - | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
2369 | 2492 | | |
2370 | 2493 | | |
2371 | 2494 | | |
2372 | | - | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
2373 | 2505 | | |
2374 | 2506 | | |
2375 | 2507 | | |
2376 | 2508 | | |
2377 | 2509 | | |
2378 | 2510 | | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
2379 | 2517 | | |
2380 | 2518 | | |
2381 | | - | |
| 2519 | + | |
2382 | 2520 | | |
2383 | 2521 | | |
2384 | 2522 | | |
| |||
2400 | 2538 | | |
2401 | 2539 | | |
2402 | 2540 | | |
2403 | | - | |
| 2541 | + | |
2404 | 2542 | | |
2405 | 2543 | | |
2406 | 2544 | | |
| |||
0 commit comments