@barefootjs/jsx 0.40.0 → 0.40.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/dist/adapters/ambiguous-nil-arithmetic.d.ts +42 -0
  2. package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +1 -0
  3. package/dist/adapters/attr-plan.d.ts.map +1 -1
  4. package/dist/adapters/boolean-carrier.d.ts +31 -0
  5. package/dist/adapters/boolean-carrier.d.ts.map +1 -0
  6. package/dist/adapters/boolean-result.d.ts +32 -10
  7. package/dist/adapters/boolean-result.d.ts.map +1 -1
  8. package/dist/adapters/brace-delimiter-text.d.ts +18 -0
  9. package/dist/adapters/brace-delimiter-text.d.ts.map +1 -0
  10. package/dist/adapters/callback-method.d.ts +38 -5
  11. package/dist/adapters/callback-method.d.ts.map +1 -1
  12. package/dist/adapters/component-props.d.ts +22 -7
  13. package/dist/adapters/component-props.d.ts.map +1 -1
  14. package/dist/adapters/computed-const.d.ts +28 -1
  15. package/dist/adapters/computed-const.d.ts.map +1 -1
  16. package/dist/adapters/dsl-template-adapter.d.ts +39 -1
  17. package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
  18. package/dist/adapters/loop-bound-names.d.ts +9 -1
  19. package/dist/adapters/loop-bound-names.d.ts.map +1 -1
  20. package/dist/adapters/loop-row-type.d.ts +52 -0
  21. package/dist/adapters/loop-row-type.d.ts.map +1 -0
  22. package/dist/adapters/nil-reading.d.ts +68 -0
  23. package/dist/adapters/nil-reading.d.ts.map +1 -0
  24. package/dist/adapters/non-primitive-equality.d.ts +33 -0
  25. package/dist/adapters/non-primitive-equality.d.ts.map +1 -0
  26. package/dist/adapters/number-value.d.ts +45 -0
  27. package/dist/adapters/number-value.d.ts.map +1 -0
  28. package/dist/adapters/operand-typing.d.ts +126 -0
  29. package/dist/adapters/operand-typing.d.ts.map +1 -0
  30. package/dist/adapters/parsed-expr-emitter.d.ts +70 -12
  31. package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
  32. package/dist/adapters/primitive-plan.d.ts +291 -0
  33. package/dist/adapters/primitive-plan.d.ts.map +1 -0
  34. package/dist/analyzer-context.d.ts +11 -0
  35. package/dist/analyzer-context.d.ts.map +1 -1
  36. package/dist/analyzer.d.ts +34 -0
  37. package/dist/analyzer.d.ts.map +1 -1
  38. package/dist/augment-inherited-props.d.ts +63 -8
  39. package/dist/augment-inherited-props.d.ts.map +1 -1
  40. package/dist/compiler.d.ts.map +1 -1
  41. package/dist/event-handler-name.d.ts +12 -0
  42. package/dist/event-handler-name.d.ts.map +1 -1
  43. package/dist/expression-parser.d.ts +8 -0
  44. package/dist/expression-parser.d.ts.map +1 -1
  45. package/dist/index.d.ts +24 -11
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +5671 -2586
  48. package/dist/ir-to-client-js/build-references.d.ts.map +1 -1
  49. package/dist/ir-to-client-js/child-props-object.d.ts +64 -0
  50. package/dist/ir-to-client-js/child-props-object.d.ts.map +1 -0
  51. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  52. package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
  53. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts +29 -0
  54. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
  55. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts +2 -0
  56. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -1
  57. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
  58. package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
  59. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts +5 -4
  60. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts.map +1 -1
  61. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +2 -0
  62. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
  63. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +15 -0
  64. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
  65. package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts +2 -0
  66. package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts.map +1 -1
  67. package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
  68. package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +22 -0
  69. package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
  70. package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts.map +1 -1
  71. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +1 -1
  72. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
  73. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -1
  74. package/dist/ir-to-client-js/html-template.d.ts +3 -2
  75. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  76. package/dist/ir-to-client-js/imports.d.ts +2 -2
  77. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  78. package/dist/ir-to-client-js/index.d.ts +2 -6
  79. package/dist/ir-to-client-js/index.d.ts.map +1 -1
  80. package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
  81. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +37 -19
  82. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
  83. package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
  84. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  85. package/dist/ir-to-client-js/safe-html.d.ts +9 -3
  86. package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
  87. package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts +3 -2
  88. package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
  89. package/dist/ir-to-client-js/types.d.ts +30 -0
  90. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  91. package/dist/ir-to-client-js/utils.d.ts +8 -0
  92. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  93. package/dist/jsx-to-ir.d.ts +1 -0
  94. package/dist/jsx-to-ir.d.ts.map +1 -1
  95. package/dist/nullable-signal-attr.d.ts +95 -10
  96. package/dist/nullable-signal-attr.d.ts.map +1 -1
  97. package/dist/prop-rewrite.d.ts +7 -0
  98. package/dist/prop-rewrite.d.ts.map +1 -1
  99. package/dist/props-binding.d.ts +27 -3
  100. package/dist/props-binding.d.ts.map +1 -1
  101. package/dist/props-object-whole-read.d.ts +15 -0
  102. package/dist/props-object-whole-read.d.ts.map +1 -0
  103. package/dist/rich-type-refusal.d.ts.map +1 -1
  104. package/dist/scope/binding-scope.d.ts +100 -4
  105. package/dist/scope/binding-scope.d.ts.map +1 -1
  106. package/dist/scope/lexical-scope-walk.d.ts +3 -2
  107. package/dist/scope/lexical-scope-walk.d.ts.map +1 -1
  108. package/dist/scope/root-prop-alias.d.ts +16 -0
  109. package/dist/scope/root-prop-alias.d.ts.map +1 -1
  110. package/dist/signal-prop-name-collision.d.ts.map +1 -1
  111. package/dist/ssr-defaults.d.ts +4 -2
  112. package/dist/ssr-defaults.d.ts.map +1 -1
  113. package/dist/ssr-seed-plan.d.ts +14 -0
  114. package/dist/ssr-seed-plan.d.ts.map +1 -1
  115. package/dist/strip-types.d.ts +13 -0
  116. package/dist/strip-types.d.ts.map +1 -1
  117. package/dist/template-parts.d.ts.map +1 -1
  118. package/dist/template-position-walk.d.ts +21 -3
  119. package/dist/template-position-walk.d.ts.map +1 -1
  120. package/dist/types.d.ts +120 -0
  121. package/dist/types.d.ts.map +1 -1
  122. package/package.json +2 -2
  123. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +3 -3
  124. package/src/__tests__/binding-scope-ratchet.test.ts +12 -2
  125. package/src/__tests__/binding-scope.test.ts +89 -1
  126. package/src/__tests__/body-destructure-props-object-alias.test.ts +123 -0
  127. package/src/__tests__/boolean-carrier.test.ts +74 -0
  128. package/src/__tests__/boolean-result.test.ts +22 -5
  129. package/src/__tests__/brace-delimiter-text.test.ts +26 -0
  130. package/src/__tests__/callback-method.test.ts +62 -2
  131. package/src/__tests__/child-components-in-map.test.ts +1 -1
  132. package/src/__tests__/component-props.test.ts +14 -0
  133. package/src/__tests__/computed-const.test.ts +188 -0
  134. package/src/__tests__/emit-to-string-call.test.ts +2 -1
  135. package/src/__tests__/expression-parser.test.ts +24 -0
  136. package/src/__tests__/hydration-payload-analysis.test.ts +166 -0
  137. package/src/__tests__/issue-2724-prop-alias-loop-not-static.test.ts +7 -7
  138. package/src/__tests__/issue-2754-rest-spread-needs-slot.test.ts +5 -2
  139. package/src/__tests__/issue-2798-static-nested-loop-bindings.test.ts +1 -1
  140. package/src/__tests__/issue-2835-props-type-member-name-collision.test.ts +4 -4
  141. package/src/__tests__/issue-3044-nested-prop-object-array-not-static.test.ts +1 -1
  142. package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +143 -0
  143. package/src/__tests__/issue-3713-props-spread-loop-row.test.ts +65 -0
  144. package/src/__tests__/lookup-literal-const.test.ts +9 -3
  145. package/src/__tests__/loop-index-reactivity.test.ts +2 -2
  146. package/src/__tests__/loop-param-accessor-key-member-safety.test.ts +1 -1
  147. package/src/__tests__/loop-plan.test.ts +1 -1
  148. package/src/__tests__/loop-row-const-initializer-shadow.test.ts +146 -0
  149. package/src/__tests__/loop-row-prop-read.test.ts +111 -0
  150. package/src/__tests__/loop-row-type.test.ts +64 -0
  151. package/src/__tests__/lowering-value-position.test.ts +4 -0
  152. package/src/__tests__/memo-body-expr.test.ts +137 -0
  153. package/src/__tests__/module-const-destructure-default.test.ts +156 -0
  154. package/src/__tests__/nested-loop-index-param.test.ts +1 -1
  155. package/src/__tests__/nested-loop-reactive-attrs.test.ts +2 -2
  156. package/src/__tests__/nested-row-shadowing.test.ts +2 -2
  157. package/src/__tests__/nil-reading.test.ts +77 -0
  158. package/src/__tests__/nullable-signal-attr.test.ts +231 -2
  159. package/src/__tests__/primitive-plan.test.ts +416 -0
  160. package/src/__tests__/profile-binding-ids.test.ts +14 -0
  161. package/src/__tests__/profile-loop-binding-ids.test.ts +2 -2
  162. package/src/__tests__/profile-nested-binding-ids.test.ts +2 -2
  163. package/src/__tests__/props-object-whole-read.test.ts +40 -0
  164. package/src/__tests__/reactive-attrs-in-map.test.ts +1 -1
  165. package/src/__tests__/reactive-factory-inlining.test.ts +4 -1
  166. package/src/__tests__/rest-binding-gaps.test.ts +192 -0
  167. package/src/__tests__/root-prop-alias.test.ts +79 -1
  168. package/src/__tests__/signal-prop-name-collision.test.ts +102 -2
  169. package/src/__tests__/source-file-cache.test.ts +105 -0
  170. package/src/__tests__/ssr-seed-plan.test.ts +43 -0
  171. package/src/__tests__/static-loop-csr-materialize.test.ts +2 -2
  172. package/src/__tests__/static-record-literal-array.test.ts +171 -0
  173. package/src/__tests__/string-concat-identifier.test.ts +40 -1
  174. package/src/__tests__/template-parts-literal-boundary.test.ts +19 -0
  175. package/src/adapters/ambiguous-nil-arithmetic.ts +103 -0
  176. package/src/adapters/attr-plan.ts +6 -2
  177. package/src/adapters/boolean-carrier.ts +76 -0
  178. package/src/adapters/boolean-result.ts +72 -66
  179. package/src/adapters/brace-delimiter-text.ts +25 -0
  180. package/src/adapters/callback-method.ts +151 -27
  181. package/src/adapters/component-props.ts +28 -8
  182. package/src/adapters/computed-const.ts +443 -10
  183. package/src/adapters/dsl-template-adapter.ts +79 -2
  184. package/src/adapters/loop-bound-names.ts +9 -1
  185. package/src/adapters/loop-plan.ts +1 -1
  186. package/src/adapters/loop-row-type.ts +139 -0
  187. package/src/adapters/nil-reading.ts +297 -0
  188. package/src/adapters/non-primitive-equality.ts +92 -0
  189. package/src/adapters/number-value.ts +108 -0
  190. package/src/adapters/operand-typing.ts +522 -0
  191. package/src/adapters/parsed-expr-emitter.ts +154 -19
  192. package/src/adapters/primitive-plan.ts +696 -0
  193. package/src/analyzer-context.ts +14 -0
  194. package/src/analyzer.ts +692 -85
  195. package/src/augment-inherited-props.ts +108 -10
  196. package/src/compiler.ts +17 -0
  197. package/src/event-handler-name.ts +15 -0
  198. package/src/expression-parser.ts +74 -2
  199. package/src/index.ts +45 -9
  200. package/src/ir-to-client-js/build-references.ts +69 -0
  201. package/src/ir-to-client-js/child-props-object.ts +106 -0
  202. package/src/ir-to-client-js/collect-elements.ts +100 -67
  203. package/src/ir-to-client-js/compute-inlinability.ts +1 -1
  204. package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +15 -1
  205. package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +85 -5
  206. package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +3 -0
  207. package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +30 -28
  208. package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +1 -0
  209. package/src/ir-to-client-js/control-flow/plan/inner-loop.ts +5 -4
  210. package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +2 -0
  211. package/src/ir-to-client-js/control-flow/plan/loop.ts +12 -0
  212. package/src/ir-to-client-js/control-flow/plan/reactive-effects.ts +2 -0
  213. package/src/ir-to-client-js/control-flow/shared.ts +23 -24
  214. package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +29 -0
  215. package/src/ir-to-client-js/control-flow/stringify/component-loop.ts +8 -2
  216. package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +8 -1
  217. package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +8 -7
  218. package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +8 -7
  219. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +4 -4
  220. package/src/ir-to-client-js/control-flow/stringify/loop.ts +3 -3
  221. package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +6 -6
  222. package/src/ir-to-client-js/emit-reactive.ts +1 -1
  223. package/src/ir-to-client-js/html-template.ts +95 -38
  224. package/src/ir-to-client-js/imports.ts +1 -1
  225. package/src/ir-to-client-js/index.ts +53 -11
  226. package/src/ir-to-client-js/plan/build-static-array-child-init.ts +42 -15
  227. package/src/ir-to-client-js/plan/static-array-child-init.ts +34 -19
  228. package/src/ir-to-client-js/prop-handling.ts +22 -3
  229. package/src/ir-to-client-js/reactivity.ts +14 -0
  230. package/src/ir-to-client-js/safe-html.ts +11 -4
  231. package/src/ir-to-client-js/stringify/static-array-child-init.ts +30 -12
  232. package/src/ir-to-client-js/types.ts +23 -0
  233. package/src/ir-to-client-js/utils.ts +15 -1
  234. package/src/jsx-to-ir.ts +510 -58
  235. package/src/nullable-signal-attr.ts +366 -28
  236. package/src/prop-rewrite.ts +30 -6
  237. package/src/props-binding.ts +54 -3
  238. package/src/props-object-whole-read.ts +87 -0
  239. package/src/rich-type-refusal.ts +2 -1
  240. package/src/scope/binding-scope.ts +203 -11
  241. package/src/scope/lexical-scope-walk.ts +4 -3
  242. package/src/scope/root-prop-alias.ts +23 -0
  243. package/src/signal-prop-name-collision.ts +113 -22
  244. package/src/ssr-defaults.ts +10 -4
  245. package/src/ssr-seed-plan.ts +82 -17
  246. package/src/strip-types.ts +31 -3
  247. package/src/template-parts.ts +21 -1
  248. package/src/template-position-walk.ts +57 -28
  249. package/src/types.ts +117 -0
