GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(compiler): Make some fixups to template binidng ingestion (#… · angular/angular@7fa791e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/compiler/src/template/pipeline/src
    • ingest.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/compiler/src/template/pipeline/src/ingest.ts‎

Copy file name to clipboardExpand all lines: packages/compiler/src/template/pipeline/src/ingest.ts
+12-14Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ function asMessage(i18nMeta: i18n.I18nMeta|null|undefined): i18n.Message|null {
801801
return null;
802802
}
803803
if (!(i18nMeta instanceof i18n.Message)) {
804-
throw Error(`Unhandled i18n metadata type for binding: ${i18nMeta.constructor.name}`);
804+
throw Error(`Expected i18n meta to be a Message, but got: ${i18nMeta.constructor.name}`);
805805
}
806806
return i18nMeta;
807807
}
@@ -867,27 +867,26 @@ function ingestTemplateBindings(
867867
if (attr instanceof t.TextAttribute) {
868868
bindings.push(createTemplateBinding(
869869
unit, op.xref, e.BindingType.Attribute, attr.name, attr.value, null, SecurityContext.NONE,
870-
true, true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
870+
true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
871871
} else {
872872
bindings.push(createTemplateBinding(
873873
unit, op.xref, attr.type, attr.name, astOf(attr.value), attr.unit, attr.securityContext,
874-
false, true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
874+
true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
875875
}
876876
}
877877

878878
for (const attr of template.attributes) {
879879
// Attribute literal bindings, such as `attr.foo="bar"`.
880880
bindings.push(createTemplateBinding(
881881
unit, op.xref, e.BindingType.Attribute, attr.name, attr.value, null, SecurityContext.NONE,
882-
true, false, templateKind, asMessage(attr.i18n), attr.sourceSpan));
882+
false, templateKind, asMessage(attr.i18n), attr.sourceSpan));
883883
}
884884

885885
for (const input of template.inputs) {
886886
// Dynamic bindings (both attribute and property bindings).
887887
bindings.push(createTemplateBinding(
888888
unit, op.xref, input.type, input.name, astOf(input.value), input.unit,
889-
input.securityContext, false, false, templateKind, asMessage(input.i18n),
890-
input.sourceSpan));
889+
input.securityContext, false, templateKind, asMessage(input.i18n), input.sourceSpan));
891890
}
892891

893892
unit.create.push(bindings.filter(
@@ -905,7 +904,8 @@ function ingestTemplateBindings(
905904
makeListenerHandlerOps(unit, output.handler, output.handlerSpan), output.phase, false,
906905
output.sourceSpan));
907906
}
908-
if (templateKind === ir.TemplateKind.Structural && output.type === e.ParsedEventType.Regular) {
907+
if (templateKind === ir.TemplateKind.Structural &&
908+
output.type !== e.ParsedEventType.Animation) {
909909
// Animation bindings are excluded from the structural template's const array.
910910
unit.create.push(ir.createExtractedAttributeOp(
911911
op.xref, ir.BindingKind.Property, output.name, null, null, null));
@@ -938,24 +938,22 @@ function ingestTemplateBindings(
938938
* string literal if the parser considered it a text binding.
939939
* @param unit If the binding has a unit (e.g. `px` for style bindings), then this is the unit.
940940
* @param securityContext The security context of the binding.
941-
* @param isTextBinding Whether the binding is a text binding according to the parser (e.g. `<div
942-
* literal="foo">`). Even if this is false, the binding still might be an extractable constant
943-
* expression (see the later attribute extraction phase).
944941
* @param isStructuralTemplateAttribute Whether this binding actually applies to the structural
945942
* ng-template. For example, an `ngFor` would actually apply to the structural template. (Most
946943
* bindings on structural elements target the inner element, not the template.)
947944
* @param templateKind Whether this is an explicit `ng-template` or an implicit template created by
948-
* a structural directive.
945+
* a structural directive. This should never be a block template.
949946
* @param i18nMessage The i18n metadata for the binding, if any.
950947
* @param sourceSpan The source span of the binding.
951948
* @returns An IR binding op, or null if the binding should be skipped.
952949
*/
953950
function createTemplateBinding(
954951
view: ViewCompilationUnit, xref: ir.XrefId, type: e.BindingType, name: string,
955952
value: e.AST|string, unit: string|null, securityContext: SecurityContext,
956-
isTextBinding: boolean, isStructuralTemplateAttribute: boolean,
957-
templateKind: ir.TemplateKind|null, i18nMessage: i18n.Message|null,
958-
sourceSpan: ParseSourceSpan): ir.BindingOp|ir.ExtractedAttributeOp|null {
953+
isStructuralTemplateAttribute: boolean, templateKind: ir.TemplateKind|null,
954+
i18nMessage: i18n.Message|null, sourceSpan: ParseSourceSpan): ir.BindingOp|
955+
ir.ExtractedAttributeOp|null {
956+
const isTextBinding = typeof value === 'string';
959957
// If this is a structural template, then several kinds of bindings should not result in an
960958
// update instruction.
961959
if (templateKind === ir.TemplateKind.Structural) {

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.