Skip to content

Commit

Permalink
[FIX] Event handlers registered with 'once' called multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
vkalpias committed Jan 22, 2016
1 parent e5dda43 commit 36952b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ pc.events = function () {
args = pc.makeArray(arguments);
args.shift();
callbacks = this._callbacks[name].slice(); // clone list so that deleting inside callbacks works
var originalIndex = 0;
for(index = 0; index < length; ++index) {
var scope = callbacks[index].scope;
callbacks[index].callback.apply(scope, args);
if (callbacks[index].callback.once) {
this._callbacks[name].splice(index, 1);
this._callbacks[name].splice(originalIndex, 1);
} else {
originalIndex++;
}
}
}
Expand Down

0 comments on commit 36952b2

Please sign in to comment.