Skip to main content

is_parse_artifact

Function is_parse_artifact 

Source
pub fn is_parse_artifact(node: &Node) -> bool
Expand description

Is node an artifact of HOW a chunk was parsed, rather than part of the chunk? True for exactly the two things that can sit ABOVE a chunk’s top-level nodes: the throwaway parse_fragment wrapper, and the parsed document node.

Callers that let someone walk a parsed tree upwards need this. Handing back the wrapper would leak an internal name into a script-facing API — and worse, let a script insert <_lxfragment> into the page — while the document node would serialize the whole chunk from a parent() call. It also removes an arbitrary inconsistency: a single-root chunk’s top node sits directly under the document node, a multi-root chunk’s under the wrapper, and neither is something the caller wrote.