mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 19:10:11 +00:00
testing and tweaking patch...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
bfdfe5be6d
commit
4f2c027e79
19
diff.js
19
diff.js
@ -1087,12 +1087,13 @@ function(diff, obj, options, types){
|
|||||||
|
|
||||||
// XXX would need to let the type handlers handle themselves a-la .handle(..)
|
// XXX would need to let the type handlers handle themselves a-la .handle(..)
|
||||||
var _patch = function(diff, obj){
|
var _patch = function(diff, obj){
|
||||||
var NONE = diff.options.placeholders.NONE
|
var NONE = diff.placeholders.NONE
|
||||||
var EMPTY = diff.options.placeholders.EMPTY
|
var EMPTY = diff.placeholders.EMPTY
|
||||||
|
var options = diff.options
|
||||||
|
|
||||||
Types.walk(diff, function(change){
|
Types.walk(diff.diff, function(change){
|
||||||
// replace the object itself...
|
// replace the object itself...
|
||||||
if(path.length == 0){
|
if(change.path.length == 0){
|
||||||
return change.B
|
return change.B
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1112,6 +1113,16 @@ var _patch = function(diff, obj){
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// XXX also check what is overwritten...
|
// XXX also check what is overwritten...
|
||||||
|
// XXX need to correctly check EMPTY/NONE...
|
||||||
|
if('A' in change
|
||||||
|
&& !(cmp(change.A, EMPTY) ?
|
||||||
|
!(key in target)
|
||||||
|
: cmp(target[key], change.A))){
|
||||||
|
// XXX
|
||||||
|
console.warn('Patch: Mismatching values at:', change.path,
|
||||||
|
'expected:', change.A,
|
||||||
|
'got:', target[key])
|
||||||
|
}
|
||||||
target[key] = change.B
|
target[key] = change.B
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user