From 309e6df8fd61b17d8672ab0d37668754d68dd214 Mon Sep 17 00:00:00 2001 From: Gregg Van Hove Date: Fri, 17 May 2019 16:31:15 -0700 Subject: [PATCH] Use `Object.create` to make an object with `null` prototype --- spec/core/matchers/toBeInstanceOfSpec.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/spec/core/matchers/toBeInstanceOfSpec.js b/spec/core/matchers/toBeInstanceOfSpec.js index 61cb5374..d31845e9 100644 --- a/spec/core/matchers/toBeInstanceOfSpec.js +++ b/spec/core/matchers/toBeInstanceOfSpec.js @@ -1,9 +1,4 @@ describe('toBeInstanceOf', function() { - function setPrototypeOf(object, proto) { - // Support older environments - Object.setPrototypeOf ? Object.setPrototypeOf(object, proto) : object.__proto__ = proto; - } - describe('when expecting Number', function() { it('passes for literal number', function() { var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); @@ -159,8 +154,7 @@ describe('toBeInstanceOf', function() { }); it('passes for objects with no constructor', function() { - var object = {}; - setPrototypeOf(object, null); + var object = Object.create(null); var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); var result = matcher.compare(object, Object);