Add additional checks for dom Element check
This commit is contained in:
parent
2e58d40c7d
commit
d32db3c312
2 changed files with 10 additions and 13 deletions
6
index.js
6
index.js
|
|
@ -161,6 +161,10 @@ is.inRange = (x, range) => {
|
|||
throw new TypeError(`Invalid range: ${util.inspect(range)}`);
|
||||
};
|
||||
|
||||
is.domElement = x => is.object(x) && x.nodeType === 1 && is.string(x.nodeName) && !is.plainObject(x);
|
||||
is.domElement = x => {
|
||||
const propsToCheck = ['innerHTML', 'ownerDocument', 'style', 'attributes', 'nodeValue'];
|
||||
return is.object(x) && x.nodeType === 1 && is.string(x.nodeName) &&
|
||||
!is.plainObject(x) && propsToCheck.every(prop => prop in x);
|
||||
};
|
||||
|
||||
module.exports = is;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue