Skip to content

Commit

Permalink
refactor(compiler): Fix extra attribute on ng-template (angular#53405)
Browse files Browse the repository at this point in the history
We no longer emit extra attribute instructions on certain `ng-template` elements with attributes.

PR Close angular#53405
  • Loading branch information
dylhunn authored and alxhub committed Dec 8, 2023
1 parent 90e0908 commit 8ab7e84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@
{
"failureMessage": "Incorrect template"
}
],
"skipForTemplatePipeline": true
]
},
{
"description": "should handle attribute bindings inside an ng-template",
Expand All @@ -378,8 +377,7 @@
{
"failureMessage": "Incorrect template"
}
],
"skipForTemplatePipeline": true
]
}
]
}
7 changes: 7 additions & 0 deletions packages/compiler/src/template/pipeline/src/ingest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ function ingestBindings(
attr.i18n);
hasI18nAttributes ||= attr.i18n !== undefined;
}

for (const input of element.inputs) {
ingestBinding(
unit, op.xref, input.name, input.value, input.type, input.unit, input.securityContext,
Expand Down Expand Up @@ -927,6 +928,12 @@ function ingestBinding(
expression = value;
}

if (type === e.BindingType.Attribute && !(flags & BindingFlags.TextValue) &&
templateKind === ir.TemplateKind.Structural) {
// TODO: big comment about why this is stupid.
return;
}

const kind: ir.BindingKind = BINDING_KINDS.get(type)!;
view.update.push(ir.createBindingOp(
xref, kind, name, expression, unit, securityContext, !!(flags & BindingFlags.TextValue),
Expand Down

0 comments on commit 8ab7e84

Please sign in to comment.