Commit c533518
feat: reorder style fns, merge static+dynamic, and use named params (#330)
* feat: reorder style fns, merge static+dynamic, and use named params
- Style function entries in stylex.create() now appear immediately after
their corresponding static style key for better readability
- When a static base style is never used without its dynamic counterpart,
they are merged into a single style function
- Style functions with a single parameter now use a named props object
pattern: `(props: {size: number}) => ({...})` instead of positional args
- Extract shared wrapCallArgForPropsObject helper to eliminate duplication
across three emitter call sites
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: skip non-computed MemberExpression properties in identifier rewrite
replaceIdentifierInAst now skips the `property` key of non-computed
MemberExpressions, preventing incorrect rewrites like `Math.min` →
`Math.props.min` when the param name matches a member property name.
Addresses review comment on #330.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: bail on base/fn merge when properties overlap
When mergeBaseIntoSingleStyleFn encounters static properties that also
exist in the dynamic function body, it now bails instead of silently
dropping the static values. This avoids any semantic ambiguity about
override priority between static and dynamic values for the same CSS
property.
Addresses review comment on #330.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: only use named params for merged-base style functions
Derived style function keys like `boxBoxShadow` already encode the
parameter name, so positional args are clearer: `styles.boxBoxShadow(shadow)`.
Named params are now only applied when the function key IS the base
style key (merged base), where the key alone doesn't communicate
what the parameter means: `styles.box({ size: 16 })`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent ea07ffd commit c533518
22 files changed
Lines changed: 733 additions & 86 deletions
File tree
- src
- __tests__
- internal
- emit-wrappers
- lower-rules
- transform-steps
- test-cases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4359 | 4359 | | |
4360 | 4360 | | |
4361 | 4361 | | |
4362 | | - | |
4363 | | - | |
4364 | | - | |
| 4362 | + | |
| 4363 | + | |
| 4364 | + | |
| 4365 | + | |
| 4366 | + | |
| 4367 | + | |
| 4368 | + | |
| 4369 | + | |
4365 | 4370 | | |
4366 | 4371 | | |
4367 | 4372 | | |
| |||
4397 | 4402 | | |
4398 | 4403 | | |
4399 | 4404 | | |
4400 | | - | |
4401 | | - | |
4402 | | - | |
| 4405 | + | |
| 4406 | + | |
| 4407 | + | |
| 4408 | + | |
| 4409 | + | |
| 4410 | + | |
| 4411 | + | |
| 4412 | + | |
4403 | 4413 | | |
4404 | 4414 | | |
4405 | 4415 | | |
| |||
4535 | 4545 | | |
4536 | 4546 | | |
4537 | 4547 | | |
4538 | | - | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
4539 | 4551 | | |
4540 | 4552 | | |
4541 | 4553 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| |||
514 | 519 | | |
515 | 520 | | |
516 | 521 | | |
517 | | - | |
| 522 | + | |
| 523 | + | |
518 | 524 | | |
519 | 525 | | |
520 | 526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
64 | 82 | | |
65 | 83 | | |
66 | 84 | | |
| |||
541 | 559 | | |
542 | 560 | | |
543 | 561 | | |
544 | | - | |
| 562 | + | |
| 563 | + | |
545 | 564 | | |
546 | 565 | | |
547 | 566 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
0 commit comments