fix(ivy): ensure animation @bindings work for {key:value} and empty bindings (#28026)
PR Close #28026
This commit is contained in:

committed by
Andrew Kushnir

parent
0136274f33
commit
94c0b7a362
@ -688,10 +688,19 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
||||
const instruction = mapBindingToInstruction(input.type);
|
||||
if (input.type === BindingType.Animation) {
|
||||
const value = input.value.visit(this._valueConverter);
|
||||
// setProperty without a value doesn't make any sense
|
||||
if (value.name || value.value) {
|
||||
const bindingName = prepareSyntheticPropertyName(input.name);
|
||||
// animation bindings can be presented in the following formats:
|
||||
// 1j [@binding]="fooExp"
|
||||
// 2. [@binding]="{value:fooExp, params:{...}}"
|
||||
// 3. [@binding]
|
||||
// 4. @binding
|
||||
// only formats 1. and 2. include the actual binding of a value to
|
||||
// an expression and therefore only those should be the only two that
|
||||
// are allowed. The check below ensures that a binding with no expression
|
||||
// does not get an empty `elementProperty` instruction created for it.
|
||||
const hasValue = value && (value instanceof LiteralPrimitive) ? !!value.value : true;
|
||||
if (hasValue) {
|
||||
this.allocateBindingSlots(value);
|
||||
const bindingName = prepareSyntheticPropertyName(input.name);
|
||||
this.updateInstruction(input.sourceSpan, R3.elementProperty, () => {
|
||||
return [
|
||||
o.literal(elementIndex), o.literal(bindingName),
|
||||
|
Reference in New Issue
Block a user