1490 Commits

Author SHA1 Message Date
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
Jeff Shen
28588e1b96 Line 1920 - Fix Spacing After Return
Fixed spacing after return to match the rest of the code
2016-02-05 11:11:57 -08:00
Craig Martin
8932ae4bc3 optimize collection get and account for edge case 2016-02-04 15:30:26 -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
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
Royce Tucker
00f5c39e27 Fixing object notation for Events.once 2016-01-28 13:05:35 -06: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
Adam Krebs
6d37e06003 Merge pull request #3928 from captbaritone/year
Update copyright year
2016-01-19 09:49:50 -05:00
Craig Martin
75666b08c9 add has method to collection 2016-01-17 12:19:36 -05:00
Jordan Eldredge
dfe0e17d09 Update copyright year 2016-01-16 20:32:52 -08:00
Justin Ridgewell
2a78313c63 Merge pull request #3886 from ClimbsRocks/patch-1
Update wording to "space-separated" to be consistent
2016-01-15 22:00:21 -05:00
Jordan Eldredge
ff555e7664 Avoid nested ternary
While looking into adding the "no-nested-ternary" ESLint rule, I realized that
this logic could be refactored a bit.

This nested ternary was introduced in pull request #3875 in order to handle
falsy returns from `parse()`.

This refactor avoids the nested ternary and also makes the intent clearer by
associating the empty array directly with `parse()`'s return.

It also more narrowly handles the falsy case (we never intended to allow you
call `set(0)` for example.)

The only down side I can see is that if `parse()` returns falsy, we will
unnecessarily slice/clone the empty array we just created.
2015-12-29 09:15:07 -08: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
cc3419e271 Add ESLint rule: block-scoped-var
We're already pretty good about this rule, except there were two places where
we defined an `i` counter, and then reused it in a different loop.
2015-12-28 20:55:20 -08:00
Jordan Eldredge
1c66a6e127 Add ESLint warning: no-extra-parens
This is only enabled as a warning, since in some cases I think it adds clarity.
I left the "gratuitous parentheses" when they were clarifying nested ternary
operators or clarifying the evaluation order of `&&`s and `||`s.
2015-12-20 11:34:49 -08:00
Justin Ridgewell
109d1f0208 Merge pull request #3894 from captbaritone/eslint-all
Large batch of ESLint cleanups
2015-12-18 17:21:04 -05:00
Jordan Eldredge
04fe60fad5 Add ESLint rule: no-lonely-if 2015-12-18 13:27:48 -08:00
Jordan Eldredge
21f1262abe Add ESLint rule: wrap-iife (inside) 2015-12-18 10:45:41 -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
Preston Parry
954ee22b98 updates wording to "space-separated" to be consistent 2015-12-11 16:15: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
John-David Dalton
24ac0661bc Ensure attr is a string when passed to this.map. 2015-11-24 09:11:00 -08:00
John-David Dalton
c23fb5dc4d Simplify pluck, thanks @jridgewell. 2015-11-23 22:28:37 -08:00
John-David Dalton
1be3730cef Change _.invoke use to _.map. 2015-11-23 16:37:14 -08:00
mieszko4
681dea993d Make item arrayizing consistent through the file 2015-11-17 05:44:44 +01: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
Justin Ridgewell
7ed8582d19 Deopt Underscore methods that change on arguments
All of our currently deoptimized Underscore methods (`pick`, `omit`,
`invoke`, `without`, and `difference`) change behavior based on the
number of arguments pass to the call. This both adds `reduce` (and
friends).

Supersedes (and incorporates) #3810.
2015-10-28 10:22:11 -04: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
fda02db428 Fix 1.2.2 Model#id regression
Fixes #3778.
2015-10-22 11:04:25 -04:00
just-boris
345dd7b128 Allow to make reduce without initial value 2015-10-07 10:59:00 -04: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
Graeme Yeates
3c6fabbc8f Use _.create in extend 2015-09-18 12:58:02 -04:00
Jeremy Ashkenas
05fde9e201 Backbone.js 1.2.3 2015-09-03 11:56:05 -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
00f8b6fe79 Backbone.js 1.2.2 2015-08-19 15:03:44 -04: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
John-David Dalton
1f29c6713a Add Modernizr style check for 'onhashchange' to avoid issues in IE compat modes. [closes #3730] 2015-08-10 12:55:41 -07:00
Graeme Yeates
a2763083c6 Merge pull request #3676 from jridgewell/collection-includes
Add Collection#includes for underscore v1.8
2015-08-06 21:17:43 -04:00
John-David Dalton
7dc9708cc1 Use _.bind instead of context param of _.sortBy. 2015-08-03 13:52:51 -07:00
Justin Ridgewell
376249e46b Add Collection#includes for underscore v1.8 2015-08-03 16:35:15 -04:00
Justin Ridgewell
f55b4a2245 Merge pull request #3680 from akre54/multi-event-maps
Event maps should support multiple event syntax
2015-06-18 10:21:50 -04:00