{"record":{"id":"ffd727be1d55d7f9","repo":"ianstormtaylor/slate","slug":"the-text-hyperscript-tag-must-only-contain-a-sin","errorCode":null,"errorMessage":"The <text> hyperscript tag must only contain a single node's worth of children.","messagePattern":"The <text> hyperscript tag must only contain a single node's worth of children\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/slate-hyperscript/src/creators.ts","lineNumber":201,"sourceCode":"      path: focus.path,\n    },\n    ...attributes,\n  }\n}\n\n/**\n * Create a `Text` object.\n */\n\nexport function createText(\n  tagName: string,\n  attributes: { [key: string]: any },\n  children: any[]\n): Text {\n  const nodes = resolveDescendants(children)\n\n  if (nodes.length > 1) {\n    throw new Error(\n      `The <text> hyperscript tag must only contain a single node's worth of children.`\n    )\n  }\n\n  let [node] = nodes\n\n  if (node == null) {\n    node = { text: '' }\n  }\n\n  if (!Text.isText(node)) {\n    throw new Error(`\n    The <text> hyperscript tag can only contain text content as children.`)\n  }\n\n  // COMPAT: If they used the <text> tag we want to guarantee that it won't be\n  // merge with other string children.\n  STRINGS.delete(node)","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/ianstormtaylor/slate/blob/72a37c701e5da4bb13a305d416d9c070d19d3a45/packages/slate-hyperscript/src/creators.ts#L183-L219","documentation":"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.","triggerScenarios":"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.","commonSituations":"Copy-pasting element structures inside a <text> tag in fixtures; assuming <text> behaves like a fragment.","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"],"exampleFix":"// before\n<text>\n  <text>a</text>\n  <text>b</text>\n</text>\n// after\n<element>\n  <text>a</text>\n  <text>b</text>\n</element>","handlingStrategy":"validation","validationCode":"// before building the fixture, ensure <text> contains only a single node's content\n// i.e. only strings/numbers or one nested token-free text run","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Put multiple text nodes inside <element>, never <text>","Treat <text> as a leaf, not a fragment","Review fixtures that nest tags inside <text>"],"tags":["slate","hyperscript","text-node","fixture"],"backgroundTag":"hyperscript-invalid-text-children","analyzedSha":"72a37c701e5da4bb13a305d416d9c070d19d3a45","analyzedAt":"2026-08-27T23:04:51.145Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}