ianstormtaylor/slate · error · Error
The <text> hyperscript tag must only contain a single node's
Error message
The <text> hyperscript tag must only contain a single node's worth of children.
What it means
Thrown by the <text> hyperscript tag when its children resolve to more than one node — a text node in Slate holds a single run of text, so multiple children nodes are invalid.
Source
Thrown at packages/slate-hyperscript/src/creators.ts:201
path: focus.path,
},
...attributes,
}
}
/**
* Create a `Text` object.
*/
export function createText(
tagName: string,
attributes: { [key: string]: any },
children: any[]
): Text {
const nodes = resolveDescendants(children)
if (nodes.length > 1) {
throw new Error(
`The <text> hyperscript tag must only contain a single node's worth of children.`
)
}
let [node] = nodes
if (node == null) {
node = { text: '' }
}
if (!Text.isText(node)) {
throw new Error(`
The <text> hyperscript tag can only contain text content as children.`)
}
// COMPAT: If they used the <text> tag we want to guarantee that it won't be
// merge with other string children.
STRINGS.delete(node)View on GitHub (pinned to 72a37c701e)
Solutions
- Move multiple text children up into an <element> instead
- Use a single string or single <text> child inside <text>
- Combine runs: <text>{'a'}{'b'}</text> as strings is fine, but only one node tag
Example fix
// before <text> <text>a</text> <text>b</text> </text> // after <element> <text>a</text> <text>b</text> </element>
Defensive patterns
Strategy: validation
Validate before calling
// before building the fixture, ensure <text> contains only a single node's content // i.e. only strings/numbers or one nested token-free text run
Type guard
null
Try / catch
null
Prevention
- Put multiple text nodes inside <element>, never <text>
- Treat <text> as a leaf, not a fragment
- Review fixtures that nest tags inside <text>
When it happens
Trigger: Nesting element tags or multiple <text> tags inside <text>, e.g. <text><text>a</text><text>b</text></text>, which resolveDescendants expands into two nodes.
Common situations: Copy-pasting element structures inside a <text> tag in fixtures; assuming <text> behaves like a fragment.
Related errors
- The <text> hyperscript tag can only contain text conten
- The <selection> hyperscript tag must have an <anchor> tag as
- The <selection> hyperscript tag must have a <focus> tag as a
- Unexpected hyperscript child object: ${child}
- Slate hyperscript ranges must have both `<anchor />` and `<f
AI-assisted analysis of ianstormtaylor/slate@72a37c701e (2026-08-27).
Data as JSON: /api/errors/ffd727be1d55d7f9.
Report an issue: GitHub.