Fixed off().
parent
d8d7fdabdd
commit
7737559dec
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue