jashkenas / backbone

Give your JS App some Backbone with Models, Views, Collections, and Events
http://backbonejs.org
MIT License
28.1k stars 5.39k forks source link

Fix wrong context passed in collection.create #4284

Closed olhapi closed 7 months ago

olhapi commented 7 months ago

Here https://github.com/jashkenas/backbone/blob/master/backbone.js#L1088 this has the wrong context, it refers to a window object in the browser because we didn't pass a previously saved collection context to it.

olhapi commented 7 months ago

@jgonggrijp can you check this and confirm that it's indeed a bug?

olhapi commented 7 months ago

I've tried that, but I don't know how to test that case properly. My test succeeded when it should have failed. :)

jgonggrijp commented 7 months ago

Alright, in that case I will do it myself some time in the near future.

olhapi commented 7 months ago

Thanks a lot

jgonggrijp commented 7 months ago

@olhapi Please remove the changes to backbone-min* and then force-push the branch. We update the minified code when we cut a new release.

(I'm working on the regression test in the meanwhile.)

olhapi commented 7 months ago

@jgonggrijp done, just pushed.

jgonggrijp commented 7 months ago

@olhapi The commit referenced above (https://github.com/jashkenas/backbone/commit/0f9956b565ca7d08421bdb3f9b2e583b38abc659) adds a test that fails without your fix and succeeds with it. Again thanks for contributing!