Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Take a copy of listeners() in overshadowListeners.

Node.js 0.7 apparently gives us a reference, causing infinite recursion.
  • Loading branch information...
commit c96cb1509abbd61f6256a4d3bee92bd286bb443b 1 parent ba4abd1
@stephank stephank authored stephank committed
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/utils.coffee
View
5 src/utils.coffee
@@ -84,7 +84,10 @@ exports.objectExtend = (dst, src) ->
return dst
exports.overshadowListeners = (ee, event, handler) ->
- old_listeners = ee.listeners(event)
+ # listeners() returns a reference to the internal array of EventEmitter.
+ # Make a copy, because we're about the replace the actual listeners.
+ old_listeners = ee.listeners(event).slice(0)
+
ee.removeAllListeners(event)
new_handler = () ->
if handler.apply(this, arguments) isnt true
Please sign in to comment.
Something went wrong with that request. Please try again.