-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if the two operands are of the same type before interpreting a missing prop as a remove op #205
Conversation
test/spec/duplexSpec.js
Outdated
]); | ||
|
||
}); | ||
it('Replacing a deep array with an object should be handled well', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's rather an array nested in an object, than deep array, as it's only shallow - one level array of primitives.
test/spec/duplexSpec.js
Outdated
]); | ||
|
||
}); | ||
it('Replacing a two-level deep array with an object should be handled well', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -217,9 +219,12 @@ function _generate(mirror, obj, patches, path) { | |||
} | |||
} | |||
} | |||
else { | |||
else if(Array.isArray(mirror) === Array.isArray(obj)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some code comments about what's happening here? Why for two arrays or two non-arrays it's a delete
, but for array and non-array, it's a replace
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add something of the effect of: Because the replace
is for the whole obj, not for obj[key]
.
When will be this merged? I created a test in mocha and the array replacement is not the only problem.
` And it fails on both getting the diff out of a Date object and also when an object is replace with an array. P.S. get and apply are literally just wrappers around functions. `
` |
Ah... I saw your comments in another issue about Date objects. Fair enough. Is not the focus of this plugin. Apologies. But the array/object replace is a must have though. |
Fixes #31