labs.events.NonDisposableEventTarget Extends
An implementation of goog.events.Listenable with full W3C EventTarget-like support (capture/bubble mechanism, stopping event propagation, preventing default actions). You may subclass this class to turn your class into a Listenable. Unlike goog.events.EventTarget, this class does not implement goog.disposable.IDisposable. Instances of this class that have had It is not necessary to call goog.dispose or #removeAllListeners in order for an instance of this class to be garbage collected. Unless propagation is stopped, an event dispatched by an EventTarget will bubble to the parent returned by getParentEventTarget. To set the parent, call setParentEventTarget. Subclasses that don't support changing the parent can override the setter to throw an error. Example usage:
  var source = new goog.labs.events.NonDisposableEventTarget();
  function handleEvent(e) {
    alert('Type: ' + e.type + '; Target: ' + e.target);
  }
  source.listen('foo', handleEvent);
  source.dispatchEvent('foo'); // will call handleEvent
TODO(user|johnlenz): Consider a more modern, less viral (not based on inheritance) replacement of goog.Disposable, which will allow goog.events.EventTarget to not be disposable.

Inheritance

Constructor

goog.labs.events.NonDisposableEventTarget()

Instance Methods

Public Protected Private
assertInitialized_()
Asserts that the event target instance is initialized properly.
code »
dispatchEvent()
No description.
code »
fireListeners()
No description.
code »
getListener()
No description.
code »
getListeners()
No description.
code »
getParentEventTarget()
No description.
code »
hasListener()
No description.
code »
listen()
No description.
code »
listenOnce()
No description.
code »
removeAllListeners()
No description.
code »
setParentEventTarget(parent)
Sets the parent of this event target to use for capture/bubble mechanism.
Arguments:
parent : goog.events.Listenable
Parent listenable (null if none).
code »
unlisten()
No description.
code »
unlistenByKey()
No description.
code »

Instance Properties

eventTargetListeners_ : goog.events.ListenerMap
Maps of event type to an array of listeners.
Code »
parentEventTarget_ : goog.events.Listenable
Parent event target, used during event bubbling.
Code »

Static Methods

goog.labs.events.NonDisposableEventTarget.dispatchEventInternal_(targeteopt_ancestorsTree) boolean
Dispatches the given event on the ancestorsTree. TODO(user): Look for a way to reuse this logic in goog.events, if possible.
Arguments:
target : !Object
The target to dispatch on.
e : goog.events.Event | Object | string
The event object.
opt_ancestorsTree : Array.<goog.events.Listenable>>
The ancestors tree of the target, in reverse order from the closest ancestor to the root event target. May be null if the target has no ancestor.
Returns: boolean  If anyone called preventDefault on the event object (or if any of the listeners returns false) this will also return false.
code »

Static Properties

goog.labs.events.NonDisposableEventTarget.MAX_ANCESTORS_ :
An artificial cap on the number of ancestors you can have. This is mainly for loop detection.
Code »

Package labs.events

Package Reference