@angular/core 14.0.2 → 14.0.5
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 +31 -35
- 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/core.mjs +1 -1
- package/esm2020/src/core_render3_private_export.mjs +2 -2
- package/esm2020/src/debug/debug_node.mjs +2 -3
- package/esm2020/src/di/injector_compatibility.mjs +6 -16
- package/esm2020/src/di/jit/util.mjs +3 -2
- package/esm2020/src/di/reflective_key.mjs +3 -2
- package/esm2020/src/errors.mjs +1 -1
- package/esm2020/src/i18n/locale_data_api.mjs +3 -2
- package/esm2020/src/render/api.mjs +2 -11
- package/esm2020/src/render3/component.mjs +3 -57
- package/esm2020/src/render3/component_ref.mjs +9 -3
- package/esm2020/src/render3/features/inherit_definition_feature.mjs +3 -5
- package/esm2020/src/render3/index.mjs +3 -3
- package/esm2020/src/render3/instructions/listener.mjs +34 -44
- package/esm2020/src/render3/instructions/lview_debug.mjs +1 -1
- package/esm2020/src/render3/instructions/shared.mjs +19 -57
- package/esm2020/src/render3/instructions/styling.mjs +2 -2
- package/esm2020/src/render3/interfaces/renderer.mjs +1 -17
- package/esm2020/src/render3/interfaces/view.mjs +1 -1
- package/esm2020/src/render3/jit/directive.mjs +20 -3
- package/esm2020/src/render3/node_manipulation.mjs +24 -87
- package/esm2020/src/render3/node_manipulation_i18n.mjs +1 -1
- package/esm2020/src/render3/util/attrs_utils.mjs +4 -12
- package/esm2020/src/render3/util/view_utils.mjs +3 -6
- 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/src/zone/ng_zone.mjs +5 -4
- 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 +1821 -2020
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +1023 -1314
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +1821 -2020
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +1023 -1314
- package/fesm2020/testing.mjs.map +1 -1
- package/index.d.ts +60 -133
- package/package.json +1 -1
- package/testing/index.d.ts +1 -1
- package/schematics/utils/schematics_prompt.d.ts +0 -17
- package/schematics/utils/schematics_prompt.js +0 -45
package/fesm2020/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.0.
|
|
2
|
+
* @license Angular v14.0.5
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -862,6 +862,68 @@ const NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
|
|
|
862
862
|
const NG_INJECTABLE_DEF = getClosureSafeProperty({ ngInjectableDef: getClosureSafeProperty });
|
|
863
863
|
const NG_INJECTOR_DEF = getClosureSafeProperty({ ngInjectorDef: getClosureSafeProperty });
|
|
864
864
|
|
|
865
|
+
/**
|
|
866
|
+
* @license
|
|
867
|
+
* Copyright Google LLC All Rights Reserved.
|
|
868
|
+
*
|
|
869
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
870
|
+
* found in the LICENSE file at https://angular.io/license
|
|
871
|
+
*/
|
|
872
|
+
/**
|
|
873
|
+
* Base URL for the error details page.
|
|
874
|
+
*
|
|
875
|
+
* Keep the files below in full sync:
|
|
876
|
+
* - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
|
|
877
|
+
* - packages/core/src/error_details_base_url.ts
|
|
878
|
+
*/
|
|
879
|
+
const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* @license
|
|
883
|
+
* Copyright Google LLC All Rights Reserved.
|
|
884
|
+
*
|
|
885
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
886
|
+
* found in the LICENSE file at https://angular.io/license
|
|
887
|
+
*/
|
|
888
|
+
/**
|
|
889
|
+
* Class that represents a runtime error.
|
|
890
|
+
* Formats and outputs the error message in a consistent way.
|
|
891
|
+
*
|
|
892
|
+
* Example:
|
|
893
|
+
* ```
|
|
894
|
+
* throw new RuntimeError(
|
|
895
|
+
* RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
|
|
896
|
+
* ngDevMode && 'Injector has already been destroyed.');
|
|
897
|
+
* ```
|
|
898
|
+
*
|
|
899
|
+
* Note: the `message` argument contains a descriptive error message as a string in development
|
|
900
|
+
* mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
|
|
901
|
+
* `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
|
|
902
|
+
*/
|
|
903
|
+
class RuntimeError extends Error {
|
|
904
|
+
constructor(code, message) {
|
|
905
|
+
super(formatRuntimeError(code, message));
|
|
906
|
+
this.code = code;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Called to format a runtime error.
|
|
911
|
+
* See additional info on the `message` argument type in the `RuntimeError` class description.
|
|
912
|
+
*/
|
|
913
|
+
function formatRuntimeError(code, message) {
|
|
914
|
+
// Error code might be a negative number, which is a special marker that instructs the logic to
|
|
915
|
+
// generate a link to the error details page on angular.io.
|
|
916
|
+
const fullCode = `NG0${Math.abs(code)}`;
|
|
917
|
+
let errorMessage = `${fullCode}${message ? ': ' + message.trim() : ''}`;
|
|
918
|
+
if (ngDevMode && code < 0) {
|
|
919
|
+
const addPeriodSeparator = !errorMessage.match(/[.,;!?]$/);
|
|
920
|
+
const separator = addPeriodSeparator ? '.' : '';
|
|
921
|
+
errorMessage =
|
|
922
|
+
`${errorMessage}${separator} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
|
|
923
|
+
}
|
|
924
|
+
return errorMessage;
|
|
925
|
+
}
|
|
926
|
+
|
|
865
927
|
/**
|
|
866
928
|
* @license
|
|
867
929
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1790,68 +1852,6 @@ function initNgDevMode() {
|
|
|
1790
1852
|
return false;
|
|
1791
1853
|
}
|
|
1792
1854
|
|
|
1793
|
-
/**
|
|
1794
|
-
* @license
|
|
1795
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1796
|
-
*
|
|
1797
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1798
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1799
|
-
*/
|
|
1800
|
-
/**
|
|
1801
|
-
* Base URL for the error details page.
|
|
1802
|
-
*
|
|
1803
|
-
* Keep the files below in full sync:
|
|
1804
|
-
* - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
|
|
1805
|
-
* - packages/core/src/error_details_base_url.ts
|
|
1806
|
-
*/
|
|
1807
|
-
const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
|
|
1808
|
-
|
|
1809
|
-
/**
|
|
1810
|
-
* @license
|
|
1811
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1812
|
-
*
|
|
1813
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1814
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1815
|
-
*/
|
|
1816
|
-
/**
|
|
1817
|
-
* Class that represents a runtime error.
|
|
1818
|
-
* Formats and outputs the error message in a consistent way.
|
|
1819
|
-
*
|
|
1820
|
-
* Example:
|
|
1821
|
-
* ```
|
|
1822
|
-
* throw new RuntimeError(
|
|
1823
|
-
* RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
|
|
1824
|
-
* ngDevMode && 'Injector has already been destroyed.');
|
|
1825
|
-
* ```
|
|
1826
|
-
*
|
|
1827
|
-
* Note: the `message` argument contains a descriptive error message as a string in development
|
|
1828
|
-
* mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
|
|
1829
|
-
* `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
|
|
1830
|
-
*/
|
|
1831
|
-
class RuntimeError extends Error {
|
|
1832
|
-
constructor(code, message) {
|
|
1833
|
-
super(formatRuntimeError(code, message));
|
|
1834
|
-
this.code = code;
|
|
1835
|
-
}
|
|
1836
|
-
}
|
|
1837
|
-
/**
|
|
1838
|
-
* Called to format a runtime error.
|
|
1839
|
-
* See additional info on the `message` argument type in the `RuntimeError` class description.
|
|
1840
|
-
*/
|
|
1841
|
-
function formatRuntimeError(code, message) {
|
|
1842
|
-
// Error code might be a negative number, which is a special marker that instructs the logic to
|
|
1843
|
-
// generate a link to the error details page on angular.io.
|
|
1844
|
-
const fullCode = `NG0${Math.abs(code)}`;
|
|
1845
|
-
let errorMessage = `${fullCode}${message ? ': ' + message.trim() : ''}`;
|
|
1846
|
-
if (ngDevMode && code < 0) {
|
|
1847
|
-
const addPeriodSeparator = !errorMessage.match(/[.,;!?]$/);
|
|
1848
|
-
const separator = addPeriodSeparator ? '.' : '';
|
|
1849
|
-
errorMessage =
|
|
1850
|
-
`${errorMessage}${separator} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
|
|
1851
|
-
}
|
|
1852
|
-
return errorMessage;
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
1855
|
/**
|
|
1856
1856
|
* @license
|
|
1857
1857
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -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);
|
|
@@ -2064,22 +2062,17 @@ function ɵɵinject(token, flags = InjectFlags.Default) {
|
|
|
2064
2062
|
* Throws an error indicating that a factory function could not be generated by the compiler for a
|
|
2065
2063
|
* particular class.
|
|
2066
2064
|
*
|
|
2067
|
-
* This instruction allows the actual error message to be optimized away when ngDevMode is turned
|
|
2068
|
-
* off, saving bytes of generated code while still providing a good experience in dev mode.
|
|
2069
|
-
*
|
|
2070
2065
|
* The name of the class is not mentioned here, but will be in the generated factory function name
|
|
2071
2066
|
* and thus in the stack trace.
|
|
2072
2067
|
*
|
|
2073
2068
|
* @codeGenApi
|
|
2074
2069
|
*/
|
|
2075
2070
|
function ɵɵinvalidFactoryDep(index) {
|
|
2076
|
-
|
|
2071
|
+
throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, ngDevMode &&
|
|
2077
2072
|
`This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
|
|
2078
2073
|
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.
|
|
2079
2074
|
|
|
2080
|
-
Please check that 1) the type for the parameter at index ${index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.`
|
|
2081
|
-
'invalid';
|
|
2082
|
-
throw new Error(msg);
|
|
2075
|
+
Please check that 1) the type for the parameter at index ${index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.`);
|
|
2083
2076
|
}
|
|
2084
2077
|
/**
|
|
2085
2078
|
* Injects a token from the currently active injector.
|
|
@@ -2154,10 +2147,7 @@ function injectArgs(types) {
|
|
|
2154
2147
|
const arg = resolveForwardRef(types[i]);
|
|
2155
2148
|
if (Array.isArray(arg)) {
|
|
2156
2149
|
if (arg.length === 0) {
|
|
2157
|
-
|
|
2158
|
-
'Arguments array must have arguments.' :
|
|
2159
|
-
'';
|
|
2160
|
-
throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, errorMessage);
|
|
2150
|
+
throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, ngDevMode && 'Arguments array must have arguments.');
|
|
2161
2151
|
}
|
|
2162
2152
|
let type = undefined;
|
|
2163
2153
|
let flags = InjectFlags.Default;
|
|
@@ -3199,87 +3189,6 @@ function getNamespaceUri(namespace) {
|
|
|
3199
3189
|
(name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
|
|
3200
3190
|
}
|
|
3201
3191
|
|
|
3202
|
-
/**
|
|
3203
|
-
* @license
|
|
3204
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3205
|
-
*
|
|
3206
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3207
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3208
|
-
*/
|
|
3209
|
-
/**
|
|
3210
|
-
* Most of the use of `document` in Angular is from within the DI system so it is possible to simply
|
|
3211
|
-
* inject the `DOCUMENT` token and are done.
|
|
3212
|
-
*
|
|
3213
|
-
* Ivy is special because it does not rely upon the DI and must get hold of the document some other
|
|
3214
|
-
* way.
|
|
3215
|
-
*
|
|
3216
|
-
* The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
|
|
3217
|
-
* Wherever ivy needs the global document, it calls `getDocument()` instead.
|
|
3218
|
-
*
|
|
3219
|
-
* When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
|
|
3220
|
-
* tell ivy what the global `document` is.
|
|
3221
|
-
*
|
|
3222
|
-
* Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
|
|
3223
|
-
* by calling `setDocument()` when providing the `DOCUMENT` token.
|
|
3224
|
-
*/
|
|
3225
|
-
let DOCUMENT = undefined;
|
|
3226
|
-
/**
|
|
3227
|
-
* Tell ivy what the `document` is for this platform.
|
|
3228
|
-
*
|
|
3229
|
-
* It is only necessary to call this if the current platform is not a browser.
|
|
3230
|
-
*
|
|
3231
|
-
* @param document The object representing the global `document` in this environment.
|
|
3232
|
-
*/
|
|
3233
|
-
function setDocument(document) {
|
|
3234
|
-
DOCUMENT = document;
|
|
3235
|
-
}
|
|
3236
|
-
/**
|
|
3237
|
-
* Access the object that represents the `document` for this platform.
|
|
3238
|
-
*
|
|
3239
|
-
* Ivy calls this whenever it needs to access the `document` object.
|
|
3240
|
-
* For example to create the renderer or to do sanitization.
|
|
3241
|
-
*/
|
|
3242
|
-
function getDocument() {
|
|
3243
|
-
if (DOCUMENT !== undefined) {
|
|
3244
|
-
return DOCUMENT;
|
|
3245
|
-
}
|
|
3246
|
-
else if (typeof document !== 'undefined') {
|
|
3247
|
-
return document;
|
|
3248
|
-
}
|
|
3249
|
-
// No "document" can be found. This should only happen if we are running ivy outside Angular and
|
|
3250
|
-
// the current platform is not a browser. Since this is not a supported scenario at the moment
|
|
3251
|
-
// this should not happen in Angular apps.
|
|
3252
|
-
// Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
|
|
3253
|
-
// public API. Meanwhile we just return `undefined` and let the application fail.
|
|
3254
|
-
return undefined;
|
|
3255
|
-
}
|
|
3256
|
-
|
|
3257
|
-
/**
|
|
3258
|
-
* @license
|
|
3259
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3260
|
-
*
|
|
3261
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3262
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3263
|
-
*/
|
|
3264
|
-
// TODO: cleanup once the code is merged in angular/angular
|
|
3265
|
-
var RendererStyleFlags3;
|
|
3266
|
-
(function (RendererStyleFlags3) {
|
|
3267
|
-
RendererStyleFlags3[RendererStyleFlags3["Important"] = 1] = "Important";
|
|
3268
|
-
RendererStyleFlags3[RendererStyleFlags3["DashCase"] = 2] = "DashCase";
|
|
3269
|
-
})(RendererStyleFlags3 || (RendererStyleFlags3 = {}));
|
|
3270
|
-
/** Returns whether the `renderer` is a `ProceduralRenderer3` */
|
|
3271
|
-
function isProceduralRenderer(renderer) {
|
|
3272
|
-
return !!(renderer.listen);
|
|
3273
|
-
}
|
|
3274
|
-
const domRendererFactory3 = {
|
|
3275
|
-
createRenderer: (hostElement, rendererType) => {
|
|
3276
|
-
return getDocument();
|
|
3277
|
-
}
|
|
3278
|
-
};
|
|
3279
|
-
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
|
3280
|
-
// failure based on types.
|
|
3281
|
-
const unusedValueExportToPlacateAjd$6 = 1;
|
|
3282
|
-
|
|
3283
3192
|
/**
|
|
3284
3193
|
* @license
|
|
3285
3194
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -3362,7 +3271,6 @@ function getNativeByTNode(tNode, lView) {
|
|
|
3362
3271
|
ngDevMode && assertTNodeForLView(tNode, lView);
|
|
3363
3272
|
ngDevMode && assertIndexInRange(lView, tNode.index);
|
|
3364
3273
|
const node = unwrapRNode(lView[tNode.index]);
|
|
3365
|
-
ngDevMode && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
|
|
3366
3274
|
return node;
|
|
3367
3275
|
}
|
|
3368
3276
|
/**
|
|
@@ -3378,7 +3286,6 @@ function getNativeByTNodeOrNull(tNode, lView) {
|
|
|
3378
3286
|
if (index !== -1) {
|
|
3379
3287
|
ngDevMode && assertTNodeForLView(tNode, lView);
|
|
3380
3288
|
const node = unwrapRNode(lView[index]);
|
|
3381
|
-
ngDevMode && node !== null && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
|
|
3382
3289
|
return node;
|
|
3383
3290
|
}
|
|
3384
3291
|
return null;
|
|
@@ -4327,7 +4234,7 @@ function isFactory(obj) {
|
|
|
4327
4234
|
}
|
|
4328
4235
|
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
|
4329
4236
|
// failure based on types.
|
|
4330
|
-
const unusedValueExportToPlacateAjd$
|
|
4237
|
+
const unusedValueExportToPlacateAjd$6 = 1;
|
|
4331
4238
|
|
|
4332
4239
|
/**
|
|
4333
4240
|
* Converts `TNodeType` into human readable text.
|
|
@@ -4346,7 +4253,7 @@ function toTNodeTypeAsString(tNodeType) {
|
|
|
4346
4253
|
}
|
|
4347
4254
|
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
|
4348
4255
|
// failure based on types.
|
|
4349
|
-
const unusedValueExportToPlacateAjd$
|
|
4256
|
+
const unusedValueExportToPlacateAjd$5 = 1;
|
|
4350
4257
|
/**
|
|
4351
4258
|
* Returns `true` if the `TNode` has a directive which has `@Input()` for `class` binding.
|
|
4352
4259
|
*
|
|
@@ -4450,7 +4357,6 @@ function assertPureTNodeType(type) {
|
|
|
4450
4357
|
* @returns the index value that was last accessed in the attributes array
|
|
4451
4358
|
*/
|
|
4452
4359
|
function setUpAttributes(renderer, native, attrs) {
|
|
4453
|
-
const isProc = isProceduralRenderer(renderer);
|
|
4454
4360
|
let i = 0;
|
|
4455
4361
|
while (i < attrs.length) {
|
|
4456
4362
|
const value = attrs[i];
|
|
@@ -4467,9 +4373,7 @@ function setUpAttributes(renderer, native, attrs) {
|
|
|
4467
4373
|
const attrName = attrs[i++];
|
|
4468
4374
|
const attrVal = attrs[i++];
|
|
4469
4375
|
ngDevMode && ngDevMode.rendererSetAttribute++;
|
|
4470
|
-
|
|
4471
|
-
renderer.setAttribute(native, attrName, attrVal, namespaceURI) :
|
|
4472
|
-
native.setAttributeNS(namespaceURI, attrName, attrVal);
|
|
4376
|
+
renderer.setAttribute(native, attrName, attrVal, namespaceURI);
|
|
4473
4377
|
}
|
|
4474
4378
|
else {
|
|
4475
4379
|
// attrName is string;
|
|
@@ -4478,14 +4382,10 @@ function setUpAttributes(renderer, native, attrs) {
|
|
|
4478
4382
|
// Standard attributes
|
|
4479
4383
|
ngDevMode && ngDevMode.rendererSetAttribute++;
|
|
4480
4384
|
if (isAnimationProp(attrName)) {
|
|
4481
|
-
|
|
4482
|
-
renderer.setProperty(native, attrName, attrVal);
|
|
4483
|
-
}
|
|
4385
|
+
renderer.setProperty(native, attrName, attrVal);
|
|
4484
4386
|
}
|
|
4485
4387
|
else {
|
|
4486
|
-
|
|
4487
|
-
renderer.setAttribute(native, attrName, attrVal) :
|
|
4488
|
-
native.setAttribute(attrName, attrVal);
|
|
4388
|
+
renderer.setAttribute(native, attrName, attrVal);
|
|
4489
4389
|
}
|
|
4490
4390
|
i++;
|
|
4491
4391
|
}
|
|
@@ -5487,7 +5387,7 @@ function reflectDependency(dep) {
|
|
|
5487
5387
|
}
|
|
5488
5388
|
else if (param instanceof Attribute) {
|
|
5489
5389
|
if (param.attributeName === undefined) {
|
|
5490
|
-
throw new
|
|
5390
|
+
throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, ngDevMode && `Attribute name must be defined.`);
|
|
5491
5391
|
}
|
|
5492
5392
|
meta.attribute = param.attributeName;
|
|
5493
5393
|
}
|
|
@@ -5627,43 +5527,98 @@ function maybeUnwrapFn$1(value) {
|
|
|
5627
5527
|
* found in the LICENSE file at https://angular.io/license
|
|
5628
5528
|
*/
|
|
5629
5529
|
/**
|
|
5630
|
-
*
|
|
5631
|
-
*
|
|
5530
|
+
* Most of the use of `document` in Angular is from within the DI system so it is possible to simply
|
|
5531
|
+
* inject the `DOCUMENT` token and are done.
|
|
5532
|
+
*
|
|
5533
|
+
* Ivy is special because it does not rely upon the DI and must get hold of the document some other
|
|
5534
|
+
* way.
|
|
5535
|
+
*
|
|
5536
|
+
* The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
|
|
5537
|
+
* Wherever ivy needs the global document, it calls `getDocument()` instead.
|
|
5538
|
+
*
|
|
5539
|
+
* When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
|
|
5540
|
+
* tell ivy what the global `document` is.
|
|
5541
|
+
*
|
|
5542
|
+
* Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
|
|
5543
|
+
* by calling `setDocument()` when providing the `DOCUMENT` token.
|
|
5632
5544
|
*/
|
|
5633
|
-
let
|
|
5545
|
+
let DOCUMENT = undefined;
|
|
5634
5546
|
/**
|
|
5635
|
-
*
|
|
5636
|
-
*
|
|
5547
|
+
* Tell ivy what the `document` is for this platform.
|
|
5548
|
+
*
|
|
5549
|
+
* It is only necessary to call this if the current platform is not a browser.
|
|
5550
|
+
*
|
|
5551
|
+
* @param document The object representing the global `document` in this environment.
|
|
5637
5552
|
*/
|
|
5638
|
-
function
|
|
5639
|
-
|
|
5640
|
-
policy$1 = null;
|
|
5641
|
-
if (_global$1.trustedTypes) {
|
|
5642
|
-
try {
|
|
5643
|
-
policy$1 = _global$1.trustedTypes.createPolicy('angular', {
|
|
5644
|
-
createHTML: (s) => s,
|
|
5645
|
-
createScript: (s) => s,
|
|
5646
|
-
createScriptURL: (s) => s,
|
|
5647
|
-
});
|
|
5648
|
-
}
|
|
5649
|
-
catch {
|
|
5650
|
-
// trustedTypes.createPolicy throws if called with a name that is
|
|
5651
|
-
// already registered, even in report-only mode. Until the API changes,
|
|
5652
|
-
// catch the error not to break the applications functionally. In such
|
|
5653
|
-
// cases, the code will fall back to using strings.
|
|
5654
|
-
}
|
|
5655
|
-
}
|
|
5656
|
-
}
|
|
5657
|
-
return policy$1;
|
|
5553
|
+
function setDocument(document) {
|
|
5554
|
+
DOCUMENT = document;
|
|
5658
5555
|
}
|
|
5659
5556
|
/**
|
|
5660
|
-
*
|
|
5661
|
-
*
|
|
5662
|
-
*
|
|
5663
|
-
*
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5557
|
+
* Access the object that represents the `document` for this platform.
|
|
5558
|
+
*
|
|
5559
|
+
* Ivy calls this whenever it needs to access the `document` object.
|
|
5560
|
+
* For example to create the renderer or to do sanitization.
|
|
5561
|
+
*/
|
|
5562
|
+
function getDocument() {
|
|
5563
|
+
if (DOCUMENT !== undefined) {
|
|
5564
|
+
return DOCUMENT;
|
|
5565
|
+
}
|
|
5566
|
+
else if (typeof document !== 'undefined') {
|
|
5567
|
+
return document;
|
|
5568
|
+
}
|
|
5569
|
+
// No "document" can be found. This should only happen if we are running ivy outside Angular and
|
|
5570
|
+
// the current platform is not a browser. Since this is not a supported scenario at the moment
|
|
5571
|
+
// this should not happen in Angular apps.
|
|
5572
|
+
// Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
|
|
5573
|
+
// public API. Meanwhile we just return `undefined` and let the application fail.
|
|
5574
|
+
return undefined;
|
|
5575
|
+
}
|
|
5576
|
+
|
|
5577
|
+
/**
|
|
5578
|
+
* @license
|
|
5579
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5580
|
+
*
|
|
5581
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
5582
|
+
* found in the LICENSE file at https://angular.io/license
|
|
5583
|
+
*/
|
|
5584
|
+
/**
|
|
5585
|
+
* The Trusted Types policy, or null if Trusted Types are not
|
|
5586
|
+
* enabled/supported, or undefined if the policy has not been created yet.
|
|
5587
|
+
*/
|
|
5588
|
+
let policy$1;
|
|
5589
|
+
/**
|
|
5590
|
+
* Returns the Trusted Types policy, or null if Trusted Types are not
|
|
5591
|
+
* enabled/supported. The first call to this function will create the policy.
|
|
5592
|
+
*/
|
|
5593
|
+
function getPolicy$1() {
|
|
5594
|
+
if (policy$1 === undefined) {
|
|
5595
|
+
policy$1 = null;
|
|
5596
|
+
if (_global$1.trustedTypes) {
|
|
5597
|
+
try {
|
|
5598
|
+
policy$1 = _global$1.trustedTypes.createPolicy('angular', {
|
|
5599
|
+
createHTML: (s) => s,
|
|
5600
|
+
createScript: (s) => s,
|
|
5601
|
+
createScriptURL: (s) => s,
|
|
5602
|
+
});
|
|
5603
|
+
}
|
|
5604
|
+
catch {
|
|
5605
|
+
// trustedTypes.createPolicy throws if called with a name that is
|
|
5606
|
+
// already registered, even in report-only mode. Until the API changes,
|
|
5607
|
+
// catch the error not to break the applications functionally. In such
|
|
5608
|
+
// cases, the code will fall back to using strings.
|
|
5609
|
+
}
|
|
5610
|
+
}
|
|
5611
|
+
}
|
|
5612
|
+
return policy$1;
|
|
5613
|
+
}
|
|
5614
|
+
/**
|
|
5615
|
+
* Unsafely promote a string to a TrustedHTML, falling back to strings when
|
|
5616
|
+
* Trusted Types are not available.
|
|
5617
|
+
* @security This is a security-sensitive function; any use of this function
|
|
5618
|
+
* must go through security review. In particular, it must be assured that the
|
|
5619
|
+
* provided string will never cause an XSS vulnerability if used in a context
|
|
5620
|
+
* that will be interpreted as HTML by a browser, e.g. when assigning to
|
|
5621
|
+
* element.innerHTML.
|
|
5667
5622
|
*/
|
|
5668
5623
|
function trustedHTMLFromString(html) {
|
|
5669
5624
|
return getPolicy$1()?.createHTML(html) || html;
|
|
@@ -6489,10 +6444,8 @@ function ɵɵsanitizeResourceUrl(unsafeResourceUrl) {
|
|
|
6489
6444
|
if (allowSanitizationBypassAndThrow(unsafeResourceUrl, "ResourceURL" /* BypassType.ResourceUrl */)) {
|
|
6490
6445
|
return trustedScriptURLFromStringBypass(unwrapSafeValue(unsafeResourceUrl));
|
|
6491
6446
|
}
|
|
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);
|
|
6447
|
+
throw new RuntimeError(904 /* RuntimeErrorCode.UNSAFE_VALUE_IN_RESOURCE_URL */, ngDevMode &&
|
|
6448
|
+
'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)');
|
|
6496
6449
|
}
|
|
6497
6450
|
/**
|
|
6498
6451
|
* A `script` sanitizer which only lets trusted javascript through.
|
|
@@ -6514,10 +6467,7 @@ function ɵɵsanitizeScript(unsafeScript) {
|
|
|
6514
6467
|
if (allowSanitizationBypassAndThrow(unsafeScript, "Script" /* BypassType.Script */)) {
|
|
6515
6468
|
return trustedScriptFromStringBypass(unwrapSafeValue(unsafeScript));
|
|
6516
6469
|
}
|
|
6517
|
-
|
|
6518
|
-
'unsafe value used in a script context' :
|
|
6519
|
-
'';
|
|
6520
|
-
throw new RuntimeError(905 /* RuntimeErrorCode.UNSAFE_VALUE_IN_SCRIPT */, errorMessage);
|
|
6470
|
+
throw new RuntimeError(905 /* RuntimeErrorCode.UNSAFE_VALUE_IN_SCRIPT */, ngDevMode && 'unsafe value used in a script context');
|
|
6521
6471
|
}
|
|
6522
6472
|
/**
|
|
6523
6473
|
* A template tag function for promoting the associated constant literal to a
|
|
@@ -7293,6 +7243,17 @@ function ensureIcuContainerVisitorLoaded(loader) {
|
|
|
7293
7243
|
}
|
|
7294
7244
|
}
|
|
7295
7245
|
|
|
7246
|
+
/**
|
|
7247
|
+
* @license
|
|
7248
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7249
|
+
*
|
|
7250
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7251
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7252
|
+
*/
|
|
7253
|
+
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
|
7254
|
+
// failure based on types.
|
|
7255
|
+
const unusedValueExportToPlacateAjd$4 = 1;
|
|
7256
|
+
|
|
7296
7257
|
/**
|
|
7297
7258
|
* @license
|
|
7298
7259
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -7375,7 +7336,7 @@ function getNearestLContainer(viewOrContainer) {
|
|
|
7375
7336
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7376
7337
|
* found in the LICENSE file at https://angular.io/license
|
|
7377
7338
|
*/
|
|
7378
|
-
const unusedValueToPlacateAjd$2 = unusedValueExportToPlacateAjd$7 + unusedValueExportToPlacateAjd$
|
|
7339
|
+
const unusedValueToPlacateAjd$2 = unusedValueExportToPlacateAjd$7 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3 + unusedValueExportToPlacateAjd$8;
|
|
7379
7340
|
/**
|
|
7380
7341
|
* NOTE: for performance reasons, the possible actions are inlined within the function instead of
|
|
7381
7342
|
* being passed as an argument.
|
|
@@ -7400,7 +7361,6 @@ function applyToElementOrContainer(action, renderer, parent, lNodeToHandle, befo
|
|
|
7400
7361
|
lNodeToHandle = lNodeToHandle[HOST];
|
|
7401
7362
|
}
|
|
7402
7363
|
const rNode = unwrapRNode(lNodeToHandle);
|
|
7403
|
-
ngDevMode && !isProceduralRenderer(renderer) && assertDomNode(rNode);
|
|
7404
7364
|
if (action === 0 /* WalkTNodeTreeAction.Create */ && parent !== null) {
|
|
7405
7365
|
if (beforeNode == null) {
|
|
7406
7366
|
nativeAppendChild(renderer, parent, rNode);
|
|
@@ -7427,17 +7387,14 @@ function applyToElementOrContainer(action, renderer, parent, lNodeToHandle, befo
|
|
|
7427
7387
|
function createTextNode(renderer, value) {
|
|
7428
7388
|
ngDevMode && ngDevMode.rendererCreateTextNode++;
|
|
7429
7389
|
ngDevMode && ngDevMode.rendererSetText++;
|
|
7430
|
-
return
|
|
7431
|
-
renderer.createTextNode(value);
|
|
7390
|
+
return renderer.createText(value);
|
|
7432
7391
|
}
|
|
7433
7392
|
function updateTextNode(renderer, rNode, value) {
|
|
7434
7393
|
ngDevMode && ngDevMode.rendererSetText++;
|
|
7435
|
-
|
|
7394
|
+
renderer.setValue(rNode, value);
|
|
7436
7395
|
}
|
|
7437
7396
|
function createCommentNode(renderer, value) {
|
|
7438
7397
|
ngDevMode && ngDevMode.rendererCreateComment++;
|
|
7439
|
-
// isProceduralRenderer check is not needed because both `Renderer2` and `Renderer3` have the same
|
|
7440
|
-
// method name.
|
|
7441
7398
|
return renderer.createComment(escapeCommentText(value));
|
|
7442
7399
|
}
|
|
7443
7400
|
/**
|
|
@@ -7449,14 +7406,7 @@ function createCommentNode(renderer, value) {
|
|
|
7449
7406
|
*/
|
|
7450
7407
|
function createElementNode(renderer, name, namespace) {
|
|
7451
7408
|
ngDevMode && ngDevMode.rendererCreateElement++;
|
|
7452
|
-
|
|
7453
|
-
return renderer.createElement(name, namespace);
|
|
7454
|
-
}
|
|
7455
|
-
else {
|
|
7456
|
-
const namespaceUri = namespace !== null ? getNamespaceUri(namespace) : null;
|
|
7457
|
-
return namespaceUri === null ? renderer.createElement(name) :
|
|
7458
|
-
renderer.createElementNS(namespaceUri, name);
|
|
7459
|
-
}
|
|
7409
|
+
return renderer.createElement(name, namespace);
|
|
7460
7410
|
}
|
|
7461
7411
|
/**
|
|
7462
7412
|
* Removes all DOM elements associated with a view.
|
|
@@ -7688,7 +7638,7 @@ function detachView(lContainer, removeIndex) {
|
|
|
7688
7638
|
function destroyLView(tView, lView) {
|
|
7689
7639
|
if (!(lView[FLAGS] & 128 /* LViewFlags.Destroyed */)) {
|
|
7690
7640
|
const renderer = lView[RENDERER];
|
|
7691
|
-
if (
|
|
7641
|
+
if (renderer.destroyNode) {
|
|
7692
7642
|
applyView(tView, lView, renderer, 3 /* WalkTNodeTreeAction.Destroy */, null, null);
|
|
7693
7643
|
}
|
|
7694
7644
|
destroyViewTree(lView);
|
|
@@ -7716,7 +7666,7 @@ function cleanUpView(tView, lView) {
|
|
|
7716
7666
|
executeOnDestroys(tView, lView);
|
|
7717
7667
|
processCleanups(tView, lView);
|
|
7718
7668
|
// For component views only, the local renderer is destroyed at clean up time.
|
|
7719
|
-
if (lView[TVIEW].type === 1 /* TViewType.Component */
|
|
7669
|
+
if (lView[TVIEW].type === 1 /* TViewType.Component */) {
|
|
7720
7670
|
ngDevMode && ngDevMode.rendererDestroy++;
|
|
7721
7671
|
lView[RENDERER].destroy();
|
|
7722
7672
|
}
|
|
@@ -7892,30 +7842,17 @@ function getClosestRElement(tView, tNode, lView) {
|
|
|
7892
7842
|
}
|
|
7893
7843
|
}
|
|
7894
7844
|
/**
|
|
7895
|
-
* Inserts a native node before another native node for a given parent
|
|
7896
|
-
* This is a utility function that can be used when native nodes were determined
|
|
7897
|
-
* actual renderer being used.
|
|
7845
|
+
* Inserts a native node before another native node for a given parent.
|
|
7846
|
+
* This is a utility function that can be used when native nodes were determined.
|
|
7898
7847
|
*/
|
|
7899
7848
|
function nativeInsertBefore(renderer, parent, child, beforeNode, isMove) {
|
|
7900
7849
|
ngDevMode && ngDevMode.rendererInsertBefore++;
|
|
7901
|
-
|
|
7902
|
-
renderer.insertBefore(parent, child, beforeNode, isMove);
|
|
7903
|
-
}
|
|
7904
|
-
else {
|
|
7905
|
-
const targetParent = isTemplateNode(parent) ? parent.content : parent;
|
|
7906
|
-
targetParent.insertBefore(child, beforeNode, isMove);
|
|
7907
|
-
}
|
|
7850
|
+
renderer.insertBefore(parent, child, beforeNode, isMove);
|
|
7908
7851
|
}
|
|
7909
7852
|
function nativeAppendChild(renderer, parent, child) {
|
|
7910
7853
|
ngDevMode && ngDevMode.rendererAppendChild++;
|
|
7911
7854
|
ngDevMode && assertDefined(parent, 'parent node must be defined');
|
|
7912
|
-
|
|
7913
|
-
renderer.appendChild(parent, child);
|
|
7914
|
-
}
|
|
7915
|
-
else {
|
|
7916
|
-
const targetParent = isTemplateNode(parent) ? parent.content : parent;
|
|
7917
|
-
targetParent.appendChild(child);
|
|
7918
|
-
}
|
|
7855
|
+
renderer.appendChild(parent, child);
|
|
7919
7856
|
}
|
|
7920
7857
|
function nativeAppendOrInsertBefore(renderer, parent, child, beforeNode, isMove) {
|
|
7921
7858
|
if (beforeNode !== null) {
|
|
@@ -7927,12 +7864,7 @@ function nativeAppendOrInsertBefore(renderer, parent, child, beforeNode, isMove)
|
|
|
7927
7864
|
}
|
|
7928
7865
|
/** Removes a node from the DOM given its native parent. */
|
|
7929
7866
|
function nativeRemoveChild(renderer, parent, child, isHostElement) {
|
|
7930
|
-
|
|
7931
|
-
renderer.removeChild(parent, child, isHostElement);
|
|
7932
|
-
}
|
|
7933
|
-
else {
|
|
7934
|
-
parent.removeChild(child);
|
|
7935
|
-
}
|
|
7867
|
+
renderer.removeChild(parent, child, isHostElement);
|
|
7936
7868
|
}
|
|
7937
7869
|
/** Checks if an element is a `<template>` node. */
|
|
7938
7870
|
function isTemplateNode(node) {
|
|
@@ -7942,13 +7874,13 @@ function isTemplateNode(node) {
|
|
|
7942
7874
|
* Returns a native parent of a given native node.
|
|
7943
7875
|
*/
|
|
7944
7876
|
function nativeParentNode(renderer, node) {
|
|
7945
|
-
return
|
|
7877
|
+
return renderer.parentNode(node);
|
|
7946
7878
|
}
|
|
7947
7879
|
/**
|
|
7948
7880
|
* Returns a native sibling of a given native node.
|
|
7949
7881
|
*/
|
|
7950
7882
|
function nativeNextSibling(renderer, node) {
|
|
7951
|
-
return
|
|
7883
|
+
return renderer.nextSibling(node);
|
|
7952
7884
|
}
|
|
7953
7885
|
/**
|
|
7954
7886
|
* Find a node in front of which `currentTNode` should be inserted.
|
|
@@ -8257,39 +8189,22 @@ function applyContainer(renderer, action, lContainer, parentRElement, beforeNode
|
|
|
8257
8189
|
* otherwise).
|
|
8258
8190
|
*/
|
|
8259
8191
|
function applyStyling(renderer, isClassBased, rNode, prop, value) {
|
|
8260
|
-
const isProcedural = isProceduralRenderer(renderer);
|
|
8261
8192
|
if (isClassBased) {
|
|
8262
8193
|
// We actually want JS true/false here because any truthy value should add the class
|
|
8263
8194
|
if (!value) {
|
|
8264
8195
|
ngDevMode && ngDevMode.rendererRemoveClass++;
|
|
8265
|
-
|
|
8266
|
-
renderer.removeClass(rNode, prop);
|
|
8267
|
-
}
|
|
8268
|
-
else {
|
|
8269
|
-
rNode.classList.remove(prop);
|
|
8270
|
-
}
|
|
8196
|
+
renderer.removeClass(rNode, prop);
|
|
8271
8197
|
}
|
|
8272
8198
|
else {
|
|
8273
8199
|
ngDevMode && ngDevMode.rendererAddClass++;
|
|
8274
|
-
|
|
8275
|
-
renderer.addClass(rNode, prop);
|
|
8276
|
-
}
|
|
8277
|
-
else {
|
|
8278
|
-
ngDevMode && assertDefined(rNode.classList, 'HTMLElement expected');
|
|
8279
|
-
rNode.classList.add(prop);
|
|
8280
|
-
}
|
|
8200
|
+
renderer.addClass(rNode, prop);
|
|
8281
8201
|
}
|
|
8282
8202
|
}
|
|
8283
8203
|
else {
|
|
8284
8204
|
let flags = prop.indexOf('-') === -1 ? undefined : RendererStyleFlags2.DashCase;
|
|
8285
8205
|
if (value == null /** || value === undefined */) {
|
|
8286
8206
|
ngDevMode && ngDevMode.rendererRemoveStyle++;
|
|
8287
|
-
|
|
8288
|
-
renderer.removeStyle(rNode, prop, flags);
|
|
8289
|
-
}
|
|
8290
|
-
else {
|
|
8291
|
-
rNode.style.removeProperty(prop);
|
|
8292
|
-
}
|
|
8207
|
+
renderer.removeStyle(rNode, prop, flags);
|
|
8293
8208
|
}
|
|
8294
8209
|
else {
|
|
8295
8210
|
// A value is important if it ends with `!important`. The style
|
|
@@ -8301,13 +8216,7 @@ function applyStyling(renderer, isClassBased, rNode, prop, value) {
|
|
|
8301
8216
|
flags |= RendererStyleFlags2.Important;
|
|
8302
8217
|
}
|
|
8303
8218
|
ngDevMode && ngDevMode.rendererSetStyle++;
|
|
8304
|
-
|
|
8305
|
-
renderer.setStyle(rNode, prop, value, flags);
|
|
8306
|
-
}
|
|
8307
|
-
else {
|
|
8308
|
-
ngDevMode && assertDefined(rNode.style, 'HTMLElement expected');
|
|
8309
|
-
rNode.style.setProperty(prop, value, isImportant ? 'important' : '');
|
|
8310
|
-
}
|
|
8219
|
+
renderer.setStyle(rNode, prop, value, flags);
|
|
8311
8220
|
}
|
|
8312
8221
|
}
|
|
8313
8222
|
}
|
|
@@ -8323,12 +8232,7 @@ function applyStyling(renderer, isClassBased, rNode, prop, value) {
|
|
|
8323
8232
|
*/
|
|
8324
8233
|
function writeDirectStyle(renderer, element, newValue) {
|
|
8325
8234
|
ngDevMode && assertString(newValue, '\'newValue\' should be a string');
|
|
8326
|
-
|
|
8327
|
-
renderer.setAttribute(element, 'style', newValue);
|
|
8328
|
-
}
|
|
8329
|
-
else {
|
|
8330
|
-
element.style.cssText = newValue;
|
|
8331
|
-
}
|
|
8235
|
+
renderer.setAttribute(element, 'style', newValue);
|
|
8332
8236
|
ngDevMode && ngDevMode.rendererSetStyle++;
|
|
8333
8237
|
}
|
|
8334
8238
|
/**
|
|
@@ -8343,17 +8247,12 @@ function writeDirectStyle(renderer, element, newValue) {
|
|
|
8343
8247
|
*/
|
|
8344
8248
|
function writeDirectClass(renderer, element, newValue) {
|
|
8345
8249
|
ngDevMode && assertString(newValue, '\'newValue\' should be a string');
|
|
8346
|
-
if (
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
renderer.removeAttribute(element, 'class');
|
|
8350
|
-
}
|
|
8351
|
-
else {
|
|
8352
|
-
renderer.setAttribute(element, 'class', newValue);
|
|
8353
|
-
}
|
|
8250
|
+
if (newValue === '') {
|
|
8251
|
+
// There are tests in `google3` which expect `element.getAttribute('class')` to be `null`.
|
|
8252
|
+
renderer.removeAttribute(element, 'class');
|
|
8354
8253
|
}
|
|
8355
8254
|
else {
|
|
8356
|
-
element
|
|
8255
|
+
renderer.setAttribute(element, 'class', newValue);
|
|
8357
8256
|
}
|
|
8358
8257
|
ngDevMode && ngDevMode.rendererSetClassName++;
|
|
8359
8258
|
}
|
|
@@ -8403,7 +8302,7 @@ function classIndexOf(className, classToSearch, startingIndex) {
|
|
|
8403
8302
|
* Use of this source code is governed by an MIT-style license that can be
|
|
8404
8303
|
* found in the LICENSE file at https://angular.io/license
|
|
8405
8304
|
*/
|
|
8406
|
-
const unusedValueToPlacateAjd$1 = unusedValueExportToPlacateAjd$
|
|
8305
|
+
const unusedValueToPlacateAjd$1 = unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4;
|
|
8407
8306
|
const NG_TEMPLATE_SELECTOR = 'ng-template';
|
|
8408
8307
|
/**
|
|
8409
8308
|
* Search the `TAttributes` to see if it contains `cssClassToMatch` (case insensitive)
|
|
@@ -10128,7 +10027,7 @@ class ReflectiveKey {
|
|
|
10128
10027
|
this.token = token;
|
|
10129
10028
|
this.id = id;
|
|
10130
10029
|
if (!token) {
|
|
10131
|
-
throw new
|
|
10030
|
+
throw new RuntimeError(208 /* RuntimeErrorCode.MISSING_INJECTION_TOKEN */, ngDevMode && 'Token must be defined!');
|
|
10132
10031
|
}
|
|
10133
10032
|
this.displayName = stringify(this.token);
|
|
10134
10033
|
}
|
|
@@ -11818,6 +11717,13 @@ class LContainerDebug {
|
|
|
11818
11717
|
}
|
|
11819
11718
|
}
|
|
11820
11719
|
|
|
11720
|
+
/**
|
|
11721
|
+
* @license
|
|
11722
|
+
* Copyright Google LLC All Rights Reserved.
|
|
11723
|
+
*
|
|
11724
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
11725
|
+
* found in the LICENSE file at https://angular.io/license
|
|
11726
|
+
*/
|
|
11821
11727
|
/**
|
|
11822
11728
|
* A permanent marker promise which signifies that the current CD tree is
|
|
11823
11729
|
* clean.
|
|
@@ -11885,7 +11791,7 @@ function refreshChildComponents(hostLView, components) {
|
|
|
11885
11791
|
/** Renders child components in the current view (creation mode). */
|
|
11886
11792
|
function renderChildComponents(hostLView, components) {
|
|
11887
11793
|
for (let i = 0; i < components.length; i++) {
|
|
11888
|
-
renderComponent
|
|
11794
|
+
renderComponent(hostLView, components[i]);
|
|
11889
11795
|
}
|
|
11890
11796
|
}
|
|
11891
11797
|
function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
|
|
@@ -12403,16 +12309,6 @@ function createViewBlueprint(bindingStartIndex, initialViewLength) {
|
|
|
12403
12309
|
function createError(text, token) {
|
|
12404
12310
|
return new Error(`Renderer: ${text} [${stringifyForError(token)}]`);
|
|
12405
12311
|
}
|
|
12406
|
-
function assertHostNodeExists(rElement, elementOrSelector) {
|
|
12407
|
-
if (!rElement) {
|
|
12408
|
-
if (typeof elementOrSelector === 'string') {
|
|
12409
|
-
throw createError('Host node with selector not found:', elementOrSelector);
|
|
12410
|
-
}
|
|
12411
|
-
else {
|
|
12412
|
-
throw createError('Host node is required:', elementOrSelector);
|
|
12413
|
-
}
|
|
12414
|
-
}
|
|
12415
|
-
}
|
|
12416
12312
|
/**
|
|
12417
12313
|
* Locates the host native element, used for bootstrapping existing nodes into rendering pipeline.
|
|
12418
12314
|
*
|
|
@@ -12421,21 +12317,9 @@ function assertHostNodeExists(rElement, elementOrSelector) {
|
|
|
12421
12317
|
* @param encapsulation View Encapsulation defined for component that requests host element.
|
|
12422
12318
|
*/
|
|
12423
12319
|
function locateHostElement(renderer, elementOrSelector, encapsulation) {
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
return renderer.selectRootElement(elementOrSelector, preserveContent);
|
|
12428
|
-
}
|
|
12429
|
-
let rElement = typeof elementOrSelector === 'string' ?
|
|
12430
|
-
renderer.querySelector(elementOrSelector) :
|
|
12431
|
-
elementOrSelector;
|
|
12432
|
-
ngDevMode && assertHostNodeExists(rElement, elementOrSelector);
|
|
12433
|
-
// Always clear host element's content when Renderer3 is in use. For procedural renderer case we
|
|
12434
|
-
// make it depend on whether ShadowDom encapsulation is used (in which case the content should be
|
|
12435
|
-
// preserved to allow native slot projection). ShadowDom encapsulation requires procedural
|
|
12436
|
-
// renderer, and procedural renderer case is handled above.
|
|
12437
|
-
rElement.textContent = '';
|
|
12438
|
-
return rElement;
|
|
12320
|
+
// When using native Shadow DOM, do not clear host element to allow native slot projection
|
|
12321
|
+
const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
|
|
12322
|
+
return renderer.selectRootElement(elementOrSelector, preserveContent);
|
|
12439
12323
|
}
|
|
12440
12324
|
/**
|
|
12441
12325
|
* Saves context for this cleanup function in LView.cleanupInstances.
|
|
@@ -12650,13 +12534,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
|
|
|
12650
12534
|
// It is assumed that the sanitizer is only added when the compiler determines that the
|
|
12651
12535
|
// property is risky, so sanitization can be done without further checks.
|
|
12652
12536
|
value = sanitizer != null ? sanitizer(value, tNode.value || '', propName) : value;
|
|
12653
|
-
|
|
12654
|
-
renderer.setProperty(element, propName, value);
|
|
12655
|
-
}
|
|
12656
|
-
else if (!isAnimationProp(propName)) {
|
|
12657
|
-
element.setProperty ? element.setProperty(propName, value) :
|
|
12658
|
-
element[propName] = value;
|
|
12659
|
-
}
|
|
12537
|
+
renderer.setProperty(element, propName, value);
|
|
12660
12538
|
}
|
|
12661
12539
|
else if (tNode.type & 12 /* TNodeType.AnyContainer */) {
|
|
12662
12540
|
// If the node is a container and the property didn't
|
|
@@ -12680,23 +12558,15 @@ function setNgReflectProperty(lView, element, type, attrName, value) {
|
|
|
12680
12558
|
const debugValue = normalizeDebugBindingValue(value);
|
|
12681
12559
|
if (type & 3 /* TNodeType.AnyRNode */) {
|
|
12682
12560
|
if (value == null) {
|
|
12683
|
-
|
|
12684
|
-
element.removeAttribute(attrName);
|
|
12561
|
+
renderer.removeAttribute(element, attrName);
|
|
12685
12562
|
}
|
|
12686
12563
|
else {
|
|
12687
|
-
|
|
12688
|
-
renderer.setAttribute(element, attrName, debugValue) :
|
|
12689
|
-
element.setAttribute(attrName, debugValue);
|
|
12564
|
+
renderer.setAttribute(element, attrName, debugValue);
|
|
12690
12565
|
}
|
|
12691
12566
|
}
|
|
12692
12567
|
else {
|
|
12693
12568
|
const textContent = escapeCommentText(`bindings=${JSON.stringify({ [attrName]: debugValue }, null, 2)}`);
|
|
12694
|
-
|
|
12695
|
-
renderer.setValue(element, textContent);
|
|
12696
|
-
}
|
|
12697
|
-
else {
|
|
12698
|
-
element.textContent = textContent;
|
|
12699
|
-
}
|
|
12569
|
+
renderer.setValue(element, textContent);
|
|
12700
12570
|
}
|
|
12701
12571
|
}
|
|
12702
12572
|
function setNgReflectProperties(lView, element, type, dataValue, value) {
|
|
@@ -13050,19 +12920,12 @@ function elementAttributeInternal(tNode, lView, name, value, sanitizer, namespac
|
|
|
13050
12920
|
function setElementAttribute(renderer, element, namespace, tagName, name, value, sanitizer) {
|
|
13051
12921
|
if (value == null) {
|
|
13052
12922
|
ngDevMode && ngDevMode.rendererRemoveAttribute++;
|
|
13053
|
-
|
|
13054
|
-
element.removeAttribute(name);
|
|
12923
|
+
renderer.removeAttribute(element, name, namespace);
|
|
13055
12924
|
}
|
|
13056
12925
|
else {
|
|
13057
12926
|
ngDevMode && ngDevMode.rendererSetAttribute++;
|
|
13058
12927
|
const strValue = sanitizer == null ? renderStringify(value) : sanitizer(value, tagName || '', name);
|
|
13059
|
-
|
|
13060
|
-
renderer.setAttribute(element, name, strValue, namespace);
|
|
13061
|
-
}
|
|
13062
|
-
else {
|
|
13063
|
-
namespace ? element.setAttributeNS(namespace, name, strValue) :
|
|
13064
|
-
element.setAttribute(name, strValue);
|
|
13065
|
-
}
|
|
12928
|
+
renderer.setAttribute(element, name, strValue, namespace);
|
|
13066
12929
|
}
|
|
13067
12930
|
}
|
|
13068
12931
|
/**
|
|
@@ -13154,7 +13017,6 @@ const LContainerArray = class LContainer extends Array {
|
|
|
13154
13017
|
*/
|
|
13155
13018
|
function createLContainer(hostNative, currentView, native, tNode) {
|
|
13156
13019
|
ngDevMode && assertLView(currentView);
|
|
13157
|
-
ngDevMode && !isProceduralRenderer(currentView[RENDERER]) && assertDomNode(native);
|
|
13158
13020
|
// https://jsperf.com/array-literal-vs-new-array-really
|
|
13159
13021
|
const lContainer = new (ngDevMode ? LContainerArray : Array)(hostNative, // host native
|
|
13160
13022
|
true, // Boolean `true` in this position signifies that this is an `LContainer`
|
|
@@ -13270,7 +13132,7 @@ function refreshContainsDirtyView(lView) {
|
|
|
13270
13132
|
}
|
|
13271
13133
|
}
|
|
13272
13134
|
}
|
|
13273
|
-
function renderComponent
|
|
13135
|
+
function renderComponent(hostLView, componentHostIdx) {
|
|
13274
13136
|
ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
|
|
13275
13137
|
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
|
|
13276
13138
|
const componentTView = componentView[TVIEW];
|
|
@@ -13622,720 +13484,116 @@ function computeStaticStyling(tNode, attrs, writeToHost) {
|
|
|
13622
13484
|
* Use of this source code is governed by an MIT-style license that can be
|
|
13623
13485
|
* found in the LICENSE file at https://angular.io/license
|
|
13624
13486
|
*/
|
|
13487
|
+
// TODO: A hack to not pull in the NullInjector from @angular/core.
|
|
13488
|
+
const NULL_INJECTOR = {
|
|
13489
|
+
get: (token, notFoundValue) => {
|
|
13490
|
+
throwProviderNotFoundError(token, 'NullInjector');
|
|
13491
|
+
}
|
|
13492
|
+
};
|
|
13625
13493
|
/**
|
|
13626
|
-
*
|
|
13494
|
+
* Creates the root component view and the root component node.
|
|
13627
13495
|
*
|
|
13628
|
-
*
|
|
13496
|
+
* @param rNode Render host element.
|
|
13497
|
+
* @param def ComponentDef
|
|
13498
|
+
* @param rootView The parent view where the host node is stored
|
|
13499
|
+
* @param rendererFactory Factory to be used for creating child renderers.
|
|
13500
|
+
* @param hostRenderer The current renderer
|
|
13501
|
+
* @param sanitizer The sanitizer, if provided
|
|
13629
13502
|
*
|
|
13630
|
-
* @
|
|
13503
|
+
* @returns Component view created
|
|
13631
13504
|
*/
|
|
13632
|
-
function
|
|
13633
|
-
const
|
|
13634
|
-
|
|
13505
|
+
function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
|
|
13506
|
+
const tView = rootView[TVIEW];
|
|
13507
|
+
const index = HEADER_OFFSET;
|
|
13508
|
+
ngDevMode && assertIndexInRange(rootView, index);
|
|
13509
|
+
rootView[index] = rNode;
|
|
13510
|
+
// '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
|
|
13511
|
+
// the same time we want to communicate the debug `TNode` that this is a special `TNode`
|
|
13512
|
+
// representing a host element.
|
|
13513
|
+
const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
|
|
13514
|
+
const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
|
|
13515
|
+
if (mergedAttrs !== null) {
|
|
13516
|
+
computeStaticStyling(tNode, mergedAttrs, true);
|
|
13517
|
+
if (rNode !== null) {
|
|
13518
|
+
setUpAttributes(hostRenderer, rNode, mergedAttrs);
|
|
13519
|
+
if (tNode.classes !== null) {
|
|
13520
|
+
writeDirectClass(hostRenderer, rNode, tNode.classes);
|
|
13521
|
+
}
|
|
13522
|
+
if (tNode.styles !== null) {
|
|
13523
|
+
writeDirectStyle(hostRenderer, rNode, tNode.styles);
|
|
13524
|
+
}
|
|
13525
|
+
}
|
|
13526
|
+
}
|
|
13527
|
+
const viewRenderer = rendererFactory.createRenderer(rNode, def);
|
|
13528
|
+
const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
|
|
13529
|
+
if (tView.firstCreatePass) {
|
|
13530
|
+
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
|
13531
|
+
markAsComponentHost(tView, tNode);
|
|
13532
|
+
initTNodeFlags(tNode, rootView.length, 1);
|
|
13533
|
+
}
|
|
13534
|
+
addToViewTree(rootView, componentView);
|
|
13535
|
+
// Store component view at node index, with node as the HOST
|
|
13536
|
+
return rootView[index] = componentView;
|
|
13635
13537
|
}
|
|
13636
13538
|
/**
|
|
13637
|
-
*
|
|
13638
|
-
*
|
|
13639
|
-
*
|
|
13640
|
-
* Marking an already dirty component as dirty won't do anything. Only one outstanding change
|
|
13641
|
-
* detection can be scheduled per component tree.
|
|
13642
|
-
*
|
|
13643
|
-
* @param component Component to mark as dirty.
|
|
13539
|
+
* Creates a root component and sets it up with features and host bindings. Shared by
|
|
13540
|
+
* renderComponent() and ViewContainerRef.createComponent().
|
|
13644
13541
|
*/
|
|
13645
|
-
function
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13542
|
+
function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
|
|
13543
|
+
const tView = rootLView[TVIEW];
|
|
13544
|
+
// Create directive instance with factory() and store at next index in viewData
|
|
13545
|
+
const component = instantiateRootComponent(tView, rootLView, componentDef);
|
|
13546
|
+
rootContext.components.push(component);
|
|
13547
|
+
componentView[CONTEXT] = component;
|
|
13548
|
+
if (hostFeatures !== null) {
|
|
13549
|
+
for (const feature of hostFeatures) {
|
|
13550
|
+
feature(component, componentDef);
|
|
13551
|
+
}
|
|
13552
|
+
}
|
|
13553
|
+
// We want to generate an empty QueryList for root content queries for backwards
|
|
13554
|
+
// compatibility with ViewEngine.
|
|
13555
|
+
if (componentDef.contentQueries) {
|
|
13556
|
+
const tNode = getCurrentTNode();
|
|
13557
|
+
ngDevMode && assertDefined(tNode, 'TNode expected');
|
|
13558
|
+
componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
|
|
13559
|
+
}
|
|
13560
|
+
const rootTNode = getCurrentTNode();
|
|
13561
|
+
ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
|
|
13562
|
+
if (tView.firstCreatePass &&
|
|
13563
|
+
(componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
|
|
13564
|
+
setSelectedIndex(rootTNode.index);
|
|
13565
|
+
const rootTView = rootLView[TVIEW];
|
|
13566
|
+
registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
|
|
13567
|
+
invokeHostBindingsInCreationMode(componentDef, component);
|
|
13568
|
+
}
|
|
13569
|
+
return component;
|
|
13570
|
+
}
|
|
13571
|
+
function createRootContext(scheduler, playerHandler) {
|
|
13572
|
+
return {
|
|
13573
|
+
components: [],
|
|
13574
|
+
scheduler: scheduler || defaultScheduler,
|
|
13575
|
+
clean: CLEAN_PROMISE,
|
|
13576
|
+
playerHandler: playerHandler || null,
|
|
13577
|
+
flags: 0 /* RootContextFlags.Empty */
|
|
13578
|
+
};
|
|
13650
13579
|
}
|
|
13651
13580
|
/**
|
|
13652
|
-
* Used to
|
|
13581
|
+
* Used to enable lifecycle hooks on the root component.
|
|
13653
13582
|
*
|
|
13654
|
-
*
|
|
13655
|
-
*
|
|
13656
|
-
*
|
|
13583
|
+
* Include this feature when calling `renderComponent` if the root component
|
|
13584
|
+
* you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
|
|
13585
|
+
* be called properly.
|
|
13657
13586
|
*
|
|
13658
|
-
*
|
|
13659
|
-
*
|
|
13660
|
-
*
|
|
13661
|
-
*
|
|
13587
|
+
* Example:
|
|
13588
|
+
*
|
|
13589
|
+
* ```
|
|
13590
|
+
* renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
|
|
13591
|
+
* ```
|
|
13662
13592
|
*/
|
|
13663
|
-
function
|
|
13664
|
-
const
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
}
|
|
13668
|
-
|
|
13669
|
-
/**
|
|
13670
|
-
* @license
|
|
13671
|
-
* Copyright Google LLC All Rights Reserved.
|
|
13672
|
-
*
|
|
13673
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
13674
|
-
* found in the LICENSE file at https://angular.io/license
|
|
13675
|
-
*/
|
|
13676
|
-
/**
|
|
13677
|
-
* Retrieves the component instance associated with a given DOM element.
|
|
13678
|
-
*
|
|
13679
|
-
* @usageNotes
|
|
13680
|
-
* Given the following DOM structure:
|
|
13681
|
-
*
|
|
13682
|
-
* ```html
|
|
13683
|
-
* <app-root>
|
|
13684
|
-
* <div>
|
|
13685
|
-
* <child-comp></child-comp>
|
|
13686
|
-
* </div>
|
|
13687
|
-
* </app-root>
|
|
13688
|
-
* ```
|
|
13689
|
-
*
|
|
13690
|
-
* Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
|
|
13691
|
-
* associated with this DOM element.
|
|
13692
|
-
*
|
|
13693
|
-
* Calling the function on `<app-root>` will return the `MyApp` instance.
|
|
13694
|
-
*
|
|
13695
|
-
*
|
|
13696
|
-
* @param element DOM element from which the component should be retrieved.
|
|
13697
|
-
* @returns Component instance associated with the element or `null` if there
|
|
13698
|
-
* is no component associated with it.
|
|
13699
|
-
*
|
|
13700
|
-
* @publicApi
|
|
13701
|
-
* @globalApi ng
|
|
13702
|
-
*/
|
|
13703
|
-
function getComponent$1(element) {
|
|
13704
|
-
ngDevMode && assertDomElement(element);
|
|
13705
|
-
const context = getLContext(element);
|
|
13706
|
-
if (context === null)
|
|
13707
|
-
return null;
|
|
13708
|
-
if (context.component === undefined) {
|
|
13709
|
-
const lView = context.lView;
|
|
13710
|
-
if (lView === null) {
|
|
13711
|
-
return null;
|
|
13712
|
-
}
|
|
13713
|
-
context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
|
|
13714
|
-
}
|
|
13715
|
-
return context.component;
|
|
13716
|
-
}
|
|
13717
|
-
/**
|
|
13718
|
-
* If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
|
|
13719
|
-
* view that the element is part of. Otherwise retrieves the instance of the component whose view
|
|
13720
|
-
* owns the element (in this case, the result is the same as calling `getOwningComponent`).
|
|
13721
|
-
*
|
|
13722
|
-
* @param element Element for which to get the surrounding component instance.
|
|
13723
|
-
* @returns Instance of the component that is around the element or null if the element isn't
|
|
13724
|
-
* inside any component.
|
|
13725
|
-
*
|
|
13726
|
-
* @publicApi
|
|
13727
|
-
* @globalApi ng
|
|
13728
|
-
*/
|
|
13729
|
-
function getContext(element) {
|
|
13730
|
-
assertDomElement(element);
|
|
13731
|
-
const context = getLContext(element);
|
|
13732
|
-
const lView = context ? context.lView : null;
|
|
13733
|
-
return lView === null ? null : lView[CONTEXT];
|
|
13734
|
-
}
|
|
13735
|
-
/**
|
|
13736
|
-
* Retrieves the component instance whose view contains the DOM element.
|
|
13737
|
-
*
|
|
13738
|
-
* For example, if `<child-comp>` is used in the template of `<app-comp>`
|
|
13739
|
-
* (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
|
|
13740
|
-
* would return `<app-comp>`.
|
|
13741
|
-
*
|
|
13742
|
-
* @param elementOrDir DOM element, component or directive instance
|
|
13743
|
-
* for which to retrieve the root components.
|
|
13744
|
-
* @returns Component instance whose view owns the DOM element or null if the element is not
|
|
13745
|
-
* part of a component view.
|
|
13746
|
-
*
|
|
13747
|
-
* @publicApi
|
|
13748
|
-
* @globalApi ng
|
|
13749
|
-
*/
|
|
13750
|
-
function getOwningComponent(elementOrDir) {
|
|
13751
|
-
const context = getLContext(elementOrDir);
|
|
13752
|
-
let lView = context ? context.lView : null;
|
|
13753
|
-
if (lView === null)
|
|
13754
|
-
return null;
|
|
13755
|
-
let parent;
|
|
13756
|
-
while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
|
|
13757
|
-
lView = parent;
|
|
13758
|
-
}
|
|
13759
|
-
return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
|
|
13760
|
-
}
|
|
13761
|
-
/**
|
|
13762
|
-
* Retrieves all root components associated with a DOM element, directive or component instance.
|
|
13763
|
-
* Root components are those which have been bootstrapped by Angular.
|
|
13764
|
-
*
|
|
13765
|
-
* @param elementOrDir DOM element, component or directive instance
|
|
13766
|
-
* for which to retrieve the root components.
|
|
13767
|
-
* @returns Root components associated with the target object.
|
|
13768
|
-
*
|
|
13769
|
-
* @publicApi
|
|
13770
|
-
* @globalApi ng
|
|
13771
|
-
*/
|
|
13772
|
-
function getRootComponents(elementOrDir) {
|
|
13773
|
-
const lView = readPatchedLView(elementOrDir);
|
|
13774
|
-
return lView !== null ? [...getRootContext(lView).components] : [];
|
|
13775
|
-
}
|
|
13776
|
-
/**
|
|
13777
|
-
* Retrieves an `Injector` associated with an element, component or directive instance.
|
|
13778
|
-
*
|
|
13779
|
-
* @param elementOrDir DOM element, component or directive instance for which to
|
|
13780
|
-
* retrieve the injector.
|
|
13781
|
-
* @returns Injector associated with the element, component or directive instance.
|
|
13782
|
-
*
|
|
13783
|
-
* @publicApi
|
|
13784
|
-
* @globalApi ng
|
|
13785
|
-
*/
|
|
13786
|
-
function getInjector(elementOrDir) {
|
|
13787
|
-
const context = getLContext(elementOrDir);
|
|
13788
|
-
const lView = context ? context.lView : null;
|
|
13789
|
-
if (lView === null)
|
|
13790
|
-
return Injector.NULL;
|
|
13791
|
-
const tNode = lView[TVIEW].data[context.nodeIndex];
|
|
13792
|
-
return new NodeInjector(tNode, lView);
|
|
13793
|
-
}
|
|
13794
|
-
/**
|
|
13795
|
-
* Retrieve a set of injection tokens at a given DOM node.
|
|
13796
|
-
*
|
|
13797
|
-
* @param element Element for which the injection tokens should be retrieved.
|
|
13798
|
-
*/
|
|
13799
|
-
function getInjectionTokens(element) {
|
|
13800
|
-
const context = getLContext(element);
|
|
13801
|
-
const lView = context ? context.lView : null;
|
|
13802
|
-
if (lView === null)
|
|
13803
|
-
return [];
|
|
13804
|
-
const tView = lView[TVIEW];
|
|
13805
|
-
const tNode = tView.data[context.nodeIndex];
|
|
13806
|
-
const providerTokens = [];
|
|
13807
|
-
const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
|
|
13808
|
-
const endIndex = tNode.directiveEnd;
|
|
13809
|
-
for (let i = startIndex; i < endIndex; i++) {
|
|
13810
|
-
let value = tView.data[i];
|
|
13811
|
-
if (isDirectiveDefHack(value)) {
|
|
13812
|
-
// The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
|
|
13813
|
-
// design flaw. We should always store same type so that we can be monomorphic. The issue
|
|
13814
|
-
// is that for Components/Directives we store the def instead the type. The correct behavior
|
|
13815
|
-
// is that we should always be storing injectable type in this location.
|
|
13816
|
-
value = value.type;
|
|
13817
|
-
}
|
|
13818
|
-
providerTokens.push(value);
|
|
13819
|
-
}
|
|
13820
|
-
return providerTokens;
|
|
13821
|
-
}
|
|
13822
|
-
/**
|
|
13823
|
-
* Retrieves directive instances associated with a given DOM node. Does not include
|
|
13824
|
-
* component instances.
|
|
13825
|
-
*
|
|
13826
|
-
* @usageNotes
|
|
13827
|
-
* Given the following DOM structure:
|
|
13828
|
-
*
|
|
13829
|
-
* ```html
|
|
13830
|
-
* <app-root>
|
|
13831
|
-
* <button my-button></button>
|
|
13832
|
-
* <my-comp></my-comp>
|
|
13833
|
-
* </app-root>
|
|
13834
|
-
* ```
|
|
13835
|
-
*
|
|
13836
|
-
* Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
|
|
13837
|
-
* directive that is associated with the DOM node.
|
|
13838
|
-
*
|
|
13839
|
-
* Calling `getDirectives` on `<my-comp>` will return an empty array.
|
|
13840
|
-
*
|
|
13841
|
-
* @param node DOM node for which to get the directives.
|
|
13842
|
-
* @returns Array of directives associated with the node.
|
|
13843
|
-
*
|
|
13844
|
-
* @publicApi
|
|
13845
|
-
* @globalApi ng
|
|
13846
|
-
*/
|
|
13847
|
-
function getDirectives(node) {
|
|
13848
|
-
// Skip text nodes because we can't have directives associated with them.
|
|
13849
|
-
if (node instanceof Text) {
|
|
13850
|
-
return [];
|
|
13851
|
-
}
|
|
13852
|
-
const context = getLContext(node);
|
|
13853
|
-
const lView = context ? context.lView : null;
|
|
13854
|
-
if (lView === null) {
|
|
13855
|
-
return [];
|
|
13856
|
-
}
|
|
13857
|
-
const tView = lView[TVIEW];
|
|
13858
|
-
const nodeIndex = context.nodeIndex;
|
|
13859
|
-
if (!tView?.data[nodeIndex]) {
|
|
13860
|
-
return [];
|
|
13861
|
-
}
|
|
13862
|
-
if (context.directives === undefined) {
|
|
13863
|
-
context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
|
|
13864
|
-
}
|
|
13865
|
-
// The `directives` in this case are a named array called `LComponentView`. Clone the
|
|
13866
|
-
// result so we don't expose an internal data structure in the user's console.
|
|
13867
|
-
return context.directives === null ? [] : [...context.directives];
|
|
13868
|
-
}
|
|
13869
|
-
/**
|
|
13870
|
-
* Returns the debug (partial) metadata for a particular directive or component instance.
|
|
13871
|
-
* The function accepts an instance of a directive or component and returns the corresponding
|
|
13872
|
-
* metadata.
|
|
13873
|
-
*
|
|
13874
|
-
* @param directiveOrComponentInstance Instance of a directive or component
|
|
13875
|
-
* @returns metadata of the passed directive or component
|
|
13876
|
-
*
|
|
13877
|
-
* @publicApi
|
|
13878
|
-
* @globalApi ng
|
|
13879
|
-
*/
|
|
13880
|
-
function getDirectiveMetadata(directiveOrComponentInstance) {
|
|
13881
|
-
const { constructor } = directiveOrComponentInstance;
|
|
13882
|
-
if (!constructor) {
|
|
13883
|
-
throw new Error('Unable to find the instance constructor');
|
|
13884
|
-
}
|
|
13885
|
-
// In case a component inherits from a directive, we may have component and directive metadata
|
|
13886
|
-
// To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
|
|
13887
|
-
const componentDef = getComponentDef$1(constructor);
|
|
13888
|
-
if (componentDef) {
|
|
13889
|
-
return {
|
|
13890
|
-
inputs: componentDef.inputs,
|
|
13891
|
-
outputs: componentDef.outputs,
|
|
13892
|
-
encapsulation: componentDef.encapsulation,
|
|
13893
|
-
changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
|
|
13894
|
-
ChangeDetectionStrategy.Default
|
|
13895
|
-
};
|
|
13896
|
-
}
|
|
13897
|
-
const directiveDef = getDirectiveDef(constructor);
|
|
13898
|
-
if (directiveDef) {
|
|
13899
|
-
return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
|
|
13900
|
-
}
|
|
13901
|
-
return null;
|
|
13902
|
-
}
|
|
13903
|
-
/**
|
|
13904
|
-
* Retrieve map of local references.
|
|
13905
|
-
*
|
|
13906
|
-
* The references are retrieved as a map of local reference name to element or directive instance.
|
|
13907
|
-
*
|
|
13908
|
-
* @param target DOM element, component or directive instance for which to retrieve
|
|
13909
|
-
* the local references.
|
|
13910
|
-
*/
|
|
13911
|
-
function getLocalRefs(target) {
|
|
13912
|
-
const context = getLContext(target);
|
|
13913
|
-
if (context === null)
|
|
13914
|
-
return {};
|
|
13915
|
-
if (context.localRefs === undefined) {
|
|
13916
|
-
const lView = context.lView;
|
|
13917
|
-
if (lView === null) {
|
|
13918
|
-
return {};
|
|
13919
|
-
}
|
|
13920
|
-
context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
|
|
13921
|
-
}
|
|
13922
|
-
return context.localRefs || {};
|
|
13923
|
-
}
|
|
13924
|
-
/**
|
|
13925
|
-
* Retrieves the host element of a component or directive instance.
|
|
13926
|
-
* The host element is the DOM element that matched the selector of the directive.
|
|
13927
|
-
*
|
|
13928
|
-
* @param componentOrDirective Component or directive instance for which the host
|
|
13929
|
-
* element should be retrieved.
|
|
13930
|
-
* @returns Host element of the target.
|
|
13931
|
-
*
|
|
13932
|
-
* @publicApi
|
|
13933
|
-
* @globalApi ng
|
|
13934
|
-
*/
|
|
13935
|
-
function getHostElement(componentOrDirective) {
|
|
13936
|
-
return getLContext(componentOrDirective).native;
|
|
13937
|
-
}
|
|
13938
|
-
/**
|
|
13939
|
-
* Retrieves the rendered text for a given component.
|
|
13940
|
-
*
|
|
13941
|
-
* This function retrieves the host element of a component and
|
|
13942
|
-
* and then returns the `textContent` for that element. This implies
|
|
13943
|
-
* that the text returned will include re-projected content of
|
|
13944
|
-
* the component as well.
|
|
13945
|
-
*
|
|
13946
|
-
* @param component The component to return the content text for.
|
|
13947
|
-
*/
|
|
13948
|
-
function getRenderedText(component) {
|
|
13949
|
-
const hostElement = getHostElement(component);
|
|
13950
|
-
return hostElement.textContent || '';
|
|
13951
|
-
}
|
|
13952
|
-
/**
|
|
13953
|
-
* Retrieves a list of event listeners associated with a DOM element. The list does include host
|
|
13954
|
-
* listeners, but it does not include event listeners defined outside of the Angular context
|
|
13955
|
-
* (e.g. through `addEventListener`).
|
|
13956
|
-
*
|
|
13957
|
-
* @usageNotes
|
|
13958
|
-
* Given the following DOM structure:
|
|
13959
|
-
*
|
|
13960
|
-
* ```html
|
|
13961
|
-
* <app-root>
|
|
13962
|
-
* <div (click)="doSomething()"></div>
|
|
13963
|
-
* </app-root>
|
|
13964
|
-
* ```
|
|
13965
|
-
*
|
|
13966
|
-
* Calling `getListeners` on `<div>` will return an object that looks as follows:
|
|
13967
|
-
*
|
|
13968
|
-
* ```ts
|
|
13969
|
-
* {
|
|
13970
|
-
* name: 'click',
|
|
13971
|
-
* element: <div>,
|
|
13972
|
-
* callback: () => doSomething(),
|
|
13973
|
-
* useCapture: false
|
|
13974
|
-
* }
|
|
13975
|
-
* ```
|
|
13976
|
-
*
|
|
13977
|
-
* @param element Element for which the DOM listeners should be retrieved.
|
|
13978
|
-
* @returns Array of event listeners on the DOM element.
|
|
13979
|
-
*
|
|
13980
|
-
* @publicApi
|
|
13981
|
-
* @globalApi ng
|
|
13982
|
-
*/
|
|
13983
|
-
function getListeners(element) {
|
|
13984
|
-
ngDevMode && assertDomElement(element);
|
|
13985
|
-
const lContext = getLContext(element);
|
|
13986
|
-
const lView = lContext === null ? null : lContext.lView;
|
|
13987
|
-
if (lView === null)
|
|
13988
|
-
return [];
|
|
13989
|
-
const tView = lView[TVIEW];
|
|
13990
|
-
const lCleanup = lView[CLEANUP];
|
|
13991
|
-
const tCleanup = tView.cleanup;
|
|
13992
|
-
const listeners = [];
|
|
13993
|
-
if (tCleanup && lCleanup) {
|
|
13994
|
-
for (let i = 0; i < tCleanup.length;) {
|
|
13995
|
-
const firstParam = tCleanup[i++];
|
|
13996
|
-
const secondParam = tCleanup[i++];
|
|
13997
|
-
if (typeof firstParam === 'string') {
|
|
13998
|
-
const name = firstParam;
|
|
13999
|
-
const listenerElement = unwrapRNode(lView[secondParam]);
|
|
14000
|
-
const callback = lCleanup[tCleanup[i++]];
|
|
14001
|
-
const useCaptureOrIndx = tCleanup[i++];
|
|
14002
|
-
// if useCaptureOrIndx is boolean then report it as is.
|
|
14003
|
-
// if useCaptureOrIndx is positive number then it in unsubscribe method
|
|
14004
|
-
// if useCaptureOrIndx is negative number then it is a Subscription
|
|
14005
|
-
const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
|
|
14006
|
-
const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
|
|
14007
|
-
if (element == listenerElement) {
|
|
14008
|
-
listeners.push({ element, name, callback, useCapture, type });
|
|
14009
|
-
}
|
|
14010
|
-
}
|
|
14011
|
-
}
|
|
14012
|
-
}
|
|
14013
|
-
listeners.sort(sortListeners);
|
|
14014
|
-
return listeners;
|
|
14015
|
-
}
|
|
14016
|
-
function sortListeners(a, b) {
|
|
14017
|
-
if (a.name == b.name)
|
|
14018
|
-
return 0;
|
|
14019
|
-
return a.name < b.name ? -1 : 1;
|
|
14020
|
-
}
|
|
14021
|
-
/**
|
|
14022
|
-
* This function should not exist because it is megamorphic and only mostly correct.
|
|
14023
|
-
*
|
|
14024
|
-
* See call site for more info.
|
|
14025
|
-
*/
|
|
14026
|
-
function isDirectiveDefHack(obj) {
|
|
14027
|
-
return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
|
|
14028
|
-
}
|
|
14029
|
-
/**
|
|
14030
|
-
* Returns the attached `DebugNode` instance for an element in the DOM.
|
|
14031
|
-
*
|
|
14032
|
-
* @param element DOM element which is owned by an existing component's view.
|
|
14033
|
-
*/
|
|
14034
|
-
function getDebugNode(element) {
|
|
14035
|
-
if (ngDevMode && !(element instanceof Node)) {
|
|
14036
|
-
throw new Error('Expecting instance of DOM Element');
|
|
14037
|
-
}
|
|
14038
|
-
const lContext = getLContext(element);
|
|
14039
|
-
const lView = lContext ? lContext.lView : null;
|
|
14040
|
-
if (lView === null) {
|
|
14041
|
-
return null;
|
|
14042
|
-
}
|
|
14043
|
-
const nodeIndex = lContext.nodeIndex;
|
|
14044
|
-
if (nodeIndex !== -1) {
|
|
14045
|
-
const valueInLView = lView[nodeIndex];
|
|
14046
|
-
// this means that value in the lView is a component with its own
|
|
14047
|
-
// data. In this situation the TNode is not accessed at the same spot.
|
|
14048
|
-
const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
|
|
14049
|
-
ngDevMode &&
|
|
14050
|
-
assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
|
|
14051
|
-
return buildDebugNode(tNode, lView);
|
|
14052
|
-
}
|
|
14053
|
-
return null;
|
|
14054
|
-
}
|
|
14055
|
-
/**
|
|
14056
|
-
* Retrieve the component `LView` from component/element.
|
|
14057
|
-
*
|
|
14058
|
-
* NOTE: `LView` is a private and should not be leaked outside.
|
|
14059
|
-
* Don't export this method to `ng.*` on window.
|
|
14060
|
-
*
|
|
14061
|
-
* @param target DOM element or component instance for which to retrieve the LView.
|
|
14062
|
-
*/
|
|
14063
|
-
function getComponentLView(target) {
|
|
14064
|
-
const lContext = getLContext(target);
|
|
14065
|
-
const nodeIndx = lContext.nodeIndex;
|
|
14066
|
-
const lView = lContext.lView;
|
|
14067
|
-
ngDevMode && assertLView(lView);
|
|
14068
|
-
const componentLView = lView[nodeIndx];
|
|
14069
|
-
ngDevMode && assertLView(componentLView);
|
|
14070
|
-
return componentLView;
|
|
14071
|
-
}
|
|
14072
|
-
/** Asserts that a value is a DOM Element. */
|
|
14073
|
-
function assertDomElement(value) {
|
|
14074
|
-
if (typeof Element !== 'undefined' && !(value instanceof Element)) {
|
|
14075
|
-
throw new Error('Expecting instance of DOM Element');
|
|
14076
|
-
}
|
|
14077
|
-
}
|
|
14078
|
-
|
|
14079
|
-
/**
|
|
14080
|
-
* @license
|
|
14081
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14082
|
-
*
|
|
14083
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
14084
|
-
* found in the LICENSE file at https://angular.io/license
|
|
14085
|
-
*/
|
|
14086
|
-
/**
|
|
14087
|
-
* Marks a component for check (in case of OnPush components) and synchronously
|
|
14088
|
-
* performs change detection on the application this component belongs to.
|
|
14089
|
-
*
|
|
14090
|
-
* @param component Component to {@link ChangeDetectorRef#markForCheck mark for check}.
|
|
14091
|
-
*
|
|
14092
|
-
* @publicApi
|
|
14093
|
-
* @globalApi ng
|
|
14094
|
-
*/
|
|
14095
|
-
function applyChanges(component) {
|
|
14096
|
-
markDirty(component);
|
|
14097
|
-
getRootComponents(component).forEach(rootComponent => detectChanges(rootComponent));
|
|
14098
|
-
}
|
|
14099
|
-
|
|
14100
|
-
/**
|
|
14101
|
-
* @license
|
|
14102
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14103
|
-
*
|
|
14104
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
14105
|
-
* found in the LICENSE file at https://angular.io/license
|
|
14106
|
-
*/
|
|
14107
|
-
/**
|
|
14108
|
-
* This file introduces series of globally accessible debug tools
|
|
14109
|
-
* to allow for the Angular debugging story to function.
|
|
14110
|
-
*
|
|
14111
|
-
* To see this in action run the following command:
|
|
14112
|
-
*
|
|
14113
|
-
* bazel run //packages/core/test/bundling/todo:devserver
|
|
14114
|
-
*
|
|
14115
|
-
* Then load `localhost:5432` and start using the console tools.
|
|
14116
|
-
*/
|
|
14117
|
-
/**
|
|
14118
|
-
* This value reflects the property on the window where the dev
|
|
14119
|
-
* tools are patched (window.ng).
|
|
14120
|
-
* */
|
|
14121
|
-
const GLOBAL_PUBLISH_EXPANDO_KEY = 'ng';
|
|
14122
|
-
let _published = false;
|
|
14123
|
-
/**
|
|
14124
|
-
* Publishes a collection of default debug tools onto`window.ng`.
|
|
14125
|
-
*
|
|
14126
|
-
* These functions are available globally when Angular is in development
|
|
14127
|
-
* mode and are automatically stripped away from prod mode is on.
|
|
14128
|
-
*/
|
|
14129
|
-
function publishDefaultGlobalUtils() {
|
|
14130
|
-
if (!_published) {
|
|
14131
|
-
_published = true;
|
|
14132
|
-
/**
|
|
14133
|
-
* Warning: this function is *INTERNAL* and should not be relied upon in application's code.
|
|
14134
|
-
* The contract of the function might be changed in any release and/or the function can be
|
|
14135
|
-
* removed completely.
|
|
14136
|
-
*/
|
|
14137
|
-
publishGlobalUtil('ɵsetProfiler', setProfiler);
|
|
14138
|
-
publishGlobalUtil('getDirectiveMetadata', getDirectiveMetadata);
|
|
14139
|
-
publishGlobalUtil('getComponent', getComponent$1);
|
|
14140
|
-
publishGlobalUtil('getContext', getContext);
|
|
14141
|
-
publishGlobalUtil('getListeners', getListeners);
|
|
14142
|
-
publishGlobalUtil('getOwningComponent', getOwningComponent);
|
|
14143
|
-
publishGlobalUtil('getHostElement', getHostElement);
|
|
14144
|
-
publishGlobalUtil('getInjector', getInjector);
|
|
14145
|
-
publishGlobalUtil('getRootComponents', getRootComponents);
|
|
14146
|
-
publishGlobalUtil('getDirectives', getDirectives);
|
|
14147
|
-
publishGlobalUtil('applyChanges', applyChanges);
|
|
14148
|
-
}
|
|
14149
|
-
}
|
|
14150
|
-
/**
|
|
14151
|
-
* Publishes the given function to `window.ng` so that it can be
|
|
14152
|
-
* used from the browser console when an application is not in production.
|
|
14153
|
-
*/
|
|
14154
|
-
function publishGlobalUtil(name, fn) {
|
|
14155
|
-
if (typeof COMPILED === 'undefined' || !COMPILED) {
|
|
14156
|
-
// Note: we can't export `ng` when using closure enhanced optimization as:
|
|
14157
|
-
// - closure declares globals itself for minified names, which sometimes clobber our `ng` global
|
|
14158
|
-
// - we can't declare a closure extern as the namespace `ng` is already used within Google
|
|
14159
|
-
// for typings for AngularJS (via `goog.provide('ng....')`).
|
|
14160
|
-
const w = _global$1;
|
|
14161
|
-
ngDevMode && assertDefined(fn, 'function not defined');
|
|
14162
|
-
if (w) {
|
|
14163
|
-
let container = w[GLOBAL_PUBLISH_EXPANDO_KEY];
|
|
14164
|
-
if (!container) {
|
|
14165
|
-
container = w[GLOBAL_PUBLISH_EXPANDO_KEY] = {};
|
|
14166
|
-
}
|
|
14167
|
-
container[name] = fn;
|
|
14168
|
-
}
|
|
14169
|
-
}
|
|
14170
|
-
}
|
|
14171
|
-
|
|
14172
|
-
/**
|
|
14173
|
-
* @license
|
|
14174
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14175
|
-
*
|
|
14176
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
14177
|
-
* found in the LICENSE file at https://angular.io/license
|
|
14178
|
-
*/
|
|
14179
|
-
// TODO: A hack to not pull in the NullInjector from @angular/core.
|
|
14180
|
-
const NULL_INJECTOR = {
|
|
14181
|
-
get: (token, notFoundValue) => {
|
|
14182
|
-
throwProviderNotFoundError(token, 'NullInjector');
|
|
14183
|
-
}
|
|
14184
|
-
};
|
|
14185
|
-
/**
|
|
14186
|
-
* Bootstraps a Component into an existing host element and returns an instance
|
|
14187
|
-
* of the component.
|
|
14188
|
-
*
|
|
14189
|
-
* Use this function to bootstrap a component into the DOM tree. Each invocation
|
|
14190
|
-
* of this function will create a separate tree of components, injectors and
|
|
14191
|
-
* change detection cycles and lifetimes. To dynamically insert a new component
|
|
14192
|
-
* into an existing tree such that it shares the same injection, change detection
|
|
14193
|
-
* and object lifetime, use {@link ViewContainer#createComponent}.
|
|
14194
|
-
*
|
|
14195
|
-
* @param componentType Component to bootstrap
|
|
14196
|
-
* @param options Optional parameters which control bootstrapping
|
|
14197
|
-
*/
|
|
14198
|
-
function renderComponent(componentType /* Type as workaround for: Microsoft/TypeScript/issues/4881 */, opts = {}) {
|
|
14199
|
-
ngDevMode && publishDefaultGlobalUtils();
|
|
14200
|
-
ngDevMode && assertComponentType(componentType);
|
|
14201
|
-
const rendererFactory = opts.rendererFactory || domRendererFactory3;
|
|
14202
|
-
const sanitizer = opts.sanitizer || null;
|
|
14203
|
-
const componentDef = getComponentDef$1(componentType);
|
|
14204
|
-
if (componentDef.type != componentType)
|
|
14205
|
-
componentDef.type = componentType;
|
|
14206
|
-
// The first index of the first selector is the tag name.
|
|
14207
|
-
const componentTag = componentDef.selectors[0][0];
|
|
14208
|
-
const hostRenderer = rendererFactory.createRenderer(null, null);
|
|
14209
|
-
const hostRNode = locateHostElement(hostRenderer, opts.host || componentTag, componentDef.encapsulation);
|
|
14210
|
-
const rootFlags = componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
|
|
14211
|
-
16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
|
|
14212
|
-
const rootContext = createRootContext(opts.scheduler, opts.playerHandler);
|
|
14213
|
-
const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
|
|
14214
|
-
const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
|
|
14215
|
-
const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null, null);
|
|
14216
|
-
enterView(rootView);
|
|
14217
|
-
let component;
|
|
14218
|
-
try {
|
|
14219
|
-
if (rendererFactory.begin)
|
|
14220
|
-
rendererFactory.begin();
|
|
14221
|
-
const componentView = createRootComponentView(hostRNode, componentDef, rootView, rendererFactory, renderer, sanitizer);
|
|
14222
|
-
component = createRootComponent(componentView, componentDef, rootView, rootContext, opts.hostFeatures || null);
|
|
14223
|
-
// create mode pass
|
|
14224
|
-
renderView(rootTView, rootView, null);
|
|
14225
|
-
// update mode pass
|
|
14226
|
-
refreshView(rootTView, rootView, null, null);
|
|
14227
|
-
}
|
|
14228
|
-
finally {
|
|
14229
|
-
leaveView();
|
|
14230
|
-
if (rendererFactory.end)
|
|
14231
|
-
rendererFactory.end();
|
|
14232
|
-
}
|
|
14233
|
-
return component;
|
|
14234
|
-
}
|
|
14235
|
-
/**
|
|
14236
|
-
* Creates the root component view and the root component node.
|
|
14237
|
-
*
|
|
14238
|
-
* @param rNode Render host element.
|
|
14239
|
-
* @param def ComponentDef
|
|
14240
|
-
* @param rootView The parent view where the host node is stored
|
|
14241
|
-
* @param rendererFactory Factory to be used for creating child renderers.
|
|
14242
|
-
* @param hostRenderer The current renderer
|
|
14243
|
-
* @param sanitizer The sanitizer, if provided
|
|
14244
|
-
*
|
|
14245
|
-
* @returns Component view created
|
|
14246
|
-
*/
|
|
14247
|
-
function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
|
|
14248
|
-
const tView = rootView[TVIEW];
|
|
14249
|
-
const index = HEADER_OFFSET;
|
|
14250
|
-
ngDevMode && assertIndexInRange(rootView, index);
|
|
14251
|
-
rootView[index] = rNode;
|
|
14252
|
-
// '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
|
|
14253
|
-
// the same time we want to communicate the debug `TNode` that this is a special `TNode`
|
|
14254
|
-
// representing a host element.
|
|
14255
|
-
const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
|
|
14256
|
-
const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
|
|
14257
|
-
if (mergedAttrs !== null) {
|
|
14258
|
-
computeStaticStyling(tNode, mergedAttrs, true);
|
|
14259
|
-
if (rNode !== null) {
|
|
14260
|
-
setUpAttributes(hostRenderer, rNode, mergedAttrs);
|
|
14261
|
-
if (tNode.classes !== null) {
|
|
14262
|
-
writeDirectClass(hostRenderer, rNode, tNode.classes);
|
|
14263
|
-
}
|
|
14264
|
-
if (tNode.styles !== null) {
|
|
14265
|
-
writeDirectStyle(hostRenderer, rNode, tNode.styles);
|
|
14266
|
-
}
|
|
14267
|
-
}
|
|
14268
|
-
}
|
|
14269
|
-
const viewRenderer = rendererFactory.createRenderer(rNode, def);
|
|
14270
|
-
const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
|
|
14271
|
-
if (tView.firstCreatePass) {
|
|
14272
|
-
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
|
14273
|
-
markAsComponentHost(tView, tNode);
|
|
14274
|
-
initTNodeFlags(tNode, rootView.length, 1);
|
|
14275
|
-
}
|
|
14276
|
-
addToViewTree(rootView, componentView);
|
|
14277
|
-
// Store component view at node index, with node as the HOST
|
|
14278
|
-
return rootView[index] = componentView;
|
|
14279
|
-
}
|
|
14280
|
-
/**
|
|
14281
|
-
* Creates a root component and sets it up with features and host bindings. Shared by
|
|
14282
|
-
* renderComponent() and ViewContainerRef.createComponent().
|
|
14283
|
-
*/
|
|
14284
|
-
function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
|
|
14285
|
-
const tView = rootLView[TVIEW];
|
|
14286
|
-
// Create directive instance with factory() and store at next index in viewData
|
|
14287
|
-
const component = instantiateRootComponent(tView, rootLView, componentDef);
|
|
14288
|
-
rootContext.components.push(component);
|
|
14289
|
-
componentView[CONTEXT] = component;
|
|
14290
|
-
if (hostFeatures !== null) {
|
|
14291
|
-
for (const feature of hostFeatures) {
|
|
14292
|
-
feature(component, componentDef);
|
|
14293
|
-
}
|
|
14294
|
-
}
|
|
14295
|
-
// We want to generate an empty QueryList for root content queries for backwards
|
|
14296
|
-
// compatibility with ViewEngine.
|
|
14297
|
-
if (componentDef.contentQueries) {
|
|
14298
|
-
const tNode = getCurrentTNode();
|
|
14299
|
-
ngDevMode && assertDefined(tNode, 'TNode expected');
|
|
14300
|
-
componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
|
|
14301
|
-
}
|
|
14302
|
-
const rootTNode = getCurrentTNode();
|
|
14303
|
-
ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
|
|
14304
|
-
if (tView.firstCreatePass &&
|
|
14305
|
-
(componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
|
|
14306
|
-
setSelectedIndex(rootTNode.index);
|
|
14307
|
-
const rootTView = rootLView[TVIEW];
|
|
14308
|
-
registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
|
|
14309
|
-
invokeHostBindingsInCreationMode(componentDef, component);
|
|
14310
|
-
}
|
|
14311
|
-
return component;
|
|
14312
|
-
}
|
|
14313
|
-
function createRootContext(scheduler, playerHandler) {
|
|
14314
|
-
return {
|
|
14315
|
-
components: [],
|
|
14316
|
-
scheduler: scheduler || defaultScheduler,
|
|
14317
|
-
clean: CLEAN_PROMISE,
|
|
14318
|
-
playerHandler: playerHandler || null,
|
|
14319
|
-
flags: 0 /* RootContextFlags.Empty */
|
|
14320
|
-
};
|
|
14321
|
-
}
|
|
14322
|
-
/**
|
|
14323
|
-
* Used to enable lifecycle hooks on the root component.
|
|
14324
|
-
*
|
|
14325
|
-
* Include this feature when calling `renderComponent` if the root component
|
|
14326
|
-
* you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
|
|
14327
|
-
* be called properly.
|
|
14328
|
-
*
|
|
14329
|
-
* Example:
|
|
14330
|
-
*
|
|
14331
|
-
* ```
|
|
14332
|
-
* renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
|
|
14333
|
-
* ```
|
|
14334
|
-
*/
|
|
14335
|
-
function LifecycleHooksFeature() {
|
|
14336
|
-
const tNode = getCurrentTNode();
|
|
14337
|
-
ngDevMode && assertDefined(tNode, 'TNode is required');
|
|
14338
|
-
registerPostOrderHooks(getLView()[TVIEW], tNode);
|
|
13593
|
+
function LifecycleHooksFeature() {
|
|
13594
|
+
const tNode = getCurrentTNode();
|
|
13595
|
+
ngDevMode && assertDefined(tNode, 'TNode is required');
|
|
13596
|
+
registerPostOrderHooks(getLView()[TVIEW], tNode);
|
|
14339
13597
|
}
|
|
14340
13598
|
/**
|
|
14341
13599
|
* Wait on component until it is rendered.
|
|
@@ -14385,10 +13643,8 @@ function ɵɵInheritDefinitionFeature(definition) {
|
|
|
14385
13643
|
}
|
|
14386
13644
|
else {
|
|
14387
13645
|
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);
|
|
13646
|
+
throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
|
|
13647
|
+
`Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
|
|
14392
13648
|
}
|
|
14393
13649
|
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
|
14394
13650
|
superDef = superType.ɵdir;
|
|
@@ -15324,6 +14580,57 @@ function ɵɵattributeInterpolateV(attrName, values, sanitizer, namespace) {
|
|
|
15324
14580
|
return ɵɵattributeInterpolateV;
|
|
15325
14581
|
}
|
|
15326
14582
|
|
|
14583
|
+
/**
|
|
14584
|
+
* @license
|
|
14585
|
+
* Copyright Google LLC All Rights Reserved.
|
|
14586
|
+
*
|
|
14587
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
14588
|
+
* found in the LICENSE file at https://angular.io/license
|
|
14589
|
+
*/
|
|
14590
|
+
/**
|
|
14591
|
+
* Synchronously perform change detection on a component (and possibly its sub-components).
|
|
14592
|
+
*
|
|
14593
|
+
* This function triggers change detection in a synchronous way on a component.
|
|
14594
|
+
*
|
|
14595
|
+
* @param component The component which the change detection should be performed on.
|
|
14596
|
+
*/
|
|
14597
|
+
function detectChanges(component) {
|
|
14598
|
+
const view = getComponentViewByInstance(component);
|
|
14599
|
+
detectChangesInternal(view[TVIEW], view, component);
|
|
14600
|
+
}
|
|
14601
|
+
/**
|
|
14602
|
+
* Marks the component as dirty (needing change detection). Marking a component dirty will
|
|
14603
|
+
* schedule a change detection on it at some point in the future.
|
|
14604
|
+
*
|
|
14605
|
+
* Marking an already dirty component as dirty won't do anything. Only one outstanding change
|
|
14606
|
+
* detection can be scheduled per component tree.
|
|
14607
|
+
*
|
|
14608
|
+
* @param component Component to mark as dirty.
|
|
14609
|
+
*/
|
|
14610
|
+
function markDirty(component) {
|
|
14611
|
+
ngDevMode && assertDefined(component, 'component');
|
|
14612
|
+
const rootView = markViewDirty(getComponentViewByInstance(component));
|
|
14613
|
+
ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
|
|
14614
|
+
scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
|
|
14615
|
+
}
|
|
14616
|
+
/**
|
|
14617
|
+
* Used to perform change detection on the whole application.
|
|
14618
|
+
*
|
|
14619
|
+
* This is equivalent to `detectChanges`, but invoked on root component. Additionally, `tick`
|
|
14620
|
+
* executes lifecycle hooks and conditionally checks components based on their
|
|
14621
|
+
* `ChangeDetectionStrategy` and dirtiness.
|
|
14622
|
+
*
|
|
14623
|
+
* The preferred way to trigger change detection is to call `markDirty`. `markDirty` internally
|
|
14624
|
+
* schedules `tick` using a scheduler in order to coalesce multiple `markDirty` calls into a
|
|
14625
|
+
* single change detection run. By default, the scheduler is `requestAnimationFrame`, but can
|
|
14626
|
+
* be changed when calling `renderComponent` and providing the `scheduler` option.
|
|
14627
|
+
*/
|
|
14628
|
+
function tick(component) {
|
|
14629
|
+
const rootView = getRootView(component);
|
|
14630
|
+
const rootContext = rootView[CONTEXT];
|
|
14631
|
+
tickRootContext(rootContext);
|
|
14632
|
+
}
|
|
14633
|
+
|
|
15327
14634
|
/**
|
|
15328
14635
|
* @license
|
|
15329
14636
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -15868,51 +15175,42 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
|
|
|
15868
15175
|
tNode.index;
|
|
15869
15176
|
// In order to match current behavior, native DOM event listeners must be added for all
|
|
15870
15177
|
// events (including outputs).
|
|
15871
|
-
|
|
15872
|
-
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
|
|
15880
|
-
|
|
15881
|
-
|
|
15882
|
-
|
|
15883
|
-
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
|
|
15893
|
-
|
|
15894
|
-
|
|
15895
|
-
|
|
15896
|
-
|
|
15897
|
-
|
|
15898
|
-
|
|
15899
|
-
|
|
15900
|
-
processOutputs = false;
|
|
15901
|
-
}
|
|
15902
|
-
else {
|
|
15903
|
-
listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
|
|
15904
|
-
const cleanupFn = renderer.listen(target, eventName, listenerFn);
|
|
15905
|
-
ngDevMode && ngDevMode.rendererAddEventListener++;
|
|
15906
|
-
lCleanup.push(listenerFn, cleanupFn);
|
|
15907
|
-
tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
|
|
15908
|
-
}
|
|
15178
|
+
// There might be cases where multiple directives on the same element try to register an event
|
|
15179
|
+
// handler function for the same event. In this situation we want to avoid registration of
|
|
15180
|
+
// several native listeners as each registration would be intercepted by NgZone and
|
|
15181
|
+
// trigger change detection. This would mean that a single user action would result in several
|
|
15182
|
+
// change detections being invoked. To avoid this situation we want to have only one call to
|
|
15183
|
+
// native handler registration (for the same element and same type of event).
|
|
15184
|
+
//
|
|
15185
|
+
// In order to have just one native event handler in presence of multiple handler functions,
|
|
15186
|
+
// we just register a first handler function as a native event listener and then chain
|
|
15187
|
+
// (coalesce) other handler functions on top of the first native handler function.
|
|
15188
|
+
let existingListener = null;
|
|
15189
|
+
// Please note that the coalescing described here doesn't happen for events specifying an
|
|
15190
|
+
// alternative target (ex. (document:click)) - this is to keep backward compatibility with the
|
|
15191
|
+
// view engine.
|
|
15192
|
+
// Also, we don't have to search for existing listeners is there are no directives
|
|
15193
|
+
// matching on a given node as we can't register multiple event handlers for the same event in
|
|
15194
|
+
// a template (this would mean having duplicate attributes).
|
|
15195
|
+
if (!eventTargetResolver && isTNodeDirectiveHost) {
|
|
15196
|
+
existingListener = findExistingListener(tView, lView, eventName, tNode.index);
|
|
15197
|
+
}
|
|
15198
|
+
if (existingListener !== null) {
|
|
15199
|
+
// Attach a new listener to coalesced listeners list, maintaining the order in which
|
|
15200
|
+
// listeners are registered. For performance reasons, we keep a reference to the last
|
|
15201
|
+
// listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
|
|
15202
|
+
// the entire set each time we need to add a new listener.
|
|
15203
|
+
const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
|
|
15204
|
+
lastListenerFn.__ngNextListenerFn__ = listenerFn;
|
|
15205
|
+
existingListener.__ngLastListenerFn__ = listenerFn;
|
|
15206
|
+
processOutputs = false;
|
|
15909
15207
|
}
|
|
15910
15208
|
else {
|
|
15911
|
-
listenerFn = wrapListener(tNode, lView, context, listenerFn,
|
|
15912
|
-
|
|
15209
|
+
listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
|
|
15210
|
+
const cleanupFn = renderer.listen(target, eventName, listenerFn);
|
|
15913
15211
|
ngDevMode && ngDevMode.rendererAddEventListener++;
|
|
15914
|
-
lCleanup.push(listenerFn);
|
|
15915
|
-
tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex,
|
|
15212
|
+
lCleanup.push(listenerFn, cleanupFn);
|
|
15213
|
+
tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
|
|
15916
15214
|
}
|
|
15917
15215
|
}
|
|
15918
15216
|
else {
|
|
@@ -17986,7 +17284,7 @@ function findStylingValue(tData, tNode, lView, prop, index, isClassBased) {
|
|
|
17986
17284
|
valueAtLViewIndex = isStylingMap ? EMPTY_ARRAY : undefined;
|
|
17987
17285
|
}
|
|
17988
17286
|
let currentValue = isStylingMap ? keyValueArrayGet(valueAtLViewIndex, prop) :
|
|
17989
|
-
key === prop ? valueAtLViewIndex : undefined;
|
|
17287
|
+
(key === prop ? valueAtLViewIndex : undefined);
|
|
17990
17288
|
if (containsStatics && !isStylingValuePresent(currentValue)) {
|
|
17991
17289
|
currentValue = keyValueArrayGet(rawKey, prop);
|
|
17992
17290
|
}
|
|
@@ -19509,7 +18807,7 @@ function findLocaleData(locale) {
|
|
|
19509
18807
|
if (parentLocale === 'en') {
|
|
19510
18808
|
return localeEn;
|
|
19511
18809
|
}
|
|
19512
|
-
throw new
|
|
18810
|
+
throw new RuntimeError(701 /* RuntimeErrorCode.MISSING_LOCALE_DATA */, ngDevMode && `Missing locale data for the locale "${locale}".`);
|
|
19513
18811
|
}
|
|
19514
18812
|
/**
|
|
19515
18813
|
* Retrieves the default currency code for the given locale.
|
|
@@ -21839,7 +21137,7 @@ function noComponentFactoryError(component) {
|
|
|
21839
21137
|
return error;
|
|
21840
21138
|
}
|
|
21841
21139
|
const ERROR_COMPONENT = 'ngComponent';
|
|
21842
|
-
function getComponent(error) {
|
|
21140
|
+
function getComponent$1(error) {
|
|
21843
21141
|
return error[ERROR_COMPONENT];
|
|
21844
21142
|
}
|
|
21845
21143
|
class _NullComponentFactoryResolver {
|
|
@@ -22023,14 +21321,6 @@ class Renderer2 {
|
|
|
22023
21321
|
* @nocollapse
|
|
22024
21322
|
*/
|
|
22025
21323
|
Renderer2.__NG_ELEMENT_ID__ = () => injectRenderer2();
|
|
22026
|
-
/** Returns a Renderer2 (or throws when application was bootstrapped with Renderer3) */
|
|
22027
|
-
function getOrCreateRenderer2(lView) {
|
|
22028
|
-
const renderer = lView[RENDERER];
|
|
22029
|
-
if (ngDevMode && !isProceduralRenderer(renderer)) {
|
|
22030
|
-
throw new Error('Cannot inject Renderer2 when the application uses Renderer3!');
|
|
22031
|
-
}
|
|
22032
|
-
return renderer;
|
|
22033
|
-
}
|
|
22034
21324
|
/** Injects a Renderer2 for the current component. */
|
|
22035
21325
|
function injectRenderer2() {
|
|
22036
21326
|
// We need the Renderer to be based on the component that it's being injected into, however since
|
|
@@ -22038,7 +21328,7 @@ function injectRenderer2() {
|
|
|
22038
21328
|
const lView = getLView();
|
|
22039
21329
|
const tNode = getCurrentTNode();
|
|
22040
21330
|
const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
|
|
22041
|
-
return
|
|
21331
|
+
return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
|
|
22042
21332
|
}
|
|
22043
21333
|
|
|
22044
21334
|
/**
|
|
@@ -22085,7 +21375,7 @@ class Version {
|
|
|
22085
21375
|
/**
|
|
22086
21376
|
* @publicApi
|
|
22087
21377
|
*/
|
|
22088
|
-
const VERSION = new Version('14.0.
|
|
21378
|
+
const VERSION = new Version('14.0.5');
|
|
22089
21379
|
|
|
22090
21380
|
/**
|
|
22091
21381
|
* @license
|
|
@@ -22423,8 +21713,7 @@ class ViewRef {
|
|
|
22423
21713
|
}
|
|
22424
21714
|
attachToViewContainerRef() {
|
|
22425
21715
|
if (this._appRef) {
|
|
22426
|
-
|
|
22427
|
-
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, errorMessage);
|
|
21716
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached directly to the ApplicationRef!');
|
|
22428
21717
|
}
|
|
22429
21718
|
this._attachedToViewContainer = true;
|
|
22430
21719
|
}
|
|
@@ -22434,8 +21723,7 @@ class ViewRef {
|
|
|
22434
21723
|
}
|
|
22435
21724
|
attachToAppRef(appRef) {
|
|
22436
21725
|
if (this._attachedToViewContainer) {
|
|
22437
|
-
|
|
22438
|
-
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, errorMessage);
|
|
21726
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
|
|
22439
21727
|
}
|
|
22440
21728
|
this._appRef = appRef;
|
|
22441
21729
|
}
|
|
@@ -22551,7 +21839,13 @@ class ComponentFactory extends ComponentFactory$1 {
|
|
|
22551
21839
|
realEnvironmentInjector;
|
|
22552
21840
|
}
|
|
22553
21841
|
const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
|
|
22554
|
-
const rendererFactory = rootViewInjector.get(RendererFactory2,
|
|
21842
|
+
const rendererFactory = rootViewInjector.get(RendererFactory2, null);
|
|
21843
|
+
if (rendererFactory === null) {
|
|
21844
|
+
throw new RuntimeError(407 /* RuntimeErrorCode.RENDERER_NOT_FOUND */, ngDevMode &&
|
|
21845
|
+
'Angular was not able to inject a renderer (RendererFactory2). ' +
|
|
21846
|
+
'Likely this is due to a broken DI hierarchy. ' +
|
|
21847
|
+
'Make sure that any injector used to create this component has a correct parent.');
|
|
21848
|
+
}
|
|
22555
21849
|
const sanitizer = rootViewInjector.get(Sanitizer, null);
|
|
22556
21850
|
const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
|
|
22557
21851
|
// Determine a tag name used for creating host elements when this component is created
|
|
@@ -22615,218 +21909,628 @@ class ComponentFactory extends ComponentFactory$1 {
|
|
|
22615
21909
|
finally {
|
|
22616
21910
|
leaveView();
|
|
22617
21911
|
}
|
|
22618
|
-
return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
|
|
21912
|
+
return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
|
|
21913
|
+
}
|
|
21914
|
+
}
|
|
21915
|
+
const componentFactoryResolver = new ComponentFactoryResolver();
|
|
21916
|
+
/**
|
|
21917
|
+
* Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
|
|
21918
|
+
* ComponentFactoryResolver
|
|
21919
|
+
* already exists, retrieves the existing ComponentFactoryResolver.
|
|
21920
|
+
*
|
|
21921
|
+
* @returns The ComponentFactoryResolver instance to use
|
|
21922
|
+
*/
|
|
21923
|
+
function injectComponentFactoryResolver() {
|
|
21924
|
+
return componentFactoryResolver;
|
|
21925
|
+
}
|
|
21926
|
+
/**
|
|
21927
|
+
* Represents an instance of a Component created via a {@link ComponentFactory}.
|
|
21928
|
+
*
|
|
21929
|
+
* `ComponentRef` provides access to the Component Instance as well other objects related to this
|
|
21930
|
+
* Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
|
|
21931
|
+
* method.
|
|
21932
|
+
*
|
|
21933
|
+
*/
|
|
21934
|
+
class ComponentRef extends ComponentRef$1 {
|
|
21935
|
+
constructor(componentType, instance, location, _rootLView, _tNode) {
|
|
21936
|
+
super();
|
|
21937
|
+
this.location = location;
|
|
21938
|
+
this._rootLView = _rootLView;
|
|
21939
|
+
this._tNode = _tNode;
|
|
21940
|
+
this.instance = instance;
|
|
21941
|
+
this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
|
|
21942
|
+
this.componentType = componentType;
|
|
21943
|
+
}
|
|
21944
|
+
get injector() {
|
|
21945
|
+
return new NodeInjector(this._tNode, this._rootLView);
|
|
21946
|
+
}
|
|
21947
|
+
destroy() {
|
|
21948
|
+
this.hostView.destroy();
|
|
21949
|
+
}
|
|
21950
|
+
onDestroy(callback) {
|
|
21951
|
+
this.hostView.onDestroy(callback);
|
|
21952
|
+
}
|
|
21953
|
+
}
|
|
21954
|
+
|
|
21955
|
+
/**
|
|
21956
|
+
* @license
|
|
21957
|
+
* Copyright Google LLC All Rights Reserved.
|
|
21958
|
+
*
|
|
21959
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
21960
|
+
* found in the LICENSE file at https://angular.io/license
|
|
21961
|
+
*/
|
|
21962
|
+
/**
|
|
21963
|
+
* Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
|
|
21964
|
+
* @param ngModule NgModule class.
|
|
21965
|
+
* @param parentInjector Optional injector instance to use as a parent for the module injector. If
|
|
21966
|
+
* not provided, `NullInjector` will be used instead.
|
|
21967
|
+
* @publicApi
|
|
21968
|
+
*/
|
|
21969
|
+
function createNgModuleRef(ngModule, parentInjector) {
|
|
21970
|
+
return new NgModuleRef(ngModule, parentInjector ?? null);
|
|
21971
|
+
}
|
|
21972
|
+
class NgModuleRef extends NgModuleRef$1 {
|
|
21973
|
+
constructor(ngModuleType, _parent) {
|
|
21974
|
+
super();
|
|
21975
|
+
this._parent = _parent;
|
|
21976
|
+
// tslint:disable-next-line:require-internal-with-underscore
|
|
21977
|
+
this._bootstrapComponents = [];
|
|
21978
|
+
this.injector = this;
|
|
21979
|
+
this.destroyCbs = [];
|
|
21980
|
+
// When bootstrapping a module we have a dependency graph that looks like this:
|
|
21981
|
+
// ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
|
|
21982
|
+
// module being resolved tries to inject the ComponentFactoryResolver, it'll create a
|
|
21983
|
+
// circular dependency which will result in a runtime error, because the injector doesn't
|
|
21984
|
+
// exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
|
|
21985
|
+
// and providing it, rather than letting the injector resolve it.
|
|
21986
|
+
this.componentFactoryResolver = new ComponentFactoryResolver(this);
|
|
21987
|
+
const ngModuleDef = getNgModuleDef(ngModuleType);
|
|
21988
|
+
ngDevMode &&
|
|
21989
|
+
assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
|
|
21990
|
+
this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
|
|
21991
|
+
this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
|
|
21992
|
+
{ provide: NgModuleRef$1, useValue: this }, {
|
|
21993
|
+
provide: ComponentFactoryResolver$1,
|
|
21994
|
+
useValue: this.componentFactoryResolver
|
|
21995
|
+
}
|
|
21996
|
+
], stringify(ngModuleType), new Set(['environment']));
|
|
21997
|
+
// We need to resolve the injector types separately from the injector creation, because
|
|
21998
|
+
// the module might be trying to use this ref in its constructor for DI which will cause a
|
|
21999
|
+
// circular error that will eventually error out, because the injector isn't created yet.
|
|
22000
|
+
this._r3Injector.resolveInjectorInitializers();
|
|
22001
|
+
this.instance = this.get(ngModuleType);
|
|
22002
|
+
}
|
|
22003
|
+
get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
|
|
22004
|
+
if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
|
|
22005
|
+
return this;
|
|
22006
|
+
}
|
|
22007
|
+
return this._r3Injector.get(token, notFoundValue, injectFlags);
|
|
22008
|
+
}
|
|
22009
|
+
destroy() {
|
|
22010
|
+
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
|
|
22011
|
+
const injector = this._r3Injector;
|
|
22012
|
+
!injector.destroyed && injector.destroy();
|
|
22013
|
+
this.destroyCbs.forEach(fn => fn());
|
|
22014
|
+
this.destroyCbs = null;
|
|
22015
|
+
}
|
|
22016
|
+
onDestroy(callback) {
|
|
22017
|
+
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
|
|
22018
|
+
this.destroyCbs.push(callback);
|
|
22019
|
+
}
|
|
22020
|
+
}
|
|
22021
|
+
class NgModuleFactory extends NgModuleFactory$1 {
|
|
22022
|
+
constructor(moduleType) {
|
|
22023
|
+
super();
|
|
22024
|
+
this.moduleType = moduleType;
|
|
22025
|
+
}
|
|
22026
|
+
create(parentInjector) {
|
|
22027
|
+
return new NgModuleRef(this.moduleType, parentInjector);
|
|
22028
|
+
}
|
|
22029
|
+
}
|
|
22030
|
+
class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
|
|
22031
|
+
constructor(providers, parent, source) {
|
|
22032
|
+
super();
|
|
22033
|
+
this.componentFactoryResolver = new ComponentFactoryResolver(this);
|
|
22034
|
+
this.instance = null;
|
|
22035
|
+
const injector = new R3Injector([
|
|
22036
|
+
...providers,
|
|
22037
|
+
{ provide: NgModuleRef$1, useValue: this },
|
|
22038
|
+
{ provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
|
|
22039
|
+
], parent || getNullInjector(), source, new Set(['environment']));
|
|
22040
|
+
this.injector = injector;
|
|
22041
|
+
injector.resolveInjectorInitializers();
|
|
22042
|
+
}
|
|
22043
|
+
destroy() {
|
|
22044
|
+
this.injector.destroy();
|
|
22045
|
+
}
|
|
22046
|
+
onDestroy(callback) {
|
|
22047
|
+
this.injector.onDestroy(callback);
|
|
22048
|
+
}
|
|
22049
|
+
}
|
|
22050
|
+
/**
|
|
22051
|
+
* Create a new environment injector.
|
|
22052
|
+
*
|
|
22053
|
+
* @publicApi
|
|
22054
|
+
* @developerPreview
|
|
22055
|
+
*/
|
|
22056
|
+
function createEnvironmentInjector(providers, parent = null, debugName = null) {
|
|
22057
|
+
const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
|
|
22058
|
+
return adapter.injector;
|
|
22059
|
+
}
|
|
22060
|
+
|
|
22061
|
+
/**
|
|
22062
|
+
* @license
|
|
22063
|
+
* Copyright Google LLC All Rights Reserved.
|
|
22064
|
+
*
|
|
22065
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
22066
|
+
* found in the LICENSE file at https://angular.io/license
|
|
22067
|
+
*/
|
|
22068
|
+
/**
|
|
22069
|
+
* A service used by the framework to create instances of standalone injectors. Those injectors are
|
|
22070
|
+
* created on demand in case of dynamic component instantiation and contain ambient providers
|
|
22071
|
+
* collected from the imports graph rooted at a given standalone component.
|
|
22072
|
+
*/
|
|
22073
|
+
class StandaloneService {
|
|
22074
|
+
constructor(_injector) {
|
|
22075
|
+
this._injector = _injector;
|
|
22076
|
+
this.cachedInjectors = new Map();
|
|
22077
|
+
}
|
|
22078
|
+
getOrCreateStandaloneInjector(componentDef) {
|
|
22079
|
+
if (!componentDef.standalone) {
|
|
22080
|
+
return null;
|
|
22081
|
+
}
|
|
22082
|
+
if (!this.cachedInjectors.has(componentDef.id)) {
|
|
22083
|
+
const providers = internalImportProvidersFrom(false, componentDef.type);
|
|
22084
|
+
const standaloneInjector = providers.length > 0 ?
|
|
22085
|
+
createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
|
|
22086
|
+
null;
|
|
22087
|
+
this.cachedInjectors.set(componentDef.id, standaloneInjector);
|
|
22088
|
+
}
|
|
22089
|
+
return this.cachedInjectors.get(componentDef.id);
|
|
22090
|
+
}
|
|
22091
|
+
ngOnDestroy() {
|
|
22092
|
+
try {
|
|
22093
|
+
for (const injector of this.cachedInjectors.values()) {
|
|
22094
|
+
if (injector !== null) {
|
|
22095
|
+
injector.destroy();
|
|
22096
|
+
}
|
|
22097
|
+
}
|
|
22098
|
+
}
|
|
22099
|
+
finally {
|
|
22100
|
+
this.cachedInjectors.clear();
|
|
22101
|
+
}
|
|
22102
|
+
}
|
|
22103
|
+
}
|
|
22104
|
+
/** @nocollapse */
|
|
22105
|
+
StandaloneService.ɵprov = ɵɵdefineInjectable({
|
|
22106
|
+
token: StandaloneService,
|
|
22107
|
+
providedIn: 'environment',
|
|
22108
|
+
factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
|
|
22109
|
+
});
|
|
22110
|
+
/**
|
|
22111
|
+
* A feature that acts as a setup code for the {@link StandaloneService}.
|
|
22112
|
+
*
|
|
22113
|
+
* The most important responsaibility of this feature is to expose the "getStandaloneInjector"
|
|
22114
|
+
* function (an entry points to a standalone injector creation) on a component definition object. We
|
|
22115
|
+
* go through the features infrastructure to make sure that the standalone injector creation logic
|
|
22116
|
+
* is tree-shakable and not included in applications that don't use standalone components.
|
|
22117
|
+
*
|
|
22118
|
+
* @codeGenApi
|
|
22119
|
+
*/
|
|
22120
|
+
function ɵɵStandaloneFeature(definition) {
|
|
22121
|
+
definition.getStandaloneInjector = (parentInjector) => {
|
|
22122
|
+
return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
|
|
22123
|
+
};
|
|
22124
|
+
}
|
|
22125
|
+
|
|
22126
|
+
/**
|
|
22127
|
+
* @license
|
|
22128
|
+
* Copyright Google LLC All Rights Reserved.
|
|
22129
|
+
*
|
|
22130
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
22131
|
+
* found in the LICENSE file at https://angular.io/license
|
|
22132
|
+
*/
|
|
22133
|
+
/**
|
|
22134
|
+
* Retrieves the component instance associated with a given DOM element.
|
|
22135
|
+
*
|
|
22136
|
+
* @usageNotes
|
|
22137
|
+
* Given the following DOM structure:
|
|
22138
|
+
*
|
|
22139
|
+
* ```html
|
|
22140
|
+
* <app-root>
|
|
22141
|
+
* <div>
|
|
22142
|
+
* <child-comp></child-comp>
|
|
22143
|
+
* </div>
|
|
22144
|
+
* </app-root>
|
|
22145
|
+
* ```
|
|
22146
|
+
*
|
|
22147
|
+
* Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
|
|
22148
|
+
* associated with this DOM element.
|
|
22149
|
+
*
|
|
22150
|
+
* Calling the function on `<app-root>` will return the `MyApp` instance.
|
|
22151
|
+
*
|
|
22152
|
+
*
|
|
22153
|
+
* @param element DOM element from which the component should be retrieved.
|
|
22154
|
+
* @returns Component instance associated with the element or `null` if there
|
|
22155
|
+
* is no component associated with it.
|
|
22156
|
+
*
|
|
22157
|
+
* @publicApi
|
|
22158
|
+
* @globalApi ng
|
|
22159
|
+
*/
|
|
22160
|
+
function getComponent(element) {
|
|
22161
|
+
ngDevMode && assertDomElement(element);
|
|
22162
|
+
const context = getLContext(element);
|
|
22163
|
+
if (context === null)
|
|
22164
|
+
return null;
|
|
22165
|
+
if (context.component === undefined) {
|
|
22166
|
+
const lView = context.lView;
|
|
22167
|
+
if (lView === null) {
|
|
22168
|
+
return null;
|
|
22169
|
+
}
|
|
22170
|
+
context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
|
|
22619
22171
|
}
|
|
22172
|
+
return context.component;
|
|
22620
22173
|
}
|
|
22621
|
-
const componentFactoryResolver = new ComponentFactoryResolver();
|
|
22622
22174
|
/**
|
|
22623
|
-
*
|
|
22624
|
-
*
|
|
22625
|
-
*
|
|
22175
|
+
* If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
|
|
22176
|
+
* view that the element is part of. Otherwise retrieves the instance of the component whose view
|
|
22177
|
+
* owns the element (in this case, the result is the same as calling `getOwningComponent`).
|
|
22626
22178
|
*
|
|
22627
|
-
* @
|
|
22179
|
+
* @param element Element for which to get the surrounding component instance.
|
|
22180
|
+
* @returns Instance of the component that is around the element or null if the element isn't
|
|
22181
|
+
* inside any component.
|
|
22182
|
+
*
|
|
22183
|
+
* @publicApi
|
|
22184
|
+
* @globalApi ng
|
|
22628
22185
|
*/
|
|
22629
|
-
function
|
|
22630
|
-
|
|
22186
|
+
function getContext(element) {
|
|
22187
|
+
assertDomElement(element);
|
|
22188
|
+
const context = getLContext(element);
|
|
22189
|
+
const lView = context ? context.lView : null;
|
|
22190
|
+
return lView === null ? null : lView[CONTEXT];
|
|
22631
22191
|
}
|
|
22632
22192
|
/**
|
|
22633
|
-
*
|
|
22193
|
+
* Retrieves the component instance whose view contains the DOM element.
|
|
22634
22194
|
*
|
|
22635
|
-
*
|
|
22636
|
-
*
|
|
22637
|
-
*
|
|
22195
|
+
* For example, if `<child-comp>` is used in the template of `<app-comp>`
|
|
22196
|
+
* (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
|
|
22197
|
+
* would return `<app-comp>`.
|
|
22638
22198
|
*
|
|
22199
|
+
* @param elementOrDir DOM element, component or directive instance
|
|
22200
|
+
* for which to retrieve the root components.
|
|
22201
|
+
* @returns Component instance whose view owns the DOM element or null if the element is not
|
|
22202
|
+
* part of a component view.
|
|
22203
|
+
*
|
|
22204
|
+
* @publicApi
|
|
22205
|
+
* @globalApi ng
|
|
22639
22206
|
*/
|
|
22640
|
-
|
|
22641
|
-
|
|
22642
|
-
|
|
22643
|
-
|
|
22644
|
-
|
|
22645
|
-
|
|
22646
|
-
|
|
22647
|
-
|
|
22648
|
-
this.componentType = componentType;
|
|
22649
|
-
}
|
|
22650
|
-
get injector() {
|
|
22651
|
-
return new NodeInjector(this._tNode, this._rootLView);
|
|
22652
|
-
}
|
|
22653
|
-
destroy() {
|
|
22654
|
-
this.hostView.destroy();
|
|
22655
|
-
}
|
|
22656
|
-
onDestroy(callback) {
|
|
22657
|
-
this.hostView.onDestroy(callback);
|
|
22207
|
+
function getOwningComponent(elementOrDir) {
|
|
22208
|
+
const context = getLContext(elementOrDir);
|
|
22209
|
+
let lView = context ? context.lView : null;
|
|
22210
|
+
if (lView === null)
|
|
22211
|
+
return null;
|
|
22212
|
+
let parent;
|
|
22213
|
+
while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
|
|
22214
|
+
lView = parent;
|
|
22658
22215
|
}
|
|
22216
|
+
return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
|
|
22659
22217
|
}
|
|
22660
|
-
|
|
22661
22218
|
/**
|
|
22662
|
-
*
|
|
22663
|
-
*
|
|
22219
|
+
* Retrieves all root components associated with a DOM element, directive or component instance.
|
|
22220
|
+
* Root components are those which have been bootstrapped by Angular.
|
|
22664
22221
|
*
|
|
22665
|
-
*
|
|
22666
|
-
*
|
|
22222
|
+
* @param elementOrDir DOM element, component or directive instance
|
|
22223
|
+
* for which to retrieve the root components.
|
|
22224
|
+
* @returns Root components associated with the target object.
|
|
22225
|
+
*
|
|
22226
|
+
* @publicApi
|
|
22227
|
+
* @globalApi ng
|
|
22667
22228
|
*/
|
|
22229
|
+
function getRootComponents(elementOrDir) {
|
|
22230
|
+
const lView = readPatchedLView(elementOrDir);
|
|
22231
|
+
return lView !== null ? [...getRootContext(lView).components] : [];
|
|
22232
|
+
}
|
|
22668
22233
|
/**
|
|
22669
|
-
*
|
|
22670
|
-
*
|
|
22671
|
-
* @param
|
|
22672
|
-
*
|
|
22234
|
+
* Retrieves an `Injector` associated with an element, component or directive instance.
|
|
22235
|
+
*
|
|
22236
|
+
* @param elementOrDir DOM element, component or directive instance for which to
|
|
22237
|
+
* retrieve the injector.
|
|
22238
|
+
* @returns Injector associated with the element, component or directive instance.
|
|
22239
|
+
*
|
|
22673
22240
|
* @publicApi
|
|
22241
|
+
* @globalApi ng
|
|
22674
22242
|
*/
|
|
22675
|
-
function
|
|
22676
|
-
|
|
22243
|
+
function getInjector(elementOrDir) {
|
|
22244
|
+
const context = getLContext(elementOrDir);
|
|
22245
|
+
const lView = context ? context.lView : null;
|
|
22246
|
+
if (lView === null)
|
|
22247
|
+
return Injector.NULL;
|
|
22248
|
+
const tNode = lView[TVIEW].data[context.nodeIndex];
|
|
22249
|
+
return new NodeInjector(tNode, lView);
|
|
22677
22250
|
}
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
|
|
22697
|
-
|
|
22698
|
-
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
}
|
|
22702
|
-
], stringify(ngModuleType), new Set(['environment']));
|
|
22703
|
-
// We need to resolve the injector types separately from the injector creation, because
|
|
22704
|
-
// the module might be trying to use this ref in its constructor for DI which will cause a
|
|
22705
|
-
// circular error that will eventually error out, because the injector isn't created yet.
|
|
22706
|
-
this._r3Injector.resolveInjectorInitializers();
|
|
22707
|
-
this.instance = this.get(ngModuleType);
|
|
22708
|
-
}
|
|
22709
|
-
get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
|
|
22710
|
-
if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
|
|
22711
|
-
return this;
|
|
22251
|
+
/**
|
|
22252
|
+
* Retrieve a set of injection tokens at a given DOM node.
|
|
22253
|
+
*
|
|
22254
|
+
* @param element Element for which the injection tokens should be retrieved.
|
|
22255
|
+
*/
|
|
22256
|
+
function getInjectionTokens(element) {
|
|
22257
|
+
const context = getLContext(element);
|
|
22258
|
+
const lView = context ? context.lView : null;
|
|
22259
|
+
if (lView === null)
|
|
22260
|
+
return [];
|
|
22261
|
+
const tView = lView[TVIEW];
|
|
22262
|
+
const tNode = tView.data[context.nodeIndex];
|
|
22263
|
+
const providerTokens = [];
|
|
22264
|
+
const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
|
|
22265
|
+
const endIndex = tNode.directiveEnd;
|
|
22266
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
22267
|
+
let value = tView.data[i];
|
|
22268
|
+
if (isDirectiveDefHack(value)) {
|
|
22269
|
+
// The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
|
|
22270
|
+
// design flaw. We should always store same type so that we can be monomorphic. The issue
|
|
22271
|
+
// is that for Components/Directives we store the def instead the type. The correct behavior
|
|
22272
|
+
// is that we should always be storing injectable type in this location.
|
|
22273
|
+
value = value.type;
|
|
22712
22274
|
}
|
|
22713
|
-
|
|
22275
|
+
providerTokens.push(value);
|
|
22714
22276
|
}
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
|
|
22720
|
-
|
|
22277
|
+
return providerTokens;
|
|
22278
|
+
}
|
|
22279
|
+
/**
|
|
22280
|
+
* Retrieves directive instances associated with a given DOM node. Does not include
|
|
22281
|
+
* component instances.
|
|
22282
|
+
*
|
|
22283
|
+
* @usageNotes
|
|
22284
|
+
* Given the following DOM structure:
|
|
22285
|
+
*
|
|
22286
|
+
* ```html
|
|
22287
|
+
* <app-root>
|
|
22288
|
+
* <button my-button></button>
|
|
22289
|
+
* <my-comp></my-comp>
|
|
22290
|
+
* </app-root>
|
|
22291
|
+
* ```
|
|
22292
|
+
*
|
|
22293
|
+
* Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
|
|
22294
|
+
* directive that is associated with the DOM node.
|
|
22295
|
+
*
|
|
22296
|
+
* Calling `getDirectives` on `<my-comp>` will return an empty array.
|
|
22297
|
+
*
|
|
22298
|
+
* @param node DOM node for which to get the directives.
|
|
22299
|
+
* @returns Array of directives associated with the node.
|
|
22300
|
+
*
|
|
22301
|
+
* @publicApi
|
|
22302
|
+
* @globalApi ng
|
|
22303
|
+
*/
|
|
22304
|
+
function getDirectives(node) {
|
|
22305
|
+
// Skip text nodes because we can't have directives associated with them.
|
|
22306
|
+
if (node instanceof Text) {
|
|
22307
|
+
return [];
|
|
22721
22308
|
}
|
|
22722
|
-
|
|
22723
|
-
|
|
22724
|
-
|
|
22309
|
+
const context = getLContext(node);
|
|
22310
|
+
const lView = context ? context.lView : null;
|
|
22311
|
+
if (lView === null) {
|
|
22312
|
+
return [];
|
|
22313
|
+
}
|
|
22314
|
+
const tView = lView[TVIEW];
|
|
22315
|
+
const nodeIndex = context.nodeIndex;
|
|
22316
|
+
if (!tView?.data[nodeIndex]) {
|
|
22317
|
+
return [];
|
|
22318
|
+
}
|
|
22319
|
+
if (context.directives === undefined) {
|
|
22320
|
+
context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
|
|
22321
|
+
}
|
|
22322
|
+
// The `directives` in this case are a named array called `LComponentView`. Clone the
|
|
22323
|
+
// result so we don't expose an internal data structure in the user's console.
|
|
22324
|
+
return context.directives === null ? [] : [...context.directives];
|
|
22325
|
+
}
|
|
22326
|
+
/**
|
|
22327
|
+
* Returns the debug (partial) metadata for a particular directive or component instance.
|
|
22328
|
+
* The function accepts an instance of a directive or component and returns the corresponding
|
|
22329
|
+
* metadata.
|
|
22330
|
+
*
|
|
22331
|
+
* @param directiveOrComponentInstance Instance of a directive or component
|
|
22332
|
+
* @returns metadata of the passed directive or component
|
|
22333
|
+
*
|
|
22334
|
+
* @publicApi
|
|
22335
|
+
* @globalApi ng
|
|
22336
|
+
*/
|
|
22337
|
+
function getDirectiveMetadata(directiveOrComponentInstance) {
|
|
22338
|
+
const { constructor } = directiveOrComponentInstance;
|
|
22339
|
+
if (!constructor) {
|
|
22340
|
+
throw new Error('Unable to find the instance constructor');
|
|
22725
22341
|
}
|
|
22726
|
-
|
|
22727
|
-
|
|
22728
|
-
constructor
|
|
22729
|
-
|
|
22730
|
-
|
|
22342
|
+
// In case a component inherits from a directive, we may have component and directive metadata
|
|
22343
|
+
// To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
|
|
22344
|
+
const componentDef = getComponentDef$1(constructor);
|
|
22345
|
+
if (componentDef) {
|
|
22346
|
+
return {
|
|
22347
|
+
inputs: componentDef.inputs,
|
|
22348
|
+
outputs: componentDef.outputs,
|
|
22349
|
+
encapsulation: componentDef.encapsulation,
|
|
22350
|
+
changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
|
|
22351
|
+
ChangeDetectionStrategy.Default
|
|
22352
|
+
};
|
|
22731
22353
|
}
|
|
22732
|
-
|
|
22733
|
-
|
|
22354
|
+
const directiveDef = getDirectiveDef(constructor);
|
|
22355
|
+
if (directiveDef) {
|
|
22356
|
+
return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
|
|
22734
22357
|
}
|
|
22358
|
+
return null;
|
|
22735
22359
|
}
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
|
|
22739
|
-
|
|
22740
|
-
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
22750
|
-
|
|
22751
|
-
|
|
22752
|
-
|
|
22753
|
-
|
|
22360
|
+
/**
|
|
22361
|
+
* Retrieve map of local references.
|
|
22362
|
+
*
|
|
22363
|
+
* The references are retrieved as a map of local reference name to element or directive instance.
|
|
22364
|
+
*
|
|
22365
|
+
* @param target DOM element, component or directive instance for which to retrieve
|
|
22366
|
+
* the local references.
|
|
22367
|
+
*/
|
|
22368
|
+
function getLocalRefs(target) {
|
|
22369
|
+
const context = getLContext(target);
|
|
22370
|
+
if (context === null)
|
|
22371
|
+
return {};
|
|
22372
|
+
if (context.localRefs === undefined) {
|
|
22373
|
+
const lView = context.lView;
|
|
22374
|
+
if (lView === null) {
|
|
22375
|
+
return {};
|
|
22376
|
+
}
|
|
22377
|
+
context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
|
|
22754
22378
|
}
|
|
22379
|
+
return context.localRefs || {};
|
|
22755
22380
|
}
|
|
22756
22381
|
/**
|
|
22757
|
-
*
|
|
22382
|
+
* Retrieves the host element of a component or directive instance.
|
|
22383
|
+
* The host element is the DOM element that matched the selector of the directive.
|
|
22384
|
+
*
|
|
22385
|
+
* @param componentOrDirective Component or directive instance for which the host
|
|
22386
|
+
* element should be retrieved.
|
|
22387
|
+
* @returns Host element of the target.
|
|
22758
22388
|
*
|
|
22759
22389
|
* @publicApi
|
|
22760
|
-
* @
|
|
22390
|
+
* @globalApi ng
|
|
22761
22391
|
*/
|
|
22762
|
-
function
|
|
22763
|
-
|
|
22764
|
-
return adapter.injector;
|
|
22392
|
+
function getHostElement(componentOrDirective) {
|
|
22393
|
+
return getLContext(componentOrDirective).native;
|
|
22765
22394
|
}
|
|
22766
|
-
|
|
22767
22395
|
/**
|
|
22768
|
-
*
|
|
22769
|
-
* Copyright Google LLC All Rights Reserved.
|
|
22396
|
+
* Retrieves the rendered text for a given component.
|
|
22770
22397
|
*
|
|
22771
|
-
*
|
|
22772
|
-
*
|
|
22398
|
+
* This function retrieves the host element of a component and
|
|
22399
|
+
* and then returns the `textContent` for that element. This implies
|
|
22400
|
+
* that the text returned will include re-projected content of
|
|
22401
|
+
* the component as well.
|
|
22402
|
+
*
|
|
22403
|
+
* @param component The component to return the content text for.
|
|
22773
22404
|
*/
|
|
22405
|
+
function getRenderedText(component) {
|
|
22406
|
+
const hostElement = getHostElement(component);
|
|
22407
|
+
return hostElement.textContent || '';
|
|
22408
|
+
}
|
|
22774
22409
|
/**
|
|
22775
|
-
*
|
|
22776
|
-
*
|
|
22777
|
-
*
|
|
22410
|
+
* Retrieves a list of event listeners associated with a DOM element. The list does include host
|
|
22411
|
+
* listeners, but it does not include event listeners defined outside of the Angular context
|
|
22412
|
+
* (e.g. through `addEventListener`).
|
|
22413
|
+
*
|
|
22414
|
+
* @usageNotes
|
|
22415
|
+
* Given the following DOM structure:
|
|
22416
|
+
*
|
|
22417
|
+
* ```html
|
|
22418
|
+
* <app-root>
|
|
22419
|
+
* <div (click)="doSomething()"></div>
|
|
22420
|
+
* </app-root>
|
|
22421
|
+
* ```
|
|
22422
|
+
*
|
|
22423
|
+
* Calling `getListeners` on `<div>` will return an object that looks as follows:
|
|
22424
|
+
*
|
|
22425
|
+
* ```ts
|
|
22426
|
+
* {
|
|
22427
|
+
* name: 'click',
|
|
22428
|
+
* element: <div>,
|
|
22429
|
+
* callback: () => doSomething(),
|
|
22430
|
+
* useCapture: false
|
|
22431
|
+
* }
|
|
22432
|
+
* ```
|
|
22433
|
+
*
|
|
22434
|
+
* @param element Element for which the DOM listeners should be retrieved.
|
|
22435
|
+
* @returns Array of event listeners on the DOM element.
|
|
22436
|
+
*
|
|
22437
|
+
* @publicApi
|
|
22438
|
+
* @globalApi ng
|
|
22778
22439
|
*/
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
|
|
22792
|
-
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22798
|
-
|
|
22799
|
-
|
|
22800
|
-
if
|
|
22801
|
-
|
|
22440
|
+
function getListeners(element) {
|
|
22441
|
+
ngDevMode && assertDomElement(element);
|
|
22442
|
+
const lContext = getLContext(element);
|
|
22443
|
+
const lView = lContext === null ? null : lContext.lView;
|
|
22444
|
+
if (lView === null)
|
|
22445
|
+
return [];
|
|
22446
|
+
const tView = lView[TVIEW];
|
|
22447
|
+
const lCleanup = lView[CLEANUP];
|
|
22448
|
+
const tCleanup = tView.cleanup;
|
|
22449
|
+
const listeners = [];
|
|
22450
|
+
if (tCleanup && lCleanup) {
|
|
22451
|
+
for (let i = 0; i < tCleanup.length;) {
|
|
22452
|
+
const firstParam = tCleanup[i++];
|
|
22453
|
+
const secondParam = tCleanup[i++];
|
|
22454
|
+
if (typeof firstParam === 'string') {
|
|
22455
|
+
const name = firstParam;
|
|
22456
|
+
const listenerElement = unwrapRNode(lView[secondParam]);
|
|
22457
|
+
const callback = lCleanup[tCleanup[i++]];
|
|
22458
|
+
const useCaptureOrIndx = tCleanup[i++];
|
|
22459
|
+
// if useCaptureOrIndx is boolean then report it as is.
|
|
22460
|
+
// if useCaptureOrIndx is positive number then it in unsubscribe method
|
|
22461
|
+
// if useCaptureOrIndx is negative number then it is a Subscription
|
|
22462
|
+
const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
|
|
22463
|
+
const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
|
|
22464
|
+
if (element == listenerElement) {
|
|
22465
|
+
listeners.push({ element, name, callback, useCapture, type });
|
|
22802
22466
|
}
|
|
22803
22467
|
}
|
|
22804
22468
|
}
|
|
22805
|
-
finally {
|
|
22806
|
-
this.cachedInjectors.clear();
|
|
22807
|
-
}
|
|
22808
22469
|
}
|
|
22470
|
+
listeners.sort(sortListeners);
|
|
22471
|
+
return listeners;
|
|
22472
|
+
}
|
|
22473
|
+
function sortListeners(a, b) {
|
|
22474
|
+
if (a.name == b.name)
|
|
22475
|
+
return 0;
|
|
22476
|
+
return a.name < b.name ? -1 : 1;
|
|
22809
22477
|
}
|
|
22810
|
-
/** @nocollapse */
|
|
22811
|
-
StandaloneService.ɵprov = ɵɵdefineInjectable({
|
|
22812
|
-
token: StandaloneService,
|
|
22813
|
-
providedIn: 'environment',
|
|
22814
|
-
factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
|
|
22815
|
-
});
|
|
22816
22478
|
/**
|
|
22817
|
-
*
|
|
22479
|
+
* This function should not exist because it is megamorphic and only mostly correct.
|
|
22818
22480
|
*
|
|
22819
|
-
*
|
|
22820
|
-
|
|
22821
|
-
|
|
22822
|
-
|
|
22481
|
+
* See call site for more info.
|
|
22482
|
+
*/
|
|
22483
|
+
function isDirectiveDefHack(obj) {
|
|
22484
|
+
return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
|
|
22485
|
+
}
|
|
22486
|
+
/**
|
|
22487
|
+
* Returns the attached `DebugNode` instance for an element in the DOM.
|
|
22823
22488
|
*
|
|
22824
|
-
* @
|
|
22489
|
+
* @param element DOM element which is owned by an existing component's view.
|
|
22825
22490
|
*/
|
|
22826
|
-
function
|
|
22827
|
-
|
|
22828
|
-
|
|
22829
|
-
}
|
|
22491
|
+
function getDebugNode(element) {
|
|
22492
|
+
if (ngDevMode && !(element instanceof Node)) {
|
|
22493
|
+
throw new Error('Expecting instance of DOM Element');
|
|
22494
|
+
}
|
|
22495
|
+
const lContext = getLContext(element);
|
|
22496
|
+
const lView = lContext ? lContext.lView : null;
|
|
22497
|
+
if (lView === null) {
|
|
22498
|
+
return null;
|
|
22499
|
+
}
|
|
22500
|
+
const nodeIndex = lContext.nodeIndex;
|
|
22501
|
+
if (nodeIndex !== -1) {
|
|
22502
|
+
const valueInLView = lView[nodeIndex];
|
|
22503
|
+
// this means that value in the lView is a component with its own
|
|
22504
|
+
// data. In this situation the TNode is not accessed at the same spot.
|
|
22505
|
+
const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
|
|
22506
|
+
ngDevMode &&
|
|
22507
|
+
assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
|
|
22508
|
+
return buildDebugNode(tNode, lView);
|
|
22509
|
+
}
|
|
22510
|
+
return null;
|
|
22511
|
+
}
|
|
22512
|
+
/**
|
|
22513
|
+
* Retrieve the component `LView` from component/element.
|
|
22514
|
+
*
|
|
22515
|
+
* NOTE: `LView` is a private and should not be leaked outside.
|
|
22516
|
+
* Don't export this method to `ng.*` on window.
|
|
22517
|
+
*
|
|
22518
|
+
* @param target DOM element or component instance for which to retrieve the LView.
|
|
22519
|
+
*/
|
|
22520
|
+
function getComponentLView(target) {
|
|
22521
|
+
const lContext = getLContext(target);
|
|
22522
|
+
const nodeIndx = lContext.nodeIndex;
|
|
22523
|
+
const lView = lContext.lView;
|
|
22524
|
+
ngDevMode && assertLView(lView);
|
|
22525
|
+
const componentLView = lView[nodeIndx];
|
|
22526
|
+
ngDevMode && assertLView(componentLView);
|
|
22527
|
+
return componentLView;
|
|
22528
|
+
}
|
|
22529
|
+
/** Asserts that a value is a DOM Element. */
|
|
22530
|
+
function assertDomElement(value) {
|
|
22531
|
+
if (typeof Element !== 'undefined' && !(value instanceof Element)) {
|
|
22532
|
+
throw new Error('Expecting instance of DOM Element');
|
|
22533
|
+
}
|
|
22830
22534
|
}
|
|
22831
22535
|
|
|
22832
22536
|
/**
|
|
@@ -24046,7 +23750,7 @@ const unusedValueExportToPlacateAjd = 1;
|
|
|
24046
23750
|
* Use of this source code is governed by an MIT-style license that can be
|
|
24047
23751
|
* found in the LICENSE file at https://angular.io/license
|
|
24048
23752
|
*/
|
|
24049
|
-
const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$
|
|
23753
|
+
const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd;
|
|
24050
23754
|
class LQuery_ {
|
|
24051
23755
|
constructor(queryList) {
|
|
24052
23756
|
this.queryList = queryList;
|
|
@@ -24713,7 +24417,7 @@ function patchModuleCompilation() {
|
|
|
24713
24417
|
function isModuleWithProviders$1(value) {
|
|
24714
24418
|
return value.ngModule !== undefined;
|
|
24715
24419
|
}
|
|
24716
|
-
function isNgModule(value) {
|
|
24420
|
+
function isNgModule$1(value) {
|
|
24717
24421
|
return !!getNgModuleDef(value);
|
|
24718
24422
|
}
|
|
24719
24423
|
|
|
@@ -25136,7 +24840,7 @@ function patchComponentDefWithScope(componentDef, transitiveScopes) {
|
|
|
25136
24840
|
* (either a NgModule or a standalone component / directive / pipe).
|
|
25137
24841
|
*/
|
|
25138
24842
|
function transitiveScopesFor(type) {
|
|
25139
|
-
if (isNgModule(type)) {
|
|
24843
|
+
if (isNgModule$1(type)) {
|
|
25140
24844
|
return transitiveScopesForNgModule(type);
|
|
25141
24845
|
}
|
|
25142
24846
|
else if (isStandalone(type)) {
|
|
@@ -25220,7 +24924,7 @@ function transitiveScopesForNgModule(moduleType) {
|
|
|
25220
24924
|
const exportedType = exported;
|
|
25221
24925
|
// Either the type is a module, a pipe, or a component/directive (which may not have a
|
|
25222
24926
|
// ɵcmp as it might be compiled asynchronously).
|
|
25223
|
-
if (isNgModule(exportedType)) {
|
|
24927
|
+
if (isNgModule$1(exportedType)) {
|
|
25224
24928
|
// When this module exports another, the exported module's exported directives and pipes are
|
|
25225
24929
|
// added to both the compilation and exported scopes of this module.
|
|
25226
24930
|
const exportedScope = transitiveScopesFor(exportedType);
|
|
@@ -25527,7 +25231,7 @@ class R3TestBedCompiler {
|
|
|
25527
25231
|
// module's provider list.
|
|
25528
25232
|
this.providerOverridesByModule = new Map();
|
|
25529
25233
|
this.providerOverridesByToken = new Map();
|
|
25530
|
-
this.
|
|
25234
|
+
this.scopesWithOverriddenProviders = new Set();
|
|
25531
25235
|
this.testModuleRef = null;
|
|
25532
25236
|
class DynamicTestModule {
|
|
25533
25237
|
}
|
|
@@ -25695,7 +25399,7 @@ class R3TestBedCompiler {
|
|
|
25695
25399
|
this.queueTypesFromModulesArray([moduleType]);
|
|
25696
25400
|
this.compileTypesSync();
|
|
25697
25401
|
this.applyProviderOverrides();
|
|
25698
|
-
this.
|
|
25402
|
+
this.applyProviderOverridesInScope(moduleType);
|
|
25699
25403
|
this.applyTransitiveScopes();
|
|
25700
25404
|
}
|
|
25701
25405
|
/**
|
|
@@ -25705,7 +25409,7 @@ class R3TestBedCompiler {
|
|
|
25705
25409
|
this.queueTypesFromModulesArray([moduleType]);
|
|
25706
25410
|
await this.compileComponents();
|
|
25707
25411
|
this.applyProviderOverrides();
|
|
25708
|
-
this.
|
|
25412
|
+
this.applyProviderOverridesInScope(moduleType);
|
|
25709
25413
|
this.applyTransitiveScopes();
|
|
25710
25414
|
}
|
|
25711
25415
|
/**
|
|
@@ -25806,50 +25510,52 @@ class R3TestBedCompiler {
|
|
|
25806
25510
|
this.seenComponents.clear();
|
|
25807
25511
|
this.seenDirectives.clear();
|
|
25808
25512
|
}
|
|
25809
|
-
|
|
25810
|
-
|
|
25513
|
+
/**
|
|
25514
|
+
* Applies provider overrides to a given type (either an NgModule or a standalone component)
|
|
25515
|
+
* and all imported NgModules and standalone components recursively.
|
|
25516
|
+
*/
|
|
25517
|
+
applyProviderOverridesInScope(type) {
|
|
25518
|
+
const hasScope = isStandaloneComponent(type) || isNgModule(type);
|
|
25519
|
+
// The function can be re-entered recursively while inspecting dependencies
|
|
25520
|
+
// of an NgModule or a standalone component. Exit early if we come across a
|
|
25521
|
+
// type that can not have a scope (directive or pipe) or the type is already
|
|
25522
|
+
// processed earlier.
|
|
25523
|
+
if (!hasScope || this.scopesWithOverriddenProviders.has(type)) {
|
|
25811
25524
|
return;
|
|
25812
25525
|
}
|
|
25813
|
-
this.
|
|
25526
|
+
this.scopesWithOverriddenProviders.add(type);
|
|
25814
25527
|
// NOTE: the line below triggers JIT compilation of the module injector,
|
|
25815
25528
|
// which also invokes verification of the NgModule semantics, which produces
|
|
25816
25529
|
// detailed error messages. The fact that the code relies on this line being
|
|
25817
25530
|
// present here is suspicious and should be refactored in a way that the line
|
|
25818
25531
|
// below can be moved (for ex. after an early exit check below).
|
|
25819
|
-
const injectorDef =
|
|
25532
|
+
const injectorDef = type[ɵNG_INJ_DEF];
|
|
25820
25533
|
// No provider overrides, exit early.
|
|
25821
25534
|
if (this.providerOverridesByToken.size === 0)
|
|
25822
25535
|
return;
|
|
25823
|
-
if (isStandaloneComponent(
|
|
25536
|
+
if (isStandaloneComponent(type)) {
|
|
25824
25537
|
// Visit all component dependencies and override providers there.
|
|
25825
|
-
const def = getComponentDef(
|
|
25538
|
+
const def = getComponentDef(type);
|
|
25826
25539
|
const dependencies = maybeUnwrapFn(def.dependencies ?? []);
|
|
25827
25540
|
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
|
-
}
|
|
25541
|
+
this.applyProviderOverridesInScope(dependency);
|
|
25836
25542
|
}
|
|
25837
25543
|
}
|
|
25838
25544
|
else {
|
|
25839
25545
|
const providers = [
|
|
25840
25546
|
...injectorDef.providers,
|
|
25841
|
-
...(this.providerOverridesByModule.get(
|
|
25547
|
+
...(this.providerOverridesByModule.get(type) || [])
|
|
25842
25548
|
];
|
|
25843
25549
|
if (this.hasProviderOverrides(providers)) {
|
|
25844
|
-
this.maybeStoreNgDef(ɵNG_INJ_DEF,
|
|
25845
|
-
this.storeFieldOfDefOnType(
|
|
25550
|
+
this.maybeStoreNgDef(ɵNG_INJ_DEF, type);
|
|
25551
|
+
this.storeFieldOfDefOnType(type, ɵNG_INJ_DEF, 'providers');
|
|
25846
25552
|
injectorDef.providers = this.getOverriddenProviders(providers);
|
|
25847
25553
|
}
|
|
25848
25554
|
// Apply provider overrides to imported modules recursively
|
|
25849
|
-
const moduleDef =
|
|
25555
|
+
const moduleDef = type[ɵNG_MOD_DEF];
|
|
25850
25556
|
const imports = maybeUnwrapFn(moduleDef.imports);
|
|
25851
25557
|
for (const importedModule of imports) {
|
|
25852
|
-
this.
|
|
25558
|
+
this.applyProviderOverridesInScope(importedModule);
|
|
25853
25559
|
}
|
|
25854
25560
|
// Also override the providers on any ModuleWithProviders imports since those don't appear in
|
|
25855
25561
|
// the moduleDef.
|
|
@@ -26086,7 +25792,7 @@ class R3TestBedCompiler {
|
|
|
26086
25792
|
});
|
|
26087
25793
|
});
|
|
26088
25794
|
this.initialNgDefs.clear();
|
|
26089
|
-
this.
|
|
25795
|
+
this.scopesWithOverriddenProviders.clear();
|
|
26090
25796
|
this.restoreComponentResolutionQueue();
|
|
26091
25797
|
// Restore the locale ID to the default value, this shouldn't be necessary but we never know
|
|
26092
25798
|
ɵsetLocaleId(ɵDEFAULT_LOCALE_ID);
|
|
@@ -26113,7 +25819,7 @@ class R3TestBedCompiler {
|
|
|
26113
25819
|
providers,
|
|
26114
25820
|
}, /* allowDuplicateDeclarationsInRoot */ true);
|
|
26115
25821
|
// clang-format on
|
|
26116
|
-
this.
|
|
25822
|
+
this.applyProviderOverridesInScope(this.testModuleType);
|
|
26117
25823
|
}
|
|
26118
25824
|
get injector() {
|
|
26119
25825
|
if (this._injector !== null) {
|
|
@@ -26213,6 +25919,9 @@ function getComponentDef(value) {
|
|
|
26213
25919
|
function hasNgModuleDef(value) {
|
|
26214
25920
|
return value.hasOwnProperty('ɵmod');
|
|
26215
25921
|
}
|
|
25922
|
+
function isNgModule(value) {
|
|
25923
|
+
return hasNgModuleDef(value);
|
|
25924
|
+
}
|
|
26216
25925
|
function maybeUnwrapFn(maybeFn) {
|
|
26217
25926
|
return maybeFn instanceof Function ? maybeFn() : maybeFn;
|
|
26218
25927
|
}
|