From 31a263ca9146867f9769b909f0d803e414aaf400 Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Mon, 9 Mar 2020 14:24:12 +0100 Subject: [PATCH] Simplify sandbox fix by reusing the fix for stubs --- lib/sinon/sandbox.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sinon/sandbox.js b/lib/sinon/sandbox.js index aa5a32fe3..dd66f346e 100644 --- a/lib/sinon/sandbox.js +++ b/lib/sinon/sandbox.js @@ -189,10 +189,9 @@ function Sandbox() { function getFakeRestorer(object, property) { var descriptor = getPropertyDescriptor(object, property); - var shadowsPrototypeProp = typeof Object.getOwnPropertyDescriptor(object, property) === "undefined"; function restorer() { - if (!shadowsPrototypeProp) { + if (descriptor.isOwn) { Object.defineProperty(object, property, descriptor); } else { delete object[property];