UNPKG

581 BJavaScriptView Raw
1import isObjectLike from './isObjectLike';
2import isPlainObject from './isPlainObject';
3
4/**
5 * Checks if `value` is likely a DOM element.
6 *
7 * @static
8 * @memberOf _
9 * @since 0.1.0
10 * @category Lang
11 * @param {*} value The value to check.
12 * @returns {boolean} Returns `true` if `value` is a DOM element,
13 * else `false`.
14 * @example
15 *
16 * _.isElement(document.body);
17 * // => true
18 *
19 * _.isElement('<body>');
20 * // => false
21 */
22function isElement(value) {
23 return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
24}
25
26export default isElement;