-
Notifications
You must be signed in to change notification settings - Fork 83
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
test case for issue #60 #117
base: master
Are you sure you want to change the base?
test case for issue #60 #117
Conversation
demonstrates issue where setting a value inside a nested array erroneously triggers and add event, when no item has been added
So, this PR should create a failing testcase? |
Yep. I'm having a look at the fix now. I'm not suggesting this should be merged yet, |
Yeah, totally, just wanted to make sure I'm understanding it correctly. 😸 |
#60 was raised 2 years ago, yet this is a very popular Backbone extension - what happened?! (Maybe I'll find out it's really hard to fix and that's the reason!) |
Checks whether or not the set method call will add a new item to a nested array. If not, the ‘add’ event is not triggered where previously it would.
I'm not convinced that this is either the most efficient, or the most robust way of tackling this. Seems to do the job though. I reckon this is ready to merge if no-one reckons we need more tests around this. |
Any news on this one? |
@@ -314,7 +321,7 @@ | |||
model._delayedChange(attrStr, val[attr], opts); | |||
} | |||
|
|||
if (_.isArray(val[attr])){ | |||
if (_.isArray(val[attr]) && shouldTriggerAdd){ |
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.
what about checking isNewValue
here instead? Is that sufficient?
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.
Nah that doesn't work. That variable seems to be for checking if the value has changed, whereas what I'm doing here is checking if the parent is an array, and this array element does not exist yet.
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.
Alright, cool. I'll get this checkout out properly and merged in soon.
demonstrates issue where setting a value inside a nested array
erroneously triggers an add event, when no item has been added