@angular/core 14.0.0-rc.2 → 14.0.0-rc.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/di/injector_compatibility.mjs +57 -15
- package/esm2020/src/errors.mjs +1 -1
- package/esm2020/src/metadata/directives.mjs +1 -1
- package/esm2020/src/render3/definition.mjs +3 -3
- package/esm2020/src/render3/instructions/element.mjs +11 -10
- package/esm2020/src/render3/instructions/shared.mjs +82 -11
- package/esm2020/src/version.mjs +1 -1
- package/esm2020/testing/src/logger.mjs +3 -3
- package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
- package/esm2020/testing/src/test_bed.mjs +5 -2
- package/fesm2015/core.mjs +152 -37
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +156 -38
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +151 -37
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +155 -38
- package/fesm2020/testing.mjs.map +1 -1
- package/index.d.ts +33 -27
- package/package.json +1 -1
- package/testing/index.d.ts +5 -2
package/fesm2020/core.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.0.0-rc.
|
|
2
|
+
* @license Angular v14.0.0-rc.3
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -954,8 +954,8 @@ function ɵɵdefineComponent(componentDefinition) {
|
|
|
954
954
|
*/
|
|
955
955
|
function ɵɵsetComponentScope(type, directives, pipes) {
|
|
956
956
|
const def = type.ɵcmp;
|
|
957
|
-
def.directiveDefs = () => directives.map(extractDirectiveDef);
|
|
958
|
-
def.pipeDefs = () => pipes.map(getPipeDef$1);
|
|
957
|
+
def.directiveDefs = () => (typeof directives === 'function' ? directives() : directives).map(extractDirectiveDef);
|
|
958
|
+
def.pipeDefs = () => (typeof pipes === 'function' ? pipes() : pipes).map(getPipeDef$1);
|
|
959
959
|
}
|
|
960
960
|
function extractDirectiveDef(type) {
|
|
961
961
|
return getComponentDef(type) || getDirectiveDef(type);
|
|
@@ -4858,9 +4858,9 @@ function setCurrentInjector(injector) {
|
|
|
4858
4858
|
function injectInjectorOnly(token, flags = InjectFlags.Default) {
|
|
4859
4859
|
if (_currentInjector === undefined) {
|
|
4860
4860
|
const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
|
|
4861
|
-
`inject() must be called from an injection context` :
|
|
4861
|
+
`inject() must be called from an injection context (a constructor, a factory function or a field initializer)` :
|
|
4862
4862
|
'';
|
|
4863
|
-
throw new RuntimeError(203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, errorMessage);
|
|
4863
|
+
throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, errorMessage);
|
|
4864
4864
|
}
|
|
4865
4865
|
else if (_currentInjector === null) {
|
|
4866
4866
|
return injectRootLimpMode(token, undefined, flags);
|
|
@@ -4895,29 +4895,71 @@ Please check that 1) the type for the parameter at index ${index} is correct and
|
|
|
4895
4895
|
}
|
|
4896
4896
|
/**
|
|
4897
4897
|
* Injects a token from the currently active injector.
|
|
4898
|
-
*
|
|
4899
|
-
*
|
|
4900
|
-
* `
|
|
4901
|
-
*
|
|
4902
|
-
*
|
|
4903
|
-
*
|
|
4904
|
-
*
|
|
4905
|
-
*
|
|
4906
|
-
* @param token
|
|
4898
|
+
* `inject` is only supported during instantiation of a dependency by the DI system. It can be used
|
|
4899
|
+
* during:
|
|
4900
|
+
* - Construction (via the `constructor`) of a class being instantiated by the DI system, such
|
|
4901
|
+
* as an `@Injectable` or `@Component`.
|
|
4902
|
+
* - In the initializer for fields of such classes.
|
|
4903
|
+
* - In the factory function specified for `useFactory` of a `Provider` or an `@Injectable`.
|
|
4904
|
+
* - In the `factory` function specified for an `InjectionToken`.
|
|
4905
|
+
*
|
|
4906
|
+
* @param token A token that represents a dependency that should be injected.
|
|
4907
4907
|
* @param flags Optional flags that control how injection is executed.
|
|
4908
4908
|
* The flags correspond to injection strategies that can be specified with
|
|
4909
4909
|
* parameter decorators `@Host`, `@Self`, `@SkipSef`, and `@Optional`.
|
|
4910
|
-
* @returns the injected value if
|
|
4910
|
+
* @returns the injected value if operation is successful, `null` otherwise.
|
|
4911
|
+
* @throws if called outside of a supported context.
|
|
4911
4912
|
*
|
|
4912
4913
|
* @usageNotes
|
|
4914
|
+
* In practice the `inject()` calls are allowed in a constructor, a constructor parameter and a
|
|
4915
|
+
* field initializer:
|
|
4913
4916
|
*
|
|
4914
|
-
*
|
|
4917
|
+
* ```typescript
|
|
4918
|
+
* @Injectable({providedIn: 'root'})
|
|
4919
|
+
* export class Car {
|
|
4920
|
+
* radio: Radio|undefined;
|
|
4921
|
+
* // OK: field initializer
|
|
4922
|
+
* spareTyre = inject(Tyre);
|
|
4915
4923
|
*
|
|
4916
|
-
* {
|
|
4924
|
+
* constructor() {
|
|
4925
|
+
* // OK: constructor body
|
|
4926
|
+
* this.radio = inject(Radio);
|
|
4927
|
+
* }
|
|
4928
|
+
* }
|
|
4929
|
+
* ```
|
|
4930
|
+
*
|
|
4931
|
+
* It is also legal to call `inject` from a provider's factory:
|
|
4932
|
+
*
|
|
4933
|
+
* ```typescript
|
|
4934
|
+
* providers: [
|
|
4935
|
+
* {provide: Car, useFactory: () => {
|
|
4936
|
+
* // OK: a class factory
|
|
4937
|
+
* const engine = inject(Engine);
|
|
4938
|
+
* return new Car(engine);
|
|
4939
|
+
* }}
|
|
4940
|
+
* ]
|
|
4941
|
+
* ```
|
|
4942
|
+
*
|
|
4943
|
+
* Calls to the `inject()` function outside of the class creation context will result in error. Most
|
|
4944
|
+
* notably, calls to `inject()` are disallowed after a class instance was created, in methods
|
|
4945
|
+
* (including lifecycle hooks):
|
|
4946
|
+
*
|
|
4947
|
+
* ```typescript
|
|
4948
|
+
* @Component({ ... })
|
|
4949
|
+
* export class CarComponent {
|
|
4950
|
+
* ngOnInit() {
|
|
4951
|
+
* // ERROR: too late, the component instance was already created
|
|
4952
|
+
* const engine = inject(Engine);
|
|
4953
|
+
* engine.start();
|
|
4954
|
+
* }
|
|
4955
|
+
* }
|
|
4956
|
+
* ```
|
|
4917
4957
|
*
|
|
4918
4958
|
* @publicApi
|
|
4919
4959
|
*/
|
|
4920
|
-
|
|
4960
|
+
function inject(token, flags = InjectFlags.Default) {
|
|
4961
|
+
return ɵɵinject(token, flags);
|
|
4962
|
+
}
|
|
4921
4963
|
function injectArgs(types) {
|
|
4922
4964
|
const args = [];
|
|
4923
4965
|
for (let i = 0; i < types.length; i++) {
|
|
@@ -11369,20 +11411,54 @@ function createTNodeAtIndex(tView, index, type, name, attrs) {
|
|
|
11369
11411
|
return tNode;
|
|
11370
11412
|
}
|
|
11371
11413
|
/**
|
|
11372
|
-
*
|
|
11414
|
+
* WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
|
|
11415
|
+
* and must **not** be used in production bundles. The function makes megamorphic reads, which might
|
|
11416
|
+
* be too slow for production mode and also it relies on the constructor function being available.
|
|
11417
|
+
*
|
|
11418
|
+
* Gets a reference to the host component def (where a current component is declared).
|
|
11373
11419
|
*
|
|
11374
11420
|
* @param lView An `LView` that represents a current component that is being rendered.
|
|
11375
11421
|
*/
|
|
11376
|
-
function
|
|
11422
|
+
function getDeclarationComponentDef(lView) {
|
|
11377
11423
|
!ngDevMode && throwError('Must never be called in production mode');
|
|
11378
11424
|
const declarationLView = lView[DECLARATION_COMPONENT_VIEW];
|
|
11379
11425
|
const context = declarationLView[CONTEXT];
|
|
11380
|
-
// Unable to obtain a context
|
|
11426
|
+
// Unable to obtain a context.
|
|
11381
11427
|
if (!context)
|
|
11382
|
-
return
|
|
11383
|
-
|
|
11428
|
+
return null;
|
|
11429
|
+
return context.constructor ? getComponentDef(context.constructor) : null;
|
|
11430
|
+
}
|
|
11431
|
+
/**
|
|
11432
|
+
* WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
|
|
11433
|
+
* and must **not** be used in production bundles. The function makes megamorphic reads, which might
|
|
11434
|
+
* be too slow for production mode.
|
|
11435
|
+
*
|
|
11436
|
+
* Checks if the current component is declared inside of a standalone component template.
|
|
11437
|
+
*
|
|
11438
|
+
* @param lView An `LView` that represents a current component that is being rendered.
|
|
11439
|
+
*/
|
|
11440
|
+
function isHostComponentStandalone(lView) {
|
|
11441
|
+
!ngDevMode && throwError('Must never be called in production mode');
|
|
11442
|
+
const componentDef = getDeclarationComponentDef(lView);
|
|
11443
|
+
// Treat host component as non-standalone if we can't obtain the def.
|
|
11384
11444
|
return !!(componentDef?.standalone);
|
|
11385
11445
|
}
|
|
11446
|
+
/**
|
|
11447
|
+
* WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
|
|
11448
|
+
* and must **not** be used in production bundles. The function makes megamorphic reads, which might
|
|
11449
|
+
* be too slow for production mode.
|
|
11450
|
+
*
|
|
11451
|
+
* Constructs a string describing the location of the host component template. The function is used
|
|
11452
|
+
* in dev mode to produce error messages.
|
|
11453
|
+
*
|
|
11454
|
+
* @param lView An `LView` that represents a current component that is being rendered.
|
|
11455
|
+
*/
|
|
11456
|
+
function getTemplateLocationDetails(lView) {
|
|
11457
|
+
!ngDevMode && throwError('Must never be called in production mode');
|
|
11458
|
+
const hostComponentDef = getDeclarationComponentDef(lView);
|
|
11459
|
+
const componentClassName = hostComponentDef?.type?.name;
|
|
11460
|
+
return componentClassName ? ` (used in the '${componentClassName}' component template)` : '';
|
|
11461
|
+
}
|
|
11386
11462
|
/**
|
|
11387
11463
|
* When elements are created dynamically after a view blueprint is created (e.g. through
|
|
11388
11464
|
* i18nApply()), we need to adjust the blueprint for future
|
|
@@ -12051,7 +12127,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
|
|
|
12051
12127
|
validateAgainstEventProperties(propName);
|
|
12052
12128
|
if (!validateProperty(element, tNode.value, propName, tView.schemas)) {
|
|
12053
12129
|
// Return here since we only log warnings for unknown properties.
|
|
12054
|
-
handleUnknownPropertyError(propName, tNode);
|
|
12130
|
+
handleUnknownPropertyError(propName, tNode, lView);
|
|
12055
12131
|
return;
|
|
12056
12132
|
}
|
|
12057
12133
|
ngDevMode.rendererSetProperty++;
|
|
@@ -12071,7 +12147,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
|
|
|
12071
12147
|
// If the node is a container and the property didn't
|
|
12072
12148
|
// match any of the inputs or schemas we should throw.
|
|
12073
12149
|
if (ngDevMode && !matchingSchemas(tView.schemas, tNode.value)) {
|
|
12074
|
-
handleUnknownPropertyError(propName, tNode);
|
|
12150
|
+
handleUnknownPropertyError(propName, tNode, lView);
|
|
12075
12151
|
}
|
|
12076
12152
|
}
|
|
12077
12153
|
}
|
|
@@ -12172,12 +12248,20 @@ function matchingSchemas(schemas, tagName) {
|
|
|
12172
12248
|
}
|
|
12173
12249
|
return false;
|
|
12174
12250
|
}
|
|
12251
|
+
/**
|
|
12252
|
+
* The set of known control flow directives.
|
|
12253
|
+
* We use this set to produce a more precises error message with a note
|
|
12254
|
+
* that the `CommonModule` should also be included.
|
|
12255
|
+
*/
|
|
12256
|
+
const KNOWN_CONTROL_FLOW_DIRECTIVES = new Set(['ngIf', 'ngFor', 'ngSwitch', 'ngSwitchCase', 'ngSwitchDefault']);
|
|
12175
12257
|
/**
|
|
12176
12258
|
* Logs or throws an error that a property is not supported on an element.
|
|
12259
|
+
*
|
|
12177
12260
|
* @param propName Name of the invalid property.
|
|
12178
|
-
* @param
|
|
12261
|
+
* @param tNode A `TNode` that represents a current component that is being rendered.
|
|
12262
|
+
* @param lView An `LView` that represents a current component that is being rendered.
|
|
12179
12263
|
*/
|
|
12180
|
-
function handleUnknownPropertyError(propName, tNode) {
|
|
12264
|
+
function handleUnknownPropertyError(propName, tNode, lView) {
|
|
12181
12265
|
let tagName = tNode.value;
|
|
12182
12266
|
// Special-case a situation when a structural directive is applied to
|
|
12183
12267
|
// an `<ng-template>` element, for example: `<ng-template *ngIf="true">`.
|
|
@@ -12188,7 +12272,36 @@ function handleUnknownPropertyError(propName, tNode) {
|
|
|
12188
12272
|
if (!tagName && tNode.type === 4 /* TNodeType.Container */) {
|
|
12189
12273
|
tagName = 'ng-template';
|
|
12190
12274
|
}
|
|
12191
|
-
const
|
|
12275
|
+
const isHostStandalone = isHostComponentStandalone(lView);
|
|
12276
|
+
const templateLocation = getTemplateLocationDetails(lView);
|
|
12277
|
+
let message = `Can't bind to '${propName}' since it isn't a known property of '${tagName}'${templateLocation}.`;
|
|
12278
|
+
const schemas = `'${isHostStandalone ? '@Component' : '@NgModule'}.schemas'`;
|
|
12279
|
+
const importLocation = isHostStandalone ?
|
|
12280
|
+
'included in the \'@Component.imports\' of this component' :
|
|
12281
|
+
'a part of an @NgModule where this component is declared';
|
|
12282
|
+
if (KNOWN_CONTROL_FLOW_DIRECTIVES.has(propName)) {
|
|
12283
|
+
// Most likely this is a control flow directive (such as `*ngIf`) used in
|
|
12284
|
+
// a template, but the `CommonModule` is not imported.
|
|
12285
|
+
message += `\nIf the '${propName}' is an Angular control flow directive, ` +
|
|
12286
|
+
`please make sure that the 'CommonModule' is ${importLocation}.`;
|
|
12287
|
+
}
|
|
12288
|
+
else {
|
|
12289
|
+
// May be an Angular component, which is not imported/declared?
|
|
12290
|
+
message += `\n1. If '${tagName}' is an Angular component and it has the ` +
|
|
12291
|
+
`'${propName}' input, then verify that it is ${importLocation}.`;
|
|
12292
|
+
// May be a Web Component?
|
|
12293
|
+
if (tagName && tagName.indexOf('-') > -1) {
|
|
12294
|
+
message += `\n2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' ` +
|
|
12295
|
+
`to the ${schemas} of this component to suppress this message.`;
|
|
12296
|
+
message += `\n3. To allow any property add 'NO_ERRORS_SCHEMA' to ` +
|
|
12297
|
+
`the ${schemas} of this component.`;
|
|
12298
|
+
}
|
|
12299
|
+
else {
|
|
12300
|
+
// If it's expected, the error can be suppressed by the `NO_ERRORS_SCHEMA` schema.
|
|
12301
|
+
message += `\n2. To allow any property add 'NO_ERRORS_SCHEMA' to ` +
|
|
12302
|
+
`the ${schemas} of this component.`;
|
|
12303
|
+
}
|
|
12304
|
+
}
|
|
12192
12305
|
if (shouldThrowErrorOnUnknownProperty) {
|
|
12193
12306
|
throw new RuntimeError(303 /* RuntimeErrorCode.UNKNOWN_BINDING */, message);
|
|
12194
12307
|
}
|
|
@@ -14974,8 +15087,7 @@ function elementStartFirstCreatePass(index, tView, lView, native, name, attrsInd
|
|
|
14974
15087
|
const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, name, attrs);
|
|
14975
15088
|
const hasDirectives = resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex));
|
|
14976
15089
|
if (ngDevMode) {
|
|
14977
|
-
|
|
14978
|
-
validateElementIsKnown(native, tNode.value, tView.schemas, hasDirectives, hostIsStandalone);
|
|
15090
|
+
validateElementIsKnown(native, lView, tNode.value, tView.schemas, hasDirectives);
|
|
14979
15091
|
}
|
|
14980
15092
|
if (tNode.attrs !== null) {
|
|
14981
15093
|
computeStaticStyling(tNode, tNode.attrs, false);
|
|
@@ -15113,12 +15225,12 @@ function ɵɵelement(index, name, attrsIndex, localRefsIndex) {
|
|
|
15113
15225
|
* - the element is allowed by one of the schemas
|
|
15114
15226
|
*
|
|
15115
15227
|
* @param element Element to validate
|
|
15228
|
+
* @param lView An `LView` that represents a current component that is being rendered.
|
|
15116
15229
|
* @param tagName Name of the tag to check
|
|
15117
15230
|
* @param schemas Array of schemas
|
|
15118
15231
|
* @param hasDirectives Boolean indicating that the element matches any directive
|
|
15119
|
-
* @param hostIsStandalone Boolean indicating whether the host is a standalone component
|
|
15120
15232
|
*/
|
|
15121
|
-
function validateElementIsKnown(element, tagName, schemas, hasDirectives
|
|
15233
|
+
function validateElementIsKnown(element, lView, tagName, schemas, hasDirectives) {
|
|
15122
15234
|
// If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
|
|
15123
15235
|
// mode where this check happens at compile time. In JIT mode, `schemas` is always present and
|
|
15124
15236
|
// defined as an array (as an empty array in case `schemas` field is not defined) and we should
|
|
@@ -15138,10 +15250,12 @@ function validateElementIsKnown(element, tagName, schemas, hasDirectives, hostIs
|
|
|
15138
15250
|
(typeof customElements !== 'undefined' && tagName.indexOf('-') > -1 &&
|
|
15139
15251
|
!customElements.get(tagName));
|
|
15140
15252
|
if (isUnknown && !matchingSchemas(schemas, tagName)) {
|
|
15141
|
-
const
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15253
|
+
const isHostStandalone = isHostComponentStandalone(lView);
|
|
15254
|
+
const templateLocation = getTemplateLocationDetails(lView);
|
|
15255
|
+
const schemas = `'${isHostStandalone ? '@Component' : '@NgModule'}.schemas'`;
|
|
15256
|
+
let message = `'${tagName}' is not a known element${templateLocation}:\n`;
|
|
15257
|
+
message += `1. If '${tagName}' is an Angular component, then verify that it is ${isHostStandalone ? 'included in the \'@Component.imports\' of this component' :
|
|
15258
|
+
'a part of an @NgModule where this component is declared'}.\n`;
|
|
15145
15259
|
if (tagName && tagName.indexOf('-') > -1) {
|
|
15146
15260
|
message +=
|
|
15147
15261
|
`2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas} of this component to suppress this message.`;
|
|
@@ -21641,7 +21755,7 @@ class Version {
|
|
|
21641
21755
|
/**
|
|
21642
21756
|
* @publicApi
|
|
21643
21757
|
*/
|
|
21644
|
-
const VERSION = new Version('14.0.0-rc.
|
|
21758
|
+
const VERSION = new Version('14.0.0-rc.3');
|
|
21645
21759
|
|
|
21646
21760
|
/**
|
|
21647
21761
|
* @license
|