Refactor is.domElement to declare constants outside the function
This commit is contained in:
parent
b22d9e88db
commit
718a216797
2 changed files with 10 additions and 6 deletions
9
index.js
9
index.js
|
|
@ -161,11 +161,12 @@ is.inRange = (x, range) => {
|
|||
throw new TypeError(`Invalid range: ${util.inspect(range)}`);
|
||||
};
|
||||
|
||||
const NODE_TYPE_ELEMENT_NODE = 1;
|
||||
const DOM_PROPERTIES_TO_CHECK = ['innerHTML', 'ownerDocument', 'style', 'attributes', 'nodeValue'];
|
||||
|
||||
is.domElement = x => {
|
||||
const ELEMENT_NODE = 1;
|
||||
const propsToCheck = ['innerHTML', 'ownerDocument', 'style', 'attributes', 'nodeValue'];
|
||||
return is.object(x) && x.nodeType === ELEMENT_NODE && is.string(x.nodeName) &&
|
||||
!is.plainObject(x) && propsToCheck.every(prop => prop in x);
|
||||
return is.object(x) && x.nodeType === NODE_TYPE_ELEMENT_NODE && is.string(x.nodeName) &&
|
||||
!is.plainObject(x) && DOM_PROPERTIES_TO_CHECK.every(property => property in x);
|
||||
};
|
||||
|
||||
is.infinite = x => x === Infinity || x === -Infinity;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue