fix(WebWorker): Return boolean from `dispatchRenderEvent`

Update web_worker `dispatchRenderEvent` to return a boolean, which
[view.ts](https://github.com/angular/angular/blob/master/modules/angular2/src/core/render/dom/view/view.ts#L85) expects.
This commit is contained in:
Tim Blasi 2015-08-26 13:25:00 -07:00
parent 5863f50316
commit 457eb5d69c
4 changed files with 10 additions and 4 deletions

View File

@ -510,6 +510,7 @@ export interface RenderEventDispatcher {
* Called when an event was triggered for a on-* attribute on an element.
* @param {Map<string, any>} locals Locals to be used to evaluate the
* event expressions
* @return {boolean} False if `preventDefault` should be called on the DOM event.
*/
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>);
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>): boolean;
}

View File

@ -17,7 +17,7 @@ export class EventDispatcher implements RenderEventDispatcher {
constructor(private _viewRef: RenderViewRef, private _sink: EventEmitter,
private _serializer: Serializer) {}
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>) {
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>): boolean {
var e = locals.get('$event');
var serializedEvent;
// TODO (jteplitz602): support custom events #3350
@ -106,5 +106,9 @@ export class EventDispatcher implements RenderEventDispatcher {
"eventName": eventName,
"locals": serializedLocals
});
// TODO(kegluneq): Eventually, we want the user to indicate from the UI side whether the event
// should be canceled, but for now just call `preventDefault` on the original DOM event.
return false;
}
}

View File

@ -52,7 +52,7 @@ class LoggingEventDispatcher implements RenderEventDispatcher {
constructor(log: List<List<any>>) { this.log = log; }
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>) {
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>): boolean {
this.log.push([elementIndex, eventName, locals]);
return true;
}

View File

@ -69,7 +69,8 @@ export function main() {
class SpyEventDispatcher implements RenderEventDispatcher {
constructor(private _callback: Function) {}
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>) {
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>): boolean {
this._callback(elementIndex, eventName, locals);
return false;
}
}