One fragment inside another
A tag is resolved to a sealed template at build time, not mounted at runtime.
A component compiles without seeing its call site, so its shape has to be predictable from the file alone.
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/cardThe 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.
Olive oil, 2L
newapp/fragments/examples/card.tsximport { 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
Holes
| Binding | Hole | Escape |
|---|---|---|
title | text | escape |
c0 | component | trusted-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.