Created
August 5, 2011 14:19
-
-
Save koichik/1127624 to your computer and use it in GitHub Desktop.
Fix this.event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 4c3ac34848bd314f2ccdd2b7cbb80c78548e784a Mon Sep 17 00:00:00 2001 | |
| From: koichik <[email protected]> | |
| Date: Fri, 5 Aug 2011 23:16:41 +0900 | |
| Subject: [PATCH] Fix this.event | |
| --- | |
| lib/events.js | 6 ++++-- | |
| 1 files changed, 4 insertions(+), 2 deletions(-) | |
| diff --git a/lib/events.js b/lib/events.js | |
| index d275b80..0e96aad 100644 | |
| --- a/lib/events.js | |
| +++ b/lib/events.js | |
| @@ -188,7 +188,6 @@ EventEmitter.prototype.emit = function() { | |
| this._events || init.call(this); | |
| var type = arguments[0]; | |
| - this.event = type; | |
| if (type === 'newListener') { | |
| if (!this._events.newListener) { return false; } | |
| @@ -200,6 +199,7 @@ EventEmitter.prototype.emit = function() { | |
| var args = new Array(l - 1); | |
| for (var i = 1; i < l; i++) args[i - 1] = arguments[i]; | |
| for (i = 0, l = this._all.length; i < l; i++) { | |
| + this.event = type; | |
| this._all[i].apply(this, args); | |
| } | |
| } | |
| @@ -232,6 +232,7 @@ EventEmitter.prototype.emit = function() { | |
| } | |
| if (typeof handler === 'function') { | |
| + this.event = type; | |
| if (arguments.length === 1) { | |
| handler.call(this); | |
| } | |
| @@ -259,6 +260,7 @@ EventEmitter.prototype.emit = function() { | |
| var listeners = handler.slice(); | |
| for (var i = 0, l = listeners.length; i < l; i++) { | |
| + this.event = type; | |
| listeners[i].apply(this, args); | |
| } | |
| return true; | |
| @@ -464,4 +466,4 @@ EventEmitter.prototype.listenersAny = function() { | |
| }; | |
| -exports.EventEmitter = EventEmitter; | |
| \ No newline at end of file | |
| +exports.EventEmitter = EventEmitter; | |
| -- | |
| 1.7.4.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment