4a1e312250fb5aad610d730b9117edc5812c2530
[platform/framework/web/crosswalk-tizen.git] /
1 var isObjectLike = require('../internal/isObjectLike'),
2     isPlainObject = require('./isPlainObject'),
3     support = require('../support');
4
5 /** Used for native method references. */
6 var objectProto = Object.prototype;
7
8 /**
9  * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
10  * of values.
11  */
12 var objToString = objectProto.toString;
13
14 /**
15  * Checks if `value` is a DOM element.
16  *
17  * @static
18  * @memberOf _
19  * @category Lang
20  * @param {*} value The value to check.
21  * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
22  * @example
23  *
24  * _.isElement(document.body);
25  * // => true
26  *
27  * _.isElement('<body>');
28  * // => false
29  */
30 function isElement(value) {
31   return !!value && value.nodeType === 1 && isObjectLike(value) &&
32     (objToString.call(value).indexOf('Element') > -1);
33 }
34 // Fallback for environments without DOM support.
35 if (!support.dom) {
36   isElement = function(value) {
37     return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
38   };
39 }
40
41 module.exports = isElement;