UNPKG

vanillajs-browser-helpers

Version:

Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS in the browser

12 lines (11 loc) 330 B
import getCurrentDocument from './getCurrentDocument'; /** * Is the given DOM node inserted into the DOM * * @param elm - The element to check * @return Is it a DOM node in the DOM or not */ export default function inDOM(elm) { const doc = getCurrentDocument(elm); return !!doc && doc !== elm && doc.contains(elm); }