@@ -0,0 +1,146 @@
1
+ /**
2
+ * #3736: a component-scope const read in a loop row whose bindings shadow a
3
+ * name the const's initializer reads (`const b = a` read as `{b}` in
4
+ * `rows.map(a => …)`). `expandConstantForReactivity` /
5
+ * `expandDynamicPropValue` (`prop-handling.ts`) used to splice the
6
+ * initializer text (`a`) into the row, where it re-resolved to the row's own
7
+ * binding, so a client-built or updated row read the row value (`a()`).
8
+ * The initializer resolves in the component scope; when a row binding would
9
+ * capture one of its free names, the row reads the const itself, which init
10
+ * declares.
11
+ *
12
+ * The emitted client JS is read with the TypeScript AST: every per-row slot
13
+ * value is a `const __x = <expr>` declaration inside a row function.
14
+ */
15
+
16
+ import { describe, test, expect } from 'bun:test'
17
+ import ts from 'typescript'
18
+ import { compileJSX } from '../compiler'
19
+ import { TestAdapter } from '../adapters/test-adapter'
20
+
21
+ const adapter = new TestAdapter()
22
+
23
+ function clientJsFor(source: string): string {
24
+ const result = compileJSX(source, 'Repro.tsx', { adapter })
25
+ expect(result.errors.filter(e => e.severity === 'error')).toHaveLength(0)
26
+ const clientJs = result.files.find(f => f.type === 'clientJs')
27
+ expect(clientJs).toBeDefined()
28
+ return clientJs!.content
29
+ }
30
+
31
+ /** The initializer text of every `const __x = …` slot-value declaration. */
32
+ function slotValues(js: string): string[] {
33
+ const sf = ts.createSourceFile('out.js', js, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS)
34
+ const values: string[] = []
35
+ const visit = (node: ts.Node): void => {
36
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === '__x' && node.initializer) {
37
+ values.push(node.initializer.getText(sf))
38
+ }
39
+ ts.forEachChild(node, visit)
40
+ }
41
+ visit(sf)
42
+ return values
43
+ }
44
+
45
+ describe('a const read in a loop row that shadows a name its initializer reads (#3736)', () => {
46
+ test('destructured prop hop: the row reads the const, not the row value', () => {
47
+ const values = slotValues(clientJsFor(`
48
+ 'use client'
49
+ export function C({ a, rows }: { a: string; rows: string[] }) {
50
+ const b = a
51
+ return <ul>{rows.map(a => <li key={a} title={b}>{b}/{a}</li>)}</ul>
52
+ }
53
+ `))
54
+ // `title={b}` and `{b}` read the const; only `{a}` reads the row.
55
+ expect(values).toContain('b')
56
+ expect(values).toContain('a()')
57
+ expect(values.every(v => v === 'b' || v === 'a()')).toBe(true)
58
+ })
59
+
60
+ test('a two-hop alias whose middle name the row binds', () => {
61
+ const values = slotValues(clientJsFor(`
62
+ 'use client'
63
+ export function C({ label, rows }: { label: string; rows: string[] }) {
64
+ const a = label
65
+ const b = a
66
+ return <ul>{rows.map(a => <li key={a}>{b}</li>)}</ul>
67
+ }
68
+ `))
69
+ expect(values.length).toBeGreaterThan(0)
70
+ expect(values.every(v => v === 'b')).toBe(true)
71
+ })
72
+
73
+ test('a row that binds the prop itself', () => {
74
+ const values = slotValues(clientJsFor(`
75
+ 'use client'
76
+ export function C({ label, rows }: { label: string; rows: string[] }) {
77
+ const c = label
78
+ return <ul>{rows.map(label => <li key={label} title={c}>{c}</li>)}</ul>
79
+ }
80
+ `))
81
+ expect(values.length).toBeGreaterThan(0)
82
+ expect(values.every(v => v === 'c')).toBe(true)
83
+ })
84
+
85
+ test('an index param and a callback preamble local shadow the name too', () => {
86
+ const indexValues = slotValues(clientJsFor(`
87
+ 'use client'
88
+ export function C({ a, rows }: { a: string; rows: string[] }) {
89
+ const b = a
90
+ return <ul>{rows.map((r, a) => <li key={r}>{b}</li>)}</ul>
91
+ }
92
+ `))
93
+ expect(indexValues.length).toBeGreaterThan(0)
94
+ expect(indexValues.every(v => v === 'b')).toBe(true)
95
+
96
+ const preambleValues = slotValues(clientJsFor(`
97
+ 'use client'
98
+ export function C({ a, rows }: { a: string; rows: string[] }) {
99
+ const b = a
100
+ return <ul>{rows.map(r => { const a = r + '!'; return <li key={r} title={a}>{b}</li> })}</ul>
101
+ }
102
+ `))
103
+ expect(preambleValues).toContain('b')
104
+ expect(preambleValues).not.toContain('_p.a')
105
+ })
106
+
107
+ test('function C(props) with a renamed body destructure', () => {
108
+ const values = slotValues(clientJsFor(`
109
+ 'use client'
110
+ export function C(props: { label: string; rows: string[] }) {
111
+ const { label: text } = props
112
+ const c = text
113
+ return <ul>{props.rows.map(text => <li key={text} title={c}>{c}/{text}</li>)}</ul>
114
+ }
115
+ `))
116
+ expect(values).toContain('c')
117
+ expect(values.filter(v => v !== 'c').every(v => v === 'text()')).toBe(true)
118
+ })
119
+
120
+ test('a const reading a signal getter the row shadows', () => {
121
+ const values = slotValues(clientJsFor(`
122
+ 'use client'
123
+ import { createSignal } from '@barefootjs/client'
124
+ export function C({ rows }: { rows: string[] }) {
125
+ const [count] = createSignal(7)
126
+ const b = count()
127
+ return <ul>{rows.map(count => <li key={count}>{b}/{count}</li>)}</ul>
128
+ }
129
+ `))
130
+ expect(values).toContain('b')
131
+ expect(values).toContain('count()')
132
+ expect(values.every(v => v === 'b' || v === 'count()')).toBe(true)
133
+ })
134
+
135
+ test('a row that shadows nothing the initializer reads still expands it', () => {
136
+ const values = slotValues(clientJsFor(`
137
+ 'use client'
138
+ export function C({ a, rows }: { a: string; rows: string[] }) {
139
+ const b = a
140
+ return <ul>{rows.map(r => <li key={r}>{b}</li>)}</ul>
141
+ }
142
+ `))
143
+ expect(values.length).toBeGreaterThan(0)
144
+ expect(values.every(v => v === '_p.a')).toBe(true)
145
+ })
146
+ })
@@ -0,0 +1,111 @@
1
+ /**
2
+ * `IRExpression.loopRowPropRead`: which child-position expressions inside a
3
+ * loop row read one of the component's own props (other than `children`),
4
+ * decided from the binding in Phase 1. The client claims and writes those row
5
+ * slots as markup, so a caller's JSX element at that prop renders once
6
+ * instead of as `[object Object]` beside a duplicate of the element.
7
+ */
8
+ import { describe, test, expect } from 'bun:test'
9
+ import { compileJSX } from '../compiler'
10
+ import { TestAdapter } from '../adapters/test-adapter'
11
+
12
+ /** `[expr, loopRowPropRead]` of every expression child, in document order. */
13
+ function propReads(source: string): [string, boolean][] {
14
+ const result = compileJSX(source.trimStart(), 'C.tsx', { adapter: new TestAdapter(), outputIR: true })
15
+ const ir = JSON.parse(result.files.find(f => f.type === 'ir')!.content)
16
+ const out: [string, boolean][] = []
17
+ const walk = (node: unknown): void => {
18
+ if (!node || typeof node !== 'object') return
19
+ const n = node as Record<string, unknown>
20
+ if (n.type === 'expression') out.push([n.expr as string, n.loopRowPropRead === true])
21
+ for (const value of Object.values(n)) {
22
+ if (Array.isArray(value)) value.forEach(walk)
23
+ else if (value && typeof value === 'object') walk(value)
24
+ }
25
+ }
26
+ walk(ir.root)
27
+ return out
28
+ }
29
+
30
+ /** The client JS of the first component in `source`. */
31
+ function clientJs(source: string): string {
32
+ const result = compileJSX(source.trimStart(), 'C.tsx', { adapter: new TestAdapter() })
33
+ return result.files.find(f => f.type === 'clientJs')!.content
34
+ }
35
+
36
+ describe('loopRowPropRead', () => {
37
+ test('a props-object member read in a row is flagged; the row item, children and an outside read are not', () => {
38
+ expect(propReads(`
39
+ export function List(props: { items: string[]; footer?: unknown; children?: unknown }) {
40
+ return (
41
+ <div>
42
+ {props.footer}
43
+ <ul>{props.items.map(i => <li key={i}>{i}{props.footer}{props.children}</li>)}</ul>
44
+ </div>
45
+ )
46
+ }
47
+ `)).toEqual([
48
+ ['props.footer', false],
49
+ ['i', false],
50
+ ['props.footer', true],
51
+ ['props.children', false],
52
+ ])
53
+ })
54
+
55
+ test('a destructured, renamed, aliased or body-destructured prop read in a row is flagged', () => {
56
+ expect(propReads(`
57
+ export function List({ items, footer: foot, label }: { items: string[]; footer?: unknown; label: string }) {
58
+ const alias = foot
59
+ return <ul>{items.map(i => <li key={i}>{foot}{alias}{label}</li>)}</ul>
60
+ }
61
+ `)).toEqual([
62
+ ['foot', true],
63
+ ['alias', true],
64
+ ['label', true],
65
+ ])
66
+ expect(propReads(`
67
+ export function List(props: { items: string[]; footer?: unknown }) {
68
+ const { footer } = props
69
+ const p = props
70
+ return <ul>{props.items.map(i => <li key={i}>{footer}{p.footer}</li>)}</ul>
71
+ }
72
+ `)).toEqual([
73
+ ['footer', true],
74
+ ['p.footer', true],
75
+ ])
76
+ })
77
+
78
+ test('a row binding that shadows the prop name or the props object is not flagged', () => {
79
+ expect(propReads(`
80
+ export function List({ items, label }: { items: string[]; label: string }) {
81
+ return <ul>{items.map(label => <li key={label}>{label}</li>)}</ul>
82
+ }
83
+ `)).toEqual([['label', false]])
84
+ expect(propReads(`
85
+ export function List(props: { items: { footer: string }[] }) {
86
+ return <ul>{props.items.map(props => <li key={props.footer}>{props.footer}</li>)}</ul>
87
+ }
88
+ `)).toEqual([['props.footer', false]])
89
+ expect(propReads(`
90
+ export function List({ items, footer }: { items: string[]; footer?: unknown }) {
91
+ return <ul>{items.map(i => { const footer = i + '!'; return <li key={i}>{footer}</li> })}</ul>
92
+ }
93
+ `)).toEqual([['footer', false]])
94
+ })
95
+
96
+ test('the client claims and writes a flagged row slot as markup, and splices it with escapeTextOrMarkup', () => {
97
+ const js = clientJs(`
98
+ 'use client'
99
+ import { createSignal } from '@barefootjs/client'
100
+ export function List(props: { footer?: unknown }) {
101
+ const [rows] = createSignal(['a'])
102
+ return <ul>{rows().map(i => <li key={i}>{i}{props.footer}</li>)}</ul>
103
+ }
104
+ `)
105
+ expect(js).toContain("{ id: 's1', kind: 'markup', path: [] }")
106
+ expect(js).toContain("{ id: 's0', kind: 'text', path: [] }")
107
+ expect(js).toContain('escapeTextOrNode(__x)')
108
+ expect(js).toContain('escapeTextOrMarkup(_p.footer)')
109
+ expect(js).toContain('escapeText(i)')
110
+ })
111
+ })
@@ -0,0 +1,64 @@
1
+ import { describe, test, expect } from 'bun:test'
2
+ import { concatType, loopRowType, type DeclaredValueTypes } from '../adapters/loop-row-type'
3
+ import { parseExpression } from '../expression-parser'
4
+ import { BindingScope } from '../scope/binding-scope'
5
+ import type { PropertyInfo, TypeInfo } from '../types'
6
+
7
+ // #3762 review: a `concat` row's field is a definite string only when it is
8
+ // one in the receiver's element type and in every argument's, whatever the
9
+ // types are named.
10
+ describe('concat row type', () => {
11
+ const str: TypeInfo = { kind: 'primitive', raw: 'string', primitive: 'string' }
12
+ const num: TypeInfo = { kind: 'primitive', raw: 'number', primitive: 'number' }
13
+ const field = (name: string, type: TypeInfo, optional = false): PropertyInfo => ({ name, type, optional, readonly: false })
14
+ const named: Record<string, PropertyInfo[]> = {
15
+ Row: [field('id', str)],
16
+ Other: [field('id', str)],
17
+ Numeric: [field('id', num)],
18
+ Optional: [field('id', str, true)],
19
+ Bare: [field('n', num)],
20
+ }
21
+ const arrayOf = (raw: string): TypeInfo => ({ kind: 'array', raw: `${raw}[]`, elementType: { kind: 'interface', raw } })
22
+ const types: DeclaredValueTypes = {
23
+ propsParams: [
24
+ ...Object.keys(named).map(name => ({ name: name.toLowerCase(), type: arrayOf(name) })),
25
+ { name: 'extras', type: { kind: 'array', raw: 'any[]', elementType: { kind: 'unknown', raw: 'any' } } },
26
+ { name: 'one', type: { kind: 'interface', raw: 'Other' } },
27
+ ],
28
+ signals: [],
29
+ memos: [],
30
+ propsObjectName: 'props',
31
+ namedFields: name => named[name],
32
+ }
33
+ const idIsString = (array: string): boolean => {
34
+ const rowType = loopRowType(types, { arrayParsed: parseExpression(array) }, BindingScope.EMPTY)
35
+ if (!rowType) return false
36
+ const scope = BindingScope.EMPTY.enterLoopRow({ param: 'r', rowType })
37
+ return scope.isStringValueName('r', () => false, false, ['id'], types.namedFields)
38
+ }
39
+
40
+ test('a field that is a string in every member stays one, across differently named types', () => {
41
+ expect(idIsString('props.row.concat(props.row)')).toBe(true)
42
+ expect(idIsString('props.row.concat(props.other)')).toBe(true)
43
+ expect(idIsString('props.row.concat(props.one)')).toBe(true)
44
+ })
45
+
46
+ test('an any, a number, an optional or a missing field in one member types nothing', () => {
47
+ expect(idIsString('props.row.concat(props.extras)')).toBe(false)
48
+ expect(idIsString('props.row.concat(props.numeric)')).toBe(false)
49
+ expect(idIsString('props.row.concat(props.optional)')).toBe(false)
50
+ expect(idIsString('props.row.concat(props.bare)')).toBe(false)
51
+ expect(idIsString('props.row.concat(props.other).concat(props.extras)')).toBe(false)
52
+ expect(idIsString('props.row.concat(props.missing)')).toBe(false)
53
+ })
54
+ })
55
+
56
+ describe('concat of the same row type keeps the plain array shape (#3762 review)', () => {
57
+ test('Row[] concat Row[] is Row[], not a union', () => {
58
+ const rows: TypeInfo = { kind: 'array', raw: 'Row[]', elementType: { kind: 'interface', raw: 'Row' } }
59
+ const copy: TypeInfo = { kind: 'array', raw: 'Row[]', elementType: { kind: 'interface', raw: 'Row' } }
60
+ const result = concatType(rows, [copy])
61
+ expect(result?.elementType).toBe(rows.elementType)
62
+ expect(result?.unionTypes).toBeUndefined()
63
+ })
64
+ })
@@ -27,6 +27,9 @@ import {
27
27
  isSupported,
28
28
  isSupportedValue,
29
29
  emitParsedExpr,
30
+ primitivesAt,
31
+ EMPTY_OPERAND_TYPING,
32
+ BindingScope,
30
33
  type LoweringPlugin,
31
34
  type LoweringEmitter,
32
35
  type ParsedExprEmitter,
@@ -174,6 +177,7 @@ describe('emitParsedExpr dispatch with an emitter.lowering seam (#2843)', () =>
174
177
  throw new Error(`unexpected emitter.${name} call in this test`)
175
178
  }
176
179
  return {
180
+ primitives: primitivesAt(EMPTY_OPERAND_TYPING, BindingScope.EMPTY, {}),
177
181
  identifier: (name: string) => `ID(${name})`,
178
182
  literal: (v) => `LIT(${JSON.stringify(v)})`,
179
183
  call: (callee, args, emit) => `CALL(${emit(callee)}, ${args.map(emit).join(', ')})`,
@@ -118,3 +118,140 @@ describe('MemoInfo.bodyExpr (#3510)', () => {
118
118
  expect(template({})).toContain('-->0<!--')
119
119
  })
120
120
  })
