Fixed off().
parent
d8d7fdabdd
commit
7737559dec
|
@ -176,7 +176,7 @@ H5P.EventDispatcher = (function () {
|
||||||
// Find specific listener
|
// Find specific listener
|
||||||
for (var i = 0; i < triggers[type].length; i++) {
|
for (var i = 0; i < triggers[type].length; i++) {
|
||||||
if (triggers[type][i].listener === listener) {
|
if (triggers[type][i].listener === listener) {
|
||||||
triggers[type].unshift(i, 1);
|
triggers[type].splice(i, 1);
|
||||||
self.trigger('removeListener', type, {'listener': listener});
|
self.trigger('removeListener', type, {'listener': listener});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -199,9 +199,12 @@ H5P.EventDispatcher = (function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clone array (prevents triggers from being modified during the event)
|
||||||
|
var handlers = triggers[type].slice();
|
||||||
|
|
||||||
// Call all listeners
|
// Call all listeners
|
||||||
for (var i = 0; i < triggers[type].length; i++) {
|
for (var i = 0; i < handlers.length; i++) {
|
||||||
var trigger = triggers[type][i];
|
var trigger = handlers[i];
|
||||||
var thisArg = (trigger.thisArg ? trigger.thisArg : this);
|
var thisArg = (trigger.thisArg ? trigger.thisArg : this);
|
||||||
trigger.listener.call(thisArg, event);
|
trigger.listener.call(thisArg, event);
|
||||||
}
|
}
|
||||||
|
@ -223,7 +226,7 @@ H5P.EventDispatcher = (function () {
|
||||||
if (event === undefined) {
|
if (event === undefined) {
|
||||||
return;
|
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);
|
event = new H5P.Event(event, eventData, extras);
|
||||||
}
|
}
|
||||||
else if (eventData !== undefined) {
|
else if (eventData !== undefined) {
|
||||||
|
|
Loading…
Reference in New Issue