{"record":{"id":"72c20be99a2c1b88","repo":"ianstormtaylor/slate","slug":"the-text-hyperscript-tag-can-only-contain-t","errorCode":null,"errorMessage":"\n    The <text> hyperscript tag can only contain text content as children.","messagePattern":"\n    The <text> hyperscript tag can only contain text content as children\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/slate-hyperscript/src/creators.ts","lineNumber":213,"sourceCode":"  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)\n\n  Object.assign(node, attributes)\n  return node\n}\n\n/**\n * Create a top-level `Editor` object.\n */\n\nexport const createEditor =\n  (makeEditor: () => Editor) =>\n  (","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/ianstormtaylor/slate/blob/72a37c701e5da4bb13a305d416d9c070d19d3a45/packages/slate-hyperscript/src/creators.ts#L195-L231","documentation":"Thrown by the <text> hyperscript tag when the resolved single child node is not a Slate Text node — i.e. an element tag (or non-text node) was nested inside <text>.","triggerScenarios":"Writing <text><element>...</element></text> or otherwise nesting an element creator inside the text tag so resolveDescendants yields an Element node.","commonSituations":"Fixture typos: wrapping paragraphs in <text> instead of <element>; mixing up tag names in custom creator setups.","solutions":["Use <element> for element nodes and <text> only for text content","Ensure custom creators map 'text' to a text-producing creator"],"exampleFix":"// before\n<text>\n  <element><text>hi</text></element>\n</text>\n// after\n<element>\n  <text>hi</text>\n</element>","handlingStrategy":"type-guard","validationCode":"import { Text } from 'slate'\nconst nodes = resolveDescendants(children)\nif (nodes.some(n => !Text.isText(n))) throw new Error('<text> children must be text')","typeGuard":"const allText = (nodes: Node[]): boolean => nodes.every(Text.isText)","tryCatchPattern":"null","preventionTips":["Use <element> for containers and <text> strictly for leaves","Avoid nesting element 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"}