121
+
122
+ describe('template text over a body destructure binding in a (props)-arg component', () => {
123
+ function analyze(body: string) {
124
+ return analyzeComponent(`
125
+ 'use client'
126
+ import { createSignal, createMemo } from '@barefootjs/client'
127
+ export function C(props: { b?: string[] }) {
128
+ ${body}
129
+ return <p>{n()}</p>
130
+ }
131
+ `, 'C.tsx')
132
+ }
133
+ const read = "(_p.b ?? (['y', ''].filter((x) => x !== '')))"
134
+
135
+ test('a memo body reads a renamed binding with a callback default as its prop', () => {
136
+ const ctx = analyze(`
137
+ const { b: local = ['y', ''].filter((x) => x !== '') } = props
138
+ const n = createMemo(() => local.length)
139
+ `)
140
+ expect(ctx.memos.find(m => m.name === 'n')?.templateBodyExpr).toBe(`${read}.length`)
141
+ })
142
+
143
+ test('a memo body reads an un-renamed binding with a callback default as its prop', () => {
144
+ const ctx = analyze(`
145
+ const { b = ['y', ''].filter((x) => x !== '') } = props
146
+ const n = createMemo(() => b.length)
147
+ `)
148
+ expect(ctx.memos.find(m => m.name === 'n')?.templateBodyExpr).toBe(`${read}.length`)
149
+ })
150
+
151
+ test('a signal seed reads the binding as its prop', () => {
152
+ const ctx = analyze(`
153
+ const { b: local = ['y', ''].filter((x) => x !== '') } = props
154
+ const [n] = createSignal(local.length)
155
+ `)
156
+ expect(ctx.signals.find(s => s.getter === 'n')?.templateInitialValue).toBe(`${read}.length`)
157
+ })
158
+
159
+ test('a binding the component mutates later keeps its local read', () => {
160
+ const ctx = analyze(`
161
+ const { b: local = ['y', ''].filter((x) => x !== '') } = props
162
+ local.push('z')
163
+ const n = createMemo(() => local.length)
164
+ `)
165
+ expect(ctx.memos.find(m => m.name === 'n')?.templateBodyExpr).toBeUndefined()
166
+ })
167
+
168
+ test('the CSR template renders the memo over the default', () => {
169
+ const result = compileJSX(`
170
+ 'use client'
171
+ import { createMemo } from '@barefootjs/client'
172
+ export function C(props: { b?: string[] }) {
173
+ const { b: local = ['y', ''].filter((x) => x !== '') } = props
174
+ const n = createMemo(() => local.length)
175
+ return <p>{n()}</p>
176
+ }
177
+ `, 'C.tsx', { adapter: new TestAdapter() })
178
+ const line = result.files.find((f) => f.type === 'clientJs')!.content.split('\n').find((l) => l.includes('hydrate('))!
179
+ const lambda = line.match(/template: (\(_p\) => `.*`) \}\)$/)![1]
180
+ const template = new Function('escapeTextOrMarkup', 'escapeText', 'escapeAttr', `return ${lambda}`)(String, String, String)
181
+ expect(template({})).toContain('-->1<!--')
182
+ expect(template({ b: ['p', 'q', 'r'] })).toContain('-->3<!--')
183
+ expect(template({ b: [] })).toContain('-->0<!--')
184
+ })
185
+ })
186
+
187
+ // The rendered values for these shapes (the colliding prop supplied) are
188
+ // asserted by the CSR conformance fixtures `memo-local-function-named-like-prop`,
189
+ // `signal-seed-local-function-named-like-prop`, `memo-module-binding-named-like-prop`,
190
+ // `memo-const-declared-after-named-like-prop` and `markup-local-function-named-like-prop`.
191
+ // Here only the analyzer's template fields and the emitted template text.
192
+ describe('template text keeps a local named like a typed prop (props)-arg component', () => {
193
+ function analyze(body: string, preamble = '') {
194
+ return analyzeComponent(`
195
+ 'use client'
196
+ import { createSignal, createMemo } from '@barefootjs/client'
197
+ ${preamble}
198
+ export function C(props: { value?: number }) {
199
+ ${body}
200
+ return <p>{n()}</p>
201
+ }
202
+ `, 'C.tsx')
203
+ }
204
+
205
+ test('a memo body calling a local function keeps the call', () => {
206
+ const ctx = analyze(`
207
+ function value() { return 1 }
208
+ const n = createMemo(() => value())
209
+ `)
210
+ expect(ctx.memos.find(m => m.name === 'n')?.templateBodyExpr).toBeUndefined()
211
+ })
212
+
213
+ test('a signal seed calling a local function keeps the call', () => {
214
+ const ctx = analyze(`
215
+ function value() { return 1 }
216
+ const [n] = createSignal(value())
217
+ `)
218
+ expect(ctx.signals.find(s => s.getter === 'n')?.templateInitialValue).toBeUndefined()
219
+ })
220
+
221
+ test('a memo body reading an ordinary const declared after it keeps the read', () => {
222
+ const ctx = analyze(`
223
+ const n = createMemo(() => value)
224
+ const value = 1
225
+ `)
226
+ expect(ctx.memos.find(m => m.name === 'n')?.templateBodyExpr).toBeUndefined()
227
+ })
228
+
229
+ test('a memo body reading a module-scope binding keeps the read', () => {
230
+ const ctx = analyze(`
231
+ const n = createMemo(() => value)
232
+ `, 'const value = 1')
233
+ expect(ctx.memos.find(m => m.name === 'n')?.templateBodyExpr).toBeUndefined()
234
+ })
235
+
236
+ test('markup calling a local function does not read the prop', () => {
237
+ const result = compileJSX(`
238
+ 'use client'
239
+ import { createSignal } from '@barefootjs/client'
240
+ export function C(props: { value?: number }) {
241
+ function value() { return 1 }
242
+ const [n] = createSignal(0)
243
+ return <p>{value()}|{n()}</p>
244
+ }
245
+ `, 'C.tsx', { adapter: new TestAdapter() })
246
+ const clientJs = result.files.find((f) => f.type === 'clientJs')!.content
247
+ expect(clientJs).not.toContain('_p.value')
248
+ })
249
+
250
+ test('a memo body still reads a body destructure binding as its prop', () => {
251
+ const ctx = analyze(`
252
+ const { value = 4 } = props
253
+ const n = createMemo(() => value * 2)
254
+ `)
255
+ expect(ctx.memos.find(m => m.name === 'n')?.templateBodyExpr).toBe('(_p.value ?? 4) * 2')
256
+ })
257
+ })
@@ -0,0 +1,156 @@
1
+ /**
2
+ * A destructured prop's client read is `_p.m ?? <default>`, so a module
3
+ * declaration the default names (`{ m = DEFAULT }`) is a client read even
4
+ * when nothing else in the component names it. The reference graph used to
5
+ * miss it, and the emitted client module read an undeclared name — a
6
+ * `ReferenceError` whenever the prop was absent (a client-side mount).
7
+ *
8
+ * Declarations are read from the emitted client JS with the TypeScript AST.
9
+ */
10
+
11
+ import { describe, test, expect } from 'bun:test'
12
+ import ts from 'typescript'
13
+ import { compileJSX } from '../compiler'
14
+ import { TestAdapter } from '../adapters/test-adapter'
15
+
16
+ function clientJs(source: string): string {
17
+ const result = compileJSX(source, 'C.tsx', { adapter: new TestAdapter() })
18
+ expect(result.errors.filter(e => e.severity === 'error')).toHaveLength(0)
19
+ return result.files.find(f => f.type === 'clientJs')!.content
20
+ }
21
+
22
+ /** Every name the client module declares (variables and functions, any depth), in order. */
23
+ function declarations(js: string): string[] {
24
+ const sf = ts.createSourceFile('c.js', js, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS)
25
+ const names: string[] = []
26
+ const visit = (node: ts.Node): void => {
27
+ if ((ts.isVariableDeclaration(node) || ts.isFunctionDeclaration(node)) && node.name && ts.isIdentifier(node.name)) {
28
+ names.push(node.name.text)
29
+ }
30
+ ts.forEachChild(node, visit)
31
+ }
32
+ visit(sf)
33
+ return names
34
+ }
35
+
36
+ const declaredNames = (js: string): Set<string> => new Set(declarations(js))
37
+ const declarationCount = (js: string, name: string): number => declarations(js).filter(n => n === name).length
38
+
39
+ describe('module declarations read only by a destructure default are emitted', () => {
40
+ test('a module const default read as text', () => {
41
+ const js = clientJs(`'use client'
42
+ const DEFAULT = 'm'
43
+ export function C({ m = DEFAULT }: { m?: string }) {
44
+ return <p>{m}</p>
45
+ }`)
46
+ expect(declaredNames(js).has('DEFAULT')).toBe(true)
47
+ })
48
+
49
+ test('a chain: the later prop reads the earlier one, whose default reads the const', () => {
50
+ const js = clientJs(`'use client'
51
+ const DEFAULT = 'm'
52
+ export function C({ a = DEFAULT, b = a }: { a?: string; b?: string }) {
53
+ return <p>{b}</p>
54
+ }`)
55
+ expect(declaredNames(js).has('DEFAULT')).toBe(true)
56
+ })
57
+
58
+ test('a member read of a module object const', () => {
59
+ const js = clientJs(`'use client'
60
+ const D = { label: 'm' }
61
+ export function C({ m = D.label }: { m?: string }) {
62
+ return <p title={m}>{m}</p>
63
+ }`)
64
+ expect(declaredNames(js).has('D')).toBe(true)
65
+ })
66
+
67
+ test('a module helper function called by the default', () => {
68
+ const js = clientJs(`'use client'
69
+ function fmt(s: string) { return s + '!' }
70
+ export function C({ m = fmt('x') }: { m?: string }) {
71
+ return <p>{m}</p>
72
+ }`)
73
+ expect(declaredNames(js).has('fmt')).toBe(true)
74
+ })
75
+
76
+ test('a signal seeded from the defaulted prop', () => {
77
+ const js = clientJs(`'use client'
78
+ import { createSignal } from '@barefootjs/client'
79
+ const START = 2
80
+ export function C({ start = START }: { start?: number }) {
81
+ const [c, setC] = createSignal(start)
82
+ return <button onClick={() => setC(c() + 1)}>{c()}</button>
83
+ }`)
84
+ expect(declaredNames(js).has('START')).toBe(true)
85
+ })
86
+
87
+ test('a body local of the same name does not get a second declaration', () => {
88
+ const js = clientJs(`'use client'
89
+ const LABEL = 'a'
90
+ export function C({ m = LABEL }: { m?: string }) {
91
+ const LABEL = 'b'
92
+ return <p title={LABEL}>{m}</p>
93
+ }`)
94
+ // Two `const LABEL` in one init body would be a SyntaxError for the module.
95
+ expect(declarationCount(js, 'LABEL')).toBeLessThanOrEqual(1)
96
+ })
97
+
98
+ test('the default of a prop the client never reads adds nothing', () => {
99
+ const js = clientJs(`'use client'
100
+ import { createSignal } from '@barefootjs/client'
101
+ const UNUSED = 'u'
102
+ export function C({ m = UNUSED }: { m?: string }) {
103
+ const [c, setC] = createSignal(0)
104
+ return <button onClick={() => setC(c() + 1)}>{c()}</button>
105
+ }`)
106
+ expect(declaredNames(js).has('UNUSED')).toBe(false)
107
+ })
108
+ })
109
+
110
+ describe('a destructure default names only its free references (#3792 review)', () => {
111
+ // A property key, a member name and a callback parameter inside the
112
+ // default are not reads of an outer binding; tracing them kept an
113
+ // unrelated module declaration in `initC` (here one reading `process`,
114
+ // which the browser lacks — a `ReferenceError` at mount).
115
+ test('an object literal key and a member name of the default', () => {
116
+ const js = clientJs(`'use client'
117
+ const label = process.env.SERVER_ONLY
118
+ export function C({ m = ({ label: 'm' }).label }: { m?: string }) {
119
+ return <p>{m}</p>
120
+ }`)
121
+ expect(declaredNames(js).has('label')).toBe(false)
122
+ expect(js).not.toContain('process')
123
+ })
124
+
125
+ test('a callback parameter of the default', () => {
126
+ const js = clientJs(`'use client'
127
+ const label = process.env.SERVER_ONLY
128
+ export function C({ m = ['m'].map(label => label)[0] }: { m?: string }) {
129
+ return <p>{m}</p>
130
+ }`)
131
+ expect(declaredNames(js).has('label')).toBe(false)
132
+ expect(js).not.toContain('process')
133
+ })
134
+
135
+ test('a genuine outer read beside a colliding key is still traced', () => {
136
+ const js = clientJs(`'use client'
137
+ const label = process.env.SERVER_ONLY
138
+ const D = { text: 'm' }
139
+ export function C({ m = ({ label: D.text }).label }: { m?: string }) {
140
+ return <p>{m}</p>
141
+ }`)
142
+ expect(declaredNames(js).has('D')).toBe(true)
143
+ expect(declaredNames(js).has('label')).toBe(false)
144
+ })
145
+
146
+ test('a chain through an earlier prop whose default has a colliding key', () => {
147
+ const js = clientJs(`'use client'
148
+ const label = process.env.SERVER_ONLY
149
+ const DEFAULT = 'm'
150
+ export function C({ a = ({ label: DEFAULT }).label, b = a }: { a?: string; b?: string }) {
151
+ return <p>{b}</p>
152
+ }`)
153
+ expect(declaredNames(js).has('DEFAULT')).toBe(true)
154
+ expect(declaredNames(js).has('label')).toBe(false)
155
+ })
156
+ })
@@ -115,7 +115,7 @@ describe('nested .map() index param referenced in key/text/attr (#2218)', () =>
115
115
  // `loop-index` source fixes this: the index is wired through the same
116
116
  // accessor `mapArray` already hands every row (#2859/#2860), and the
117
117
  // slot now gets a real update effect.
118
- expect(content).toContain(`createEffect(() => { __bfw_s0('s0', String(i())) })`)
118
+ expect(content).toContain(`createEffect(() => { __bfw_s0('s0', textOrNode(i())) })`)
119
119
  })
