Commit ccc2dcb
committed
fix(stx): also drop reserved keywords from createSafeFunction params
The previous fix dropped only non-identifier names from the function
parameter list. JavaScript also rejects identifiers that match reserved
words ("Cannot use the keyword 'class' as a parameter name"), and
strict-mode-reserved words like `let`, `static`, `arguments`, `eval`.
Real templates trip this constantly: Vue-/Tailwind-style components
spread `class`, `style`, `for`, `data-*`, `aria-*` etc. into the
evaluator as prop bag keys. A single offending key — `class`,
`for`, `let` — used to crash every `@if` / `{{ }}` / safe-evaluation
in the template. The Stacks dashboard hit this on every UI component
that takes a `class` prop (Select, Input, Button, …).
Add a RESERVED_PARAM_NAMES Set covering every word the spec or
strict mode forbids in parameter position, and skip those keys
alongside the existing identifier filter. Same projection wrapper
keeps callers' positional values aligned with the surviving columns.
Tests cover individual reserved words, a grab-bag of common HTML
attribute names, and an end-to-end `@if(disabled)` case where the
context also has a `class` key (the real AppButton scenario).1 parent 146780d commit ccc2dcb
2 files changed
Lines changed: 81 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
453 | 479 | | |
454 | 480 | | |
455 | 481 | | |
| |||
469 | 495 | | |
470 | 496 | | |
471 | 497 | | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
482 | 517 | | |
483 | 518 | | |
484 | 519 | | |
485 | 520 | | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
490 | 526 | | |
491 | 527 | | |
492 | 528 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
41 | 72 | | |
42 | 73 | | |
43 | 74 | | |
| |||
0 commit comments