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
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
Craig Martin
1aa7f7685a
add tests solidifying behavior for modelId with polymorphic models
2016-01-20 09:23:50 -05:00
Adam Krebs
82d8ec840c
Merge pull request #3929 from craigmichaelmartin/avoid-redefinitions
...
eliminate shadowed variable declarations
2016-01-19 13:56:36 -05:00
Craig Martin
e0a5cc75ba
eliminate shadowed variable declarations
...
Also, add eslint rule no-shadow to enforce
2016-01-19 12:34:08 -05:00
Craig Martin
75666b08c9
add has method to collection
2016-01-17 12:19:36 -05:00
Jordan Eldredge
be1f2a87c5
Add ESLint rule: eqeqeq
...
Underscore uses this triple-equals syntax for its module loader.
2015-12-28 21:37:17 -08:00
Jordan Eldredge
37465828d6
Add ESLint warning for quoted keys to tests
...
I've opted to leave the quotes and associated warnings in the case where the
keys include protected words or integers.
2015-12-18 13:27:48 -08:00
Jordan Eldredge
9eb9124ec9
Enforce camelCase ESLint rule in tests
2015-12-18 13:27:48 -08:00
Jordan Eldredge
3dbdfab21b
Enable ESLint semicolons for tests
2015-12-18 13:27:48 -08:00
Jordan Eldredge
d91405d54f
Enable ESLint rule: 'quotes' for tests
...
These changes were done automatically by ESLint's `--fix` tag. Thanks ESLint!
2015-12-18 13:27:48 -08:00
Jordan Eldredge
7dbdd0ac6b
Add ESLint rule: no-undef
2015-12-18 13:27:48 -08:00
Jordan Eldredge
2f5cd8bee9
Enable ESLint rule: new-cap
...
Constructor functions must start with a capital letter.
2015-12-18 08:35:28 -08:00
Jordan Eldredge
2ae117a7cb
Add ESLint rule: key-spacing
2015-12-16 10:00:19 -08:00
Jordan Eldredge
b0a6274290
Non-controversial ESLint whitespace rules
...
In an attempt to bring our ESLint rules closer to those in Underscore, I've
started by adding some whitespace rules which don't involve any significantly
opinionated changes.
2015-12-16 07:43:26 -08:00
Ilia Ablamonov
19b88d2c2d
Fixed Collection#set regression when parse returns falsy value
...
Fixes #3871
2015-12-01 10:00:36 +04:00
Justin Ridgewell
569f07e6a6
Merge pull request #3820 from jridgewell/reduce-deopt
...
Deopt Underscore methods that change on arguments
2015-10-28 09:36:49 -05:00
Graeme Yeates
d1880dda6c
Merge pull request #3834 from jridgewell/model-change-id-regression
...
Fix _onModelEvent regression
2015-10-26 15:18:41 -04:00
Justin Ridgewell
67667c5b8f
Fix _onModelEvent regression
...
Fixes #3662 .
2015-10-26 15:13:17 -04:00
Justin Ridgewell
7bbbcc8c51
Always return removed array from #_removeModels
...
Fixes #3835 .
2015-10-26 11:19:26 -04:00
Justin Ridgewell
2e60498b3d
Merge pull request #3821 from captbaritone/indent-fix
...
Fix indention in tests
2015-10-07 11:04:18 -05:00
Jordan Eldredge
2984d95a85
Fix indention in tests
2015-10-07 08:57:41 -07:00
Jordan Eldredge
4b6ad311bd
Document using [] for empty Collections with options
...
The documented example shows passing `[]` to instantiate an empty collection
while still supplying an options object. This change makes the preceding
documentation consistent with that example.
I also noticed that we don't have any tests covering the previously recommended
approach of passing `null` (or any falsey value) for models. I've added a test
to ensure we continue to support that usage.
2015-10-07 08:49:52 -07:00
just-boris
345dd7b128
Allow to make reduce without initial value
2015-10-07 10:59:00 -04:00
Kevin Partington
9c681906a4
Tests: Migrated unit tests to QUnit 2.0 syntax. ( fixes #3813 )
2015-10-06 23:35:30 -05:00
Jacob Buck
6cff9419fb
Add findIndex and findLastIndex underscore methods to Collection.
2015-09-30 10:20:33 +13:00
Jeremy Ashkenas
979adf5200
Merge pull request #3803 from jridgewell/removeModels-regression
...
Fix _removeModels regression
2015-09-25 10:48:48 -04:00
Justin Ridgewell
4b64eebcba
Fix _removeModels regression
...
Fixes #3693 .
This leaves open the question of whether events triggered on the model
during a ‘remove’ listener should also trigger on the model. Just
something to revisit for V2.
```js
col.on('other', (model) => {
// Should this be triggered?
});
col.on('remove', (model) => {
// If the model is really "removed" (we can't `#get` it anymore)
// by the time this listener is called, then I'd argue that this
// shouldn't trigger the 'other' event on the collection...
model.trigger('other');
});
```
2015-09-23 11:24:16 -04:00
Andrew Humphreys
91d0824190
fix error when adding model to collection at an out of bounds index
2015-08-21 17:15:07 +01:00
Jeremy Ashkenas
09fca1dc7e
Merge pull request #3663 from jridgewell/collection-set-style-compat
...
Collection#set style (Backwards Compatible)
2015-08-18 17:35:20 -04:00
Justin Ridgewell
a6e2f0fb54
Test null set doesn't clear model.
...
https://github.com/jashkenas/backbone/pull/3663#discussion_r36124174
2015-08-07 13:20:41 -04:00
John-David Dalton
0bc02af704
Use some, includes, map in tests instead of any, include, pluck.
2015-08-07 01:58:09 -07:00
Linus-A. M. Gubenis
d6dd17c1ee
typos
2015-07-13 09:50:11 -05:00
Linus-A. M. Gubenis
a37d30a3e1
Update collection.js
2015-07-13 09:43:55 -05:00
sophietk
0d43789682
Fix test for IE7/IE8 build
2015-06-24 10:25:45 +02:00
sophietk
007a1b85f4
Collection methods from underscore (reject, filter, some, every, ...) take function, set of model attributes, or attribute name as argument
...
- Expand the use of inherited underscore methods, to iteratee as function, object or string
- Apply iteratee transformation to groupBy, countBy, sortBy, indexBy
2015-06-11 18:04:30 +02:00
Justin Ridgewell
c40396228b
Fix incorrect test
2015-06-10 14:26:37 -04:00
Justin Ridgewell
0052c2fc5c
Keep backwards compatibility with v1
2015-06-03 20:59:59 -04:00
Justin Ridgewell
a082d2fdf9
Return only added or merged models
...
Mirrors the change in #3512 .
2015-06-03 02:53:40 -04:00
Justin Ridgewell
e81474880b
Don't bother with Collection#set unless models
2015-06-03 02:52:57 -04:00
Justin Ridgewell
fdea29dfc8
Collection#add shouldn't parse a model instance
...
Fixes #3636 , but in a backwards compatible way.
2015-06-02 14:06:50 -04:00
Andrey Kuzmin
ffa4fa597d
Added failing test case
2015-06-02 13:58:13 -04:00
Justin Ridgewell
c95d9775e7
Revert "Merge pull request #3644 from jridgewell/collection-parse"
...
This reverts commit ff57b54cbb , reversing
changes made to 5ea158506f .
2015-06-02 13:55:21 -04:00
Justin Ridgewell
13de636df1
Ensure fetch'd data is only parsed once
2015-05-30 02:27:51 -04:00
Justin Ridgewell
415c3a7a13
Collection#set shouldn't parse
...
Fixes #3636 , #2824 .
Reverts #1407 .
2015-05-30 02:27:51 -04:00