How a DOM Element is Attached
The implementation of Node::attach() is just a recursive depth-first traversal. However,Element::attach() does a bit more, also creating a renderer (if necessary) and resolving style for the element.
This diagram illustrates how it happens, showing relationships between the objects involved.