Skip to content

Commit

Permalink
[fix] sandbox.restore handles protype props
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Mar 9, 2020
1 parent aac0bc3 commit 4b55c62
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/sinon/sandbox.js
Expand Up @@ -189,9 +189,14 @@ function Sandbox() {

function getFakeRestorer(object, property) {
var descriptor = getPropertyDescriptor(object, property);
var shadowsPrototypeProp = typeof Object.getOwnPropertyDescriptor(object, property) === "undefined";

function restorer() {
Object.defineProperty(object, property, descriptor);
if (!shadowsPrototypeProp) {
Object.defineProperty(object, property, descriptor);
} else {
delete object[property];
}
}
restorer.object = object;
restorer.property = property;
Expand Down

0 comments on commit 4b55c62

Please sign in to comment.