120
120
 
121
121
  test('index referenced in a reactive attribute expression is bound', () => {
@@ -347,7 +347,7 @@ describe('reactive attributes inside a nested .map() body (#135)', () => {
347
347
  // The innermost loop's per-item renderItem must emit BOTH a
348
348
  // reactive-text effect for `panel.text` and a reactive-attr effect
349
349
  // for `panel.cls` — the bug dropped only the former.
350
- expect(content).toMatch(/createEffect\(\(\) => \{[\s\S]*?__bfw_\w+\('s\d+', String\(panel\(\)\.text\)\)/)
350
+ expect(content).toMatch(/createEffect\(\(\) => \{[\s\S]*?__bfw_\w+\('s\d+', textOrNode\(panel\(\)\.text\)\)/)
351
351
  expect(content).toContain("setAttribute('class'")
352
352
  })
353
353
 
@@ -405,7 +405,7 @@ describe('reactive attributes inside a nested .map() body (#135)', () => {
405
405
  // effect missing (the exact regression here). `pi` reads the row's
406
406
  // live index accessor (#2859), so `labelAt(pi())` also stays correct
407
407
  // if this innermost loop's rows ever survive a same-key reorder.
408
- expect(content).toMatch(/createEffect\(\(\) => \{[\s\S]*?__bfw_\w+\('s\d+', String\(labelAt\(pi\(\)\)\)\)/)
408
+ expect(content).toMatch(/createEffect\(\(\) => \{[\s\S]*?__bfw_\w+\('s\d+', textOrNode\(labelAt\(pi\(\)\)\)\)/)
409
409
  expect(content).toContain("setAttribute('class'")
410
410
  })
411
411
  })