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
22 lines (21 loc) • 737 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const isDocument_1 = __importDefault(require("./isDocument"));
const isDOMNode_1 = __importDefault(require("./isDOMNode"));
const isWindow_1 = __importDefault(require("./isWindow"));
function getCurrentDocument(obj) {
if ((0, isDocument_1.default)(obj)) {
return obj;
}
if ((0, isWindow_1.default)(obj)) {
return obj.document;
}
if (!(0, isDOMNode_1.default)(obj)) {
return null;
}
return obj.ownerDocument;
}
exports.default = getCurrentDocument;