@angular/core 14.0.2 → 14.0.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/application_ref.mjs +10 -24
- package/esm2020/src/change_detection/differs/default_iterable_differ.mjs +3 -5
- package/esm2020/src/change_detection/differs/default_keyvalue_differ.mjs +3 -5
- package/esm2020/src/change_detection/differs/iterable_differs.mjs +3 -5
- package/esm2020/src/change_detection/differs/keyvalue_differs.mjs +2 -5
- package/esm2020/src/di/injector_compatibility.mjs +4 -9
- package/esm2020/src/render3/features/inherit_definition_feature.mjs +3 -5
- package/esm2020/src/render3/jit/directive.mjs +20 -3
- package/esm2020/src/render3/view_ref.mjs +3 -5
- package/esm2020/src/sanitization/sanitization.mjs +4 -9
- 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/r3_test_bed_compiler.mjs +30 -25
- package/fesm2015/core.mjs +47 -67
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +44 -53
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +47 -67
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +44 -53
- package/fesm2020/testing.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/testing/index.d.ts +1 -1
package/fesm2020/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.0.
|
|
2
|
+
* @license Angular v14.0.3
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -2045,10 +2045,8 @@ function setCurrentInjector(injector) {
|
|
|
2045
2045
|
}
|
|
2046
2046
|
function injectInjectorOnly(token, flags = InjectFlags.Default) {
|
|
2047
2047
|
if (_currentInjector === undefined) {
|
|
2048
|
-
|
|
2049
|
-
`inject() must be called from an injection context (a constructor, a factory function or a field initializer)`
|
|
2050
|
-
'';
|
|
2051
|
-
throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, errorMessage);
|
|
2048
|
+
throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, ngDevMode &&
|
|
2049
|
+
`inject() must be called from an injection context (a constructor, a factory function or a field initializer)`);
|
|
2052
2050
|
}
|
|
2053
2051
|
else if (_currentInjector === null) {
|
|
2054
2052
|
return injectRootLimpMode(token, undefined, flags);
|
|
@@ -2154,10 +2152,7 @@ function injectArgs(types) {
|
|
|
2154
2152
|
const arg = resolveForwardRef(types[i]);
|
|
2155
2153
|
if (Array.isArray(arg)) {
|
|
2156
2154
|
if (arg.length === 0) {
|
|
2157
|
-
|
|
2158
|
-
'Arguments array must have arguments.' :
|
|
2159
|
-
'';
|
|
2160
|
-
throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, errorMessage);
|
|
2155
|
+
throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, ngDevMode && 'Arguments array must have arguments.');
|
|
2161
2156
|
}
|
|
2162
2157
|
let type = undefined;
|
|
2163
2158
|
let flags = InjectFlags.Default;
|
|
@@ -6489,10 +6484,8 @@ function ɵɵsanitizeResourceUrl(unsafeResourceUrl) {
|
|
|
6489
6484
|
if (allowSanitizationBypassAndThrow(unsafeResourceUrl, "ResourceURL" /* BypassType.ResourceUrl */)) {
|
|
6490
6485
|
return trustedScriptURLFromStringBypass(unwrapSafeValue(unsafeResourceUrl));
|
|
6491
6486
|
}
|
|
6492
|
-
|
|
6493
|
-
'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)'
|
|
6494
|
-
'';
|
|
6495
|
-
throw new RuntimeError(904 /* RuntimeErrorCode.UNSAFE_VALUE_IN_RESOURCE_URL */, errorMessage);
|
|
6487
|
+
throw new RuntimeError(904 /* RuntimeErrorCode.UNSAFE_VALUE_IN_RESOURCE_URL */, ngDevMode &&
|
|
6488
|
+
'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)');
|
|
6496
6489
|
}
|
|
6497
6490
|
/**
|
|
6498
6491
|
* A `script` sanitizer which only lets trusted javascript through.
|
|
@@ -6514,10 +6507,7 @@ function ɵɵsanitizeScript(unsafeScript) {
|
|
|
6514
6507
|
if (allowSanitizationBypassAndThrow(unsafeScript, "Script" /* BypassType.Script */)) {
|
|
6515
6508
|
return trustedScriptFromStringBypass(unwrapSafeValue(unsafeScript));
|
|
6516
6509
|
}
|
|
6517
|
-
|
|
6518
|
-
'unsafe value used in a script context' :
|
|
6519
|
-
'';
|
|
6520
|
-
throw new RuntimeError(905 /* RuntimeErrorCode.UNSAFE_VALUE_IN_SCRIPT */, errorMessage);
|
|
6510
|
+
throw new RuntimeError(905 /* RuntimeErrorCode.UNSAFE_VALUE_IN_SCRIPT */, ngDevMode && 'unsafe value used in a script context');
|
|
6521
6511
|
}
|
|
6522
6512
|
/**
|
|
6523
6513
|
* A template tag function for promoting the associated constant literal to a
|
|
@@ -14385,10 +14375,8 @@ function ɵɵInheritDefinitionFeature(definition) {
|
|
|
14385
14375
|
}
|
|
14386
14376
|
else {
|
|
14387
14377
|
if (superType.ɵcmp) {
|
|
14388
|
-
|
|
14389
|
-
`Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`
|
|
14390
|
-
'';
|
|
14391
|
-
throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, errorMessage);
|
|
14378
|
+
throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
|
|
14379
|
+
`Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
|
|
14392
14380
|
}
|
|
14393
14381
|
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
|
14394
14382
|
superDef = superType.ɵdir;
|
|
@@ -22085,7 +22073,7 @@ class Version {
|
|
|
22085
22073
|
/**
|
|
22086
22074
|
* @publicApi
|
|
22087
22075
|
*/
|
|
22088
|
-
const VERSION = new Version('14.0.
|
|
22076
|
+
const VERSION = new Version('14.0.3');
|
|
22089
22077
|
|
|
22090
22078
|
/**
|
|
22091
22079
|
* @license
|
|
@@ -22423,8 +22411,7 @@ class ViewRef {
|
|
|
22423
22411
|
}
|
|
22424
22412
|
attachToViewContainerRef() {
|
|
22425
22413
|
if (this._appRef) {
|
|
22426
|
-
|
|
22427
|
-
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, errorMessage);
|
|
22414
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached directly to the ApplicationRef!');
|
|
22428
22415
|
}
|
|
22429
22416
|
this._attachedToViewContainer = true;
|
|
22430
22417
|
}
|
|
@@ -22434,8 +22421,7 @@ class ViewRef {
|
|
|
22434
22421
|
}
|
|
22435
22422
|
attachToAppRef(appRef) {
|
|
22436
22423
|
if (this._attachedToViewContainer) {
|
|
22437
|
-
|
|
22438
|
-
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, errorMessage);
|
|
22424
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
|
|
22439
22425
|
}
|
|
22440
22426
|
this._appRef = appRef;
|
|
22441
22427
|
}
|
|
@@ -24713,7 +24699,7 @@ function patchModuleCompilation() {
|
|
|
24713
24699
|
function isModuleWithProviders$1(value) {
|
|
24714
24700
|
return value.ngModule !== undefined;
|
|
24715
24701
|
}
|
|
24716
|
-
function isNgModule(value) {
|
|
24702
|
+
function isNgModule$1(value) {
|
|
24717
24703
|
return !!getNgModuleDef(value);
|
|
24718
24704
|
}
|
|
24719
24705
|
|
|
@@ -25136,7 +25122,7 @@ function patchComponentDefWithScope(componentDef, transitiveScopes) {
|
|
|
25136
25122
|
* (either a NgModule or a standalone component / directive / pipe).
|
|
25137
25123
|
*/
|
|
25138
25124
|
function transitiveScopesFor(type) {
|
|
25139
|
-
if (isNgModule(type)) {
|
|
25125
|
+
if (isNgModule$1(type)) {
|
|
25140
25126
|
return transitiveScopesForNgModule(type);
|
|
25141
25127
|
}
|
|
25142
25128
|
else if (isStandalone(type)) {
|
|
@@ -25220,7 +25206,7 @@ function transitiveScopesForNgModule(moduleType) {
|
|
|
25220
25206
|
const exportedType = exported;
|
|
25221
25207
|
// Either the type is a module, a pipe, or a component/directive (which may not have a
|
|
25222
25208
|
// ɵcmp as it might be compiled asynchronously).
|
|
25223
|
-
if (isNgModule(exportedType)) {
|
|
25209
|
+
if (isNgModule$1(exportedType)) {
|
|
25224
25210
|
// When this module exports another, the exported module's exported directives and pipes are
|
|
25225
25211
|
// added to both the compilation and exported scopes of this module.
|
|
25226
25212
|
const exportedScope = transitiveScopesFor(exportedType);
|
|
@@ -25527,7 +25513,7 @@ class R3TestBedCompiler {
|
|
|
25527
25513
|
// module's provider list.
|
|
25528
25514
|
this.providerOverridesByModule = new Map();
|
|
25529
25515
|
this.providerOverridesByToken = new Map();
|
|
25530
|
-
this.
|
|
25516
|
+
this.scopesWithOverriddenProviders = new Set();
|
|
25531
25517
|
this.testModuleRef = null;
|
|
25532
25518
|
class DynamicTestModule {
|
|
25533
25519
|
}
|
|
@@ -25695,7 +25681,7 @@ class R3TestBedCompiler {
|
|
|
25695
25681
|
this.queueTypesFromModulesArray([moduleType]);
|
|
25696
25682
|
this.compileTypesSync();
|
|
25697
25683
|
this.applyProviderOverrides();
|
|
25698
|
-
this.
|
|
25684
|
+
this.applyProviderOverridesInScope(moduleType);
|
|
25699
25685
|
this.applyTransitiveScopes();
|
|
25700
25686
|
}
|
|
25701
25687
|
/**
|
|
@@ -25705,7 +25691,7 @@ class R3TestBedCompiler {
|
|
|
25705
25691
|
this.queueTypesFromModulesArray([moduleType]);
|
|
25706
25692
|
await this.compileComponents();
|
|
25707
25693
|
this.applyProviderOverrides();
|
|
25708
|
-
this.
|
|
25694
|
+
this.applyProviderOverridesInScope(moduleType);
|
|
25709
25695
|
this.applyTransitiveScopes();
|
|
25710
25696
|
}
|
|
25711
25697
|
/**
|
|
@@ -25806,50 +25792,52 @@ class R3TestBedCompiler {
|
|
|
25806
25792
|
this.seenComponents.clear();
|
|
25807
25793
|
this.seenDirectives.clear();
|
|
25808
25794
|
}
|
|
25809
|
-
|
|
25810
|
-
|
|
25795
|
+
/**
|
|
25796
|
+
* Applies provider overrides to a given type (either an NgModule or a standalone component)
|
|
25797
|
+
* and all imported NgModules and standalone components recursively.
|
|
25798
|
+
*/
|
|
25799
|
+
applyProviderOverridesInScope(type) {
|
|
25800
|
+
const hasScope = isStandaloneComponent(type) || isNgModule(type);
|
|
25801
|
+
// The function can be re-entered recursively while inspecting dependencies
|
|
25802
|
+
// of an NgModule or a standalone component. Exit early if we come across a
|
|
25803
|
+
// type that can not have a scope (directive or pipe) or the type is already
|
|
25804
|
+
// processed earlier.
|
|
25805
|
+
if (!hasScope || this.scopesWithOverriddenProviders.has(type)) {
|
|
25811
25806
|
return;
|
|
25812
25807
|
}
|
|
25813
|
-
this.
|
|
25808
|
+
this.scopesWithOverriddenProviders.add(type);
|
|
25814
25809
|
// NOTE: the line below triggers JIT compilation of the module injector,
|
|
25815
25810
|
// which also invokes verification of the NgModule semantics, which produces
|
|
25816
25811
|
// detailed error messages. The fact that the code relies on this line being
|
|
25817
25812
|
// present here is suspicious and should be refactored in a way that the line
|
|
25818
25813
|
// below can be moved (for ex. after an early exit check below).
|
|
25819
|
-
const injectorDef =
|
|
25814
|
+
const injectorDef = type[ɵNG_INJ_DEF];
|
|
25820
25815
|
// No provider overrides, exit early.
|
|
25821
25816
|
if (this.providerOverridesByToken.size === 0)
|
|
25822
25817
|
return;
|
|
25823
|
-
if (isStandaloneComponent(
|
|
25818
|
+
if (isStandaloneComponent(type)) {
|
|
25824
25819
|
// Visit all component dependencies and override providers there.
|
|
25825
|
-
const def = getComponentDef(
|
|
25820
|
+
const def = getComponentDef(type);
|
|
25826
25821
|
const dependencies = maybeUnwrapFn(def.dependencies ?? []);
|
|
25827
25822
|
for (const dependency of dependencies) {
|
|
25828
|
-
|
|
25829
|
-
// when a dependency is a standalone component or an NgModule.
|
|
25830
|
-
// In AOT, the `dependencies` might also contain regular (NgModule-based)
|
|
25831
|
-
// Component, Directive and Pipes. Skip them here, they are handled in a
|
|
25832
|
-
// different location (in the `configureTestingModule` function).
|
|
25833
|
-
if (isStandaloneComponent(dependency) || hasNgModuleDef(dependency)) {
|
|
25834
|
-
this.applyProviderOverridesToModule(dependency);
|
|
25835
|
-
}
|
|
25823
|
+
this.applyProviderOverridesInScope(dependency);
|
|
25836
25824
|
}
|
|
25837
25825
|
}
|
|
25838
25826
|
else {
|
|
25839
25827
|
const providers = [
|
|
25840
25828
|
...injectorDef.providers,
|
|
25841
|
-
...(this.providerOverridesByModule.get(
|
|
25829
|
+
...(this.providerOverridesByModule.get(type) || [])
|
|
25842
25830
|
];
|
|
25843
25831
|
if (this.hasProviderOverrides(providers)) {
|
|
25844
|
-
this.maybeStoreNgDef(ɵNG_INJ_DEF,
|
|
25845
|
-
this.storeFieldOfDefOnType(
|
|
25832
|
+
this.maybeStoreNgDef(ɵNG_INJ_DEF, type);
|
|
25833
|
+
this.storeFieldOfDefOnType(type, ɵNG_INJ_DEF, 'providers');
|
|
25846
25834
|
injectorDef.providers = this.getOverriddenProviders(providers);
|
|
25847
25835
|
}
|
|
25848
25836
|
// Apply provider overrides to imported modules recursively
|
|
25849
|
-
const moduleDef =
|
|
25837
|
+
const moduleDef = type[ɵNG_MOD_DEF];
|
|
25850
25838
|
const imports = maybeUnwrapFn(moduleDef.imports);
|
|
25851
25839
|
for (const importedModule of imports) {
|
|
25852
|
-
this.
|
|
25840
|
+
this.applyProviderOverridesInScope(importedModule);
|
|
25853
25841
|
}
|
|
25854
25842
|
// Also override the providers on any ModuleWithProviders imports since those don't appear in
|
|
25855
25843
|
// the moduleDef.
|
|
@@ -26086,7 +26074,7 @@ class R3TestBedCompiler {
|
|
|
26086
26074
|
});
|
|
26087
26075
|
});
|
|
26088
26076
|
this.initialNgDefs.clear();
|
|
26089
|
-
this.
|
|
26077
|
+
this.scopesWithOverriddenProviders.clear();
|
|
26090
26078
|
this.restoreComponentResolutionQueue();
|
|
26091
26079
|
// Restore the locale ID to the default value, this shouldn't be necessary but we never know
|
|
26092
26080
|
ɵsetLocaleId(ɵDEFAULT_LOCALE_ID);
|
|
@@ -26113,7 +26101,7 @@ class R3TestBedCompiler {
|
|
|
26113
26101
|
providers,
|
|
26114
26102
|
}, /* allowDuplicateDeclarationsInRoot */ true);
|
|
26115
26103
|
// clang-format on
|
|
26116
|
-
this.
|
|
26104
|
+
this.applyProviderOverridesInScope(this.testModuleType);
|
|
26117
26105
|
}
|
|
26118
26106
|
get injector() {
|
|
26119
26107
|
if (this._injector !== null) {
|
|
@@ -26213,6 +26201,9 @@ function getComponentDef(value) {
|
|
|
26213
26201
|
function hasNgModuleDef(value) {
|
|
26214
26202
|
return value.hasOwnProperty('ɵmod');
|
|
26215
26203
|
}
|
|
26204
|
+
function isNgModule(value) {
|
|
26205
|
+
return hasNgModuleDef(value);
|
|
26206
|
+
}
|
|
26216
26207
|
function maybeUnwrapFn(maybeFn) {
|
|
26217
26208
|
return maybeFn instanceof Function ? maybeFn() : maybeFn;
|
|
26218
26209
|
}
|