The DOM

The browser's live object model of the document: nodes, attributes, listeners, computed style, layout boxes and the accessibility semantics derived from all of it.

The DOM Is Not Your HTML
▶ lab

A tree of live objects the parser built from your markup and script has since diverged from — each node carrying attributes, properties, listeners, computed style, a layout box and an accessibility role.

Q · What is the browser actually holding for each element, and why does it stop matching the HTML I wrote?
What a Mutation Costs

Which changes invalidate style, which force layout, which repaint and which the compositor can absorb — and why the honest answer to most of them is "it depends what else is on the page".

Q · I changed one property on one element. How much work did I just ask the browser to do?
Queries, Live Collections and Stale References

Some queries return a snapshot, some return a view that keeps changing under you, and some are not questions about the tree at all — they force layout to answer.

Q · When I ask the DOM for a set of elements, what exactly did I get — and will it still be true in a moment?
Node Identity Across Updates

Focus, selection, caret position, scroll, animation progress and uncontrolled input values live on the node object — so whether an update reuses a node or replaces it is a visible product decision.

Q · When the data behind a list changes, how does the browser know that this row is still the same row?
Shadow DOM and the Composed Tree

A second tree attached to a host element: styles do not cross, queries do not cross, events retarget — and id-based accessibility relationships break in ways nothing warns you about.

Q · What does a shadow root actually isolate, and what still crosses the boundary?
Detached Nodes and What Keeps Them Alive

Removing a node from the document frees one reference, not the node — and because nodes point at their parents, siblings and children, one surviving reference retains an entire subtree.

Q · The nodes are gone from the page, so why does memory keep growing?