feat(ivy): support host attribute and property bindings (#22334)

PR Close #22334
This commit is contained in:
Chuck Jazdzewski
2018-02-15 16:43:16 -08:00
committed by Kara Erickson
parent c499c8f4db
commit 73c203fda9
8 changed files with 201 additions and 62 deletions

View File

@ -63,9 +63,8 @@ export class BindingParser {
getUsedPipes(): CompilePipeSummary[] { return Array.from(this._usedPipes.values()); }
createDirectiveHostPropertyAsts(
dirMeta: CompileDirectiveSummary, elementSelector: string,
sourceSpan: ParseSourceSpan): BoundElementPropertyAst[]|null {
createBoundHostProperties(dirMeta: CompileDirectiveSummary, sourceSpan: ParseSourceSpan):
BoundProperty[]|null {
if (dirMeta.hostProperties) {
const boundProps: BoundProperty[] = [];
Object.keys(dirMeta.hostProperties).forEach(propName => {
@ -78,11 +77,19 @@ export class BindingParser {
sourceSpan);
}
});
return boundProps.map((prop) => this.createElementPropertyAst(elementSelector, prop));
return boundProps;
}
return null;
}
createDirectiveHostPropertyAsts(
dirMeta: CompileDirectiveSummary, elementSelector: string,
sourceSpan: ParseSourceSpan): BoundElementPropertyAst[]|null {
const boundProps = this.createBoundHostProperties(dirMeta, sourceSpan);
return boundProps &&
boundProps.map((prop) => this.createElementPropertyAst(elementSelector, prop));
}
createDirectiveHostEventAsts(dirMeta: CompileDirectiveSummary, sourceSpan: ParseSourceSpan):
BoundEventAst[]|null {
if (dirMeta.hostListeners) {

View File

@ -100,6 +100,8 @@ export class TemplateParser {
private _htmlParser: I18NHtmlParser, private _console: Console,
public transforms: TemplateAstVisitor[]) {}
public get expressionParser() { return this._exprParser; }
parse(
component: CompileDirectiveMetadata, template: string|ParseTreeResult,
directives: CompileDirectiveSummary[], pipes: CompilePipeSummary[], schemas: SchemaMetadata[],
@ -434,6 +436,7 @@ class TemplateParseVisitor implements html.Visitor {
const bindParts = name.match(BIND_NAME_REGEXP);
let hasBinding = false;
const boundEvents: BoundEventAst[] = [];
if (bindParts !== null) {
hasBinding = true;
@ -814,7 +817,7 @@ class ElementOrDirectiveRef {
}
}
/** Splits a raw, potentially comma-delimted `exportAs` value into an array of names. */
/** Splits a raw, potentially comma-delimited `exportAs` value into an array of names. */
function splitExportAs(exportAs: string | null): string[] {
return exportAs ? exportAs.split(',').map(e => e.trim()) : [];
}