Skip to content

Commit

Permalink
perf(proxy): deletion of an undeclared property
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Dec 15, 2018
1 parent 90f75e2 commit c0ce252
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/proxy.js
Expand Up @@ -107,18 +107,21 @@ function set(state, prop, value) {
}

function deleteProperty(state, prop) {
state.assigned[prop] = false
markChanged(state)
delete state.copy[prop]
// The `undefined` check is a fast path for pre-existing keys.
if (state.base[prop] !== undefined || prop in state.base) {
state.assigned[prop] = false
markChanged(state)
}
if (state.copy) delete state.copy[prop]
return true
}

function getOwnPropertyDescriptor(state, prop) {
const owner = state.modified
? state.copy
: has(state.proxies, prop)
? state.proxies
: state.base
? state.proxies
: state.base
const descriptor = Reflect.getOwnPropertyDescriptor(owner, prop)
if (descriptor && !(Array.isArray(owner) && prop === "length"))
descriptor.configurable = true
Expand Down

0 comments on commit c0ce252

Please sign in to comment.