@barefootjs/jsx 0.40.0 → 0.40.1

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 (140) hide show
  1. package/dist/adapters/ambiguous-nil-arithmetic.d.ts +41 -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/component-props.d.ts +22 -7
  7. package/dist/adapters/component-props.d.ts.map +1 -1
  8. package/dist/adapters/computed-const.d.ts +17 -0
  9. package/dist/adapters/computed-const.d.ts.map +1 -1
  10. package/dist/adapters/dsl-template-adapter.d.ts +18 -1
  11. package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
  12. package/dist/adapters/number-value.d.ts +43 -0
  13. package/dist/adapters/number-value.d.ts.map +1 -0
  14. package/dist/analyzer-context.d.ts +7 -0
  15. package/dist/analyzer-context.d.ts.map +1 -1
  16. package/dist/analyzer.d.ts +34 -0
  17. package/dist/analyzer.d.ts.map +1 -1
  18. package/dist/expression-parser.d.ts.map +1 -1
  19. package/dist/index.d.ts +6 -3
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1006 -351
  22. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  23. package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
  24. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts +29 -0
  25. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
  26. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts +2 -0
  27. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -1
  28. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
  29. package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
  30. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts +5 -4
  31. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts.map +1 -1
  32. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +2 -0
  33. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
  34. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +15 -0
  35. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
  36. package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts +2 -0
  37. package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts.map +1 -1
  38. package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
  39. package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +20 -0
  40. package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
  41. package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts.map +1 -1
  42. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +1 -1
  43. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
  44. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -1
  45. package/dist/ir-to-client-js/html-template.d.ts +3 -2
  46. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  47. package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
  48. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +7 -1
  49. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
  50. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  51. package/dist/ir-to-client-js/safe-html.d.ts +9 -3
  52. package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
  53. package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
  54. package/dist/ir-to-client-js/types.d.ts +30 -0
  55. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  56. package/dist/ir-to-client-js/utils.d.ts +8 -0
  57. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  58. package/dist/jsx-to-ir.d.ts.map +1 -1
  59. package/dist/nullable-signal-attr.d.ts +29 -3
  60. package/dist/nullable-signal-attr.d.ts.map +1 -1
  61. package/dist/props-binding.d.ts +27 -3
  62. package/dist/props-binding.d.ts.map +1 -1
  63. package/dist/scope/binding-scope.d.ts +22 -1
  64. package/dist/scope/binding-scope.d.ts.map +1 -1
  65. package/dist/scope/root-prop-alias.d.ts +14 -1
  66. package/dist/scope/root-prop-alias.d.ts.map +1 -1
  67. package/dist/signal-prop-name-collision.d.ts.map +1 -1
  68. package/dist/ssr-defaults.d.ts +4 -2
  69. package/dist/ssr-defaults.d.ts.map +1 -1
  70. package/dist/ssr-seed-plan.d.ts +14 -0
  71. package/dist/ssr-seed-plan.d.ts.map +1 -1
  72. package/dist/template-parts.d.ts.map +1 -1
  73. package/dist/types.d.ts +30 -0
  74. package/dist/types.d.ts.map +1 -1
  75. package/package.json +2 -2
  76. package/src/__tests__/binding-scope-ratchet.test.ts +12 -2
  77. package/src/__tests__/boolean-carrier.test.ts +74 -0
  78. package/src/__tests__/component-props.test.ts +14 -0
  79. package/src/__tests__/computed-const.test.ts +85 -0
  80. package/src/__tests__/expression-parser.test.ts +24 -0
  81. package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +142 -0
  82. package/src/__tests__/loop-row-prop-read.test.ts +111 -0
  83. package/src/__tests__/memo-body-expr.test.ts +137 -0
  84. package/src/__tests__/nullable-signal-attr.test.ts +97 -2
  85. package/src/__tests__/profile-binding-ids.test.ts +14 -0
  86. package/src/__tests__/root-prop-alias.test.ts +34 -1
  87. package/src/__tests__/signal-prop-name-collision.test.ts +102 -2
  88. package/src/__tests__/source-file-cache.test.ts +105 -0
  89. package/src/__tests__/ssr-seed-plan.test.ts +43 -0
  90. package/src/__tests__/template-parts-literal-boundary.test.ts +19 -0
  91. package/src/adapters/ambiguous-nil-arithmetic.ts +94 -0
  92. package/src/adapters/attr-plan.ts +6 -2
  93. package/src/adapters/boolean-carrier.ts +76 -0
  94. package/src/adapters/component-props.ts +28 -8
  95. package/src/adapters/computed-const.ts +206 -7
  96. package/src/adapters/dsl-template-adapter.ts +39 -0
  97. package/src/adapters/number-value.ts +95 -0
  98. package/src/analyzer-context.ts +8 -0
  99. package/src/analyzer.ts +187 -66
  100. package/src/expression-parser.ts +4 -1
  101. package/src/index.ts +12 -2
  102. package/src/ir-to-client-js/collect-elements.ts +104 -46
  103. package/src/ir-to-client-js/compute-inlinability.ts +1 -1
  104. package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +15 -1
  105. package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +79 -4
  106. package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +3 -0
  107. package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +1 -0
  108. package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +1 -0
  109. package/src/ir-to-client-js/control-flow/plan/inner-loop.ts +5 -4
  110. package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +2 -0
  111. package/src/ir-to-client-js/control-flow/plan/loop.ts +12 -0
  112. package/src/ir-to-client-js/control-flow/plan/reactive-effects.ts +2 -0
  113. package/src/ir-to-client-js/control-flow/shared.ts +3 -2
  114. package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +27 -0
  115. package/src/ir-to-client-js/control-flow/stringify/component-loop.ts +8 -2
  116. package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +8 -1
  117. package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +8 -7
  118. package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +8 -7
  119. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +4 -4
  120. package/src/ir-to-client-js/control-flow/stringify/loop.ts +3 -3
  121. package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +6 -6
  122. package/src/ir-to-client-js/emit-reactive.ts +1 -1
  123. package/src/ir-to-client-js/html-template.ts +70 -30
  124. package/src/ir-to-client-js/plan/build-static-array-child-init.ts +11 -1
  125. package/src/ir-to-client-js/plan/static-array-child-init.ts +7 -1
  126. package/src/ir-to-client-js/reactivity.ts +14 -0
  127. package/src/ir-to-client-js/safe-html.ts +11 -4
  128. package/src/ir-to-client-js/stringify/static-array-child-init.ts +6 -4
  129. package/src/ir-to-client-js/types.ts +23 -0
  130. package/src/ir-to-client-js/utils.ts +15 -1
  131. package/src/jsx-to-ir.ts +78 -35
  132. package/src/nullable-signal-attr.ts +134 -13
  133. package/src/props-binding.ts +54 -3
  134. package/src/scope/binding-scope.ts +30 -2
  135. package/src/scope/root-prop-alias.ts +17 -1
  136. package/src/signal-prop-name-collision.ts +113 -22
  137. package/src/ssr-defaults.ts +10 -4
  138. package/src/ssr-seed-plan.ts +82 -17
  139. package/src/template-parts.ts +21 -1
  140. package/src/types.ts +30 -0
@@ -683,7 +683,7 @@ function collectTemplateRiskyNames(irRoot: IRNode): Set<string> {
683
683
  },
684
684
  component: ({ descend, descendJsxChildren }) => {
685
685
  // Component props are stripped from `renderChild` when
686
- // `transformExpr` returns UNSAFE_TEMPLATE_EXPR (see
686
+ // `transformExprOrUnsafe` reports them unsafe (see
687
687
  // html-template.ts). `initChild`'s getter binding then fills
688
688
  // the prop once init runs. No diagnostic needed.
689
689
  descend()
@@ -32,6 +32,7 @@ import {
32
32
  } from '../shared.ts'
33
33
  import { irChildrenToJsExpr, renderPreamble } from '../../html-template.ts'
34
34
  import { buildReactiveEffectsPlan } from './build-reactive-effects.ts'
35
+ import { buildForwardedInnerLoopsPlan } from './build-inner-loop.ts'
35
36
  import type { ComponentLoopPlan, NestedComponentInit } from './types.ts'
36
37
  import { internalInvariant } from '../../../errors.ts'
37
38
 
@@ -146,10 +147,21 @@ export function buildComponentLoopPlan(elem: TopLevelLoop, profileComponentName?
146
147
  // loop has no delegation pass (`loopEventDelegationVariant` returns null
147
148
  // for it), so each row attaches its handlers directly, exactly like the
148
149
  // composite row's `outerEvents`. Events inside an inner loop of the
149
- // forwarded children (`nestedLoops` non-empty) are not reached here.
150
+ // forwarded children (`nestedLoops` non-empty) go to `innerLoops` below.
150
151
  const rowEvents = elem.bindings.events
151
152
  .filter(ev => ev.nestedLoops.length === 0)
152
153
  .map(ev => buildRowEventBinding(ev, elem.param, elem.paramBindings, elem.index))
154
+ // #3694: an event inside an inner loop of the forwarded children is wired
155
+ // by running that inner loop's composite-row emission over each row's
156
+ // element, hydrated and client-built alike.
157
+ const forwardedInnerLoops = (parentElVar: '__existing' | '__csrEl') => buildForwardedInnerLoopsPlan({
158
+ innerLoops: elem.innerLoops,
159
+ events: elem.bindings.events,
160
+ parentElVar,
161
+ outerLoopParam: elem.param,
162
+ outerLoopParamBindings: elem.paramBindings,
163
+ outerLoopIndex: elem.index,
164
+ })
153
165
 
154
166
  return {
155
167
  kind: 'component',
@@ -170,6 +182,7 @@ export function buildComponentLoopPlan(elem: TopLevelLoop, profileComponentName?
170
182
  keyExpr,
171
183
  nestedComps,
172
184
  rowEvents,
185
+ innerLoops: { hydrated: forwardedInnerLoops('__existing'), created: forwardedInnerLoops('__csrEl') },
173
186
  // #3612: refs on elements forwarded as the root component's own
174
187
  // `children` (`<Chip><input ref={el => …} /></Chip>`), collected by the
175
188
  // same `collectLoopChildBindings` walk as `rowEvents` above and resolved
@@ -179,6 +192,7 @@ export function buildComponentLoopPlan(elem: TopLevelLoop, profileComponentName?
179
192
  // binding here: it goes to the component through `componentPropsExpr`.
180
193
  childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
181
194
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : undefined,
195
+ profileComponentName,
182
196
  reactiveEffects: hasReactiveEffects
183
197
  ? buildReactiveEffectsPlan({
184
198
  attrs: elem.bindings.reactiveAttrs,
@@ -24,6 +24,7 @@
24
24
  */
25
25
 
26
26
  import type {
27
+ LoopChildConditional,
27
28
  LoopChildEvent,
28
29
  NestedLoop,
29
30
  } from '../../types.ts'
@@ -42,6 +43,7 @@ import {
42
43
  attrValueToString,
43
44
  } from '../../utils.ts'
44
45
  import { buildChildRefBindings } from '../shared.ts'
46
+ import { buildLoopChainExpr } from '../../../loop-chain.ts'
45
47
  import { renderPreamble, irToHtmlTemplate } from '../../html-template.ts'
46
48
  import { buildLoopChildConditionalsPlan } from './build-loop-child-arm.ts'
47
49
  import type { LoopChildConditionalPlan } from './loop-child-arm.ts'
@@ -71,7 +73,9 @@ function wrapAttrValueExpression(value: AttrValue, wrap: (s: string) => string):
71
73
  }
72
74
  }
73
75
  import type { DepthLevel } from '../shared.ts'
76
+ import type { LoopRowEventBinding } from './loop.ts'
74
77
  import {
78
+ buildDepthLevels,
75
79
  destructureLoopParam,
76
80
  loopKeyFn,
77
81
  nestedLoopIndexAlias,
@@ -143,7 +147,14 @@ export function buildInnerLoopsPlan(args: BuildInnerLoopsArgs): InnerLoopsPlan {
143
147
  // shortcut was unsound.
144
148
  const emit: InnerLoopReactiveEmit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex)
145
149
 
146
- const arrayExpr = wrapOuter(inner.array)
150
+ // The inner `.filter()` / `.toSorted()` chain (#3694), so the rows
151
+ // reconciled are the rows the template rendered.
152
+ const arrayExpr = wrapOuter(buildLoopChainExpr({
153
+ base: inner.array,
154
+ filterPredicate: inner.filterPredicate,
155
+ sortComparator: inner.sortComparator,
156
+ chainOrder: inner.chainOrder,
157
+ }))
147
158
 
148
159
  const childLevelsPlan = childLevels.length > 0
149
160
  ? buildInnerLoopsPlan({
@@ -231,15 +242,20 @@ function buildReactiveEmit(
231
242
  props: comp.props.map(p => ({ ...p, value: wrapAttrValueExpression(p.value, wrapInner) })),
232
243
  children: comp.children?.map(wrapIRNode),
233
244
  }))
234
- const events: LoopChildEvent[] = level.events.map(ev => ({
235
- ...ev,
236
- handler: wrapInner(ev.handler),
245
+ // Resolved against every enclosing row, like the texts below (#3694): an
246
+ // inner-wrap-only handler left a grandparent row's item two loops up
247
+ // unwrapped (`o.id` on the accessor reads `undefined`).
248
+ const events: LoopRowEventBinding[] = level.events.map(ev => ({
249
+ childSlotId: ev.childSlotId,
250
+ eventName: ev.eventName,
251
+ handler: wrapBoth(ev.handler),
237
252
  }))
238
253
 
239
254
  const reactiveTexts: InnerLoopText[] = inner.bindings.reactiveTexts.map(text => ({
240
255
  slotId: text.slotId,
241
256
  wrappedExpression: wrapLoopParamAsAccessor(wrapOuterRow(text.expression), inner.param, inner.paramBindings, inner.index),
242
257
  insideConditional: !!text.insideConditional,
258
+ ...(text.markup && { markup: true as const }),
243
259
  }))
244
260
 
245
261
  const reactiveAttrs: InnerLoopReactiveAttr[] = inner.bindings.reactiveAttrs.map(attr => {
@@ -320,3 +336,62 @@ function buildReactiveEmit(
320
336
  childRefs,
321
337
  }
322
338
  }
339
+
340
+ export interface BuildForwardedInnerLoopsArgs {
341
+ /** The row's inner loops, DFS-ordered (`TopLevelLoop.innerLoops`). */
342
+ innerLoops: readonly NestedLoop[] | undefined
343
+ /** The row's collected events (`TopLevelLoop.bindings.events`). */
344
+ events: readonly LoopChildEvent[]
345
+ /** The row element the inner loop containers are looked up in. */
346
+ parentElVar: string
347
+ /** The outer row's param, or `undefined` when the row binds it as a plain value (a static array). */
348
+ outerLoopParam?: string
349
+ outerLoopParamBindings?: readonly LoopParamBinding[]
350
+ outerLoopIndex?: string | null
351
+ }
352
+
353
+ /**
354
+ * The inner-loop plan for the inner loops of a component-root row's
355
+ * forwarded children (`<Chip key={o.id}><ul>{o.tags.map(tag => <li><button
356
+ * onClick={…}/></li>)}</ul></Chip>`, #3694). The child component renders its
357
+ * `children` once, so nothing else reaches an element inside such an inner
358
+ * loop: a handler there was dropped. Each row now runs the composite row's
359
+ * inner-loop emission (`buildInnerLoopsPlan`) over its own element, which
360
+ * claims the rendered inner rows and attaches the handlers with the inner
361
+ * and the outer bindings resolved the same way as on a composite row.
362
+ *
363
+ * Only inner loops that carry an event, and the enclosing loops they need,
364
+ * are planned; the others keep their output unchanged. Child components
365
+ * inside an inner loop are left to their existing pass (`comps` empty), so
366
+ * none is initialised twice.
367
+ */
368
+ export function buildForwardedInnerLoopsPlan(args: BuildForwardedInnerLoopsArgs): InnerLoopsPlan {
369
+ const { innerLoops, events, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex } = args
370
+ if (!innerLoops || innerLoops.length === 0) return []
371
+ const levels = buildDepthLevels([...innerLoops], [], [...events])
372
+ const kept = levels.filter((_, i) => levelCarriesEvent(levels, i))
373
+ if (kept.length === 0) return []
374
+ return buildInnerLoopsPlan({ levels: kept, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex })
375
+ }
376
+
377
+ /**
378
+ * Whether `levels[i]` or a loop nested inside it (the deeper levels right
379
+ * after it) carries an event, on its row or inside a conditional of its row.
380
+ */
381
+ function levelCarriesEvent(levels: readonly DepthLevel[], i: number): boolean {
382
+ const depth = levels[i].loopInfo?.depth ?? 0
383
+ for (let j = i; j < levels.length; j++) {
384
+ if (j > i && (levels[j].loopInfo?.depth ?? 0) <= depth) break
385
+ if (levels[j].events.length > 0) return true
386
+ if (conditionalsCarryEvent(levels[j].loopInfo?.bindings.conditionals ?? [])) return true
387
+ }
388
+ return false
389
+ }
390
+
391
+ function conditionalsCarryEvent(conditionals: readonly LoopChildConditional[]): boolean {
392
+ return conditionals.some(c => [c.whenTrue, c.whenFalse].some(branch =>
393
+ (branch.events?.length ?? 0) > 0
394
+ || conditionalsCarryEvent(branch.conditionals ?? [])
395
+ || (branch.innerLoops ?? []).some(l => l.bindings.events.length > 0 || conditionalsCarryEvent(l.bindings.conditionals)),
396
+ ))
397
+ }
@@ -59,6 +59,8 @@ export interface LazyRowAttrBinding {
59
59
  /** One reactive text (content slot) of a lazy row. */
60
60
  export interface LazyRowTextBinding {
61
61
  slotId: string
62
+ /** Claimed and written as markup (`RowTextSlot`). */
63
+ markup?: true
62
64
  wrappedExpression: string
63
65
  ordinal: number
64
66
  readsItem: boolean
@@ -340,6 +342,7 @@ export function decideLazyRow(args: BuildLazyRowArgs): {
340
342
  readsItem: c.readsItem || !c.readsOuter,
341
343
  readsOuter: c.readsOuter,
342
344
  readsPreamble: c.readsPreamble,
345
+ ...(text.markup && { markup: true as const }),
343
346
  }
344
347
  })
345
348
 
@@ -342,6 +342,7 @@ export function buildBranchInnerLoopsPlan(
342
342
  slotId: text.slotId,
343
343
  wrappedExpression: wrapBoth(text.expression),
344
344
  insideConditional: !!text.insideConditional,
345
+ ...(text.markup && { markup: true as const }),
345
346
  }))
346
347
 
347
348
  plan.push({
@@ -98,6 +98,7 @@ export function buildReactiveEffectsPlan(
98
98
  const outerTexts: ReactiveTextEffect[] = texts.map(text => ({
99
99
  slotId: text.slotId,
100
100
  wrappedExpression: wrap(text.expression),
101
+ ...(text.markup && { markup: true as const }),
101
102
  }))
102
103
 
103
104
  // 3. Per-conditional plans. Each arm's own reactive attrs / texts come
@@ -16,13 +16,12 @@
16
16
  * reactivity in the row. See `build-inner-loop.ts`'s module docstring.
17
17
  */
18
18
 
19
- import type { LoopChildEvent } from '../../types.ts'
20
19
  import type {
21
20
  AttrMeta,
22
21
  IRLoopChildComponent,
23
22
  LoopParamBinding,
24
23
  } from '../../../types.ts'
25
- import type { LoopChildRefBinding } from './loop.ts'
24
+ import type { LoopChildRefBinding, LoopRowEventBinding } from './loop.ts'
26
25
  import type { LoopChildConditionalPlan } from './loop-child-arm.ts'
27
26
 
28
27
  /**
@@ -40,6 +39,8 @@ export type PreludeStatements = readonly string[]
40
39
  /** A reactive text effect inside a reactive inner loop's renderItem body. */
41
40
  export interface InnerLoopText {
42
41
  slotId: string
42
+ /** Claimed and written as markup (`RowTextSlot`). */
43
+ markup?: true
43
44
  /** Already wrapped via inner+outer loop param accessor (`wrapBoth`). */
44
45
  wrappedExpression: string
45
46
  /**
@@ -142,8 +143,8 @@ export interface InnerLoopReactiveEmit {
142
143
  wrappedKey: string | null
143
144
  /** Inner-wrapped components for emitComponentAndEventSetup. */
144
145
  components: readonly IRLoopChildComponent[]
145
- /** Inner-wrapped events for emitComponentAndEventSetup. */
146
- events: readonly LoopChildEvent[]
146
+ /** Events resolved against the inner and every enclosing row, attached directly to each inner row. */
147
+ events: readonly LoopRowEventBinding[]
147
148
  /** Pre-wrapped reactive text effects for the inner-item body. */
148
149
  reactiveTexts: readonly InnerLoopText[]
149
150
  /** Pre-wrapped reactive attribute effects for the inner-item body. */
@@ -76,6 +76,8 @@ export type BranchChildComponentInitsPlan = readonly BranchChildComponentInit[]
76
76
  /** A reactive text effect inside a branch inner loop's renderItem body. */
77
77
  export interface BranchInnerLoopText {
78
78
  slotId: string
79
+ /** Claimed and written as markup (`RowTextSlot`). */
80
+ markup?: true
79
81
  /** Already wrapped via inner+outer loop param accessor (`wrapBoth`). */
80
82
  wrappedExpression: string
81
83
  /**
@@ -130,6 +130,8 @@ export interface LoopRowEventBinding {
130
130
  eventName: string
131
131
  /** Handler expression, as the row's binding of the item reads it. */
132
132
  handler: JsSourceText
133
+ /** See `LoopChildEvent.receiverSlotIds` (#3695). */
134
+ receiverSlotIds?: readonly string[]
133
135
  }
134
136
 
135
137
  /**
@@ -240,6 +242,14 @@ interface ComponentLoopVariant extends DynamicLoopCommon {
240
242
  * the SSR/CSR split shape (the simple shape has no row handle).
241
243
  */
242
244
  rowEvents: readonly LoopRowEventBinding[]
245
+ /**
246
+ * Inner loops of the ROOT component's forwarded `children` that carry an
247
+ * event handler (#3694), planned once per row element: `hydrated` over
248
+ * `__existing`, `created` over `__csrEl`. Each row runs them after its own
249
+ * `rowEvents`, so the handlers reach the inner rows. Empty when no inner
250
+ * loop carries an event; non-empty forces the SSR/CSR split shape.
251
+ */
252
+ innerLoops: { hydrated: InnerLoopsPlan; created: InnerLoopsPlan }
243
253
  /**
244
254
  * Reactive-effects plan for the loop ROOT component's own reactive attrs /
245
255
  * texts / conditionals — i.e. bindings on elements forwarded as the root
@@ -254,6 +264,8 @@ interface ComponentLoopVariant extends DynamicLoopCommon {
254
264
  * `mapArray`. Undefined off → byte-identical (SR8).
255
265
  */
256
266
  profileLoopId?: string
267
+ /** Owning component name in profile mode, threaded to `stringifyInnerLoops`. */
268
+ profileComponentName?: string
257
269
  }
258
270
 
259
271
  /**
@@ -37,6 +37,8 @@ export interface ReactiveAttrSlot {
37
37
  /** A reactive text effect (one createEffect updating textContent). */
38
38
  export interface ReactiveTextEffect {
39
39
  slotId: string
40
+ /** Claimed and written as markup (`RowTextSlot`). */
41
+ markup?: true
40
42
  /** Already wrapped via wrapLoopParamAsAccessor at build time. */
41
43
  wrappedExpression: string
42
44
  }
@@ -385,7 +385,7 @@ function emitEventSetup(
385
385
  ): void {
386
386
  const binding = loopParam
387
387
  ? buildRowEventBinding(ev, loopParam, loopParamBindings, loopIndex)
388
- : { childSlotId: ev.childSlotId, eventName: ev.eventName, handler: ev.handler }
388
+ : { childSlotId: ev.childSlotId, eventName: ev.eventName, handler: ev.handler, receiverSlotIds: ev.receiverSlotIds }
389
389
  emitRowEventListener(ls, indent, elVar, binding, bodyIsMultiRoot)
390
390
  }
391
391
 
@@ -405,6 +405,7 @@ export function buildRowEventBinding(
405
405
  childSlotId: ev.childSlotId,
406
406
  eventName: ev.eventName,
407
407
  handler: wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings, loopIndex),
408
+ receiverSlotIds: ev.receiverSlotIds,
408
409
  }
409
410
  }
410
411
 
@@ -422,7 +423,7 @@ export function emitRowEventListener(
422
423
  binding: LoopRowEventBinding,
423
424
  bodyIsMultiRoot: boolean = false,
424
425
  ): void {
425
- emitListenerBlock(ls, indent, elVar, binding.childSlotId, '__e', binding.eventName, binding.handler, 'dom', bodyIsMultiRoot)
426
+ emitListenerBlock(ls, indent, elVar, binding.childSlotId, '__e', binding.eventName, binding.handler, 'dom', bodyIsMultiRoot, binding.receiverSlotIds)
426
427
  }
427
428
 
428
429
  /**
@@ -44,6 +44,33 @@ export interface ClaimSlotSpec {
44
44
  readonly markerless?: boolean
45
45
  }
46
46
 
47
+ /**
48
+ * A loop-row content slot. `markup` is set for a row's read of the
49
+ * component's own prop (Phase 1's `IRExpression.loopRowPropRead`, carried as
50
+ * `LoopChildReactiveText.markup`): the caller may pass a JSX element there,
51
+ * so the slot is claimed and written as markup, the same way the read is
52
+ * outside a loop (`markup-slots.ts`). Every other row text stays 'text'.
53
+ */
54
+ export interface RowTextSlot {
55
+ readonly slotId: string
56
+ readonly markup?: true
57
+ }
58
+
59
+ /** The claim kind of a loop-row content slot (see {@link RowTextSlot}). */
60
+ export function rowTextSlotKind(text: RowTextSlot): 'text' | 'markup' {
61
+ return text.markup ? 'markup' : 'text'
62
+ }
63
+
64
+ /**
65
+ * The value a loop-row content slot's writer receives: `escapeTextOrNode`
66
+ * for a markup slot (unwraps a `bfMarkup()` value, passes a Node or a
67
+ * `__slot()` marker through, escapes a string before the markup writer's
68
+ * `innerHTML`), `coerce(expr)` for a 'text' slot.
69
+ */
70
+ export function rowTextSlotValue(text: RowTextSlot, expr: string, coerce: 'String' | 'textOrNode'): string {
71
+ return text.markup ? `escapeTextOrNode(${expr})` : `${coerce}(${expr})`
72
+ }
73
+
47
74
  /** Render one `SlotSpec` as a source-text object literal. */
48
75
  function slotSpecLiteral(slot: ClaimSlotSpec): string {
49
76
  const pathSrc = slot.pathExpr ?? `[${slot.path.join(', ')}]`
@@ -42,6 +42,7 @@ import type { ComponentLoopPlan, NestedComponentInit } from '../plan/types.ts'
42
42
  import { nameForRegistryRef } from '../../component-scope.ts'
43
43
  import { stringifyChildrenTextEffect, emitRowEventListener } from '../shared.ts'
44
44
  import { emitLoopChildRefs } from './loop.ts'
45
+ import { stringifyInnerLoops } from './inner-loop.ts'
45
46
 
46
47
  export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan): void {
47
48
  const {
@@ -57,9 +58,11 @@ export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan)
57
58
  keyExpr,
58
59
  nestedComps,
59
60
  rowEvents,
61
+ innerLoops,
60
62
  childRefs,
61
63
  reactiveEffects,
62
64
  profileLoopId,
65
+ profileComponentName,
63
66
  mapPreambleWrapped,
64
67
  } = plan
65
68
 
@@ -88,8 +91,9 @@ export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan)
88
91
  //
89
92
  // #3607: the same holds for a handler on a forwarded element — it needs
90
93
  // the row element to attach to, and (#3612) for a `ref` callback on one —
91
- // it needs the row element to look the target up in.
92
- if (nestedComps.length === 0 && !reactiveEffects && rowEvents.length === 0 && childRefs.length === 0) {
94
+ // it needs the row element to look the target up in. So does (#3694) an
95
+ // inner loop of the forwarded children that carries a handler.
96
+ if (nestedComps.length === 0 && !reactiveEffects && rowEvents.length === 0 && innerLoops.hydrated.length === 0 && childRefs.length === 0) {
93
97
  lines.push(` if (__existing) { initChild('${scopedComp}', __existing, ${componentPropsExpr}); return __existing }`)
94
98
  lines.push(` return createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`)
95
99
  lines.push(` }, '${markerId}'${loopBfId})`)
@@ -101,6 +105,7 @@ export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan)
101
105
  lines.push(` initChild('${scopedComp}', __existing, ${componentPropsExpr})`)
102
106
  for (const nc of nestedComps) emitNestedInit(lines, ' ', '__existing', nc)
103
107
  for (const ev of rowEvents) emitRowEventListener(lines, ' ', '__existing', ev)
108
+ stringifyInnerLoops(lines, innerLoops.hydrated, ' ', profileComponentName)
104
109
  if (reactiveEffects) {
105
110
  stringifyReactiveEffects(lines, reactiveEffects, { indent: ' ', elVar: '__existing' })
106
111
  }
@@ -116,6 +121,7 @@ export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan)
116
121
  lines.push(` const __csrEl = createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`)
117
122
  for (const nc of nestedComps) emitNestedInit(lines, ' ', '__csrEl', nc)
118
123
  for (const ev of rowEvents) emitRowEventListener(lines, ' ', '__csrEl', ev)
124
+ stringifyInnerLoops(lines, innerLoops.created, ' ', profileComponentName)
119
125
  if (reactiveEffects) {
120
126
  stringifyReactiveEffects(lines, reactiveEffects, { indent: ' ', elVar: '__csrEl' })
121
127
  }
@@ -61,9 +61,16 @@ export function emitListenerBlock(
61
61
  handler: JsSourceText,
62
62
  mode: EventNameMode = 'dom',
63
63
  bodyIsMultiRoot: boolean = false,
64
+ receiverSlotIds?: readonly string[],
64
65
  ): void {
65
66
  const wrapped = handler.trim()
66
67
  const name = mode === 'dom' ? toDomEventName(eventName) : eventName
67
68
  const lookup = bodyIsMultiRoot ? 'qsaItem' : 'qsa'
68
- lines.push(`${indent}{ const ${elementLocal} = ${lookup}(${scopeVar}, '[bf="${slotId}"]'); if (${elementLocal}) ${elementLocal}.addEventListener('${name}', ${wrapped}) }`)
69
+ // A parent-owned element forwarded through components nested below the
70
+ // row root (#3695) renders inside their scopes, which `qsa` crosses only
71
+ // for the nominated receivers hosted by this component (`__scopeId`).
72
+ const receiverArgs = !bodyIsMultiRoot && receiverSlotIds && receiverSlotIds.length > 0
73
+ ? `, ${JSON.stringify(receiverSlotIds)}, __scopeId`
74
+ : ''
75
+ lines.push(`${indent}{ const ${elementLocal} = ${lookup}(${scopeVar}, '[bf="${slotId}"]'${receiverArgs}); if (${elementLocal}) ${elementLocal}.addEventListener('${name}', ${wrapped}) }`)
69
76
  }
@@ -24,11 +24,11 @@
24
24
  */
25
25
 
26
26
  import { keyAttrName, mapArrayKeyArgs, profileBindingId, varSlotId } from '../../utils.ts'
27
- import { emitComponentAndEventSetup } from '../shared.ts'
27
+ import { emitComponentAndEventSetup, emitRowEventListener } from '../shared.ts'
28
28
  import { emitDedupedAttrUpdate, DEDUP_STORE_DECL } from '../../emit-reactive.ts'
29
29
  import { emitMultiRootTemplateCloneLines, namespaceWrapForTemplate } from './template-parse.ts'
30
30
  import { emitLoopChildRefs } from './loop.ts'
31
- import { claimPlanLiteral, claimWriterVarName, type ClaimSlotSpec } from './claim-plan.ts'
31
+ import { claimPlanLiteral, claimWriterVarName, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
32
32
  import { stringifyLoopChildConditionals } from './loop-child-arm.ts'
33
33
  import type {
34
34
  InnerLoopPlan,
@@ -86,19 +86,20 @@ function emitReactive(lines: string[], inner: InnerLoopPlan, indent: string, pc:
86
86
  if (emit.wrappedKey) {
87
87
  lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${emit.wrappedKey}))`)
88
88
  }
89
- if (emit.components.length > 0 || emit.events.length > 0) {
89
+ if (emit.components.length > 0) {
90
90
  emitComponentAndEventSetup(
91
91
  lines,
92
92
  `${indent} `,
93
93
  `__innerEl${uid}`,
94
94
  [...emit.components],
95
- [...emit.events],
95
+ [],
96
96
  inner.outerLoopParam,
97
97
  inner.outerLoopParamBindings,
98
98
  false,
99
99
  inner.outerLoopIndex,
100
100
  )
101
101
  }
102
+ for (const ev of emit.events) emitRowEventListener(lines, `${indent} `, `__innerEl${uid}`, ev)
102
103
  if (inner.childLevels.length > 0) {
103
104
  stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc)
104
105
  }
@@ -111,14 +112,14 @@ function emitReactive(lines: string[], inner: InnerLoopPlan, indent: string, pc:
111
112
  // writes are a plain, idempotent `nodeValue` assignment with no
112
113
  // dedup/trust-first-run state to go stale — so re-claiming here is exactly
113
114
  // as safe as, and replaces, the old re-query-$t-on-every-run discipline.
114
- lines.push(`${indent} createEffect(() => { claimSlots(__innerEl${uid}, [{ id: '${text.slotId}', kind: 'text', path: [] }]).write('${text.slotId}', String(${text.wrappedExpression})) }${bf})`)
115
+ lines.push(`${indent} createEffect(() => { claimSlots(__innerEl${uid}, [{ id: '${text.slotId}', kind: '${rowTextSlotKind(text)}', path: [] }]).write('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${bf})`)
115
116
  }
116
117
  if (plainTexts.length > 0) {
117
- const slots: ClaimSlotSpec[] = plainTexts.map(t => ({ id: t.slotId, kind: 'text', path: [] }))
118
+ const slots: ClaimSlotSpec[] = plainTexts.map(t => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }))
118
119
  const writer = claimWriterVarName(slots, varSlotId)
119
120
  lines.push(`${indent} const ${writer} = lazySlots(__innerEl${uid}, ${claimPlanLiteral(slots)})`)
120
121
  for (const text of plainTexts) {
121
- lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${profileBindingId(pc, text.slotId)})`)
122
+ lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${profileBindingId(pc, text.slotId)})`)
122
123
  }
123
124
  }
124
125
  if (emit.reactiveAttrs.length > 0) lines.push(`${indent} ${DEDUP_STORE_DECL}`)
@@ -63,7 +63,7 @@ import { isBooleanAttr } from '../../../html-constants.ts'
63
63
  import { emitDedupedAttrUpdate, dedupGuard } from '../../emit-reactive.ts'
64
64
  import { toHtmlAttrName } from '../../utils.ts'
65
65
  import type { SkeletonSlotPaths } from '../../html-template.ts'
66
- import { claimPlanLiteral, type ClaimSlotSpec } from './claim-plan.ts'
66
+ import { claimPlanLiteral, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
67
67
  import { pathExpr } from './skeleton-paths.ts'
68
68
  import {
69
69
  emitHoistedTemplateDecl,
@@ -156,13 +156,13 @@ export function stringifyLazyRowLoop(lines: string[], o: StringifyLazyRowOptions
156
156
  let freshPlanVar: string | null = null
157
157
  if (lazyRow.texts.length > 0) {
158
158
  adoptedPlanVar = `__lzs_${mid}`
159
- const adoptedSlots: ClaimSlotSpec[] = lazyRow.texts.map(t => ({ id: t.slotId, kind: 'text', path: [] }))
159
+ const adoptedSlots: ClaimSlotSpec[] = lazyRow.texts.map(t => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }))
160
160
  lines.push(`${indent}const ${adoptedPlanVar} = ${claimPlanLiteral(adoptedSlots)}`)
161
161
  if (textPathVar) {
162
162
  freshPlanVar = `__lzsc_${mid}`
163
163
  const freshSlots: ClaimSlotSpec[] = lazyRow.texts.map((t, i) => ({
164
164
  id: t.slotId,
165
- kind: 'text',
165
+ kind: rowTextSlotKind(t),
166
166
  path: [],
167
167
  pathExpr: `${textPathVar}[${i}]`,
168
168
  }))
@@ -535,15 +535,16 @@ function emitTextBinding(
535
535
  ? `${doorExpr}.write('${t.slotId}', ${valueExpr})`
536
536
  : `${doorExpr}('${t.slotId}', ${valueExpr})`
537
537
 
538
+ const value = rowTextSlotValue(t, '__x', 'textOrNode')
538
539
  if (mode === 'outer') {
539
540
  lines.push(`${ind}if (__seed) {`)
540
- lines.push(`${ind} const __s = textOrNode(__x)`)
541
+ lines.push(`${ind} const __s = ${value}`)
541
542
  lines.push(`${ind} if (${doorExpr}.read('${t.slotId}') !== __s) ${writeOf('__s')}`)
542
- lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf('textOrNode(__x)')}`)
543
+ lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf(value)}`)
543
544
  } else if (mode === 'item') {
544
- lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf('textOrNode(__x)')}`)
545
+ lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf(value)}`)
545
546
  } else {
546
- lines.push(`${ind}${writeOf('textOrNode(__x)')}`)
547
+ lines.push(`${ind}${writeOf(value)}`)
547
548
  }
548
549
  lines.push(`${ind}__l[${t.ordinal}] = __x }`)
549
550
  }
@@ -17,7 +17,7 @@ import { emitDedupedAttrUpdate, DEDUP_STORE_DECL } from '../../emit-reactive.ts'
17
17
  import { namespaceWrapForTemplate } from './template-parse.ts'
18
18
  import { emitListenerLine } from './event-listener.ts'
19
19
  import { nameForRegistryRef } from '../../component-scope.ts'
20
- import { claimPlanLiteral, claimWriterVarName, type ClaimSlotSpec } from './claim-plan.ts'
20
+ import { claimPlanLiteral, claimWriterVarName, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
21
21
  import type {
22
22
  BranchChildComponentInitsPlan,
23
23
  BranchEventBindingsPlan,
@@ -198,14 +198,14 @@ export function stringifyBranchInnerLoops(
198
198
  // insert() may swap the branch's DOM between runs, and a 'text' write
199
199
  // is a plain, idempotent `nodeValue` assignment with no dedup state to
200
200
  // go stale — replaces the old re-query-$t-on-every-run discipline.
201
- lines.push(`${indent} createEffect(() => { claimSlots(__bel${uid}, [{ id: '${text.slotId}', kind: 'text', path: [] }]).write('${text.slotId}', String(${text.wrappedExpression})) }${bf})`)
201
+ lines.push(`${indent} createEffect(() => { claimSlots(__bel${uid}, [{ id: '${text.slotId}', kind: '${rowTextSlotKind(text)}', path: [] }]).write('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${bf})`)
202
202
  }
203
203
  if (plainTexts.length > 0) {
204
- const slots: ClaimSlotSpec[] = plainTexts.map(t => ({ id: t.slotId, kind: 'text', path: [] }))
204
+ const slots: ClaimSlotSpec[] = plainTexts.map(t => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }))
205
205
  const writer = claimWriterVarName(slots, varSlotId)
206
206
  lines.push(`${indent} const ${writer} = lazySlots(__bel${uid}, ${claimPlanLiteral(slots)})`)
207
207
  for (const text of plainTexts) {
208
- lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${profileBindingId(pc, text.slotId)})`)
208
+ lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${profileBindingId(pc, text.slotId)})`)
209
209
  }
210
210
  }
211
211
  if (inner.nestedConditionals.length > 0) {
@@ -36,7 +36,7 @@ import { emitTemplateCloneInline, emitLoopItemElementSetup, emitHoistedTemplateD
36
36
  import { buildSkeletonPathPlan, type SkeletonPathPlan } from './skeleton-paths.ts'
37
37
  import { stringifyComponentLoop } from './component-loop.ts'
38
38
  import { stringifyCompositeLoop } from './composite-loop.ts'
39
- import { claimPlanLiteral, claimWriterVarName, type ClaimSlotSpec } from './claim-plan.ts'
39
+ import { claimPlanLiteral, claimWriterVarName, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
40
40
  import { stringifyLazyRowLoop } from './lazy-row.ts'
41
41
  import type { LoopChildRefBinding, LoopPlan, PlainLoopPlan, StaticLoopPlan } from '../plan/types.ts'
42
42
 
@@ -515,11 +515,11 @@ export function stringifyStaticLoop(lines: string[], plan: StaticLoopPlan): void
515
515
  lines.push(` }`)
516
516
  }
517
517
  if (texts.length > 0) {
518
- const slots: ClaimSlotSpec[] = texts.map(t => ({ id: t.slotId, kind: 'text', path: [] }))
518
+ const slots: ClaimSlotSpec[] = texts.map(t => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }))
519
519
  const writer = claimWriterVarName(slots, varSlotId)
520
520
  lines.push(` const ${writer} = lazySlots(__iterEl, ${claimPlanLiteral(slots)})`)
521
521
  for (const text of texts) {
522
- lines.push(` createEffect(() => { ${writer}('${text.slotId}', String(${text.expression})) }${profileBindingId(pc, text.slotId)})`)
522
+ lines.push(` createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.expression, 'String')}) }${profileBindingId(pc, text.slotId)})`)
523
523
  }
524
524
  }
525
525
  // Ref callbacks fire on every forEach iteration — initial mount and any
@@ -34,7 +34,7 @@
34
34
  import { varSlotId, profileBindingId } from '../../utils.ts'
35
35
  import { emitDedupedAttrUpdate, DEDUP_STORE_DECL } from '../../emit-reactive.ts'
36
36
  import { stringifyLoopChildArm, conditionGetterExpr } from './loop-child-arm.ts'
37
- import { claimPlanLiteral, claimWriterVarName, type ClaimSlotSpec } from './claim-plan.ts'
37
+ import { claimPlanLiteral, claimWriterVarName, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
38
38
  import type {
39
39
  NestedConditionalPlan,
40
40
  ReactiveAttrSlot,
@@ -277,7 +277,7 @@ function emitConsolidatedRowEffect(
277
277
  // preamble regions (kind 'markup') — mixed-kind plans are supported by
278
278
  // claim-slots.ts's per-slot `kind` dispatch.
279
279
  const claimSlots: ClaimSlotSpec[] = [
280
- ...outerTexts.map((t): ClaimSlotSpec => ({ id: t.slotId, kind: 'text', path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
280
+ ...outerTexts.map((t): ClaimSlotSpec => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
281
281
  ...preambleRegions.map((r): ClaimSlotSpec => ({ id: r.slotId, kind: 'markup', path: [] })),
282
282
  ]
283
283
  const writer = claimSlots.length > 0 ? claimWriterVarName(claimSlots, varSlotId) : null
@@ -294,7 +294,7 @@ function emitConsolidatedRowEffect(
294
294
  // preamble region) uses the multi-line block.
295
295
  if (attrSlots.length === 0 && preambleRegions.length === 0 && outerTexts.length === 1) {
296
296
  const text = outerTexts[0]
297
- lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) })`)
297
+ lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) })`)
298
298
  return
299
299
  }
300
300
  lines.push(`${indent}createEffect(() => {`)
@@ -319,7 +319,7 @@ function emitConsolidatedRowEffect(
319
319
  lines.push(`${indent} }`)
320
320
  }
321
321
  for (const text of outerTexts) {
322
- lines.push(`${indent} ${writer}('${text.slotId}', String(${text.wrappedExpression}))`)
322
+ lines.push(`${indent} ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')})`)
323
323
  }
324
324
  for (const region of preambleRegions) {
325
325
  lines.push(`${indent} ${writer}('${region.slotId}', ${region.valueExpr})`)
@@ -338,14 +338,14 @@ function emitOuterTexts(
338
338
  if (texts.length === 0) return
339
339
  const slots: ClaimSlotSpec[] = texts.map(t => ({
340
340
  id: t.slotId,
341
- kind: 'text',
341
+ kind: rowTextSlotKind(t),
342
342
  path: [],
343
343
  pathExpr: textClaimPathExprs?.get(t.slotId),
344
344
  }))
345
345
  const writer = claimWriterVarName(slots, varSlotId)
346
346
  lines.push(`${indent}const ${writer} = lazySlots(${elVar}, ${claimPlanLiteral(slots)})`)
347
347
  for (const text of texts) {
348
- lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${bindingBfId(text.slotId)})`)
348
+ lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${bindingBfId(text.slotId)})`)
349
349
  }
350
350
  }
351
351