3 ms·
I also have custom DOM helpers I carry around with me: * getNodesByType - allows me to get things like attributes, text, and comments directly * getAncestor -
by austincheney 6y ago
I also have custom DOM helpers I carry around with me:
* getNodesByType - allows me to get things like attributes, text, and comments directly
* getAncestor - allows me to get a specified element somewhere between a target element and the document.documentElement
- felixfbecker 6y agogetAncestor is built-in: element.closest() :)
- austincheney 6y agoSlow. It uses a selector as an argument, which requires a parse step. It doesn’t take much effort to write something substantially better.