UNPKG

vanilla-type-check

Version:
22 lines (21 loc) 566 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Check if something is an DOM element * * @param value value to check * @returns `true` if `obj` is a DOM element */ function isDom(value) { try { return value instanceof HTMLElement; } catch (e) { return value != null && typeof value === 'object' && value.nodeType === 1 && typeof value.style === 'object' && typeof value.ownerDocument === 'object'; } } exports.isDom = isDom;