Permalink
Browse files

LucidJS.emitter no longer will over write existing emitters.

  • Loading branch information...
1 parent 2506687 commit e2e870f4aac389ffca9090b3c9714a4eeaaf7700 @RobertWHurst committed Aug 31, 2012
Showing with 22 additions and 9 deletions.
  1. +22 −9 lucid.js
View
31 lucid.js
@@ -42,15 +42,28 @@
function EventEmitter(object) {
var emitter = object || {}, listeners = {}, setEvents = {}, pipes = {};
- emitter.on = on;
- emitter.once = once;
- emitter.trigger = trigger;
- emitter.set = set;
- emitter.set.clear = clearSet;
- emitter.pipe = pipe;
- emitter.pipe.clear = clearPipes;
- emitter.listeners = getListeners;
- emitter.listeners.clear = clearListeners;
+ //augment an object if it isn't already an emitter
+ if(
+ !emitter.on &&
+ !emitter.once &&
+ !emitter.trigger &&
+ !emitter.set &&
+ !emitter.pipe &&
+ !emitter.pipe &&
@Pumpuli
Pumpuli Sep 3, 2012

Why is emitter.pipe checked twice?

@RobertWHurst
RobertWHurst Sep 4, 2012

A mistake you caught. Thanks.

+ !emitter.listeners
+ ) {
+ emitter.on = on;
+ emitter.once = once;
+ emitter.trigger = trigger;
+ emitter.set = set;
+ emitter.set.clear = clearSet;
+ emitter.pipe = pipe;
+ emitter.pipe.clear = clearPipes;
+ emitter.listeners = getListeners;
+ emitter.listeners.clear = clearListeners;
+ } else {
+ return emitter;
+ }
if(emitter.addEventListener || emitter.attachEvent) {
handleNode(emitter);

0 comments on commit e2e870f

Please sign in to comment.