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) 328 B
import getCurrentDocument from './getCurrentDocument'; /** * Is the given object root node of the DOM * * @param obj - The object to check * @return Is it the root node of the DOM or not */ export default function isDOMRoot(obj) { const doc = getCurrentDocument(obj); return !!doc && obj === doc.documentElement; }