Skip to main content

split_node

Function split_node 

Source
pub fn split_node(
    node: &NodeRef,
    offset: usize,
) -> Result<(Option<NodeRef>, NodeRef), LexicalError>
Expand description

$splitNode(node, offset): splits the element at its child offset and each ancestor up to the nearest root or shadow root, and returns the top of the left tree (node’s ancestor below the root, which keeps the children before the offset) and of the right tree (a copy, which gets the rest). The child at offset moves into the right tree; its ancestors are copied. An offset past the end splits after the last child. JS’s return type lets the left be null; it never is.