diff --git a/packages/compiler/src/compiler_util/expression_converter.ts b/packages/compiler/src/compiler_util/expression_converter.ts index e105a818535..7e0d8336adc 100644 --- a/packages/compiler/src/compiler_util/expression_converter.ts +++ b/packages/compiler/src/compiler_util/expression_converter.ts @@ -100,20 +100,6 @@ export class ConvertPropertyBindingResult { constructor(public stmts: o.Statement[], public currValExpr: o.Expression) {} } -export enum BindingForm { - // The general form of binding expression, supports all expressions. - General, - - // Try to generate a simple binding (no temporaries or statements) - // otherwise generate a general binding - TrySimple, - - // Inlines assignment of temporaries into the generated expression. The result may still - // have statements attached for declarations of temporary variables. - // This is the only relevant form for Ivy, the other forms are only used in ViewEngine. - Expression, -} - /** * Converts the given expression AST into an executable output AST, assuming the expression * is used in property binding. The expression has to be preprocessed via @@ -121,7 +107,7 @@ export enum BindingForm { */ export function convertPropertyBinding( localResolver: LocalResolver|null, implicitReceiver: o.Expression, - expressionWithoutBuiltins: cdAst.AST, bindingId: string, form: BindingForm, + expressionWithoutBuiltins: cdAst.AST, bindingId: string, interpolationFunction?: InterpolationFunction): ConvertPropertyBindingResult { if (!localResolver) { localResolver = new DefaultLocalResolver(); @@ -135,15 +121,7 @@ export function convertPropertyBinding( localResolver.notifyImplicitReceiverUse(); } - if (visitor.temporaryCount === 0 && form == BindingForm.TrySimple) { - return new ConvertPropertyBindingResult([], outputExpr); - } else if (form === BindingForm.Expression) { - return new ConvertPropertyBindingResult(stmts, outputExpr); - } - - const currValExpr = createCurrValueExpr(bindingId); - stmts.push(currValExpr.set(outputExpr).toDeclStmt(o.DYNAMIC_TYPE, [o.StmtModifier.Final])); - return new ConvertPropertyBindingResult(stmts, currValExpr); + return new ConvertPropertyBindingResult(stmts, outputExpr); } /** @@ -906,10 +884,6 @@ class DefaultLocalResolver implements LocalResolver { } } -function createCurrValueExpr(bindingId: string): o.ReadVarExpr { - return o.variable(`currVal_${bindingId}`); // fix syntax highlighting: ` -} - export class BuiltinFunctionCall extends cdAst.Call { constructor( span: cdAst.ParseSpan, sourceSpan: cdAst.AbsoluteSourceSpan, args: cdAst.AST[], diff --git a/packages/compiler/src/render3/view/compiler.ts b/packages/compiler/src/render3/view/compiler.ts index 475ce119b74..17f5e371809 100644 --- a/packages/compiler/src/render3/view/compiler.ts +++ b/packages/compiler/src/render3/view/compiler.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {BindingForm, convertPropertyBinding} from '../../compiler_util/expression_converter'; +import {convertPropertyBinding} from '../../compiler_util/expression_converter'; import {ConstantPool} from '../../constant_pool'; import * as core from '../../core'; import {AST, ParsedEvent, ParsedEventType, ParsedProperty} from '../../expression_parser/ast'; @@ -646,7 +646,7 @@ function createHostBindingsFunction( function bindingFn(implicit: any, value: AST) { return convertPropertyBinding( - null, implicit, value, 'b', BindingForm.Expression, () => error('Unexpected interpolation')); + null, implicit, value, 'b', () => error('Unexpected interpolation')); } function convertStylingCall( diff --git a/packages/compiler/src/render3/view/template.ts b/packages/compiler/src/render3/view/template.ts index 7f287645dde..5902e824d03 100644 --- a/packages/compiler/src/render3/view/template.ts +++ b/packages/compiler/src/render3/view/template.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {BindingForm, BuiltinFunctionCall, convertActionBinding, convertPropertyBinding, convertUpdateArguments, LocalResolver} from '../../compiler_util/expression_converter'; +import {BuiltinFunctionCall, convertActionBinding, convertPropertyBinding, convertUpdateArguments, LocalResolver} from '../../compiler_util/expression_converter'; import {ConstantPool} from '../../constant_pool'; import * as core from '../../core'; import {AST, AstMemoryEfficientTransformer, BindingPipe, BindingType, Call, ImplicitReceiver, Interpolation, LiteralArray, LiteralMap, LiteralPrimitive, ParsedEventType, PropertyRead} from '../../expression_parser/ast'; @@ -1261,7 +1261,7 @@ export class TemplateDefinitionBuilder implements t.Visitor, LocalResolver private convertPropertyBinding(value: AST): o.Expression { const convertedPropertyBinding = convertPropertyBinding( - this, this.getImplicitReceiverExpr(), value, this.bindingContext(), BindingForm.Expression, + this, this.getImplicitReceiverExpr(), value, this.bindingContext(), () => error('Unexpected interpolation')); const valExpr = convertedPropertyBinding.currValExpr; this._tempVariables.push(...convertedPropertyBinding.stmts);