Skip to content

Instantly share code, notes, and snippets.

@sayrer
Created January 10, 2015 22:36
Show Gist options
  • Save sayrer/ba1c1d0d63b0c3bbf25c to your computer and use it in GitHub Desktop.
Save sayrer/ba1c1d0d63b0c3bbf25c to your computer and use it in GitHub Desktop.
/**
* Records information for later handling of events. This type is
* shared, and instances of it are passed, between the eventcontract
* and the dispatcher jsbinary. Therefore, the fields of this type are
* referenced by string literals rather than property literals
* throughout the code.
*
* 'targetElement' is the element the action occured on, 'actionElement'
* is the element that has the jsaction handler.
*
* A null 'actionElement' identifies an EventInfo instance that didn't match a
* jsaction attribute. This allows us to execute global event handlers with the
* appropriate event type (including a11y clicks and custom events).
*
* TODO(user): Using literals to access properties makes type
* checking partially ineffective. Accessing a wrongly spelled field
* this way doesn't create a compiler error, and passing such an
* untyped field to a place where a type is expected doesn't create a
* jscompiler error either. Assigning a value of the wrong type in
* this way, however, does trigger a jscompiler error (seen when
* assigning Event to 'target', which requires !Event).
*
* @typedef {{
* eventType: string,
* event: !Event,
* targetElement: !Element,
* action: string,
* actionElement: Element,
* timeStamp: number
* }}
*/
exports.EventInfo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment