Skip to content

Commit 85a3c0b

Browse files
rotdroprisadams
authored andcommitted
Avoid referencing _events property of potentially deleted this object.
1 parent 3c4d241 commit 85a3c0b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/contrib/microevent.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ MicroEvent.prototype = {
2525
this._events[event].splice(this._events[event].indexOf(fct), 1);
2626
},
2727
trigger: function(event /* , args... */){
28-
this._events = this._events || {};
29-
if (event in this._events === false) return;
30-
for (var i = 0; i < this._events[event].length; i++){
31-
this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
28+
const events = this._events = this._events || {};
29+
if (event in events === false) return;
30+
for (var i = 0; i < events[event].length; i++){
31+
events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
3232
}
3333
}
3434
};
@@ -45,4 +45,4 @@ MicroEvent.mixin = function(destObject){
4545
for (var i = 0; i < props.length; i++){
4646
destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
4747
}
48-
};
48+
};

0 commit comments

Comments
 (0)