refactor(compiler): generate host listeners in DirectiveWrappers

Part of #11683
This commit is contained in:
Tobias Bosch
2016-10-26 16:58:35 -07:00
committed by vsavkin
parent a664aba2c9
commit 32feb8a532
15 changed files with 628 additions and 316 deletions

View File

@ -76,19 +76,23 @@ export class BoundElementPropertyAst implements TemplateAst {
* `(@trigger.phase)="callback($event)"`).
*/
export class BoundEventAst implements TemplateAst {
static calcFullName(name: string, target: string, phase: string): string {
if (target) {
return `${target}:${name}`;
} else if (phase) {
return `@${name}.${phase}`;
} else {
return name;
}
}
constructor(
public name: string, public target: string, public phase: string, public handler: AST,
public sourceSpan: ParseSourceSpan) {}
visit(visitor: TemplateAstVisitor, context: any): any {
return visitor.visitEvent(this, context);
}
get fullName() {
if (this.target) {
return `${this.target}:${this.name}`;
} else {
return this.name;
}
}
get fullName() { return BoundEventAst.calcFullName(this.name, this.target, this.phase); }
get isAnimation(): boolean { return !!this.phase; }
}