diff --git a/src/utils/isPlainObject.js b/src/utils/isPlainObject.js index 3560c2ca0..9732cb0a8 100644 --- a/src/utils/isPlainObject.js +++ b/src/utils/isPlainObject.js @@ -8,7 +8,11 @@ export default function isPlainObject(obj) { let proto = obj while (Object.getPrototypeOf(proto) !== null) { proto = Object.getPrototypeOf(proto) + + if (proto.constructor && !(proto.constructor.create && Object.getPrototypeOf(proto.constructor.create(proto)) === proto)) { + return false + } } - return Object.getPrototypeOf(obj) === proto -} + return true +} \ No newline at end of file diff --git a/test/utils/isPlainObject.spec.js b/test/utils/isPlainObject.spec.js index f8addd779..a29b899ab 100644 --- a/test/utils/isPlainObject.spec.js +++ b/test/utils/isPlainObject.spec.js @@ -16,6 +16,10 @@ describe('isPlainObject', () => { expect(isPlainObject([1, 2, 3])).toBe(false) expect(isPlainObject(null)).toBe(false) expect(isPlainObject()).toBe(false) + expect(isPlainObject(Object.create(null))).toBe(true) + expect(isPlainObject(Object.create(Object.create(null)))).toBe(true) + expect(isPlainObject(Object.create({}))).toBe(true) + expect(isPlainObject(Object.create(Object.create({})))).toBe(true) expect(isPlainObject({ x: 1, y: 2 })).toBe(true) }) })