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

Collection#set treats Object.prototypes as existing Models #2719

Closed
metafeather opened this issue Aug 12, 2013 · 0 comments
Closed

Collection#set treats Object.prototypes as existing Models #2719

metafeather opened this issue Aug 12, 2013 · 0 comments

Comments

@metafeather
Copy link

Ran into this as a bug in Firefox only due to my data which errors as:

TypeError: existing.set is not a function

this is because one of my model.id is 'watch' (for a wrist watch) however Backbone is checking this id in the Collections._byId cache and matching theObject.watch() method.

A reduced example is here: http://jsbin.com/akaluh/1/edit

The console output for Firefox is [native code] whereas Chrome and Safari it is undefined.

This is similar to other bugs/issues such as: #964, #1495, #2296.

I've introduced a check that the return from Collection.get is actually an Object - I can't think why it would ever need to be something else? Pull request coming shortly.

I also investigated using this._byId.hasOwnProperty() however it broke my app. I think that because Collections can be extended the _byId object may not be on 'this' collection.

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

No branches or pull requests

2 participants