Skip to content

Commit

Permalink
Fix for the once event listener not removing the correct handler func…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Manuel Overdijk committed Oct 7, 2015
1 parent af4951b commit ee4f0a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/core/PrioritisedArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ export class PrioritisedArray extends Array {
* @returns {void}
*/
once(event, handler, context = this) {
return this.on(event, function () {
return this.on(event, function onceWrapper() {
/* TODO: bug in traceur preventing us from using ...arguments as expected: https://github.com/google/traceur-compiler/issues/1118
* We want to do this: handler.call(context, ...arguments); */
handler.call(context, arguments);
this.off(event, handler, context);
this.off(event, onceWrapper, context);
}, this);
}

Expand Down
6 changes: 4 additions & 2 deletions src/core/PrioritisedObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ export class PrioritisedObject extends EventEmitter {
* @returns {void}
*/
once(event, handler, context = this) {
return this.on(event, function () {
return this.on(event, function onceWrapper() {
/* TODO: bug in traceur preventing us from using ...arguments as expected: https://github.com/google/traceur-compiler/issues/1118
* We want to do this: handler.call(context, ...arguments); */
handler.call(context, arguments);
this.off(event, handler, context);
this.off(event, onceWrapper, context);
}, this);
}

Expand Down

0 comments on commit ee4f0a1

Please sign in to comment.