jenkins-bot has submitted this change and it was merged.

Change subject: EventEmitter: Remove unneeded Array.prototype.slice call
......................................................................


EventEmitter: Remove unneeded Array.prototype.slice call

apply() requires an Array-like object as second parameter. Arguments
objects fulfill this requirement. We already depend on this elsewhere.

Also:
* Change context from hard-coded eventEmitter to 'this'.
  It is not once()'s responsibility to set the context. That is already
  handled by on(). Just use whatever context was set by on() and forward
  it to the handler.
* Add 'return' statement so that the wrapper is functionality
  equivalent to the original handler. While we don't currently use
  this, it should not reject the return value.

Change-Id: Icd9ca5a1dc4561a33fda13cb1d46f73bbba38681
---
M src/EventEmitter.js
1 file changed, 4 insertions(+), 4 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/EventEmitter.js b/src/EventEmitter.js
index 7ab463f..aa2a919 100644
--- a/src/EventEmitter.js
+++ b/src/EventEmitter.js
@@ -95,11 +95,11 @@
         */
        oo.EventEmitter.prototype.once = function ( event, listener ) {
                var eventEmitter = this,
-                       listenerWrapper = function () {
-                               eventEmitter.off( event, listenerWrapper );
-                               listener.apply( eventEmitter, 
Array.prototype.slice.call( arguments, 0 ) );
+                       wrapper = function () {
+                               eventEmitter.off( event, wrapper );
+                               return listener.apply( this, arguments );
                        };
-               return this.on( event, listenerWrapper );
+               return this.on( event, wrapper );
        };
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/187635
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icd9ca5a1dc4561a33fda13cb1d46f73bbba38681
Gerrit-PatchSet: 4
Gerrit-Project: oojs/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Ricordisamoa <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to