Skip to content
Myr

Processed review comments

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent 53a6f87 · Browse files · 2 files+10 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−6 removed

  • tests:+1 added−1 removed
  • other:+9 added−5 removed

2 files+10 added−6 removed

modified:__tests__/frozen.js+1 added-1 removed
modified:immer.js+9 added-5 removed
90 unmodified lines
91 if (isPlainObject(base) || Array.isArray(base)) {92 if (isProxy(base)) return base // avoid double wrapping93 if (revocableProxies.has(base))94 return revocableProxies.get(base).proxy95 let proxyTarget = base95 let proxyTarget96 // special case, if the base tree is frozen, we cannot modify it's proxy it in strict mode, clone first.97 if (Object.isFrozen(proxyTarget)) {98 proxyTarget = Array.isArray(proxyTarget)99 ? proxyTarget.slice()100 : {...proxyTarget}97 if (Object.isFrozen(base)) {98 proxyTarget = Array.isArray(base)99 ? base.slice()100 : Object.assign({}, base)101 Object.defineProperty(proxyTarget, CLONE_TARGET, {102 enumerable: false,103 value: base,104 configurable: true,105 })106 } else {107 proxyTarget = base108 }109 // create the proxy110 const revocableProxy = Proxy.revocable(proxyTarget, objectTraps)111 revocableProxies.set(base, revocableProxy)
95 unmodified lines
207 * Automatically freezes any state trees generated by immer.208 * This protects against accidental modifications of the state tree outside of an immer function.209 * This comes with a performance impact, so it is recommended to disable this option in production.210 * It is by default enabled.211 *212 * @returns {void}213 */214function setAutoFreeze(enableAutoFreeze) {215 autoFreeze = enableAutoFreeze216}
6 unmodified lines