Commit 111c00b6 111c00b6857d662a4f7961bebb1723aa5aac3601 by Nicolas Perriault

refs #328 - added EventEmitter.removeAllFilters()

1 parent 51ded333
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 // USE OR OTHER DEALINGS IN THE SOFTWARE. 20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 21
22 /*global CasperError*/
23
22 var isArray = Array.isArray; 24 var isArray = Array.isArray;
23 25
24 function EventEmitter() { 26 function EventEmitter() {
...@@ -230,6 +232,17 @@ EventEmitter.prototype.filter = function() { ...@@ -230,6 +232,17 @@ EventEmitter.prototype.filter = function() {
230 return filter.apply(this, Array.prototype.splice.call(arguments, 1)); 232 return filter.apply(this, Array.prototype.splice.call(arguments, 1));
231 }; 233 };
232 234
235 EventEmitter.prototype.removeAllFilters = function(type) {
236 if (arguments.length === 0) {
237 this._filters = {};
238 return this;
239 }
240 if (type && this._filters && this._filters[type]) {
241 this._filters[type] = null;
242 }
243 return this;
244 };
245
233 EventEmitter.prototype.setFilter = function(type, filterFn) { 246 EventEmitter.prototype.setFilter = function(type, filterFn) {
234 if (!this._filters) { 247 if (!this._filters) {
235 this._filters = {}; 248 this._filters = {};
......