@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
@@ -2,15 +2,16 @@
2
2
  * IR tree traversal → collect elements into ClientJsContext.
3
3
  */
4
4
 
5
- import { type IRNode, type IRElement, type IRComponent, type IRConditional, type IRLoop, type IRProp, pickAttrMetaFromIR } from '../types.ts'
5
+ import { type AttrValue, type IRNode, type IRElement, type IRComponent, type IRConditional, type IRLoop, type IRProp, pickAttrMetaFromIR } from '../types.ts'
6
6
  import type { ClientJsContext, ConditionalBranchChildComponent, ConditionalBranchReactiveAttr, BranchLoop, ConditionalBranchTextEffect, ConditionalElement, LoopChildBindings, LoopChildBranchSummary, LoopChildConditional, LoopOffset, NestedLoop } from './types.ts'
7
- import { attrValueToString, freeIdsFromRefs, quotePropName, PROPS_PARAM, toHtmlAttrName, rowBoundNames, withRowAccessor, type LoopParamSpec } from './utils.ts'
7
+ import { attrValueToString, freeIdsFromRefs, PROPS_PARAM, toHtmlAttrName, rowBoundNames, withRowAccessor, type LoopParamSpec } from './utils.ts'
8
8
  import { classifyReactivity, needsEffectWrapper, decideWrapForAttr, decideWrapForChildProp, decideWrapFromAstFlags, collectEventHandlersFromIR, collectConditionalBranchEvents, collectConditionalBranchRefs, collectConditionalBranchChildComponents, collectConditionalBranchComponentNodes, collectLoopChildEventsWithNesting, collectLoopChildReactiveAttrs, collectLoopChildReactiveTexts, collectLoopChildRefs, emptyLoopChildBindings, buildLoopRowScope, anyNameIn } from './reactivity.ts'
9
9
  import { irToHtmlTemplate, irToPlaceholderTemplate, irChildrenToJsExpr, jsxChildrenPropGetterExpr, buildLoopSkeletonTemplate, computeSkeletonSlotPaths, renderFlatMapClientBody, renderFlatMapProjectionClientBody, flatMapCallbackHasKeyedLeaf, type SkeletonSlotPaths } from './html-template.ts'
10
10
  import { detectRootNamespaceWrapTag } from './control-flow/stringify/template-parse.ts'
11
11
  import { expandDynamicPropValue, expandConstantForReactivity, resolveRestSpreadOrigin, resolveRestSpreadNames } from './prop-handling.ts'
12
12
  import { extractFreeIdentifiersFromText } from './csr-substitute.ts'
13
13
  import { walkIR, stopAt } from './walker.ts'
14
+ import { callerFirstPropExpr, childPropsObjectExpr, isSpreadPropName, lastPropsObjectSpreadIndex } from './child-props-object.ts'
14
15
  import { buildLoopChainExpr } from '../loop-chain.ts'
15
16
  import { classifyDOMProp } from '@barefootjs/shared'
16
17
  import type { BindingScope } from '../scope/binding-scope.ts'
@@ -445,6 +446,11 @@ export function collectInnerLoops(
445
446
  childComponents,
446
447
  insideConditional: !flat && scope.insideCond ? true : undefined,
447
448
  offset: flat ? undefined : resolveLoopOffset(siblingOffsets.get(n)),
449
+ filterPredicate: n.filterPredicate ? { param: n.filterPredicate.param, raw: n.filterPredicate.raw } : undefined,
450
+ sortComparator: n.sortComparator
451
+ ? { paramA: n.sortComparator.paramA, paramB: n.sortComparator.paramB, raw: n.sortComparator.raw }
452
+ : undefined,
453
+ chainOrder: n.chainOrder,
448
454
  bindings,
449
455
  })
450
456
  // Branch-mode callers handle deeper nesting via their own collection paths.
@@ -504,6 +510,18 @@ function decideLoopRendering(
504
510
  return { useElementReconciliation, innerLoops }
505
511
  }
506
512
 
