Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tomhicks
Copy link

demonstrates issue where setting a value inside a nested array
erroneously triggers an add event, when no item has been added

demonstrates issue where setting a value inside a nested array
erroneously triggers and add event, when no item has been added
@tomhicks
Copy link
Author

I meant "issue #60" not "PR #60" in the title but I can't edit it - 422 (Unprocessable Entity)

@gkatsev
Copy link
Collaborator

gkatsev commented May 11, 2014

So, this PR should create a failing testcase?

@tomhicks
Copy link
Author

Yep. I'm having a look at the fix now.

I'm not suggesting this should be merged yet,

@gkatsev
Copy link
Collaborator

gkatsev commented May 11, 2014

Yeah, totally, just wanted to make sure I'm understanding it correctly. 😸

@tomhicks
Copy link
Author

#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.
@tomhicks
Copy link
Author

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.

@tomhicks
Copy link
Author

Any news on this one?

@gkatsev gkatsev changed the title test case for PR #60 test case for issue #60 May 14, 2014
@@ -314,7 +321,7 @@
model._delayedChange(attrStr, val[attr], opts);
}

if (_.isArray(val[attr])){
if (_.isArray(val[attr]) && shouldTriggerAdd){
Copy link
Collaborator

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?

Copy link
Author

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.

Copy link
Collaborator

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.

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.

2 participants