@angular/compiler 14.0.0-next.2 → 14.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/src/render3/partial/class_metadata.mjs +1 -1
- package/esm2020/src/render3/partial/directive.mjs +1 -1
- package/esm2020/src/render3/partial/factory.mjs +1 -1
- package/esm2020/src/render3/partial/injectable.mjs +1 -1
- package/esm2020/src/render3/partial/injector.mjs +1 -1
- package/esm2020/src/render3/partial/ng_module.mjs +1 -1
- package/esm2020/src/render3/partial/pipe.mjs +1 -1
- package/esm2020/src/render3/view/compiler.mjs +40 -40
- package/esm2020/src/render3/view/template.mjs +78 -122
- package/esm2020/src/render3/view/util.mjs +94 -15
- package/esm2020/src/version.mjs +1 -1
- package/fesm2015/compiler.mjs +216 -181
- package/fesm2015/compiler.mjs.map +1 -1
- package/fesm2015/testing.mjs +1 -1
- package/fesm2020/compiler.mjs +216 -181
- package/fesm2020/compiler.mjs.map +1 -1
- package/fesm2020/testing.mjs +1 -1
- package/package.json +1 -1
- package/src/render3/view/template.d.ts +0 -3
- package/src/render3/view/util.d.ts +19 -2
package/fesm2015/compiler.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.0.0-next.
|
|
2
|
+
* @license Angular v14.0.0-next.3
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -4876,6 +4876,65 @@ const IMPLICIT_REFERENCE = '$implicit';
|
|
|
4876
4876
|
const NON_BINDABLE_ATTR = 'ngNonBindable';
|
|
4877
4877
|
/** Name for the variable keeping track of the context returned by `ɵɵrestoreView`. */
|
|
4878
4878
|
const RESTORED_VIEW_CONTEXT_NAME = 'restoredCtx';
|
|
4879
|
+
/** Instructions that support chaining. */
|
|
4880
|
+
const CHAINABLE_INSTRUCTIONS = new Set([
|
|
4881
|
+
Identifiers.element,
|
|
4882
|
+
Identifiers.elementStart,
|
|
4883
|
+
Identifiers.elementEnd,
|
|
4884
|
+
Identifiers.elementContainer,
|
|
4885
|
+
Identifiers.elementContainerStart,
|
|
4886
|
+
Identifiers.elementContainerEnd,
|
|
4887
|
+
Identifiers.i18nExp,
|
|
4888
|
+
Identifiers.listener,
|
|
4889
|
+
Identifiers.classProp,
|
|
4890
|
+
Identifiers.syntheticHostListener,
|
|
4891
|
+
Identifiers.hostProperty,
|
|
4892
|
+
Identifiers.syntheticHostProperty,
|
|
4893
|
+
Identifiers.property,
|
|
4894
|
+
Identifiers.propertyInterpolate1,
|
|
4895
|
+
Identifiers.propertyInterpolate2,
|
|
4896
|
+
Identifiers.propertyInterpolate3,
|
|
4897
|
+
Identifiers.propertyInterpolate4,
|
|
4898
|
+
Identifiers.propertyInterpolate5,
|
|
4899
|
+
Identifiers.propertyInterpolate6,
|
|
4900
|
+
Identifiers.propertyInterpolate7,
|
|
4901
|
+
Identifiers.propertyInterpolate8,
|
|
4902
|
+
Identifiers.propertyInterpolateV,
|
|
4903
|
+
Identifiers.attribute,
|
|
4904
|
+
Identifiers.attributeInterpolate1,
|
|
4905
|
+
Identifiers.attributeInterpolate2,
|
|
4906
|
+
Identifiers.attributeInterpolate3,
|
|
4907
|
+
Identifiers.attributeInterpolate4,
|
|
4908
|
+
Identifiers.attributeInterpolate5,
|
|
4909
|
+
Identifiers.attributeInterpolate6,
|
|
4910
|
+
Identifiers.attributeInterpolate7,
|
|
4911
|
+
Identifiers.attributeInterpolate8,
|
|
4912
|
+
Identifiers.attributeInterpolateV,
|
|
4913
|
+
Identifiers.styleProp,
|
|
4914
|
+
Identifiers.stylePropInterpolate1,
|
|
4915
|
+
Identifiers.stylePropInterpolate2,
|
|
4916
|
+
Identifiers.stylePropInterpolate3,
|
|
4917
|
+
Identifiers.stylePropInterpolate4,
|
|
4918
|
+
Identifiers.stylePropInterpolate5,
|
|
4919
|
+
Identifiers.stylePropInterpolate6,
|
|
4920
|
+
Identifiers.stylePropInterpolate7,
|
|
4921
|
+
Identifiers.stylePropInterpolate8,
|
|
4922
|
+
Identifiers.stylePropInterpolateV,
|
|
4923
|
+
Identifiers.textInterpolate,
|
|
4924
|
+
Identifiers.textInterpolate1,
|
|
4925
|
+
Identifiers.textInterpolate2,
|
|
4926
|
+
Identifiers.textInterpolate3,
|
|
4927
|
+
Identifiers.textInterpolate4,
|
|
4928
|
+
Identifiers.textInterpolate5,
|
|
4929
|
+
Identifiers.textInterpolate6,
|
|
4930
|
+
Identifiers.textInterpolate7,
|
|
4931
|
+
Identifiers.textInterpolate8,
|
|
4932
|
+
Identifiers.textInterpolateV,
|
|
4933
|
+
]);
|
|
4934
|
+
/** Generates a call to a single instruction. */
|
|
4935
|
+
function invokeInstruction(span, reference, params) {
|
|
4936
|
+
return importExpr(reference, null, span).callFn(params, span);
|
|
4937
|
+
}
|
|
4879
4938
|
/**
|
|
4880
4939
|
* Creates an allocator for a temporary variable.
|
|
4881
4940
|
*
|
|
@@ -5017,20 +5076,6 @@ function getAttrsForDirectiveMatching(elOrTpl) {
|
|
|
5017
5076
|
}
|
|
5018
5077
|
return attributesMap;
|
|
5019
5078
|
}
|
|
5020
|
-
/** Returns a call expression to a chained instruction, e.g. `property(params[0])(params[1])`. */
|
|
5021
|
-
function chainedInstruction(reference, calls, span) {
|
|
5022
|
-
let expression = importExpr(reference, null, span);
|
|
5023
|
-
if (calls.length > 0) {
|
|
5024
|
-
for (let i = 0; i < calls.length; i++) {
|
|
5025
|
-
expression = expression.callFn(calls[i], span);
|
|
5026
|
-
}
|
|
5027
|
-
}
|
|
5028
|
-
else {
|
|
5029
|
-
// Add a blank invocation, in case the `calls` array is empty.
|
|
5030
|
-
expression = expression.callFn([], span);
|
|
5031
|
-
}
|
|
5032
|
-
return expression;
|
|
5033
|
-
}
|
|
5034
5079
|
/**
|
|
5035
5080
|
* Gets the number of arguments expected to be passed to a generated instruction in the case of
|
|
5036
5081
|
* interpolation instructions.
|
|
@@ -5048,6 +5093,40 @@ function getInterpolationArgsLength(interpolation) {
|
|
|
5048
5093
|
return expressions.length + strings.length;
|
|
5049
5094
|
}
|
|
5050
5095
|
}
|
|
5096
|
+
/**
|
|
5097
|
+
* Generates the final instruction call statements based on the passed in configuration.
|
|
5098
|
+
* Will try to chain instructions as much as possible, if chaining is supported.
|
|
5099
|
+
*/
|
|
5100
|
+
function getInstructionStatements(instructions) {
|
|
5101
|
+
var _a;
|
|
5102
|
+
const statements = [];
|
|
5103
|
+
let pendingExpression = null;
|
|
5104
|
+
let pendingExpressionType = null;
|
|
5105
|
+
for (const current of instructions) {
|
|
5106
|
+
const resolvedParams = (_a = (typeof current.paramsOrFn === 'function' ? current.paramsOrFn() : current.paramsOrFn)) !== null && _a !== void 0 ? _a : [];
|
|
5107
|
+
const params = Array.isArray(resolvedParams) ? resolvedParams : [resolvedParams];
|
|
5108
|
+
// If the current instruction is the same as the previous one
|
|
5109
|
+
// and it can be chained, add another call to the chain.
|
|
5110
|
+
if (pendingExpressionType === current.reference &&
|
|
5111
|
+
CHAINABLE_INSTRUCTIONS.has(pendingExpressionType)) {
|
|
5112
|
+
// We'll always have a pending expression when there's a pending expression type.
|
|
5113
|
+
pendingExpression = pendingExpression.callFn(params, pendingExpression.sourceSpan);
|
|
5114
|
+
}
|
|
5115
|
+
else {
|
|
5116
|
+
if (pendingExpression !== null) {
|
|
5117
|
+
statements.push(pendingExpression.toStmt());
|
|
5118
|
+
}
|
|
5119
|
+
pendingExpression = invokeInstruction(current.span, current.reference, params);
|
|
5120
|
+
pendingExpressionType = current.reference;
|
|
5121
|
+
}
|
|
5122
|
+
}
|
|
5123
|
+
// Since the current instruction adds the previous one to the statements,
|
|
5124
|
+
// we may be left with the final one at the end that is still pending.
|
|
5125
|
+
if (pendingExpression !== null) {
|
|
5126
|
+
statements.push(pendingExpression.toStmt());
|
|
5127
|
+
}
|
|
5128
|
+
return statements;
|
|
5129
|
+
}
|
|
5051
5130
|
|
|
5052
5131
|
/**
|
|
5053
5132
|
* @license
|
|
@@ -16946,9 +17025,9 @@ class TemplateDefinitionBuilder {
|
|
|
16946
17025
|
this.i18nEnd(null, selfClosingI18nInstruction);
|
|
16947
17026
|
}
|
|
16948
17027
|
// Generate all the creation mode instructions (e.g. resolve bindings in listeners)
|
|
16949
|
-
const creationStatements = this._creationCodeFns
|
|
17028
|
+
const creationStatements = getInstructionStatements(this._creationCodeFns);
|
|
16950
17029
|
// Generate all the update mode instructions (e.g. resolve property or text bindings)
|
|
16951
|
-
const updateStatements = this._updateCodeFns
|
|
17030
|
+
const updateStatements = getInstructionStatements(this._updateCodeFns);
|
|
16952
17031
|
// Variable declaration must occur after binding resolution so we can generate context
|
|
16953
17032
|
// instructions that build on each other.
|
|
16954
17033
|
// e.g. const b = nextContext().$implicit(); const b = nextContext();
|
|
@@ -17101,7 +17180,7 @@ class TemplateDefinitionBuilder {
|
|
|
17101
17180
|
if (Object.keys(icuMapping).length) {
|
|
17102
17181
|
args.push(mapLiteral(icuMapping, true));
|
|
17103
17182
|
}
|
|
17104
|
-
return
|
|
17183
|
+
return invokeInstruction(null, Identifiers.i18nPostprocess, args);
|
|
17105
17184
|
};
|
|
17106
17185
|
}
|
|
17107
17186
|
this.i18nTranslate(meta, params, context.ref, transformFn);
|
|
@@ -17136,14 +17215,12 @@ class TemplateDefinitionBuilder {
|
|
|
17136
17215
|
// setup accumulated bindings
|
|
17137
17216
|
const { index, bindings } = this.i18n;
|
|
17138
17217
|
if (bindings.size) {
|
|
17139
|
-
const
|
|
17140
|
-
|
|
17141
|
-
|
|
17142
|
-
|
|
17143
|
-
|
|
17144
|
-
|
|
17145
|
-
// necessary lifecycle hooks of components/directives are properly flushed.
|
|
17146
|
-
this.updateInstructionChainWithAdvance(this.getConstCount() - 1, Identifiers.i18nExp, chainBindings);
|
|
17218
|
+
for (const binding of bindings) {
|
|
17219
|
+
// for i18n block, advance to the most recent element index (by taking the current number of
|
|
17220
|
+
// elements and subtracting one) before invoking `i18nExp` instructions, to make sure the
|
|
17221
|
+
// necessary lifecycle hooks of components/directives are properly flushed.
|
|
17222
|
+
this.updateInstructionWithAdvance(this.getConstCount() - 1, span, Identifiers.i18nExp, () => this.convertPropertyBinding(binding));
|
|
17223
|
+
}
|
|
17147
17224
|
this.updateInstruction(span, Identifiers.i18nApply, [literal(index)]);
|
|
17148
17225
|
}
|
|
17149
17226
|
if (!selfClosing) {
|
|
@@ -17154,7 +17231,6 @@ class TemplateDefinitionBuilder {
|
|
|
17154
17231
|
i18nAttributesInstruction(nodeIndex, attrs, sourceSpan) {
|
|
17155
17232
|
let hasBindings = false;
|
|
17156
17233
|
const i18nAttrArgs = [];
|
|
17157
|
-
const bindings = [];
|
|
17158
17234
|
attrs.forEach(attr => {
|
|
17159
17235
|
const message = attr.i18n;
|
|
17160
17236
|
const converted = attr.value.visit(this._valueConverter);
|
|
@@ -17165,16 +17241,10 @@ class TemplateDefinitionBuilder {
|
|
|
17165
17241
|
i18nAttrArgs.push(literal(attr.name), this.i18nTranslate(message, params));
|
|
17166
17242
|
converted.expressions.forEach(expression => {
|
|
17167
17243
|
hasBindings = true;
|
|
17168
|
-
|
|
17169
|
-
sourceSpan,
|
|
17170
|
-
value: () => this.convertPropertyBinding(expression),
|
|
17171
|
-
});
|
|
17244
|
+
this.updateInstructionWithAdvance(nodeIndex, sourceSpan, Identifiers.i18nExp, () => this.convertPropertyBinding(expression));
|
|
17172
17245
|
});
|
|
17173
17246
|
}
|
|
17174
17247
|
});
|
|
17175
|
-
if (bindings.length > 0) {
|
|
17176
|
-
this.updateInstructionChainWithAdvance(nodeIndex, Identifiers.i18nExp, bindings);
|
|
17177
|
-
}
|
|
17178
17248
|
if (i18nAttrArgs.length > 0) {
|
|
17179
17249
|
const index = literal(this.allocateDataSlot());
|
|
17180
17250
|
const constIndex = this.addToConsts(literalArr(i18nAttrArgs));
|
|
@@ -17303,11 +17373,9 @@ class TemplateDefinitionBuilder {
|
|
|
17303
17373
|
}
|
|
17304
17374
|
// Generate Listeners (outputs)
|
|
17305
17375
|
if (element.outputs.length > 0) {
|
|
17306
|
-
const
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
}));
|
|
17310
|
-
this.creationInstructionChain(Identifiers.listener, listeners);
|
|
17376
|
+
for (const outputAst of element.outputs) {
|
|
17377
|
+
this.creationInstruction(outputAst.sourceSpan, Identifiers.listener, this.prepareListenerParameter(element.name, outputAst, elementIndex));
|
|
17378
|
+
}
|
|
17311
17379
|
}
|
|
17312
17380
|
// Note: it's important to keep i18n/i18nStart instructions after i18nAttributes and
|
|
17313
17381
|
// listeners, to make sure i18nAttributes instruction targets current element at runtime.
|
|
@@ -17348,9 +17416,8 @@ class TemplateDefinitionBuilder {
|
|
|
17348
17416
|
const hasValue = value instanceof LiteralPrimitive ? !!value.value : true;
|
|
17349
17417
|
this.allocateBindingSlots(value);
|
|
17350
17418
|
propertyBindings.push({
|
|
17351
|
-
|
|
17352
|
-
|
|
17353
|
-
value: () => hasValue ? this.convertPropertyBinding(value) : emptyValueBindInstruction
|
|
17419
|
+
span: input.sourceSpan,
|
|
17420
|
+
paramsOrFn: getBindingFunctionParams(() => hasValue ? this.convertPropertyBinding(value) : emptyValueBindInstruction, prepareSyntheticPropertyName(input.name))
|
|
17354
17421
|
});
|
|
17355
17422
|
}
|
|
17356
17423
|
else {
|
|
@@ -17387,10 +17454,8 @@ class TemplateDefinitionBuilder {
|
|
|
17387
17454
|
// [prop]="value"
|
|
17388
17455
|
// Collect all the properties so that we can chain into a single function at the end.
|
|
17389
17456
|
propertyBindings.push({
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
value: () => this.convertPropertyBinding(value),
|
|
17393
|
-
params
|
|
17457
|
+
span: input.sourceSpan,
|
|
17458
|
+
paramsOrFn: getBindingFunctionParams(() => this.convertPropertyBinding(value), attrName, params)
|
|
17394
17459
|
});
|
|
17395
17460
|
}
|
|
17396
17461
|
}
|
|
@@ -17404,10 +17469,8 @@ class TemplateDefinitionBuilder {
|
|
|
17404
17469
|
// [attr.name]="value" or attr.name="{{value}}"
|
|
17405
17470
|
// Collect the attribute bindings so that they can be chained at the end.
|
|
17406
17471
|
attributeBindings.push({
|
|
17407
|
-
|
|
17408
|
-
|
|
17409
|
-
value: () => this.convertPropertyBinding(boundValue),
|
|
17410
|
-
params
|
|
17472
|
+
span: input.sourceSpan,
|
|
17473
|
+
paramsOrFn: getBindingFunctionParams(() => this.convertPropertyBinding(boundValue), attrName, params)
|
|
17411
17474
|
});
|
|
17412
17475
|
}
|
|
17413
17476
|
}
|
|
@@ -17423,11 +17486,11 @@ class TemplateDefinitionBuilder {
|
|
|
17423
17486
|
}
|
|
17424
17487
|
}
|
|
17425
17488
|
});
|
|
17426
|
-
|
|
17427
|
-
this.
|
|
17489
|
+
for (const propertyBinding of propertyBindings) {
|
|
17490
|
+
this.updateInstructionWithAdvance(elementIndex, propertyBinding.span, Identifiers.property, propertyBinding.paramsOrFn);
|
|
17428
17491
|
}
|
|
17429
|
-
|
|
17430
|
-
this.
|
|
17492
|
+
for (const attributeBinding of attributeBindings) {
|
|
17493
|
+
this.updateInstructionWithAdvance(elementIndex, attributeBinding.span, Identifiers.attribute, attributeBinding.paramsOrFn);
|
|
17431
17494
|
}
|
|
17432
17495
|
// Traverse element child nodes
|
|
17433
17496
|
visitAll$1(this, element.children);
|
|
@@ -17507,12 +17570,8 @@ class TemplateDefinitionBuilder {
|
|
|
17507
17570
|
this.templatePropertyBindings(templateIndex, inputs);
|
|
17508
17571
|
}
|
|
17509
17572
|
// Generate listeners for directive output
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
sourceSpan: outputAst.sourceSpan,
|
|
17513
|
-
params: this.prepareListenerParameter('ng_template', outputAst, templateIndex)
|
|
17514
|
-
}));
|
|
17515
|
-
this.creationInstructionChain(Identifiers.listener, listeners);
|
|
17573
|
+
for (const outputAst of template.outputs) {
|
|
17574
|
+
this.creationInstruction(outputAst.sourceSpan, Identifiers.listener, this.prepareListenerParameter('ng_template', outputAst, templateIndex));
|
|
17516
17575
|
}
|
|
17517
17576
|
}
|
|
17518
17577
|
}
|
|
@@ -17567,7 +17626,7 @@ class TemplateDefinitionBuilder {
|
|
|
17567
17626
|
const transformFn = (raw) => {
|
|
17568
17627
|
const params = Object.assign(Object.assign({}, vars), placeholders);
|
|
17569
17628
|
const formatted = i18nFormatPlaceholderNames(params, /* useCamelCase */ false);
|
|
17570
|
-
return
|
|
17629
|
+
return invokeInstruction(null, Identifiers.i18nPostprocess, [raw, mapLiteral(formatted, true)]);
|
|
17571
17630
|
};
|
|
17572
17631
|
// in case the whole i18n message is a single ICU - we do not need to
|
|
17573
17632
|
// create a separate top-level translation, we can use the root ref instead
|
|
@@ -17609,32 +17668,33 @@ class TemplateDefinitionBuilder {
|
|
|
17609
17668
|
}
|
|
17610
17669
|
templatePropertyBindings(templateIndex, attrs) {
|
|
17611
17670
|
const propertyBindings = [];
|
|
17612
|
-
|
|
17613
|
-
if (input instanceof BoundAttribute) {
|
|
17614
|
-
|
|
17615
|
-
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17671
|
+
for (const input of attrs) {
|
|
17672
|
+
if (!(input instanceof BoundAttribute)) {
|
|
17673
|
+
continue;
|
|
17674
|
+
}
|
|
17675
|
+
const value = input.value.visit(this._valueConverter);
|
|
17676
|
+
if (value === undefined) {
|
|
17677
|
+
continue;
|
|
17678
|
+
}
|
|
17679
|
+
this.allocateBindingSlots(value);
|
|
17680
|
+
if (value instanceof Interpolation) {
|
|
17681
|
+
// Params typically contain attribute namespace and value sanitizer, which is applicable
|
|
17682
|
+
// for regular HTML elements, but not applicable for <ng-template> (since props act as
|
|
17683
|
+
// inputs to directives), so keep params array empty.
|
|
17684
|
+
const params = [];
|
|
17685
|
+
// prop="{{value}}" case
|
|
17686
|
+
this.interpolatedUpdateInstruction(getPropertyInterpolationExpression(value), templateIndex, input.name, input, value, params);
|
|
17687
|
+
}
|
|
17688
|
+
else {
|
|
17689
|
+
// [prop]="value" case
|
|
17690
|
+
propertyBindings.push({
|
|
17691
|
+
span: input.sourceSpan,
|
|
17692
|
+
paramsOrFn: getBindingFunctionParams(() => this.convertPropertyBinding(value), input.name)
|
|
17693
|
+
});
|
|
17634
17694
|
}
|
|
17635
|
-
}
|
|
17636
|
-
|
|
17637
|
-
this.
|
|
17695
|
+
}
|
|
17696
|
+
for (const propertyBinding of propertyBindings) {
|
|
17697
|
+
this.updateInstructionWithAdvance(templateIndex, propertyBinding.span, Identifiers.property, propertyBinding.paramsOrFn);
|
|
17638
17698
|
}
|
|
17639
17699
|
}
|
|
17640
17700
|
// Bindings must only be resolved after all local refs have been visited, so all
|
|
@@ -17642,39 +17702,23 @@ class TemplateDefinitionBuilder {
|
|
|
17642
17702
|
// Otherwise, we wouldn't be able to support local refs that are defined after their
|
|
17643
17703
|
// bindings. e.g. {{ foo }} <div #foo></div>
|
|
17644
17704
|
instructionFn(fns, span, reference, paramsOrFn, prepend = false) {
|
|
17645
|
-
fns[prepend ? 'unshift' : 'push'](
|
|
17646
|
-
const params = Array.isArray(paramsOrFn) ? paramsOrFn : paramsOrFn();
|
|
17647
|
-
return instruction(span, reference, params).toStmt();
|
|
17648
|
-
});
|
|
17705
|
+
fns[prepend ? 'unshift' : 'push']({ span, reference, paramsOrFn });
|
|
17649
17706
|
}
|
|
17650
17707
|
processStylingUpdateInstruction(elementIndex, instruction) {
|
|
17651
17708
|
let allocateBindingSlots = 0;
|
|
17652
17709
|
if (instruction) {
|
|
17653
|
-
const calls
|
|
17654
|
-
instruction.calls.forEach(call => {
|
|
17710
|
+
for (const call of instruction.calls) {
|
|
17655
17711
|
allocateBindingSlots += call.allocateBindingSlots;
|
|
17656
|
-
|
|
17657
|
-
|
|
17658
|
-
value
|
|
17659
|
-
|
|
17660
|
-
this.getUpdateInstructionArguments(value) :
|
|
17661
|
-
this.convertPropertyBinding(value));
|
|
17662
|
-
}
|
|
17663
|
-
});
|
|
17664
|
-
});
|
|
17665
|
-
this.updateInstructionChainWithAdvance(elementIndex, instruction.reference, calls);
|
|
17712
|
+
this.updateInstructionWithAdvance(elementIndex, call.sourceSpan, instruction.reference, () => call.params(value => (call.supportsInterpolation && value instanceof Interpolation) ?
|
|
17713
|
+
this.getUpdateInstructionArguments(value) :
|
|
17714
|
+
this.convertPropertyBinding(value)));
|
|
17715
|
+
}
|
|
17666
17716
|
}
|
|
17667
17717
|
return allocateBindingSlots;
|
|
17668
17718
|
}
|
|
17669
17719
|
creationInstruction(span, reference, paramsOrFn, prepend) {
|
|
17670
17720
|
this.instructionFn(this._creationCodeFns, span, reference, paramsOrFn || [], prepend);
|
|
17671
17721
|
}
|
|
17672
|
-
creationInstructionChain(reference, calls) {
|
|
17673
|
-
const span = calls.length ? calls[0].sourceSpan : null;
|
|
17674
|
-
this._creationCodeFns.push(() => {
|
|
17675
|
-
return chainedInstruction(reference, calls.map(call => call.params()), span).toStmt();
|
|
17676
|
-
});
|
|
17677
|
-
}
|
|
17678
17722
|
updateInstructionWithAdvance(nodeIndex, span, reference, paramsOrFn) {
|
|
17679
17723
|
this.addAdvanceInstructionIfNecessary(nodeIndex, span);
|
|
17680
17724
|
this.updateInstruction(span, reference, paramsOrFn);
|
|
@@ -17682,28 +17726,6 @@ class TemplateDefinitionBuilder {
|
|
|
17682
17726
|
updateInstruction(span, reference, paramsOrFn) {
|
|
17683
17727
|
this.instructionFn(this._updateCodeFns, span, reference, paramsOrFn || []);
|
|
17684
17728
|
}
|
|
17685
|
-
updateInstructionChain(reference, bindings) {
|
|
17686
|
-
const span = bindings.length ? bindings[0].sourceSpan : null;
|
|
17687
|
-
this._updateCodeFns.push(() => {
|
|
17688
|
-
const calls = bindings.map(property => {
|
|
17689
|
-
const value = property.value();
|
|
17690
|
-
const fnParams = Array.isArray(value) ? value : [value];
|
|
17691
|
-
if (property.params) {
|
|
17692
|
-
fnParams.push(...property.params);
|
|
17693
|
-
}
|
|
17694
|
-
if (property.name) {
|
|
17695
|
-
// We want the property name to always be the first function parameter.
|
|
17696
|
-
fnParams.unshift(literal(property.name));
|
|
17697
|
-
}
|
|
17698
|
-
return fnParams;
|
|
17699
|
-
});
|
|
17700
|
-
return chainedInstruction(reference, calls, span).toStmt();
|
|
17701
|
-
});
|
|
17702
|
-
}
|
|
17703
|
-
updateInstructionChainWithAdvance(nodeIndex, reference, bindings) {
|
|
17704
|
-
this.addAdvanceInstructionIfNecessary(nodeIndex, bindings.length ? bindings[0].sourceSpan : null);
|
|
17705
|
-
this.updateInstructionChain(reference, bindings);
|
|
17706
|
-
}
|
|
17707
17729
|
addAdvanceInstructionIfNecessary(nodeIndex, span) {
|
|
17708
17730
|
if (nodeIndex !== this._currentIndex) {
|
|
17709
17731
|
const delta = nodeIndex - this._currentIndex;
|
|
@@ -17989,9 +18011,6 @@ function pureFunctionCallInfo(args) {
|
|
|
17989
18011
|
isVarLength: !identifier,
|
|
17990
18012
|
};
|
|
17991
18013
|
}
|
|
17992
|
-
function instruction(span, reference, params) {
|
|
17993
|
-
return importExpr(reference, null, span).callFn(params, span);
|
|
17994
|
-
}
|
|
17995
18014
|
// e.g. x(2);
|
|
17996
18015
|
function generateNextContextExpr(relativeLevelDiff) {
|
|
17997
18016
|
return importExpr(Identifiers.nextContext)
|
|
@@ -18196,7 +18215,7 @@ class BindingScope {
|
|
|
18196
18215
|
restoreViewStatement() {
|
|
18197
18216
|
const statements = [];
|
|
18198
18217
|
if (this.restoreViewVariable) {
|
|
18199
|
-
const restoreCall =
|
|
18218
|
+
const restoreCall = invokeInstruction(null, Identifiers.restoreView, [this.restoreViewVariable]);
|
|
18200
18219
|
// Either `const restoredCtx = restoreView($state$);` or `restoreView($state$);`
|
|
18201
18220
|
// depending on whether it is being used.
|
|
18202
18221
|
statements.push(this.usesRestoredViewContext ?
|
|
@@ -18208,7 +18227,9 @@ class BindingScope {
|
|
|
18208
18227
|
viewSnapshotStatements() {
|
|
18209
18228
|
// const $state$ = getCurrentView();
|
|
18210
18229
|
return this.restoreViewVariable ?
|
|
18211
|
-
[
|
|
18230
|
+
[
|
|
18231
|
+
this.restoreViewVariable.set(invokeInstruction(null, Identifiers.getCurrentView, [])).toConstDecl()
|
|
18232
|
+
] :
|
|
18212
18233
|
[];
|
|
18213
18234
|
}
|
|
18214
18235
|
isListenerScope() {
|
|
@@ -18481,6 +18502,20 @@ function isTextNode(node) {
|
|
|
18481
18502
|
function hasTextChildrenOnly(children) {
|
|
18482
18503
|
return children.every(isTextNode);
|
|
18483
18504
|
}
|
|
18505
|
+
function getBindingFunctionParams(deferredParams, name, eagerParams) {
|
|
18506
|
+
return () => {
|
|
18507
|
+
const value = deferredParams();
|
|
18508
|
+
const fnParams = Array.isArray(value) ? value : [value];
|
|
18509
|
+
if (eagerParams) {
|
|
18510
|
+
fnParams.push(...eagerParams);
|
|
18511
|
+
}
|
|
18512
|
+
if (name) {
|
|
18513
|
+
// We want the property name to always be the first function parameter.
|
|
18514
|
+
fnParams.unshift(literal(name));
|
|
18515
|
+
}
|
|
18516
|
+
return fnParams;
|
|
18517
|
+
};
|
|
18518
|
+
}
|
|
18484
18519
|
/** Name of the global variable that is used to determine if we use Closure translations or not */
|
|
18485
18520
|
const NG_I18N_CLOSURE_MODE = 'ngI18nClosureMode';
|
|
18486
18521
|
/**
|
|
@@ -18862,14 +18897,14 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
18862
18897
|
if (classAttr !== undefined) {
|
|
18863
18898
|
styleBuilder.registerClassAttr(classAttr);
|
|
18864
18899
|
}
|
|
18865
|
-
const
|
|
18866
|
-
const
|
|
18900
|
+
const createInstructions = [];
|
|
18901
|
+
const updateInstructions = [];
|
|
18902
|
+
const updateVariables = [];
|
|
18867
18903
|
const hostBindingSourceSpan = typeSourceSpan;
|
|
18868
18904
|
// Calculate host event bindings
|
|
18869
18905
|
const eventBindings = bindingParser.createDirectiveHostEventAsts(hostBindingsMetadata.listeners, hostBindingSourceSpan);
|
|
18870
18906
|
if (eventBindings && eventBindings.length) {
|
|
18871
|
-
|
|
18872
|
-
createStatements.push(...listeners);
|
|
18907
|
+
createInstructions.push(...createHostListeners(eventBindings, name));
|
|
18873
18908
|
}
|
|
18874
18909
|
// Calculate the host property bindings
|
|
18875
18910
|
const bindings = bindingParser.createBoundHostProperties(hostBindingsMetadata.properties, hostBindingSourceSpan);
|
|
@@ -18905,7 +18940,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
18905
18940
|
const propertyBindings = [];
|
|
18906
18941
|
const attributeBindings = [];
|
|
18907
18942
|
const syntheticHostBindings = [];
|
|
18908
|
-
|
|
18943
|
+
for (const binding of allOtherBindings) {
|
|
18909
18944
|
// resolve literal arrays and literal objects
|
|
18910
18945
|
const value = binding.expression.visit(getValueConverter());
|
|
18911
18946
|
const bindingExpr = bindingFn(bindingContext, value);
|
|
@@ -18931,7 +18966,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
18931
18966
|
if (sanitizerFn) {
|
|
18932
18967
|
instructionParams.push(sanitizerFn);
|
|
18933
18968
|
}
|
|
18934
|
-
|
|
18969
|
+
updateVariables.push(...bindingExpr.stmts);
|
|
18935
18970
|
if (instruction === Identifiers.hostProperty) {
|
|
18936
18971
|
propertyBindings.push(instructionParams);
|
|
18937
18972
|
}
|
|
@@ -18942,17 +18977,17 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
18942
18977
|
syntheticHostBindings.push(instructionParams);
|
|
18943
18978
|
}
|
|
18944
18979
|
else {
|
|
18945
|
-
|
|
18980
|
+
updateInstructions.push({ reference: instruction, paramsOrFn: instructionParams, span: null });
|
|
18946
18981
|
}
|
|
18947
|
-
});
|
|
18948
|
-
if (propertyBindings.length > 0) {
|
|
18949
|
-
updateStatements.push(chainedInstruction(Identifiers.hostProperty, propertyBindings).toStmt());
|
|
18950
18982
|
}
|
|
18951
|
-
|
|
18952
|
-
|
|
18983
|
+
for (const bindingParams of propertyBindings) {
|
|
18984
|
+
updateInstructions.push({ reference: Identifiers.hostProperty, paramsOrFn: bindingParams, span: null });
|
|
18985
|
+
}
|
|
18986
|
+
for (const bindingParams of attributeBindings) {
|
|
18987
|
+
updateInstructions.push({ reference: Identifiers.attribute, paramsOrFn: bindingParams, span: null });
|
|
18953
18988
|
}
|
|
18954
|
-
|
|
18955
|
-
|
|
18989
|
+
for (const bindingParams of syntheticHostBindings) {
|
|
18990
|
+
updateInstructions.push({ reference: Identifiers.syntheticHostProperty, paramsOrFn: bindingParams, span: null });
|
|
18956
18991
|
}
|
|
18957
18992
|
// since we're dealing with directives/components and both have hostBinding
|
|
18958
18993
|
// functions, we need to generate a special hostAttrs instruction that deals
|
|
@@ -18968,30 +19003,30 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
18968
19003
|
// the update block of a component/directive templateFn/hostBindingsFn so that the bindings
|
|
18969
19004
|
// are evaluated and updated for the element.
|
|
18970
19005
|
styleBuilder.buildUpdateLevelInstructions(getValueConverter()).forEach(instruction => {
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
|
|
18978
|
-
|
|
19006
|
+
for (const call of instruction.calls) {
|
|
19007
|
+
// we subtract a value of `1` here because the binding slot was already allocated
|
|
19008
|
+
// at the top of this method when all the input bindings were counted.
|
|
19009
|
+
totalHostVarsCount +=
|
|
19010
|
+
Math.max(call.allocateBindingSlots - MIN_STYLING_BINDING_SLOTS_REQUIRED, 0);
|
|
19011
|
+
updateInstructions.push({
|
|
19012
|
+
reference: instruction.reference,
|
|
19013
|
+
paramsOrFn: convertStylingCall(call, bindingContext, bindingFn),
|
|
19014
|
+
span: null
|
|
18979
19015
|
});
|
|
18980
|
-
updateStatements.push(chainedInstruction(instruction.reference, calls).toStmt());
|
|
18981
19016
|
}
|
|
18982
19017
|
});
|
|
18983
19018
|
}
|
|
18984
19019
|
if (totalHostVarsCount) {
|
|
18985
19020
|
definitionMap.set('hostVars', literal(totalHostVarsCount));
|
|
18986
19021
|
}
|
|
18987
|
-
if (
|
|
19022
|
+
if (createInstructions.length > 0 || updateInstructions.length > 0) {
|
|
18988
19023
|
const hostBindingsFnName = name ? `${name}_HostBindings` : null;
|
|
18989
19024
|
const statements = [];
|
|
18990
|
-
if (
|
|
18991
|
-
statements.push(renderFlagCheckIfStmt(1 /* Create */,
|
|
19025
|
+
if (createInstructions.length > 0) {
|
|
19026
|
+
statements.push(renderFlagCheckIfStmt(1 /* Create */, getInstructionStatements(createInstructions)));
|
|
18992
19027
|
}
|
|
18993
|
-
if (
|
|
18994
|
-
statements.push(renderFlagCheckIfStmt(2 /* Update */,
|
|
19028
|
+
if (updateInstructions.length > 0) {
|
|
19029
|
+
statements.push(renderFlagCheckIfStmt(2 /* Update */, updateVariables.concat(getInstructionStatements(updateInstructions))));
|
|
18995
19030
|
}
|
|
18996
19031
|
return fn([new FnParam(RENDER_FLAGS, NUMBER_TYPE), new FnParam(CONTEXT_NAME, null)], statements, INFERRED_TYPE, null, hostBindingsFnName);
|
|
18997
19032
|
}
|
|
@@ -19027,10 +19062,10 @@ function getBindingNameAndInstruction(binding) {
|
|
|
19027
19062
|
return { bindingName, instruction, isAttribute: !!attrMatches };
|
|
19028
19063
|
}
|
|
19029
19064
|
function createHostListeners(eventBindings, name) {
|
|
19030
|
-
const
|
|
19031
|
-
const
|
|
19065
|
+
const listenerParams = [];
|
|
19066
|
+
const syntheticListenerParams = [];
|
|
19032
19067
|
const instructions = [];
|
|
19033
|
-
|
|
19068
|
+
for (const binding of eventBindings) {
|
|
19034
19069
|
let bindingName = binding.name && sanitizeIdentifier(binding.name);
|
|
19035
19070
|
const bindingFnName = binding.type === 1 /* Animation */ ?
|
|
19036
19071
|
prepareSyntheticListenerFunctionName(bindingName, binding.targetOrPhase) :
|
|
@@ -19038,17 +19073,17 @@ function createHostListeners(eventBindings, name) {
|
|
|
19038
19073
|
const handlerName = name && bindingName ? `${name}_${bindingFnName}_HostBindingHandler` : null;
|
|
19039
19074
|
const params = prepareEventListenerParameters(BoundEvent.fromParsedEvent(binding), handlerName);
|
|
19040
19075
|
if (binding.type == 1 /* Animation */) {
|
|
19041
|
-
|
|
19076
|
+
syntheticListenerParams.push(params);
|
|
19042
19077
|
}
|
|
19043
19078
|
else {
|
|
19044
|
-
|
|
19079
|
+
listenerParams.push(params);
|
|
19045
19080
|
}
|
|
19046
|
-
});
|
|
19047
|
-
if (syntheticListeners.length > 0) {
|
|
19048
|
-
instructions.push(chainedInstruction(Identifiers.syntheticHostListener, syntheticListeners).toStmt());
|
|
19049
19081
|
}
|
|
19050
|
-
|
|
19051
|
-
instructions.push(
|
|
19082
|
+
for (const params of syntheticListenerParams) {
|
|
19083
|
+
instructions.push({ reference: Identifiers.syntheticHostListener, paramsOrFn: params, span: null });
|
|
19084
|
+
}
|
|
19085
|
+
for (const params of listenerParams) {
|
|
19086
|
+
instructions.push({ reference: Identifiers.listener, paramsOrFn: params, span: null });
|
|
19052
19087
|
}
|
|
19053
19088
|
return instructions;
|
|
19054
19089
|
}
|
|
@@ -19600,7 +19635,7 @@ function publishFacade(global) {
|
|
|
19600
19635
|
* Use of this source code is governed by an MIT-style license that can be
|
|
19601
19636
|
* found in the LICENSE file at https://angular.io/license
|
|
19602
19637
|
*/
|
|
19603
|
-
const VERSION = new Version('14.0.0-next.
|
|
19638
|
+
const VERSION = new Version('14.0.0-next.3');
|
|
19604
19639
|
|
|
19605
19640
|
/**
|
|
19606
19641
|
* @license
|
|
@@ -21627,7 +21662,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
|
|
|
21627
21662
|
function compileDeclareClassMetadata(metadata) {
|
|
21628
21663
|
const definitionMap = new DefinitionMap();
|
|
21629
21664
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
21630
|
-
definitionMap.set('version', literal('14.0.0-next.
|
|
21665
|
+
definitionMap.set('version', literal('14.0.0-next.3'));
|
|
21631
21666
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21632
21667
|
definitionMap.set('type', metadata.type);
|
|
21633
21668
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -21744,7 +21779,7 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
21744
21779
|
function createDirectiveDefinitionMap(meta) {
|
|
21745
21780
|
const definitionMap = new DefinitionMap();
|
|
21746
21781
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
21747
|
-
definitionMap.set('version', literal('14.0.0-next.
|
|
21782
|
+
definitionMap.set('version', literal('14.0.0-next.3'));
|
|
21748
21783
|
// e.g. `type: MyDirective`
|
|
21749
21784
|
definitionMap.set('type', meta.internalType);
|
|
21750
21785
|
// e.g. `selector: 'some-dir'`
|
|
@@ -21965,7 +22000,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
21965
22000
|
function compileDeclareFactoryFunction(meta) {
|
|
21966
22001
|
const definitionMap = new DefinitionMap();
|
|
21967
22002
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
21968
|
-
definitionMap.set('version', literal('14.0.0-next.
|
|
22003
|
+
definitionMap.set('version', literal('14.0.0-next.3'));
|
|
21969
22004
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
21970
22005
|
definitionMap.set('type', meta.internalType);
|
|
21971
22006
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -22007,7 +22042,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
22007
22042
|
function createInjectableDefinitionMap(meta) {
|
|
22008
22043
|
const definitionMap = new DefinitionMap();
|
|
22009
22044
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
22010
|
-
definitionMap.set('version', literal('14.0.0-next.
|
|
22045
|
+
definitionMap.set('version', literal('14.0.0-next.3'));
|
|
22011
22046
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22012
22047
|
definitionMap.set('type', meta.internalType);
|
|
22013
22048
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -22065,7 +22100,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
22065
22100
|
function createInjectorDefinitionMap(meta) {
|
|
22066
22101
|
const definitionMap = new DefinitionMap();
|
|
22067
22102
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
22068
|
-
definitionMap.set('version', literal('14.0.0-next.
|
|
22103
|
+
definitionMap.set('version', literal('14.0.0-next.3'));
|
|
22069
22104
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22070
22105
|
definitionMap.set('type', meta.internalType);
|
|
22071
22106
|
definitionMap.set('providers', meta.providers);
|
|
@@ -22102,7 +22137,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
|
|
|
22102
22137
|
function createNgModuleDefinitionMap(meta) {
|
|
22103
22138
|
const definitionMap = new DefinitionMap();
|
|
22104
22139
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
22105
|
-
definitionMap.set('version', literal('14.0.0-next.
|
|
22140
|
+
definitionMap.set('version', literal('14.0.0-next.3'));
|
|
22106
22141
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22107
22142
|
definitionMap.set('type', meta.internalType);
|
|
22108
22143
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -22160,7 +22195,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
22160
22195
|
function createPipeDefinitionMap(meta) {
|
|
22161
22196
|
const definitionMap = new DefinitionMap();
|
|
22162
22197
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
22163
|
-
definitionMap.set('version', literal('14.0.0-next.
|
|
22198
|
+
definitionMap.set('version', literal('14.0.0-next.3'));
|
|
22164
22199
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
22165
22200
|
// e.g. `type: MyPipe`
|
|
22166
22201
|
definitionMap.set('type', meta.internalType);
|