Skip to content

fix(vue): update host spreads when their expression changes - #1108

Merged
jonkwheeler merged 6 commits into
tsrx-org:mainfrom
jonkwheeler:fix/spread-reactive
Nov 12, 2026
Merged

jonkwheeler merged 6 commits into
tsrx-org:mainfrom
jonkwheeler:fix/spread-reactive

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1107; review the commits after aa75b23 (the Vue change is 78280ac; 47577de merges in #1107's later commit); merge after #1107.

Summary

On Vue, a host spread now updates when its expression changes. <button {...bag.value} /> kept title="before" and stayed enabled after bag.value = { title: 'after', disabled: true }, with or without a ref on the element. It now updates like native vue-jsx-vapor JSX.

Every Vue host spread was lowered to a setup declaration, so the bag was read once and the render effect saw no reactive read:

let App__spread_props1 = __normalize_spread_props_for_ref_attr(bag.value);
return <button {...App__spread_props1} ref={App__spread_props1?.ref} />;

vue-jsx-vapor evaluates a spread inside the element's render effect and sets the template ref after the props, so Vue now uses the in-place binding React, Preact, and Hono already use:

let App__spread_props1;
return <button {...(App__spread_props1 = __normalize_spread_props_for_ref_attr(bag.value))} ref={App__spread_props1?.ref} />;

which vue-jsx-vapor compiles to:

_renderEffect(() => {
	_setDynamicProps(_n0, [App__spread_props1 = __normalize_spread_props_for_ref_attr(bag.value)]);
	_setTemplateRef(_n0, App__spread_props1?.ref);
});

As in native Vue, the effect now sets the element's template ref again when the spread changes. The type-only print keeps the initialized declaration, as on the other targets. The hostSpreadRefBinding: 'in-place' docs now cover vue-jsx-vapor's order.

#1107 fixes the Solid half of #864. This PR is stacked on it so that #864 closes only when both targets are fixed.

Verification

  • New Vue runtime test (tsrx-vue-runtime): a spread with and without a ref, before and after replacing bag.value. It fails on main (both stay before) and passes here. The existing Vue spread, ref, and named-ref tests pass, including innerHTML beside a spread.
  • Checked the real vue-jsx-vapor 3.2.14 compiler output for a spread before and after a ref, inside @if, and with several elements in one effect: the props come first in every case.
  • tsrx-vue compile tests updated to the in-place form.
  • React, Preact, Hono, Solid, and Vue compiler and runtime projects plus the vite-plugin projects on this branch: 77 files, 5,785 tests passed. Full npx vitest run with all three spread branches merged locally: 176 files, 10,042 tests passed. pnpm typecheck, prettier --check, and pnpm changeset:check pass.

Related

Fixes #864

Cursor Bugbot

🤖 Generated with Claude Code


Note

Medium Risk
Changes Vue compile output for every host spread and ref-merge path; behavior is covered by new runtime and compile tests but touches reactive rendering and ref assignment order.

Overview
Vue host spreads are now reactive by compiling them with in-place binding ({...(bag = normalize(expr))}) instead of a one-shot setup let, so vue-jsx-vapor’s render effect re-reads the spread when bag.value (or similar) changes.

The Vue platform sets hostSpreadRefBinding: 'in-place' and the new jsx.refAfterProps: true, documenting that vapor applies ref after other props. Core JSX lowering adds keeps_merged_ref_in_place, so merged ref values stay in authored order only when the runtime does not apply ref last; on Vue, ref before a spread still ends up merged last to match vapor.

Compile and vite-plugin-vue runtime tests cover in-place output, reactive spread updates, and ref + spread ordering.

Reviewed by Cursor Bugbot for commit 03ab337. Bugbot is set up for automated code reviews on this repo. Configure here.

jonkwheeler and others added 2 commits October 26, 2026 14:50
On Solid, a host element with one spread and its own `ref` was lowered to

  let X = __normalize_spread_props_for_ref_attr(rest);
  <input {...X} ref={[a, X?.ref]} />

which broke three things that work in plain Solid TSX:

- `ref={a}` never assigned `a`: Solid only calls the functions in a ref
  array (tsrx-org#1072).
- The spread's `ref` ran twice, because Solid's `spread()` reads the bag's
  non-enumerable `ref` and applies it again (tsrx-org#236).
- The bag was read once in setup, so `{...bag()}` stopped updating (tsrx-org#864).

Solid's `spread()` already applies a bag's `ref` beside the element's own,
so the element now keeps its `ref` as written and spreads the normalized bag
in place: `<input ref={a} {...__normalize_spread_props(rest)} />`. Solid's
prop merge keeps only the last of several spreads' refs, so an element with
more than one spread still merges them into its ref array. The new
`jsx.hostSpreadRefStrategy: 'spread'` option selects this in core's lowering,
which handles elements in plain-JS expression positions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every Vue host spread was lowered to a setup declaration,

  let X = __normalize_spread_props_for_ref_attr(bag.value);
  <button {...X} ref={X?.ref} />

so the bag was read once and vue-jsx-vapor's render effect never saw a
reactive read: replacing `bag.value` left the element's attributes at their
first values (tsrx-org#864).

vue-jsx-vapor evaluates a spread inside the element's render effect and sets
its template ref after the props, so Vue now opts into the in-place binding
React, Preact, and Hono use: `{...(X = normalize(bag.value))} ref={X?.ref}`.
The type-only print keeps the initialized declaration, as on those targets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonkwheeler and others added 2 commits October 26, 2026 17:04
An element with two or more spreads and its own `ref` still went through the
merged ref array, so on Solid `ref={el}` never assigned `el` (tsrx-org#1072), the
last bag's `ref` ran twice because `spread()` read it again (tsrx-org#236), and the
bags were read once in setup (tsrx-org#864).

Solid's prop merge keeps only the last spread's `ref`, so these elements now
group their bags with the Solid runtime's new `spread_ref_bags`:

  let X = __spread_ref_bags(() => first, () => second);
  <input ref={el} {...X.bag(0)} {...X.bag(1)} {...X.refs} />

Each bag is normalized lazily in a memo shared by its spread and by `refs`.
`bag(i)` hands Solid the bag itself, or, when it has a `ref`, Solid's
`omit(bag, 'ref')`, which keeps its getters lazy; and
`refs.ref` lists every bag's ref in order for `spread()` to apply after the
element's own `ref`. A bag that gains or loses a ref updates, the bags stay
reactive, and the element's children are not rebuilt on prop changes. The
type-only print keeps the merged ref array.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in tsrx-org#1107's lowering for Solid elements with several host spreads
beside their own `ref`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 47577de. Configure here.

Comment thread packages/tsrx-solid-runtime/src/ref.js Resolved
jonkwheeler and others added 2 commits November 12, 2026 09:48
main now has tsrx-org#1107's squash commit; merged against the parent commit this branch has so git doesn't redo that work.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
This branch binds Vue host spreads in place so they stay reactive. Main
meanwhile (tsrx-org#1109) keeps a bound-in-place element's merged ref where its own
`ref` is written and reads the ref of a bag spread after it through a
deferred `(node) => __mergeRefs(bag?.ref)(node)`, so the ref expression runs
in written order on React, Preact, and Hono. On Vue that put a second Vue
`mergeRefs` wrapper on the node inside the first, which ran the cleanup of a
ref the author merged themselves: `ref={mergeRefs(a, input_ref)} {...props}`
called `input_ref(null)` right after setting it.

vue-jsx-vapor sets a template ref after the element's props wherever it is
written, so the written position gains nothing there. A new
`jsx.refAfterProps` platform option, set by Vue, keeps the merged ref last
and reads each bag's ref directly, as before tsrx-org#1109.

tsrx-org#1168's test pinned the spread as `{...bag}` from a setup declaration, the
non-reactive form this branch replaces; it now expects the in-place
`{...(bag = __normalize_spread_props_for_ref_attr(props))}` before the
scope class, still without `merge_spread_class`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
@jonkwheeler
jonkwheeler merged commit 04ef167 into tsrx-org:main Nov 12, 2026
8 checks passed
jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 12, 2026
Main's tsrx-org#1108 moved the merged-ref placement test into keeps_merged_ref_in_place, which skips platforms with refAfterProps, and still wrapped a later bag's ref in an arrow. This branch binds the own ref and puts the merged ref after the spreads instead, so the arrow stays removed, and the own-ref binding and merge_duplicate_refs placement now use keeps_merged_ref_in_place. jsx-platform.d.ts combines both descriptions of hostSpreadRefBinding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 12, 2026
Main's tsrx-org#1108 binds Vue host spreads in place, as `{...(X = normalize(expr))}`, so vue-jsx-vapor's render effect reads the bag again when it changes. A `yield` in that bag would then run inside the effect, outside its generator, so TSRX2034 reported it and the runtime test's yielding spread stopped compiling.

A generator yields a value once, so an effect could never read a yielded bag again anyway. On a target that reports deferred template yields, a host spread whose bag yields keeps its setup declaration, evaluated before the element where the generator runs it, as every Vue spread was before tsrx-org#1108. Every other spread, including one beside it, is still bound in place, and React, Preact and Hono are unchanged. A new Vue test pins both forms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit that referenced this pull request Nov 12, 2026
* fix(solid, vue): report a yield in a template as TSRX2034

babel-preset-solid and vue-jsx-vapor move template expressions into
reactive effect callbacks. A `yield` there no longer runs in its
generator, so the build failed later with `A 'yield' expression is only
allowed in a generator body.` (or, for `yield*`, `The keyword 'yield' is
reserved`), pointing at compiled code.

Solid and Vue now set `validation.templateYieldUnsupported`, and core
reports each `yield` in a template as TSRX2034
(TARGET_TEMPLATE_YIELD_UNSUPPORTED) at the authored `yield`, in source
order: attribute values, children, spread values, component props,
directive heads and bodies, including `yield*`. A `yield` in a nested
function, or in the setup statements of a function's own `@{ … }` body,
stays allowed.

A reported `yield` is recorded so the shared checks for a `yield` in a
generated callback (TSRX2022) and for the `super` such a callback can't
read (TSRX2023) don't report it a second time. React, Preact and Hono
evaluate templates eagerly and don't set the flag.

The error gets a Solid example in `@tsrx/content-mapper`'s error
examples, and a line in the specification's code list.

Fixes #259

* fix(solid, vue): report TSRX2034 only where the target's compiler moves the yield

The previous commit reported every `yield` in a Solid or Vue template.
Some of them build today, because the target's JSX compiler leaves the
value in place, so the check now mirrors each compiler on TSRX's final
output, which is what that compiler reads.

Core runs the target's new `findDeferredTemplateYields` hook after the
generated closures are suspended, and reports what it returns. A
`yield*` that delegates to a generator made from a generated closure
now carries that generator in `metadata.generated_delegation`, and
stands for the authored `yield`s inside it. A `yield` that already has
an error at or inside it (TSRX2022, TSRX2023) gets no second one. The
source-level walk, the `templateYieldUnsupported` flag and the
`rejected_yields` set are gone.

- Solid (`template-yield.js`) follows babel-preset-solid's JSX compiler.
  An element returned or assigned as a whole, and the elements nested in
  it, are created in place; any other host element is created in an
  immediately called arrow. A dynamic value is evaluated in an effect,
  an inserted arrow or a prop getter, and a static one in place, using
  the compiler's own test (a member access, call, spread or `in`).
  `class` and `style` are always in an effect unless the value is an
  object literal. An array `ref` goes in an arrow; event handlers and
  other refs stay in place. An assignable component `ref` goes in a
  callback, and other component refs are passed on or dropped.
  Component children are passed in a getter when there are several, or
  one is an element or dynamic.
- Vue (`template-yield.js`) reports any `yield` in an element or
  fragment. vue-jsx-vapor creates every element in an immediately called
  arrow, but a host spread TSRX evaluates into a variable before the
  element stays allowed.

Checked against babel-preset-solid and vue-jsx-vapor on 4009 shapes per
target (contexts, positions, value kinds and TSRX directives): TSRX2034
appears exactly when the compiled output fails to parse. Exempt shapes
build and run in the Solid and Vue Vite runtime tests.

Related: #259

* test(core): skip only #246's no-error check on Solid and Vue

The previous commit skipped #246's whole shared block on Solid and Vue.
Only its check that the shapes compile without errors depends on the
target, since those targets report some of them as TSRX2034. The
mapping check and the `@for` body check still apply there. Keeping
the block's `describe` line as it was also lets this merge cleanly
with #1220's tests next to it.

Related: #259

* test(solid, vue): check TSRX2034 against the installed JSX compilers

The Solid rule mirrors dom-expressions' choices about which template
values it evaluates in place, and consumers get whatever compiler
their vite-plugin-solid brings. Two probe tests now run reported and
exempt shapes through TSRX, then the installed babel-preset-solid (as
vite-plugin-solid calls it) or vue-jsx-vapor, then Vite's TypeScript
strip. They assert that TSRX2034 appears exactly when the result fails
a strict module parse. The probes cover each branch of the rules: 43
for Solid and 17 for Vue. A compiler release that diverges now fails
CI instead of giving a false error.

The rules record the compiler versions they follow:
@dom-expressions/babel-plugin-jsx 0.50.0-next.44 (babel-preset-solid
2.0.0-rc.2) and vue-jsx-vapor 3.2.14.

Related: #259

* fix(solid): read TypeScript wrappers and ref calls as babel-preset-solid does

vite-plugin-solid hands babel the TypeScript as written, so
dom-expressions sees `as`, `satisfies` and `!` as ordinary expressions.
The Solid rule looked through them. As a result, it left out a returned
or declared element behind one (`return (<input title={yield t} />) as
any`), which the compiler creates in an immediately called arrow, and a
class or style object behind one, which goes in an effect. Both failed
the DOM build with no TSRX2034. The rule now looks through parentheses
only. The exceptions are where the compiler strips a wrapper itself: `as`
and `!` on a host ref, and `satisfies` too on a component ref.

A component whose `ref` is a call is created inside an immediately
called arrow, so every value on it is now deferred too. An optional
member ref, which the compiler drops, is left alone.

New guard probes: the TypeScript-wrapped elements and objects, the
component ref forms, and the Bugbot shapes (an assigned element, `open`,
`one` and a fragment inside the returned element). 6 of them fail on the
previous head.

Related: #259

* fix(solid): follow dom-expressions for spreads, select values and folded values

Four false reports and two misses in #1280's DOM rule, each checked
against the installed babel-preset-solid's DOM output:

- Beside a host spread, every attribute but `ref` is a prop of the
  spread: a dynamic one in a getter, any other in place. So
  `<div {...bag} class={yield t} />` builds and is no longer reported,
  and `<button {...bag} onClick={yield bag.onClick} />` fails and is.
- A `<select>`'s value, unless it's a literal, is assigned in a
  microtask as well as in place, so `<select value={yield t} />` is
  reported.
- The compiler folds a host attribute value, or a value in an object
  there, into a literal when it evaluates to a string, number or
  boolean, and a host child into text when it evaluates to a string or
  number. `title={{ a: yield t, b: 'x'.length }}` is static after that,
  and the `yield` in `title={false && (yield bag.x)}` is dropped. The
  rule reads only literals for this: templates, members of string and
  number literals, unary operators and short circuits on them.
- dom-expressions counts a tagged template as dynamic only as the whole
  value, so `title={(yield t) + tag`x`}` builds and is no longer
  reported.

* docs(changeset): describe the spread, select and folding rules

* fix(solid): split class and style objects as dom-expressions does

Codex found more false reports in the DOM rule's class and style
handling, each checked against the installed babel-preset-solid:

- dom-expressions splits a `class` object, and a `['static', { … }]`
  array, into one attribute per key, drops a key whose value it can
  evaluate, and sets each remaining key in an effect only if its value
  is dynamic. So `class={{ active: yield t, big: bag.big }}` builds.
  A computed key, or one with a space or colon, keeps the object
  whole, set in an effect, which the rule missed.
- It inlines a `style` key whose value is a string or number, drops a
  `null` or `undefined` one, and splits off the rest the same way; a
  computed key or a spread keeps the object whole.
- `className` is a plain attribute to it, set in an effect only when
  dynamic.
- babel evaluates a sequence to its last value, so
  `title={(yield bag.x, 'a')}` folds into a literal.

* fix(solid): read evaluated class and style values as dom-expressions does

A second Codex pass found false reports where dom-expressions sets a
`class` or `style` value in place because babel can evaluate it:
`class={null && (yield t)}`, a computed key like
`[(yield t, 'active')]`, and a class key holding an array it
evaluates. A whole `class` or `style` value, or what stays in a style
object, is now set in an effect only when it is dynamic or can't be
evaluated, and literal values cover arrays and objects. An object's
nested values are checked as part of the object, so a tagged template
inside one isn't dynamic.

* refactor(solid): drop a fold check that changes no result

A value that folds into a literal keeps no `yield`, since
`collect_folded_yields` drops them, so only an object's values need
folding in the dynamic test. Turning the check off failed no test.

* fix(solid): drop duplicate attributes and fold typeof a class

A third Codex pass found two more false reports: without a spread,
dom-expressions keeps only the last attribute of a name (but every
`ref`), so a `yield` in an earlier one is dropped; and babel evaluates
`typeof` a function or class to `'function'` without running it.

* fix(solid): rename stateful properties before dropping duplicates

dom-expressions renames a stateful property set to something other than
a literal (`value`, `checked`, …) to `prop:…` before it drops duplicate
attributes, so `<input value={yield bag.value} value="kept" />` keeps
both and moves the `yield` into an effect. The previous commit dropped
the first one and missed it (found by Codex).

* docs(changeset): describe the class, style and duplicate rules

* fix(solid): read stateful properties exactly as the compiler does

A fifth Codex pass found edge cases in the stateful-property names: the
compiler looks the tag up in upper case, doesn't count a RegExp or
BigInt as a literal, and folds a textarea's literal value into its
content, which removes that attribute before duplicates are dropped.

* fix(solid): skip children the compiler drops or replaces

Two false reports from the re-review, each checked against the DOM
build: a textarea's literal `value` or `defaultValue` (or a bare
`value`) replaces its children, so `<textarea value="x">{yield bag.t}</textarea>`
builds; and without a spread, a `children` attribute is dropped when
the element has children of its own, so
`<div children={yield bag.t}>x</div>` builds too.

* fix(solid): drop a children attribute on a void element

dom-expressions never writes children for a void element, so a
`children` attribute there is dropped too:
`<input children={yield bag.t} />` builds.

* test(solid): cover a children attribute on a void element

* fix(solid): report yields in kept class objects and listener data

Two misses from the re-review, each checked against the DOM build:

- A `class` object with a method or accessor keeps the whole object,
  which dom-expressions sets in an effect beside the split keys, so
  `class={{ a: yield t, b() { return 1; } }}` fails to build.
- On an event it doesn't delegate (`onScroll`, `on:click`), a
  `[handler, data]` array becomes `e => handler(data, e)`, so both
  elements move into a new listener; a third element is dropped.
  Delegated events keep both in place.

* docs(changeset): note the children and listener rules for TSRX2034

* fix(solid): skip void and noscript children, split any listener data

From a Codex pass on 0740ad7..6a35169, each checked against the
DOM build:

- dom-expressions writes no children for a void element or a
  `<noscript>`, so `<input>{yield bag.t}</input>` builds.
- A `[handler, data]` array on an event it doesn't delegate keeps only
  the first two elements whatever follows, so
  `onScroll={[bag.h, yield t, ...bag.e]}` fails; a spread for the data
  is passed as is. A hole or a spread handler, or a hole for the data,
  makes the compiler throw, so those stay unreported.

The changeset now names `defaultValue` and a bare `value` too.

* fix(solid): apply the drop rules to elements created in an arrow

From a second Codex pass, on 8b4cacc, each checked against the DOM
build:

- A host element the compiler creates in an immediately called arrow
  (a ternary arm, a fragment, a dynamic child) was reported whole, so
  what it drops was reported too: `t ? <input>{yield bag.t}</input> : null`
  builds. It's now walked like an inline element, with everything it
  keeps moved.
- A `children` attribute is also dropped on a `<noscript>` and beside a
  textarea's literal value, which writes its own children.

The exempt-shape test title now says the DOM output leaves the `yield`
in place or drops it.

* fix(solid): skip delegated event tails, $key and shadowed children props

From a third Codex pass, on bf62582, each checked against the DOM
build:

- The compiler keeps only the first two elements of an event array on
  a delegated event too, so `t ? <button onClick={[h, d, yield x]} /> : null`
  builds.
- A component's `children` prop is dropped when the component has
  children: `<Comp children={yield bag.t}>x</Comp>` builds.
- The DOM output removes an element's first `$key`:
  `<div $key={yield bag.k} />` builds.

A top-level `<svg xmlns={yield …}>` is left as a known gap.

* test(solid): report the className and spread-in-a-ternary yields main now defers

Since main's #1232, Solid TSRX compiles a host element's className to class, which babel-preset-solid sets in an effect. Since #1107, it wraps a host spread in a normalize_spread_props call, so in a ternary arm (#246's shape) the compiler creates the element in an immediately called arrow. A yield in either place now leaves its generator, so TSRX2034 is right there. The downstream probes against the installed babel-preset-solid already agree.

Move both shapes to the reported list. The runtime test keeps a yield beside a host spread and a ref, on the returned element, which the compiler still evaluates in place.

* fix(vue): evaluate a host spread that yields before the element

Main's #1108 binds Vue host spreads in place, as `{...(X = normalize(expr))}`, so vue-jsx-vapor's render effect reads the bag again when it changes. A `yield` in that bag would then run inside the effect, outside its generator, so TSRX2034 reported it and the runtime test's yielding spread stopped compiling.

A generator yields a value once, so an effect could never read a yielded bag again anyway. On a target that reports deferred template yields, a host spread whose bag yields keeps its setup declaration, evaluated before the element where the generator runs it, as every Vue spread was before #1108. Every other spread, including one beside it, is still bound in place, and React, Preact and Hono are unchanged. A new Vue test pins both forms.

* test(solid): report a yield in a static @for iterable now that main wraps it

Since main's #1134, Solid TSRX passes an @for iterable to `for_items(...)`, so `each={__for_items(yield t)}` is a call. babel-preset-solid reads such a <For> prop in a getter, where the `yield` no longer runs in its generator. The compiled output fails to parse, and the downstream probe against the installed babel-preset-solid agrees. TSRX2034 is right there now.

Move the case from "allows" to "reports", as with the className and #246 shapes. A yield in a static @if test still runs in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit that referenced this pull request Nov 19, 2026
… as TSRX2021 (#1377)

* fix(vue, solid): report an await in a plain async function's template as TSRX2021

In a plain async function (not a component), an `await` in an element or
fragment of a `@{ … }` template compiled without an error on Vue and
Solid, and the build then failed with `await` is only allowed within
async functions: vue-jsx-vapor and babel-preset-solid move template
values into effects, getters and immediately called arrows, which aren't
async. Since #1079, an awaiting `@for` inside an element reached the same
failure on Vue (#1370).

Core now runs a target's new `findDeferredTemplateAwaits` hook on the
final output, next to `findDeferredTemplateYields` (#259), and reports
each `await` it returns as TSRX2021 at the authored `await`, in source
order. An `await` core adds for a generated closure it made async (an
`@if` or `@switch` body, or `map_iterable_async` for an awaiting `@for`)
now carries that closure in `metadata.generated_await`, so it is reported
at the authored `await`s inside. An `await` that already has an error
(a component's, or one in a callback the target calls) isn't reported
again.

- Vue: any `await` in an element or fragment whose nearest function is
  async. An awaiting `@for` that is the template's only output still
  compiles and renders, since `map_iterable_async` is awaited in the
  function itself. A host spread that awaits is evaluated in its setup
  declaration before the element, as one that yields is (#1108), so it
  builds, in the editor and the build alike.
- Solid: babel-preset-solid compiles an `await` as it compiles a
  `yield`, so the Solid finder reads `await`s with the TSRX2034 rules,
  for the DOM output and, with `ssr: true`, the SSR output too.
  `<p>{await text}</p>` stays in place and still compiles.

React, Preact and Hono don't set the hook and are unchanged.

Fixes #1370

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46


* fix(vue, solid): give a template await its own TSRX2021 message and model Solid's control-flow components

Follow-up to the review of the previous commit.

- Solid: `is_component_name` counted a tag as a component only when it
  started with a capital, but dom-expressions' `isComponent` also counts
  one that starts with something other than a letter, which includes
  TSRX's generated `__Show`, `__Switch`/`__Match`, `__ErrorBoundary` and
  `__Loading`. Their bodies were modelled as host elements: a static
  value in an `@if`, `@switch`, `@try` or `@pending` body, which
  babel-preset-solid passes in a children getter, went unreported (for
  `yield` on main, TSRX2034, and for `await`), and a static value of one
  of them in a fragment, such as `<>@if (await t) { <p>a</p> }</>`, was
  reported though it builds.
- A template `await` now has its own TSRX2021 message, worded like
  TSRX2034's: the callback message told the user to move the `await`
  into an async child component, which doesn't apply in a plain async
  function and isn't possible on Vue.
- A module's top level counts as async for both finders, so an `await`
  in JSX there (`export const el = <p>{await load()}</p>;`) is reported
  where the target's compiler moves it.

The new message gets a content-mapper error example and a line in the
specification's code list. Docs: the Solid plugins' `ssr`/`solid` option
docs name TSRX2021 beside TSRX2034, and llms.txt names Vue's awaiting
host spread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Solid and Vue host spreads stop updating reactive attributes after setup

1 participant