File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import {generatePatches} from "./patches"
44import {
55 assign ,
66 each ,
7+ has ,
78 is ,
89 isDraft ,
910 isDraftable ,
@@ -135,9 +136,18 @@ export class Immer {
135136 state . finalized = true
136137 this . finalizeTree ( state . draft , path , patches , inversePatches )
137138 if ( this . onDelete ) {
138- const { assigned} = state
139- for ( const prop in assigned )
140- assigned [ prop ] || this . onDelete ( state , prop )
139+ // The `assigned` object is unreliable with ES5 drafts.
140+ if ( this . useProxies ) {
141+ const { assigned} = state
142+ for ( const prop in assigned ) {
143+ if ( ! assigned [ prop ] ) this . onDelete ( state , prop )
144+ }
145+ } else {
146+ const { base, copy} = state
147+ eachOwn ( base , prop => {
148+ if ( ! has ( copy , prop ) ) this . onDelete ( state , prop )
149+ } )
150+ }
141151 }
142152 if ( this . onCopy ) this . onCopy ( state )
143153
You can’t perform that action at this time.
0 commit comments