Skip to content

Conversation

benweet
Copy link

@benweet benweet commented Mar 30, 2014

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)

@benjamine
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants