Permalink
Browse files

Fixed; made `removeAllListeners` behavior with no arguments consisten…

…t between

browser and node 0.4.
  • Loading branch information...
rauchg committed Jun 18, 2011
1 parent 570c418 commit 2b9b5493d07ad12be1adbbc10afaed6cdcb126db
Showing with 9 additions and 7 deletions.
  1. +5 −4 lib/events.js
  2. +4 −3 test/events.test.js
View
@@ -109,10 +109,11 @@
*/
EventEmitter.prototype.removeAllListeners = function (name) {
- if (name === undefined) {
- this.$events = {};
- return this;
- }
+ // TODO: enable this when node 0.5 is stable
+ //if (name === undefined) {
+ //this.$events = {};
+ //return this;
+ //}
if (this.$events && this.$events[name]) {
this.$events[name] = null;
View
@@ -36,16 +36,17 @@
event.listeners('test:more').should().eql([empty]);
},
- 'remove all listeners': function () {
+ 'remove all listeners with no arguments': function () {
var event = new io.EventEmitter;
function empty () { }
event.on('test', empty);
event.on('test:more', empty);
event.removeAllListeners();
- event.listeners('test').should().eql([]);
- event.listeners('test:more').should().eql([]);
+ // TODO: with node 0.5 we'll change this to expect []
+ event.listeners('test').should().eql([empty]);
+ event.listeners('test:more').should().eql([empty]);
},
'remove listeners functions': function () {

0 comments on commit 2b9b549

Please sign in to comment.