Refs #687 -- ACTUALLY fixes the issue :-) by special-casing 'fail' events for prepending
Showing
1 changed file
with
2 additions
and
2 deletions
... | @@ -129,7 +129,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) { | ... | @@ -129,7 +129,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) { |
129 | } else if (isArray(this._events[type])) { | 129 | } else if (isArray(this._events[type])) { |
130 | 130 | ||
131 | // If we've already got an array, just append. | 131 | // If we've already got an array, just append. |
132 | this._events[type].push(listener); | 132 | this._events[type]['fail' === type ? 'unshift' : 'push'](listener); |
133 | 133 | ||
134 | // Check for listener leak | 134 | // Check for listener leak |
135 | if (!this._events[type].warned) { | 135 | if (!this._events[type].warned) { |
... | @@ -151,7 +151,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) { | ... | @@ -151,7 +151,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) { |
151 | } | 151 | } |
152 | } else { | 152 | } else { |
153 | // Adding the second element, need to change to array. | 153 | // Adding the second element, need to change to array. |
154 | this._events[type] = [this._events[type], listener]; | 154 | this._events[type] = 'fail' === type ? [listener, this._events[type]] : [this._events[type], listener]; |
155 | } | 155 | } |
156 | 156 | ||
157 | return this; | 157 | return this; | ... | ... |
-
Please register or sign in to post a comment