time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

isElement.js (574B)


      1 var isObjectLike = require('./isObjectLike'),
      2     isPlainObject = require('./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, else `false`.
     13  * @example
     14  *
     15  * _.isElement(document.body);
     16  * // => true
     17  *
     18  * _.isElement('<body>');
     19  * // => false
     20  */
     21 function isElement(value) {
     22   return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
     23 }
     24 
     25 module.exports = isElement;