Add additional checks for dom Element check

This commit is contained in:
Melvin Philips 2017-10-05 02:43:46 -07:00
parent 2e58d40c7d
commit d32db3c312
2 changed files with 10 additions and 13 deletions

View file

@ -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;