513
+ /**
514
+ * Whether a top-level loop carries its collected inner loops to the client
515
+ * JS plans: a reconciled (composite) row, a static array's row, and a
516
+ * component-root row (#3694), whose forwarded children's inner loops get
517
+ * their event handlers wired per row (`buildForwardedInnerLoopsPlan`).
518
+ */
519
+ function keepsInnerLoops(loop: IRLoop, useElementReconciliation: boolean, innerLoops: NestedLoop[] | undefined): boolean {
520
+ if (useElementReconciliation) return true
521
+ if (!innerLoops || innerLoops.length === 0) return false
522
+ return loop.isStaticArray || !!loop.childComponent
523
+ }
524
+
507
525
  /** Check whether an array of IR nodes contains any component nodes (recursively). */
508
526
  function jsxChildrenContainComponent(nodes: IRNode[]): boolean {
509
527
  for (const node of nodes) {
@@ -517,70 +535,86 @@ function jsxChildrenContainComponent(nodes: IRNode[]): boolean {
517
535
  return false
518
536
  }
519
537
 
538
+ /**
539
+ * One explicit prop's `initChild` props-object entry: its value expression,
540
+ * and whether it is read through a getter (deferred, so reactive) or is a
541
+ * plain data property.
542
+ */
543
+ function componentInitPropValue(prop: IRProp, ctx: ClientJsContext): { expr: string; getter: boolean } {
544
+ if (isEventHandlerName(prop.name)) {
545
+ // Event handlers reach here only as `expression` variants.
546
+ return { expr: attrValueToString(prop.value) ?? prop.name, getter: false }
547
+ }
548
+ switch (prop.value.kind) {
549
+ case 'jsx-children':
550
+ if (jsxChildrenContainComponent(prop.value.children)) {
551
+ return { expr: `__slot(() => ${irChildrenToJsExpr(prop.value.children)})`, getter: true }
552
+ }
553
+ // Brand via the shared door (#2651/#2702) — see
554
+ // `jsxChildrenPropGetterExpr`'s docstring.
555
+ return { expr: jsxChildrenPropGetterExpr(prop.value.children, prop.name), getter: true }
556
+ case 'expression':
557
+ case 'template':
558
+ case 'spread':
559
+ return { expr: expandDynamicPropValue(attrValueToString(prop.value)!, ctx), getter: true }
560
+ case 'literal':
561
+ return { expr: JSON.stringify(prop.value.value), getter: false }
562
+ case 'boolean-shorthand':
563
+ case 'boolean-attr':
564
+ // `boolean-attr` should not reach here for component props
565
+ // (processComponentProps promotes it to boolean-shorthand), but handle
566
+ // it defensively.
567
+ return { expr: 'true', getter: false }
568
+ }
569
+ }
570
+
571
+ /**
572
+ * The merged value of the explicit prop at `index` for a reactive DOM
573
+ * mirror: caller-first when a later props-object spread (at `spreadAt`, see
574
+ * `lastPropsObjectSpreadIndex`) overrides it, `expr` as written otherwise.
575
+ */
576
+ function mergedMirrorExpr(name: string, expr: string, index: number, spreadAt: number): string {
577
+ return index < spreadAt ? callerFirstPropExpr(name, expr) : expr
578
+ }
579
+
580
+ /**
581
+ * Which caller bag an element's spread attribute forwards, for
582
+ * `applyRestAttrs`: its text resolved through any `const x__alias = x` hop
583
+ * onto the rest/props binding (#2723, `resolveRestSpreadOrigin`). Null
584
+ * when Phase 1 did not resolve the spread to the bag
585
+ * (`SpreadAttr.callerBag`): a loop row or callback parameter spelled like
586
+ * the rest binding is that binding (#3851).
587
+ */
588
+ function callerBagSpreadOrigin(value: AttrValue, ctx: ClientJsContext): 'rest' | 'props' | null {
589
+ if (value.kind !== 'spread' || value.callerBag === undefined) return null
590
+ const spreadVal = attrValueToString(value) ?? ''
591
+ return spreadVal ? resolveRestSpreadOrigin(ctx, spreadVal) : null
592
+ }
593
+
594
+ /**
595
+ * The live `_p.<key>` read a closed-rest-expanded attribute binds to
596
+ * (`IRAttribute.restExpandedKey`, #3057), with the value an earlier
597
+ * attribute gave the key when the caller omits it, as SSR rendered it
598
+ * (`IRAttribute.restFallback`, #3851).
599
+ */
600
+ function restKeyLiveRead(attr: IRElement['attrs'][number]): string {
601
+ const read = `${PROPS_PARAM}.${attr.name}`
602
+ return attr.restFallback === undefined ? read : `${read} ?? (${attr.restFallback})`
603
+ }
604
+
520
605
  /** Build propsExpr for a child component from its IR props. */
521
606
  function buildComponentPropsExpr(props: IRProp[], ctx: ClientJsContext): string {
522
607
  const knownSpreadProp = props.find(p => {
523
- if (p.name !== '...' && !p.name.startsWith('...')) return false
608
+ if (!isSpreadPropName(p.name)) return false
524
609
  if (p.value.kind !== 'spread' && p.value.kind !== 'expression') return false
525
610
  const expr = p.value.kind === 'spread' ? p.value.expr : p.value.expr
526
611
  // #2723: resolve through any `const x__alias = x` hop onto the
527
612
  // rest/props binding — see `resolveRestSpreadOrigin`'s docstring.
528
613
  return resolveRestSpreadOrigin(ctx, expr) !== null
529
614
  })
530
- const spreadSource = knownSpreadProp ? PROPS_PARAM : null
531
-
532
- const propsForInit: string[] = []
533
- const explicitPropNames: string[] = []
534
- for (const prop of props) {
535
- if (prop.name === '...' || prop.name.startsWith('...')) continue
536
- explicitPropNames.push(prop.name)
537
- const isEventHandler = isEventHandlerName(prop.name)
538
- if (isEventHandler) {
539
- // Event handlers reach here only as `expression` variants.
540
- propsForInit.push(`${quotePropName(prop.name)}: ${attrValueToString(prop.value) ?? prop.name}`)
541
- continue
542
- }
543
- switch (prop.value.kind) {
544
- case 'jsx-children': {
545
- if (jsxChildrenContainComponent(prop.value.children)) {
546
- const jsxExpr = irChildrenToJsExpr(prop.value.children)
547
- propsForInit.push(`get ${quotePropName(prop.name)}() { return __slot(() => ${jsxExpr}) }`)
548
- } else {
549
- // Brand via the shared door (#2651/#2702) — see
550
- // `jsxChildrenPropGetterExpr`'s docstring.
551
- const jsxExpr = jsxChildrenPropGetterExpr(prop.value.children, prop.name)
552
- propsForInit.push(`get ${quotePropName(prop.name)}() { return ${jsxExpr} }`)
553
- }
554
- break
555
- }
556
- case 'expression':
557
- case 'template':
558
- case 'spread': {
559
- const valueExpr = attrValueToString(prop.value)!
560
- const expandedValue = expandDynamicPropValue(valueExpr, ctx)
561
- propsForInit.push(`get ${quotePropName(prop.name)}() { return ${expandedValue} }`)
562
- break
563
- }
564
- case 'literal':
565
- propsForInit.push(`${quotePropName(prop.name)}: ${JSON.stringify(prop.value.value)}`)
566
- break
567
- case 'boolean-shorthand':
568
- propsForInit.push(`${quotePropName(prop.name)}: true`)
569
- break
570
- case 'boolean-attr':
571
- // Should not reach here for component props (processComponentProps
572
- // promotes to boolean-shorthand), but handle defensively.
573
- propsForInit.push(`${quotePropName(prop.name)}: true`)
574
- break
575
- }
576
- }
577
-
578
- if (spreadSource) {
579
- const overrides = propsForInit.length > 0 ? `{ ${propsForInit.join(', ')} }` : '{}'
580
- const excludeKeys = JSON.stringify(explicitPropNames)
581
- return `forwardProps(${spreadSource}, ${overrides}, ${excludeKeys})`
582
- }
583
- return propsForInit.length > 0 ? `{ ${propsForInit.join(', ')} }` : '{}'
615
+ return childPropsObjectExpr(props, prop => componentInitPropValue(prop, ctx), {
616
+ forwardCaller: knownSpreadProp !== undefined,
617
+ })
584
618
  }
585
619
 
586
620
  /**
@@ -589,7 +623,8 @@ function buildComponentPropsExpr(props: IRProp[], ctx: ClientJsContext): string
589
623
  * side-effect helper so `buildComponentPropsExpr` stays a pure function.
590
624
  */
591
625
  function collectReactiveChildProps(node: IRComponent, ctx: ClientJsContext): void {
592
- for (const prop of node.props) {
626
+ const spreadAt = lastPropsObjectSpreadIndex(node.props)
627
+ for (const [index, prop] of node.props.entries()) {
593
628
  if (prop.name === '...' || prop.name.startsWith('...')) continue
594
629
  if (prop.value.kind === 'jsx-children') continue
595
630
  // `classifyDOMProp` is the single source of truth for "how does this prop
@@ -629,7 +664,7 @@ function collectReactiveChildProps(node: IRComponent, ctx: ClientJsContext): voi
629
664
  slotId: node.slotId,
630
665
  propName: prop.name,
631
666
  attrName,
632
- expression: expandedValue,
667
+ expression: mergedMirrorExpr(prop.name, expandedValue, index, spreadAt),
633
668
  ...pickAttrMetaFromIR(prop),
634
669
  })
635
670
  }
@@ -971,7 +1006,7 @@ export function collectElements(
971
1006
  nestedComponents: l.nestedComponents,
972
1007
  isStaticArray: clientIsStaticArray,
973
1008
  useElementReconciliation,
974
- innerLoops: (useElementReconciliation || (l.isStaticArray && innerLoops?.length)) ? innerLoops : undefined,
1009
+ innerLoops: keepsInnerLoops(l, useElementReconciliation, innerLoops) ? innerLoops : undefined,
975
1010
  offset: resolveLoopOffset(siblingOffsets.get(l)),
976
1011
  filterPredicate: l.filterPredicate ? {
977
1012
  param: l.filterPredicate.param,
@@ -1004,7 +1039,8 @@ export function collectElements(
1004
1039
  component: ({ node: c, descend, descendJsxChildren }) => {
1005
1040
  if (c.slotId) {
1006
1041
  // Reactive props need effects to update the element when values change.
1007
- for (const prop of c.props) {
1042
+ const spreadAt = lastPropsObjectSpreadIndex(c.props)
1043
+ for (const [index, prop] of c.props.entries()) {
1008
1044
  if (prop.value.kind === 'jsx-children') continue
1009
1045
  if (isEventHandlerName(prop.name)) continue
1010
1046
  // Only `expression` variants reach the signal/memo getter heuristic
@@ -1020,7 +1056,7 @@ export function collectElements(
1020
1056
  ctx.reactiveProps.push({
1021
1057
  slotId: c.slotId,
1022
1058
  propName: prop.name,
1023
- expression: fnName,
1059
+ expression: mergedMirrorExpr(prop.name, value, index, spreadAt),
1024
1060
  componentName: c.name,
1025
1061
  })
1026
1062
  }
@@ -1099,10 +1135,7 @@ function collectFromElement(element: IRElement, ctx: ClientJsContext, insideCond
1099
1135
  // Other identifiers or complex expressions may not exist in the compiled init scope.
1100
1136
  // Always use PROPS_PARAM as the source since the init function parameter is PROPS_PARAM.
1101
1137
  if (attr.name === '...' && attr.value) {
1102
- const spreadVal = attrValueToString(attr.value) ?? ''
1103
- // #2723: resolve through any `const x__alias = x` hop onto the
1104
- // rest/props binding — see `resolveRestSpreadOrigin`'s docstring.
1105
- const spreadOrigin = spreadVal ? resolveRestSpreadOrigin(ctx, spreadVal) : null
1138
+ const spreadOrigin = callerBagSpreadOrigin(attr.value, ctx)
1106
1139
  if (spreadOrigin !== null) {
1107
1140
  // `applyRestAttrs(_el, _p, exclude)` is handed the FULL props
1108
1141
  // object (`PROPS_PARAM`), not a computed JS rest binding, and the
@@ -1191,7 +1224,7 @@ function collectFromElement(element: IRElement, ctx: ClientJsContext, insideCond
1191
1224
  ctx.reactiveAttrs.push({
1192
1225
  slotId: element.slotId,
1193
1226
  attrName: attr.name,
1194
- expression: `${PROPS_PARAM}.${attr.name}`,
1227
+ expression: restKeyLiveRead(attr),
1195
1228
  ...pickAttrMetaFromIR(attr),
1196
1229
  })
1197
1230
  continue
@@ -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'
@@ -67,11 +69,18 @@ function wrapAttrValueExpression(value: AttrValue, wrap: (s: string) => string):
67
69
  return AttrValueOf.expression(wrap(flat ?? 'undefined'))
68
70
  }
69
71
  case 'spread':
70
- return AttrValueOf.spread(wrap(value.expr), value.templateExpr ? wrap(value.templateExpr) : undefined)
72
+ // Keep the Phase-1 props-object marker: the props object merges this
73
+ // spread in source order (#3713).
74
+ return {
75
+ ...AttrValueOf.spread(wrap(value.expr), value.templateExpr ? wrap(value.templateExpr) : undefined),
76
+ ...(value.propsObject && { propsObject: true as const }),
77
+ }
71
78
  }
72
79
  }
73
80
  import type { DepthLevel } from '../shared.ts'
81
+ import type { LoopRowEventBinding } from './loop.ts'
74
82
  import {
83
+ buildDepthLevels,
75
84
  destructureLoopParam,
76
85
  loopKeyFn,
77
86
  nestedLoopIndexAlias,
@@ -143,7 +152,14 @@ export function buildInnerLoopsPlan(args: BuildInnerLoopsArgs): InnerLoopsPlan {
143
152
  // shortcut was unsound.
144
153
  const emit: InnerLoopReactiveEmit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex)
145
154
 
146
- const arrayExpr = wrapOuter(inner.array)
155
+ // The inner `.filter()` / `.toSorted()` chain (#3694), so the rows
156
+ // reconciled are the rows the template rendered.
157
+ const arrayExpr = wrapOuter(buildLoopChainExpr({
158
+ base: inner.array,
159
+ filterPredicate: inner.filterPredicate,
160
+ sortComparator: inner.sortComparator,
161
+ chainOrder: inner.chainOrder,
162
+ }))
147
163
 
148
164
  const childLevelsPlan = childLevels.length > 0
149
165
  ? buildInnerLoopsPlan({
@@ -231,15 +247,20 @@ function buildReactiveEmit(
231
247
  props: comp.props.map(p => ({ ...p, value: wrapAttrValueExpression(p.value, wrapInner) })),
232
248
  children: comp.children?.map(wrapIRNode),
233
249
  }))
234
- const events: LoopChildEvent[] = level.events.map(ev => ({
235
- ...ev,
236
- handler: wrapInner(ev.handler),
250
+ // Resolved against every enclosing row, like the texts below (#3694): an
251
+ // inner-wrap-only handler left a grandparent row's item two loops up
252
+ // unwrapped (`o.id` on the accessor reads `undefined`).
253
+ const events: LoopRowEventBinding[] = level.events.map(ev => ({
254
+ childSlotId: ev.childSlotId,
255
+ eventName: ev.eventName,
256
+ handler: wrapBoth(ev.handler),
237
257
  }))
238
258
 
239
259
  const reactiveTexts: InnerLoopText[] = inner.bindings.reactiveTexts.map(text => ({
240
260
  slotId: text.slotId,
241
261
  wrappedExpression: wrapLoopParamAsAccessor(wrapOuterRow(text.expression), inner.param, inner.paramBindings, inner.index),
242
262
  insideConditional: !!text.insideConditional,
263
+ ...(text.markup && { markup: true as const }),
243
264
  }))
244
265
 
245
266
  const reactiveAttrs: InnerLoopReactiveAttr[] = inner.bindings.reactiveAttrs.map(attr => {
@@ -320,3 +341,62 @@ function buildReactiveEmit(
320
341
  childRefs,
321
342
  }
322
343
  }
344
+
345
+ export interface BuildForwardedInnerLoopsArgs {
346
+ /** The row's inner loops, DFS-ordered (`TopLevelLoop.innerLoops`). */
347
+ innerLoops: readonly NestedLoop[] | undefined
348
+ /** The row's collected events (`TopLevelLoop.bindings.events`). */
349
+ events: readonly LoopChildEvent[]
350
+ /** The row element the inner loop containers are looked up in. */
351
+ parentElVar: string
352
+ /** The outer row's param, or `undefined` when the row binds it as a plain value (a static array). */
353
+ outerLoopParam?: string
354
+ outerLoopParamBindings?: readonly LoopParamBinding[]
355
+ outerLoopIndex?: string | null
356
+ }
357
+
358
+ /**
359
+ * The inner-loop plan for the inner loops of a component-root row's
360
+ * forwarded children (`<Chip key={o.id}><ul>{o.tags.map(tag => <li><button
361
+ * onClick={…}/></li>)}</ul></Chip>`, #3694). The child component renders its
362
+ * `children` once, so nothing else reaches an element inside such an inner
363
+ * loop: a handler there was dropped. Each row now runs the composite row's
364
+ * inner-loop emission (`buildInnerLoopsPlan`) over its own element, which
365
+ * claims the rendered inner rows and attaches the handlers with the inner
366
+ * and the outer bindings resolved the same way as on a composite row.
367
+ *
368
+ * Only inner loops that carry an event, and the enclosing loops they need,
369
+ * are planned; the others keep their output unchanged. Child components
370
+ * inside an inner loop are left to their existing pass (`comps` empty), so
371
+ * none is initialised twice.
372
+ */
373
+ export function buildForwardedInnerLoopsPlan(args: BuildForwardedInnerLoopsArgs): InnerLoopsPlan {
374
+ const { innerLoops, events, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex } = args
375
+ if (!innerLoops || innerLoops.length === 0) return []
376
+ const levels = buildDepthLevels([...innerLoops], [], [...events])
377
+ const kept = levels.filter((_, i) => levelCarriesEvent(levels, i))
378
+ if (kept.length === 0) return []
379
+ return buildInnerLoopsPlan({ levels: kept, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex })
380
+ }
381
+
382
+ /**
383
+ * Whether `levels[i]` or a loop nested inside it (the deeper levels right
384
+ * after it) carries an event, on its row or inside a conditional of its row.
385
+ */
386
+ function levelCarriesEvent(levels: readonly DepthLevel[], i: number): boolean {
387
+ const depth = levels[i].loopInfo?.depth ?? 0
388
+ for (let j = i; j < levels.length; j++) {
389
+ if (j > i && (levels[j].loopInfo?.depth ?? 0) <= depth) break
390
+ if (levels[j].events.length > 0) return true
391
+ if (conditionalsCarryEvent(levels[j].loopInfo?.bindings.conditionals ?? [])) return true
392
+ }
393
+ return false
394
+ }
395
+
396
+ function conditionalsCarryEvent(conditionals: readonly LoopChildConditional[]): boolean {
397
+ return conditionals.some(c => [c.whenTrue, c.whenFalse].some(branch =>
398
+ (branch.events?.length ?? 0) > 0
399
+ || conditionalsCarryEvent(branch.conditionals ?? [])
400
+ || (branch.innerLoops ?? []).some(l => l.bindings.events.length > 0 || conditionalsCarryEvent(l.bindings.conditionals)),
401
+ ))
402
+ }
@@ -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
 
@@ -24,7 +24,7 @@ import type {
24
24
  LoopParamBinding,
25
25
  } from '../../../types.ts'
26
26
  import { AttrValueOf, pickAttrMeta } from '../../../types.ts'
27
- import { quotePropName, wrapLoopParamAsAccessor, attrValueToString, rowBoundNames, unionNames, type ShadowableWrap } from '../../utils.ts'
27
+ import { wrapLoopParamAsAccessor, attrValueToString, rowBoundNames, unionNames, type ShadowableWrap } from '../../utils.ts'
28
28
  import { addCondAttrToTemplate, irChildrenToJsExpr } from '../../html-template.ts'
29
29
  import type { ReactiveAttrSlot } from './reactive-effects.ts'
30
30
 
@@ -58,12 +58,18 @@ function wrapAttrValueExpression(value: AttrValue, wrap: (s: string) => string):
58
58
  return AttrValueOf.expression(wrap(flat ?? 'undefined'))
59
59
  }
60
60
  case 'spread':
61
- return AttrValueOf.spread(wrap(value.expr), value.templateExpr ? wrap(value.templateExpr) : undefined)
61
+ // Keep the Phase-1 props-object marker: the props object merges this
62
+ // spread in source order (#3713).
63
+ return {
64
+ ...AttrValueOf.spread(wrap(value.expr), value.templateExpr ? wrap(value.templateExpr) : undefined),
65
+ ...(value.propsObject && { propsObject: true as const }),
66
+ }
62
67
  }
63
68
  }
64
69
  import { destructureLoopParam, loopKeyFn, buildCompSelector, nestedLoopIndexAlias } from '../shared.ts'
65
70
  import { BF_HOST, BF_AT } from '@barefootjs/shared'
66
71
  import { isEventHandlerName } from '../../../event-handler-name.ts'
72
+ import { childPropsObjectExpr, type ChildPropValue } from '../../child-props-object.ts'
67
73
  import type {
68
74
  BranchChildComponentInit,
69
75
  BranchChildComponentInitsPlan,
@@ -172,35 +178,30 @@ export function buildBranchChildComponentInitsPlan(
172
178
  for (const comp of components) {
173
179
  const selector = buildCompSelector(comp)
174
180
 
175
- const propsEntries = comp.props
176
- .filter(p => p.name !== 'key')
177
- .map(p => {
178
- if (isEventHandlerName(p.name)) {
179
- return `${quotePropName(p.name)}: ${wrap(attrValueToString(p.value) ?? 'undefined')}`
180
- }
181
- switch (p.value.kind) {
182
- case 'literal':
183
- return `get ${quotePropName(p.name)}() { return ${JSON.stringify(p.value.value)} }`
184
- case 'boolean-shorthand':
185
- case 'boolean-attr':
186
- return `get ${quotePropName(p.name)}() { return true }`
187
- case 'jsx-children':
188
- case 'expression':
189
- case 'template':
190
- case 'spread': {
191
- const expr = attrValueToString(p.value) ?? 'undefined'
192
- return `get ${quotePropName(p.name)}() { return ${wrap(expr)} }`
193
- }
194
- }
195
- })
196
-
197
181
  // Children are needed for CSR createComponent; SSR initChild ignores them
198
182
  // (text already lives in the rendered HTML).
199
183
  const childrenExpr = comp.children?.length ? irChildrenToJsExpr(comp.children) : null
200
- if (childrenExpr) {
201
- propsEntries.push(`get children() { return ${wrap(childrenExpr)} }`)
202
- }
203
- const propsExpr = propsEntries.length > 0 ? `{ ${propsEntries.join(', ')} }` : '{}'
184
+ const trailing = childrenExpr ? [`get children() { return ${wrap(childrenExpr)} }`] : []
185
+ // A props-object spread merges in source order through the shared door
186
+ // (#3713) instead of becoming a getter named `...`.
187
+ const propsExpr = childPropsObjectExpr(comp.props, (p): ChildPropValue | null => {
188
+ if (p.name === 'key') return null
189
+ if (isEventHandlerName(p.name)) {
190
+ return { expr: wrap(attrValueToString(p.value) ?? 'undefined'), getter: false }
191
+ }
192
+ switch (p.value.kind) {
193
+ case 'literal':
194
+ return { expr: JSON.stringify(p.value.value), getter: true }
195
+ case 'boolean-shorthand':
196
+ case 'boolean-attr':
197
+ return { expr: 'true', getter: true }
198
+ case 'jsx-children':
199
+ case 'expression':
200
+ case 'template':
201
+ case 'spread':
202
+ return { expr: wrap(attrValueToString(p.value) ?? 'undefined'), getter: true }
203
+ }
204
+ }, { trailing })
204
205
 
205
206
  inits.push({
206
207
  name: comp.name,
@@ -342,6 +343,7 @@ export function buildBranchInnerLoopsPlan(
342
343
  slotId: text.slotId,
343
344
  wrappedExpression: wrapBoth(text.expression),
344
345
  insideConditional: !!text.insideConditional,
346
+ ...(text.markup && { markup: true as const }),
345
347
  }))
346
348
 
347
349
  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
  }