mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Ensure _.isPlainObject returns false for objects with a custom [[Prototype]]. [closes #2085]
This commit is contained in:
@@ -10607,7 +10607,7 @@
|
|||||||
if (proto === null) {
|
if (proto === null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var Ctor = proto.constructor;
|
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
||||||
return (typeof Ctor == 'function' &&
|
return (typeof Ctor == 'function' &&
|
||||||
Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
|
Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
|
||||||
}
|
}
|
||||||
|
|||||||
12
test/test.js
12
test/test.js
@@ -10856,6 +10856,18 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should return `false` for objects with a custom `[[Prototype]]`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
if (create) {
|
||||||
|
var object = create({ 'a': 1 });
|
||||||
|
assert.strictEqual(_.isPlainObject(object), false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipAssert(assert);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should return `false` for DOM elements', function(assert) {
|
QUnit.test('should return `false` for DOM elements', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user