The MDN documentation for MutationObserver.observe() states that the first parameter passed into observe() should be “A DOM Node (which may be an Element) within the DOM tree to watch for changes, or to be the root of a subtree of nodes to be watched.” All the examples I’ve seen for high-level DOM observation advise passing in document.body here, but can
Tag: standards
Closest ancestor matching selector using native DOM?
Is anybody working on a jQuery.closest() equivalent in the DOM api? Looks like the Selectors Level 2 draft adds matches() equivalent to jQuery.is(), so native closest should be much easier to write. Has adding closest() to Selectors come up? Answer See the element.closest() documentation. Implementing such function with Element.matches() seems not optimal in terms of performance, cause apparently matches() will