Skip to content

Commit

Permalink
Code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
gukoff committed Sep 1, 2023
1 parent eecb5a7 commit eab4560
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/sinon/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ function Sandbox() {
const descriptor = getPropertyDescriptor(object, property);

function restorer() {
if (typeof descriptor === 'undefined') {
delete object[property];
}
else if (descriptor.isOwn) {
if (descriptor?.isOwn) {
Object.defineProperty(object, property, descriptor);
} else {
delete object[property];
Expand Down Expand Up @@ -288,7 +285,7 @@ function Sandbox() {
sandbox.define = function define(object, property, value) {
const descriptor = getPropertyDescriptor(object, property);

if (typeof descriptor !== "undefined") {
if (descriptor) {
throw new TypeError(
`Cannot define the already existing property ${valueToString(
property
Expand All @@ -300,8 +297,6 @@ function Sandbox() {
throw new TypeError("Expected value argument to be defined");
}

// Check just in case we allow to replace properties by undefined in the future.
// In the implementation at the moment of writing, this check always succeeds.
verifyNotReplaced(object, property);

// store a function for restoring the defined property
Expand Down

0 comments on commit eab4560

Please sign in to comment.