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

16 lines (15 loc) 360 B
import isDocument from './isDocument'; import isDOMNode from './isDOMNode'; import isWindow from './isWindow'; export default function getCurrentDocument(obj) { if (isDocument(obj)) { return obj; } if (isWindow(obj)) { return obj.document; } if (!isDOMNode(obj)) { return null; } return obj.ownerDocument; }