Skip to content

Commit

Permalink
Don't wrapApply before checking if callback should be executed
Browse files Browse the repository at this point in the history
  • Loading branch information
djeremh committed Aug 30, 2015
1 parent 3826fe9 commit b7f36fe
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-hotkeys",
"version": "1.4.8",
"version": "1.5.0",
"main": [
"build/hotkeys.min.js",
"build/hotkeys.min.css"
Expand All @@ -16,5 +16,8 @@
"mousetrap": "~1.5.2",
"angular-mocks": "~1.2.15",
"angular-route": "~1.2.15"
},
"dependencies": {
"bind-polyfill": "~1.0.0"
}
}
9 changes: 6 additions & 3 deletions build/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,18 @@
}

if (shouldExecute) {
wrapApply(_callback.apply(this, arguments));
wrapApply(_callback.bind(this, arguments))();
}
};
// if this is an array, it means we provided a route object
} else if (callback instanceof Array) {
callback = wrapApply(callback);
}

if (typeof(action) === 'string') {
Mousetrap.bind(combo, wrapApply(callback), action);
Mousetrap.bind(combo, callback, action);
} else {
Mousetrap.bind(combo, wrapApply(callback));
Mousetrap.bind(combo, callback);
}

var hotkey = new Hotkey(combo, description, callback, action, allowIn, persistent);
Expand Down
Loading

0 comments on commit b7f36fe

Please sign in to comment.