With the following bit of code –
var myEl = document.getElementById('myElement');
myEl.ownerDocument.defaultView;
does getting to the original window via ownerDocument.defaultView mean that I’m traversing up the DOM from the myEl element to the document and then to the window?
It’s not really traversing, per se.
Every DOM object has an
ownerDocumentproperty. This is the document that the node is associated with, if any.Every document object has a
defaultViewproperty (provided your browser supports it — not true in IE <9). This is thewindowobject where the document is shown, if any,.So it’s really just reading a couple of properties from objects, rather than traversal.