diff --git a/lib/sinon/sandbox.js b/lib/sinon/sandbox.js index 47b75eb06..385fa431d 100644 --- a/lib/sinon/sandbox.js +++ b/lib/sinon/sandbox.js @@ -197,18 +197,15 @@ function Sandbox() { }; sandbox.restoreContext = function restoreContext() { - let injectedKeys = sandbox.injectedKeys; - const injectInto = sandbox.injectInto; - - if (!injectedKeys) { + if (!sandbox.injectedKeys) { return; } - forEach(injectedKeys, function (injectedKey) { - delete injectInto[injectedKey]; + forEach(sandbox.injectedKeys, function (injectedKey) { + delete sandbox.injectInto[injectedKey]; }); - injectedKeys = []; + sandbox.injectedKeys.length = 0; }; function getFakeRestorer(object, property) {