1015 Commits

Author SHA1 Message Date
Julian Gonggrijp
801db14766 Merge pull request #4278 from jgonggrijp/issue-templates 2024-01-23 22:13:59 +01:00
Julian Gonggrijp
d981caa7bc Add regression test for #4284 2024-01-23 22:05:27 +01:00
Julian Gonggrijp
5ae5639de8 Move debugInfo to a separate module 2024-01-23 19:48:43 +01:00
Julian Gonggrijp
a2bcf1989e Add debugInfo method 2024-01-23 19:48:41 +01:00
Julian Gonggrijp
f65a59c0c0 Add tests for the notfound event 2023-08-09 00:16:14 +02:00
Julian Gonggrijp
9ef1cba06b Merge pull request #4265 from jgonggrijp/wait-error-fix
Trigger error from failing Collection.create with wait:true
2023-07-23 12:55:46 +02:00
Kyle Dickerson
425b931c36 #3391 - Add History trailingSlash option always use trailing slash on root. 2023-07-21 13:28:52 -07:00
Julian Gonggrijp
f30f974198 Add sanity checks against double forward and error listener erasion (#4262) 2023-07-20 22:37:26 +02:00
Julian Gonggrijp
b22474b517 Wait, how about success? (#4262)
Amazingly, this test passes.
2023-07-19 00:53:02 +02:00
Julian Gonggrijp
2104aa771f But does the created model trigger 'error'? (#4262)
Yes, it does.
2023-07-19 00:49:28 +02:00
Julian Gonggrijp
0b831f19af Also add a test to verify that the problem is not in Model.save (#4262) 2023-07-19 00:26:38 +02:00
Julian Gonggrijp
0a18362b70 Add a test that reproduces #4262 literally 2023-07-19 00:18:27 +02:00
Julian Gonggrijp
ffdaa7142a Adress linter warnings (#3964) 2023-07-18 14:44:56 +02:00
Julian Gonggrijp
5e8d8e60b3 Merge remote-tracking branch 'jrdb/master' into tryout-patch-3964 2023-07-18 14:20:39 +02:00
Geoffrey Booth
21742f3633 Update CoffeeScript dependency to version 2; update test per https://coffeescript.org/#breaking-changes-super-extends 2022-04-25 21:31:05 -07:00
Julian Gonggrijp
19ce298f78 Address linter errors and warnings (#4251 #4246) 2022-02-18 17:15:59 +01:00
Paul Falgout
7712b8ec6c Add model changeId event
Fixes #3882
Fixes #4159

Backbone does a bit of extra work to determine when to update `_byId` on every model change event because `change:id` will not work if `idAttribute` has changed.  This causes issues as the `change` event happens after every `change:` event which means during a change the `_byId` hasn't updated.  Rather than adding complexity to collection the solution is to have the model notify with the id changes.

If adding a public event isn't desired, for an internal solution the model is aware of it's collection and could modify model.collection._byId directly within the set.

Either of these solutions seem preferrable to handling `change:[idAttribute]`

Replaces the need for:
https://github.com/jashkenas/backbone/pull/4227/files#diff-c773bb9be277f0f3f2baa308b6e0f3a486790fe99fea81ddd0ba409846250571R1205
2022-01-12 23:26:10 +09:00
Alexey
2ea3a221ad Remove try..catch 2022-01-09 20:17:55 +03:00
Alexey
e54031f227 Return function 2022-01-09 20:14:20 +03:00
Alexey
4515b8c20a Fix synatx error 2022-01-09 20:13:45 +03:00
Alexey
f6f5deeae9 Add test 2022-01-08 12:42:00 +03:00
jashkenas
0b1c2e3fce Resolve merge conflicts 2019-12-13 11:41:21 -08:00
Graeme Yeates
e524804592 Implement Model.mixin and Collection.mixin (#4024)
Combine implementation of collection and model underscore methods
2017-04-18 15:29:55 -07:00
John Boehr
e4939e4b5d Merge branch 'master' into private-listening-public-on 2017-04-04 14:28:17 -07:00
ksladkov
7da4ed73e7 #4103 check if obj is Model in Collection.get (#4104) 2016-12-01 16:01:59 -05:00
Lee Byron
a2fc65b979 Implements the JavaScript Iterable protocol.
This introduces new methods related to Iterators on Backbone.Collection to mirror those found on Array: `values`, `keys`, `entries`, and `@@iterator`. Each of these methods will return a JavaScript Iterator, which has a `next` method, yielding the models or ids of models contained in the Collection.

The CollectionIterator is careful to use the `at()` and `modelId()` methods on the host collection rather than direct access to the `models` property, which should ensure it is resilient to creative subclassing of Backbone.Collection and future feature addition.

The [`@@iterator`](http://www.ecma-international.org/ecma-262/6.0/#sec-well-known-symbols) method is defined using `Symbol.iterator` if it exists in the JavaScript runtime (modern browsers/node.js) and falls back to the string `"@@iterator"` which was popularized by older versions of Firefox and has become the standard fallback behavior for other third-party libraries. This ensures that Backbone can still be used across all browsers, even with use of these new methods.

Supporting Iterable allows better integration between Backbone and the most recent additions to the JavaScript language, including `for of` loops and data-collection constructor functions, as well as better integration with other third-party libraries that accept Iterables instead of only Arrays.

Fixes #3954
2016-07-21 13:33:30 -07:00
Adam Krebs
02891a2924 cleanup some automatic test failures, fix lint issues 2016-06-20 16:17:15 -04:00
Adam Krebs
55bab76349 Upgrade Qunit to 2.0, auto-convert tests using apsdehal/qunit-migrate 2016-06-20 16:04:30 -04:00
Graeme Yeates
e4c85afa6b Merge pull request #3827 from benmccormick/master
Add a preinitialize method to allow for true instance properties and ES6 classes
2016-05-06 13:10:30 -04:00
Ilia Ablamonov
57e89d86fa Fixed updating URL with uri-decoded value
Fixes #4025
2016-04-30 21:57:39 +04:00
Ben McCormick
f6d8c3e51d Add a preinitialize function to allow modifying Backbone objects before
instantiation logic is run.

This allows greater flexibility for several use cases including
- #3620
- #3685
- Easing use of ES6 classes with Backbone
2016-04-24 22:26:51 -04:00
Adam Krebs
788dc91070 Remove test elements after insterting to fix failing global tests 2016-03-29 14:55:41 -04:00
Adam Krebs
a640b3bdd4 use _.indexOf instead of Array.prototype.indexOf in test. Fixes failing IE8 case 2016-03-29 14:50:06 -04:00
Graeme Yeates
1db79ddd33 Fix 1.3.1 regression with once and no context 2016-03-08 11:23:00 -05:00
Adam Miller
b3a2813290 Only pass idAttribute to collection.modelId() 2016-02-24 17:36:51 -08:00
Adam Miller
c71336641e Update to modelId()
- modelId now takes the model in question as the second argument
 - modelId will look at the model in question's idAttribute before falling back to Collection.prototype.model.modelId and then 'id'
 - Makes basic polymorphic collection work out of the box while retaining backwards compatability
2016-02-09 13:02:06 -08:00
Jeff deBeer
e81b4ad2ea #3961 - add events sends options.index that correspond to wrong index
fix and test for #3961 - add events sends options.index that correspond
to wrong index
2016-02-08 18:14:59 -05:00
Jeff deBeer
4cd41161ca #3961 Collection#set - add events sends options.index that
Fix and test for issue #3961 - Collection#set - add events sends
options.index that correspond to wrong index
2016-02-08 18:05:56 -05:00
Jeff deBeer
9f6dc4d575 #3961
Fix and test for issue #3961 - Collection#set - add events sends
options.index that correspond to wrong index
2016-02-08 17:53:27 -05:00
Ash Lux
32d89dc47e When listening to numerous events and stopListening is called, then _.isEmpty is painfully slowly and assigning _listenTo to undefined isn't necessary. 2016-02-08 15:16:10 -05:00
Adam Krebs
8d8b854abf rename at => val in test to be clearer 2016-02-04 17:16:06 -05:00
Craig Martin
8932ae4bc3 optimize collection get and account for edge case 2016-02-04 15:30:26 -05:00
Craig Martin
47fb04a373 fix failing linting tests 2016-02-04 15:16:41 -05:00
Adam Krebs
b0161947eb Fix #3951: options.index should never exceed collection.length 2016-02-04 15:01:59 -05:00
Justin Ridgewell
92fb299c2a Use _.extend to avoid Object.prototype collisions 2016-02-03 12:56:45 -05:00
Justin Ridgewell
67790b27de Merge pull request #3945 from jridgewell/collection-has-test-fix
Use strictEqual in Collection#has Tests
2016-02-02 11:27:19 -05:00
Justin Ridgewell
2f85060e59 Upgrade vendor QUnit 2016-02-02 11:21:37 -05:00
Graeme Yeates
c380607704 Merge pull request #3940 from roycetucker/patch-2
Fixing object notation for Events.once
2016-02-01 13:52:57 -05:00
Graeme Yeates
670ff30aa4 Improve collection 'update' event consistency 2016-02-01 11:33:39 -05:00
Linus-A. M. Gubenis
90cb566250 Pass added and removed models to collection update events 2016-02-01 11:18:09 -05:00