Add check against a plain object
This commit is contained in:
parent
6a787261fe
commit
2e58d40c7d
2 changed files with 3 additions and 2 deletions
2
index.js
2
index.js
|
|
@ -161,6 +161,6 @@ is.inRange = (x, range) => {
|
|||
throw new TypeError(`Invalid range: ${util.inspect(range)}`);
|
||||
};
|
||||
|
||||
is.domElement = x => is.object(x) && x.nodeType === 1;
|
||||
is.domElement = x => is.object(x) && x.nodeType === 1 && is.string(x.nodeName) && !is.plainObject(x);
|
||||
|
||||
module.exports = is;
|
||||
|
|
|
|||
3
test.js
3
test.js
|
|
@ -362,6 +362,7 @@ test('is.inRange', t => {
|
|||
|
||||
test('is.domElement', t => {
|
||||
const document = jsdom();
|
||||
|
||||
t.true(m.domElement(document.createElement('div')));
|
||||
t.false(m.domElement('hello world'));
|
||||
t.false(m.domElement([]));
|
||||
|
|
@ -371,5 +372,5 @@ test('is.domElement', t => {
|
|||
t.false(m.domElement(0));
|
||||
t.false(m.domElement(NaN));
|
||||
t.false(m.domElement(Infinity));
|
||||
t.false(m.domElement({}));
|
||||
t.false(m.domElement({nodeType: 1, nodeName: 'div'}));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue