weft
ir 2.6.0 · warp 1.8.0

One fragment inside another

A tag is resolved to a sealed template at build time, not mounted at runtime.

<Card>outer template
children — one hole, any shape
one stream of segments · nothing nested at runtime
Composition happens in the byte stream. At runtime there is no tree to walk and no component to instantiate — the child’s segments are simply part of the parent’s.
✓ Valid One root, children as the sole child

A component compiles without seeing its call site, so its shape has to be predictable from the file alone.

✕ Refused children beside a sibling
what you wrote→the children hole must be the only child of its element→E_CHILDREN_NOT_SOLE_CHILD

Two more follow from the same rule: E_COMPONENT_NOT_SINGLE_ROOT and E_PRIVATE_COMPONENT_NESTED.

In plain terms

One fragment can sit inside another. Because the compiler lowers each one without seeing where it will be used, a component has to be predictable: a single root, and children as the sole child of their element.

A capitalised tag is resolved at build time to another fragment’s sealed template. Nothing is mounted, no function runs at render time, and the instance is a projection of the caller’s values into the child’s holes.

A component hole

examples/card

The card renders the badge. Two sealed templates, and the instance is a projection of the caller’s values rather than a value of its own.

output

Olive oil, 2L

new
app/fragments/examples/card.tsx
import { fragment } from '@weftjs/core'
import Badge from './badge.tsx'

/**
 * A fragment rendering another fragment.
 *
 * `<Badge/>` is not mounted and it is not a function call at runtime: the compiler resolves the tag
 * to a sealed template and leaves a component hole that projects this fragment's values into it. So
 * one `Badge` used a hundred times is one sealed template and a hundred projections.
 */
export default fragment(({ title, label }: { title: string; label: string }) => (
  <article class="card">
    <h3>{title}</h3>
    <Badge label={label} />
  </article>
))
What the compiler knows
Holes2
Escape elided0
Effect setnone — static
Wire formshtml · bundle · split · patch · delta

Holes

BindingHoleEscape
titletextescape
c0componenttrusted-raw

What the client wires on adoption

No wiring: nothing on this template changes after it is painted, so the client attaches nothing to it.

Sealed templates
2
Version
e9199c0717e062dd18da20ba9fa37b51

Which is what keeps a component transparent to a delta: a change to the parent binding is a change to the child’s hole, with no path syntax to invent.

Why a projection rather than a call

Because a projection stays addressable. A component that ran as a function would produce markup nobody could later describe; a component hole leaves the parent able to say "this hole’s value changed", which is what lets a delta cross a component boundary with no path syntax to invent.

It is also what makes the cost model legible: one Card used a hundred times is one sealed template and a hundred value sets, not a hundred component instances.

Containment

A fragment that reads identity would normally make its caller private. When the child is private and the parent is not, the compiler isolates the instance instead: the parent leaves a boundary and the kernel fills it, exactly as it does for a slot. So one private card does not make a whole shared page private.