Fixed off().

editor-padding
Frode Petterson 2015-08-27 11:36:07 +02:00
parent d8d7fdabdd
commit 7737559dec
1 changed files with 9 additions and 6 deletions

View File

@ -176,7 +176,7 @@ H5P.EventDispatcher = (function () {
// Find specific listener
for (var i = 0; i < triggers[type].length; i++) {
if (triggers[type][i].listener === listener) {
triggers[type].unshift(i, 1);
triggers[type].splice(i, 1);
self.trigger('removeListener', type, {'listener': listener});
break;
}
@ -199,9 +199,12 @@ H5P.EventDispatcher = (function () {
return;
}
// Clone array (prevents triggers from being modified during the event)
var handlers = triggers[type].slice();
// Call all listeners
for (var i = 0; i < triggers[type].length; i++) {
var trigger = triggers[type][i];
for (var i = 0; i < handlers.length; i++) {
var trigger = handlers[i];
var thisArg = (trigger.thisArg ? trigger.thisArg : this);
trigger.listener.call(thisArg, event);
}
@ -223,7 +226,7 @@ H5P.EventDispatcher = (function () {
if (event === undefined) {
return;
}
if (typeof event === 'string') { // TODO: Check instanceof String as well?
if (event instanceof String || typeof event === 'string') {
event = new H5P.Event(event, eventData, extras);
}
else if (eventData !== undefined) {