docs/solutions/best-practices/2026-05-09-lexical-element-node-harvest-rows-need-api-shape-splitting.md
Lexical element-node tests look portable at first, but the file combines several owners: JSON schema, element child queries, text traversal, splice behavior, transform scheduling, DOM slot rendering, and DOM index helpers. A direct copy would drag Lexical architecture into Slate tests.
getChildren, getAllTextNodes, getFirstChild, getLastChild, and
getTextContent are portable query behavior.splice rows overlap with Slate operation, transform, and selection-rebase
contracts.getDOMSlot, indexPath, Lexical JSON schema, node keys, and transform
scheduling are not raw Slate package behavior.Split Lexical element-node rows by the API the Slate caller actually observes:
Node.children, Node.texts, Node.first,
Node.last, and Node.string;For this pass, the useful proof landed in
.tmp/slate-v2/packages/slate/test/query-contract.ts:
Node.string contract.The Slate test should protect observable editor behavior, not Lexical's class model. Query APIs own text traversal; operation APIs own structural mutation; React/browser tests own DOM slot behavior. Keeping those owners separate makes the harvested coverage stronger and smaller.