From d367cff8c545785060b7cb877fa60057b0e3ca2c Mon Sep 17 00:00:00 2001 From: fkloft Date: Sat, 10 Oct 2015 23:56:46 +0200 Subject: [PATCH] Fix pull request --- code/hooks.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/hooks.js b/code/hooks.js index 44c6826c..26c4bb9d 100644 --- a/code/hooks.js +++ b/code/hooks.js @@ -110,6 +110,10 @@ window.removeHook = function(event, callback) { if (typeof callback !== 'function') throw('Callback must be a function.'); if (_hooks[event]) { - _hooks[event].splice(_hooks[event].indexOf(callback), 1); + var index = _hooks[event].indexOf(callback); + if(index == -1) + console.warn('Callback wasn\'t registered for this event.'); + else + _hooks[event].splice(index, 1); } }