Ensure _.isPlainObject returns false for objects with a custom [[Prototype]]. [closes #2085]

This commit is contained in:
John-David Dalton
2016-03-03 22:46:23 -08:00
parent 16ed42b188
commit 9e11ebb62a
2 changed files with 13 additions and 1 deletions

View File

@@ -10607,7 +10607,7 @@
if (proto === null) {
return true;
}
var Ctor = proto.constructor;
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
return (typeof Ctor == 'function' &&
Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
}

View File

@@ -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) {
assert.expect(1);