Skip to content

Commit

Permalink
Avoid referencing _events property of potentially deleted this object.
Browse files Browse the repository at this point in the history
  • Loading branch information
rotdrop authored and risadams committed Aug 20, 2022
1 parent 3c4d241 commit 85a3c0b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/contrib/microevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ MicroEvent.prototype = {
this._events[event].splice(this._events[event].indexOf(fct), 1);
},
trigger: function(event /* , args... */){
this._events = this._events || {};
if (event in this._events === false) return;
for (var i = 0; i < this._events[event].length; i++){
this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
const events = this._events = this._events || {};
if (event in events === false) return;
for (var i = 0; i < events[event].length; i++){
events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
}
}
};
Expand All @@ -45,4 +45,4 @@ MicroEvent.mixin = function(destObject){
for (var i = 0; i < props.length; i++){
destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
}
};
};

0 comments on commit 85a3c0b

Please sign in to comment.