Permalink
Browse files

Manager : fix off method

When you didn't attach an event and you use a Hammerjs.Manager.off
method , you will see script error.

Fixes #768
Closes #839
Ref #770
  • Loading branch information...
sculove authored and arschmitz committed Aug 10, 2015
1 parent 70075f2 commit da49a2730779ecc3b4dd147cc418a0df7c70fad9
Showing with 13 additions and 1 deletion.
  1. +1 −1 src/manager.js
  2. +12 −0 tests/unit/test_events.js
View
@@ -206,7 +206,7 @@ Manager.prototype = {
if (!handler) {
delete handlers[event];
} else {
handlers[event].splice(inArray(handlers[event], handler), 1);
handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
}
});
return this;
View
@@ -47,3 +47,15 @@ test('test the eventemitter', function() {
ee.emit('testEvent2', inputData); // doenst trigger a thing
ee.emit('testEvent3', inputData); // doenst trigger a thing
});
/*
* Hammer.Manager.off method : exception handling
*/
test("When Hammer.Manager didn't attach an event, 'off' method is ignored", function() {
var count = 0;
hammer = new Hammer(el, { inputTarget: document.body });
hammer.off("swipeleft", function(e) {
count++;
});
ok(true, "nothing");
});

0 comments on commit da49a27

Please sign in to comment.