jsondiffpatch icon indicating copy to clipboard operation
jsondiffpatch copied to clipboard

Fixed patch crash on removed objects

Open benweet opened this issue 11 years ago • 1 comments

The patch method crashes when trying to patch nested object that has been removed from the target.

> var diff = jsondiffpatch.diff({abc:{value:1}},{abc:{value:2}})
undefined
> jsondiffpatch.patch({}, diff)
TypeError: Cannot read property 'value' of undefined
    at nestedPatchFilter (jsondiffpatch/build/bundle.js:793:46)
    at Pipe.process (jsondiffpatch/build/bundle.js:1080:9)
    at Processor.process (jsondiffpatch/build/bundle.js:1219:12)
    at DiffPatcher.patch (jsondiffpatch/build/bundle.js:208:27)
    at repl:1:16
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)

benweet avatar Mar 30 '14 14:03 benweet

Thanks, I understand this request, but I don't want last-wins to be the default, I want any conflict to raise an error (although I'm aware implementation for this might be incomplete in some cases), Later I plan to add support for conflict resolution strategies to be plugged in, where last-wins would ideally be a builtin example, but it's a strategy that's not suitable for all scenarios.

benjamine avatar Mar 31 '14 21:03 benjamine