Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix removeAllListeners to unregister the dom listeners

  • Loading branch information...
commit 7a536683459a674920a87c038536022b9bc899fa 1 parent a41e9f8
@substack authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 index.js
View
20 index.js
@@ -27,6 +27,26 @@ Ever.prototype.removeListener = function (type, listener, useCapture) {
if (ix >= 0) xs.splice(ix, 1);
};
+Ever.prototype.removeAllListeners = function (type) {
+ var self = this;
+ function removeAll (t) {
+ var xs = self.listeners(t);
+ for (var i = 0; i < xs.length; i++) {
+ self.removeListener(t, xs[i]);
+ }
+ }
+
+ if (type) {
+ removeAll(type)
+ }
+ else if (self._events) {
+ for (var key in self._events) {
+ if (key) removeAll(key);
+ }
+ }
+ EventEmitter.prototype.removeAllListeners.apply(self, arguments);
+}
+
var initSignatures = require('./init.json');
Ever.prototype.emit = function (name, ev) {
Please sign in to comment.
Something went wrong with that request. Please try again.