Skip to content

Commit

Permalink
Fix chieffancypants#101: Prevents propagation when callback returns f…
Browse files Browse the repository at this point in the history
…alse. Inspired by PR chieffancypants#39
  • Loading branch information
leyanlo committed Jun 9, 2016
1 parent 0725137 commit 7cbd0fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions build/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@
}

if (shouldExecute) {
wrapApply(_callback.apply(this, arguments));
return _callback.apply(this, arguments);
}
};
}
Expand Down Expand Up @@ -570,9 +570,9 @@

// this takes place outside angular, so we'll have to call
// $apply() to make sure angular's digest happens
$rootScope.$apply(function() {
return $rootScope.$apply(function() {
// call the original hotkey callback with the keyboard event
callback(event, _get(combo));
return callback(event, _get(combo));
});
};
}
Expand Down Expand Up @@ -911,14 +911,14 @@
}

/**
* stops propogation for this event
* stops immediate propagation for this event
*
* @param {Event} e
* @returns void
*/
function _stopPropagation(e) {
if (e.stopPropagation) {
e.stopPropagation();
function _stopImmediatePropagation(e) {
if (e.stopImmediatePropagation) {
e.stopImmediatePropagation();
return;
}

Expand Down Expand Up @@ -1244,7 +1244,7 @@

if (callback(e, combo) === false) {
_preventDefault(e);
_stopPropagation(e);
_stopImmediatePropagation(e);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
}

if (shouldExecute) {
wrapApply(_callback.apply(this, arguments));
return _callback.apply(this, arguments);
}
};
}
Expand Down Expand Up @@ -564,9 +564,9 @@

// this takes place outside angular, so we'll have to call
// $apply() to make sure angular's digest happens
$rootScope.$apply(function() {
return $rootScope.$apply(function() {
// call the original hotkey callback with the keyboard event
callback(event, _get(combo));
return callback(event, _get(combo));
});
};
}
Expand Down

0 comments on commit 7cbd0fe

Please sign in to comment.