91 Commits

Author SHA1 Message Date
Royce Tucker
d2099dd283 Adding a unit test for once with object notation 2016-01-30 14:37:37 -06: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
89d50840b6 Add ESLint rule: dot-notation 2015-12-28 21:09:44 -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
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
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
Kevin Partington
9c681906a4 Tests: Migrated unit tests to QUnit 2.0 syntax. (fixes #3813) 2015-10-06 23:35:30 -05:00
Adam Krebs
6b927eb5e7 Event maps should support multiple event syntax 2015-06-10 17:33:03 -04:00
Justin Ridgewell
6ecee63738 Juggle context param with event maps
When using event maps, it's a little nicer to specify the `context`
parameter as the second argument. This keeps backwards compatibility,
though the feature wasn't documented.

```javascript
obj.on({
    a: method,
    b: other
}, context);
```

When you explicitly pass a `context`, we don't override.

```javascript
obj.on({
    a: function() { ok(this === context); },
}, otherContext, context);
```
2015-05-13 20:41:51 -04:00
Justin Ridgewell
9ad11ddf80 Ensure #on and #off **never** alter callback list 2015-05-01 20:20:21 -04:00
Justin Ridgewell
020bec3b22 Refine eventsApi
Based off code from https://github.com/jashkenas/backbone/pull/3476
2015-05-01 20:20:21 -04:00
Jeremy Ashkenas
dfec4b837d Merge pull request #3463 from jridgewell/on-does-not-alter
Do not alter the "on" events array
2015-03-04 11:35:24 -05:00
Justin Ridgewell
6aed2485ae Revert "Merge pull request #3465 from jridgewell/trigger-objects"
This reverts commit 760004faa7, reversing
changes made to 7315c56d2e.
2015-02-17 17:06:21 -05:00
Jeremy Ashkenas
377b9c89e4 Merge pull request #3485 from megawac/qunit-update
[minor] Update QUnit to v1.7.1
2015-02-10 10:47:20 -05:00
Graeme
1577524edd Update QUnit to v1.7.1 2015-02-10 00:31:04 -05:00
Justin Ridgewell
3aac74d121 Undo concat #on tests 2015-01-29 23:23:22 -05:00
Justin Ridgewell
3d3f0a0b02 Prevent "on" and "off" from altering trigger events array 2015-01-28 15:31:55 -05:00
Justin Ridgewell
778d447922 Address listenTo and off memory leak
https://github.com/jashkenas/backbone/pull/3455#issuecomment-71677970
2015-01-27 20:55:54 -05:00
Justin Ridgewell
59c3704955 Test trigger arguments behavior
To be clear, I think the trigger with object behavior is silly. But I
needed tests to ensure that my [`eventsApi` refactor]
(https://github.com/jridgewell/backbone/tree/eventsApi-refactor) kept
the current functionality.
2015-01-26 16:54:54 -05:00
Justin Ridgewell
85fb8c30de Fix listenTo memory leak
Fixes https://github.com/jashkenas/backbone/issues/3453
2015-01-24 14:56:10 -05:00
Justin Ridgewell
c48cf5f22e Do not alter the "on" events array 2015-01-24 14:44:17 -05:00
Justin Ridgewell
85885130a8 Ensure listenToOnce without a callback noops
This mirrors the test directly above, ensuring `#once` without a
callback noops.
2015-01-23 14:08:21 -05:00
Brad Dunbar
dc048c6bf8 Ensure events are triggered by the correct name. 2015-01-19 12:36:44 -05:00
Brad Dunbar
f6695d13fe Fix #3448. Ensure listenToOnce splits event names.
Calling `listenToOnce('x y', …)` should be functionally equivalent
to `listenToOnce('x', …); listenToOnce('y', …)`.
2015-01-19 09:42:11 -05:00
Justin Ridgewell
2450b70af8 Test that listenToOnce is only called once 2014-11-03 09:52:14 -05:00
Justin Ridgewell
fab32cc93a Remove duplicated tests 2014-11-03 09:52:14 -05:00
Adam Krebs
740946142e check for cleaned up references in listenToOnce with stopListening 2014-11-03 09:52:14 -05:00
Justin Ridgewell
b3ab6117c0 Test both _listeningTo and _events are empty 2014-11-03 09:52:13 -05:00
Adam Krebs
c6a1df5084 use clearer event names 2014-11-03 09:52:13 -05:00
Adam Krebs
d84e15b08c test for correct context in event maps 2014-11-03 09:52:12 -05:00
Jmeas
459dc24f80 Fixes listenToOnce memory leak. 2014-11-03 09:52:12 -05:00
Jmeas
71cecdc1e2 Failing spec for listenToOnce 2014-11-03 09:52:12 -05:00
Luke Rodgers
da55501da7 Use QUnit raises instead of throws.
`throws` is a future reserved word.
2013-10-17 00:01:38 -04:00
Adam Krebs
2bd5df99c5 remove $(document).ready(...) from tests 2013-09-16 10:51:32 -04:00
Jeremy Ashkenas
8810453495 Adding test from #2619 2013-09-11 17:51:10 -03:00
Jeremy Ashkenas
22ab3ea78a Fixing borked listeners test. #2724 2013-09-11 15:33:37 -03:00
Jeremy Ashkenas
42370dd80f Test from #2724 for listener cleanup. 2013-09-11 14:20:05 -03:00
Jeremy Ashkenas
b7096f8f74 typo 2013-03-19 19:16:34 +08:00
Jeremy Ashkenas
2b42cc069c Merge pull request #2191 from byroot/feature-ignore-undefined-methods-in-views-events
Improve consistency: get rid of "a zealous early error breaking apps in inconvenient ways"
2013-03-19 04:13:33 -07:00
Casey Foster
86451644f0 Fix possible memory leak in stopListening, refactor 2013-02-08 23:17:26 -08:00
Casey Foster
1dfebab17e Tweak chainable events tests 2013-01-27 07:02:02 -08:00
KungD
78b55f7e0f also tested noevents and eventsAPI code branches 2013-01-27 15:30:02 +01:00
KungD
770883fd25 added event functions chaining tests 2013-01-27 15:04:18 +01:00
Jean Boussier
108e114bd1 Improve consistency: get rid of a zealous early error breaking apps in inconvenient ways
Since jQuery.on() and Backbone.Events.on are silently ignoring invalid callbacks,
Backbone.View.delegateEvents should too.

See #2184 for previous discussion about how Backbone is supposed to behave on obvious developer errors
2013-01-25 11:24:57 -05:00
Genadi Samokovarov
3caee55366 Rename Events#oneTimeListenTo to Events#listenToOnce 2013-01-17 23:20:18 +02:00
Genadi Samokovarov
1f6ed0679f Add tests for Events#oneTimeListenTo 2013-01-17 23:08:19 +02:00
Casey Foster
4d8ca2b837 Account for listenTo/stopListening edge cases, add tests 2013-01-15 06:53:39 -08:00
Tim Griesser
201f9e4f18 fix for #2100 2013-01-15 07:59:24 -05:00
Genadi Samokovarov
baac55096f Add listenTo yourself and cleaning with stopListening test 2012-12-29 16:33:40 +02:00