Permalink
Cannot retrieve contributors at this time
29 lines (26 sloc)
769 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@sinonjs/samsam/lib/is-element.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var div = typeof document !== "undefined" && document.createElement("div"); | |
/** | |
* Returns `true` when `object` is a DOM element node. | |
* | |
* Unlike Underscore.js/lodash, this function will return `false` if `object` | |
* is an *element-like* object, i.e. a regular object with a `nodeType` | |
* property that holds the value `1`. | |
* | |
* @alias module:samsam.isElement | |
* @param {object} object The object to examine | |
* @returns {boolean} Returns `true` for DOM element nodes | |
*/ | |
function isElement(object) { | |
if (!object || object.nodeType !== 1 || !div) { | |
return false; | |
} | |
try { | |
object.appendChild(div); | |
object.removeChild(div); | |
} catch (e) { | |
return false; | |
} | |
return true; | |
} | |
module.exports = isElement; |