Skip to content

Commit

Permalink
Simplify sandbox fix by reusing the fix for stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Mar 9, 2020
1 parent 39e0939 commit 31a263c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/sinon/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 31a263c

Please sign in to comment.