How the triple-linked list data structure works
mainLinkeDOM uses a triple-linked list structure where all nodes are linked on both sides. This allows for extremely fast DOM manipulations (like moving thousands of nodes) because operations only require updating a few pointers rather than performing array or memory reallocations.
Key characteristics:
- Performance: Moving nodes is an $O(1)$ operation regarding memory/array shifts, making it scale linearly from small to very large documents.
- Stability: The structure helps avoid "Maximum call stack size exceeded" errors and reduces memory pressure compared to JSDOM.
- No Caching by default: To avoid the complexity of state invalidation,
childNodesandchildrenare computed on demand. If you need cached performance, you must explicitly importlinkedom/cached.