@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/fesm2015/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
|
*/
|
|
@@ -863,6 +863,68 @@ const NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
|
|
|
863
863
|
const NG_INJECTABLE_DEF = getClosureSafeProperty({ ngInjectableDef: getClosureSafeProperty });
|
|
864
864
|
const NG_INJECTOR_DEF = getClosureSafeProperty({ ngInjectorDef: getClosureSafeProperty });
|
|
865
865
|
|
|
866
|
+
/**
|
|
867
|
+
* @license
|
|
868
|
+
* Copyright Google LLC All Rights Reserved.
|
|
869
|
+
*
|
|
870
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
871
|
+
* found in the LICENSE file at https://angular.io/license
|
|
872
|
+
*/
|
|
873
|
+
/**
|
|
874
|
+
* Base URL for the error details page.
|
|
875
|
+
*
|
|
876
|
+
* Keep the files below in full sync:
|
|
877
|
+
* - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
|
|
878
|
+
* - packages/core/src/error_details_base_url.ts
|
|
879
|
+
*/
|
|
880
|
+
const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* @license
|
|
884
|
+
* Copyright Google LLC All Rights Reserved.
|
|
885
|
+
*
|
|
886
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
887
|
+
* found in the LICENSE file at https://angular.io/license
|
|
888
|
+
*/
|
|
889
|
+
/**
|
|
890
|
+
* Class that represents a runtime error.
|
|
891
|
+
* Formats and outputs the error message in a consistent way.
|
|
892
|
+
*
|
|
893
|
+
* Example:
|
|
894
|
+
* ```
|
|
895
|
+
* throw new RuntimeError(
|
|
896
|
+
* RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
|
|
897
|
+
* ngDevMode && 'Injector has already been destroyed.');
|
|
898
|
+
* ```
|
|
899
|
+
*
|
|
900
|
+
* Note: the `message` argument contains a descriptive error message as a string in development
|
|
901
|
+
* mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
|
|
902
|
+
* `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
|
|
903
|
+
*/
|
|
904
|
+
class RuntimeError extends Error {
|
|
905
|
+
constructor(code, message) {
|
|
906
|
+
super(formatRuntimeError(code, message));
|
|
907
|
+
this.code = code;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Called to format a runtime error.
|
|
912
|
+
* See additional info on the `message` argument type in the `RuntimeError` class description.
|
|
913
|
+
*/
|
|
914
|
+
function formatRuntimeError(code, message) {
|
|
915
|
+
// Error code might be a negative number, which is a special marker that instructs the logic to
|
|
916
|
+
// generate a link to the error details page on angular.io.
|
|
917
|
+
const fullCode = `NG0${Math.abs(code)}`;
|
|
918
|
+
let errorMessage = `${fullCode}${message ? ': ' + message.trim() : ''}`;
|
|
919
|
+
if (ngDevMode && code < 0) {
|
|
920
|
+
const addPeriodSeparator = !errorMessage.match(/[.,;!?]$/);
|
|
921
|
+
const separator = addPeriodSeparator ? '.' : '';
|
|
922
|
+
errorMessage =
|
|
923
|
+
`${errorMessage}${separator} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
|
|
924
|
+
}
|
|
925
|
+
return errorMessage;
|
|
926
|
+
}
|
|
927
|
+
|
|
866
928
|
/**
|
|
867
929
|
* @license
|
|
868
930
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1791,68 +1853,6 @@ function initNgDevMode() {
|
|
|
1791
1853
|
return false;
|
|
1792
1854
|
}
|
|
1793
1855
|
|
|
1794
|
-
/**
|
|
1795
|
-
* @license
|
|
1796
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1797
|
-
*
|
|
1798
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1799
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1800
|
-
*/
|
|
1801
|
-
/**
|
|
1802
|
-
* Base URL for the error details page.
|
|
1803
|
-
*
|
|
1804
|
-
* Keep the files below in full sync:
|
|
1805
|
-
* - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
|
|
1806
|
-
* - packages/core/src/error_details_base_url.ts
|
|
1807
|
-
*/
|
|
1808
|
-
const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
|
|
1809
|
-
|
|
1810
|
-
/**
|
|
1811
|
-
* @license
|
|
1812
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1813
|
-
*
|
|
1814
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1815
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1816
|
-
*/
|
|
1817
|
-
/**
|
|
1818
|
-
* Class that represents a runtime error.
|
|
1819
|
-
* Formats and outputs the error message in a consistent way.
|
|
1820
|
-
*
|
|
1821
|
-
* Example:
|
|
1822
|
-
* ```
|
|
1823
|
-
* throw new RuntimeError(
|
|
1824
|
-
* RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
|
|
1825
|
-
* ngDevMode && 'Injector has already been destroyed.');
|
|
1826
|
-
* ```
|
|
1827
|
-
*
|
|
1828
|
-
* Note: the `message` argument contains a descriptive error message as a string in development
|
|
1829
|
-
* mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
|
|
1830
|
-
* `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
|
|
1831
|
-
*/
|
|
1832
|
-
class RuntimeError extends Error {
|
|
1833
|
-
constructor(code, message) {
|
|
1834
|
-
super(formatRuntimeError(code, message));
|
|
1835
|
-
this.code = code;
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
/**
|
|
1839
|
-
* Called to format a runtime error.
|
|
1840
|
-
* See additional info on the `message` argument type in the `RuntimeError` class description.
|
|
1841
|
-
*/
|
|
1842
|
-
function formatRuntimeError(code, message) {
|
|
1843
|
-
// Error code might be a negative number, which is a special marker that instructs the logic to
|
|
1844
|
-
// generate a link to the error details page on angular.io.
|
|
1845
|
-
const fullCode = `NG0${Math.abs(code)}`;
|
|
1846
|
-
let errorMessage = `${fullCode}${message ? ': ' + message.trim() : ''}`;
|
|
1847
|
-
if (ngDevMode && code < 0) {
|
|
1848
|
-
const addPeriodSeparator = !errorMessage.match(/[.,;!?]$/);
|
|
1849
|
-
const separator = addPeriodSeparator ? '.' : '';
|
|
1850
|
-
errorMessage =
|
|
1851
|
-
`${errorMessage}${separator} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
|
|
1852
|
-
}
|
|
1853
|
-
return errorMessage;
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
1856
|
/**
|
|
1857
1857
|
* @license
|
|
1858
1858
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -2046,10 +2046,8 @@ function setCurrentInjector(injector) {
|
|
|
2046
2046
|
}
|
|
2047
2047
|
function injectInjectorOnly(token, flags = InjectFlags.Default) {
|
|
2048
2048
|
if (_currentInjector === undefined) {
|
|
2049
|
-
|
|
2050
|
-
`inject() must be called from an injection context (a constructor, a factory function or a field initializer)`
|
|
2051
|
-
'';
|
|
2052
|
-
throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, errorMessage);
|
|
2049
|
+
throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, ngDevMode &&
|
|
2050
|
+
`inject() must be called from an injection context (a constructor, a factory function or a field initializer)`);
|
|
2053
2051
|
}
|
|
2054
2052
|
else if (_currentInjector === null) {
|
|
2055
2053
|
return injectRootLimpMode(token, undefined, flags);
|
|
@@ -2065,22 +2063,17 @@ function ɵɵinject(token, flags = InjectFlags.Default) {
|
|
|
2065
2063
|
* Throws an error indicating that a factory function could not be generated by the compiler for a
|
|
2066
2064
|
* particular class.
|
|
2067
2065
|
*
|
|
2068
|
-
* This instruction allows the actual error message to be optimized away when ngDevMode is turned
|
|
2069
|
-
* off, saving bytes of generated code while still providing a good experience in dev mode.
|
|
2070
|
-
*
|
|
2071
2066
|
* The name of the class is not mentioned here, but will be in the generated factory function name
|
|
2072
2067
|
* and thus in the stack trace.
|
|
2073
2068
|
*
|
|
2074
2069
|
* @codeGenApi
|
|
2075
2070
|
*/
|
|
2076
2071
|
function ɵɵinvalidFactoryDep(index) {
|
|
2077
|
-
|
|
2072
|
+
throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, ngDevMode &&
|
|
2078
2073
|
`This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
|
|
2079
2074
|
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.
|
|
2080
2075
|
|
|
2081
|
-
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.`
|
|
2082
|
-
'invalid';
|
|
2083
|
-
throw new Error(msg);
|
|
2076
|
+
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.`);
|
|
2084
2077
|
}
|
|
2085
2078
|
/**
|
|
2086
2079
|
* Injects a token from the currently active injector.
|
|
@@ -2155,10 +2148,7 @@ function injectArgs(types) {
|
|
|
2155
2148
|
const arg = resolveForwardRef(types[i]);
|
|
2156
2149
|
if (Array.isArray(arg)) {
|
|
2157
2150
|
if (arg.length === 0) {
|
|
2158
|
-
|
|
2159
|
-
'Arguments array must have arguments.' :
|
|
2160
|
-
'';
|
|
2161
|
-
throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, errorMessage);
|
|
2151
|
+
throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, ngDevMode && 'Arguments array must have arguments.');
|
|
2162
2152
|
}
|
|
2163
2153
|
let type = undefined;
|
|
2164
2154
|
let flags = InjectFlags.Default;
|
|
@@ -3193,87 +3183,6 @@ function getNamespaceUri(namespace) {
|
|
|
3193
3183
|
(name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
|
|
3194
3184
|
}
|
|
3195
3185
|
|
|
3196
|
-
/**
|
|
3197
|
-
* @license
|
|
3198
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3199
|
-
*
|
|
3200
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3201
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3202
|
-
*/
|
|
3203
|
-
/**
|
|
3204
|
-
* Most of the use of `document` in Angular is from within the DI system so it is possible to simply
|
|
3205
|
-
* inject the `DOCUMENT` token and are done.
|
|
3206
|
-
*
|
|
3207
|
-
* Ivy is special because it does not rely upon the DI and must get hold of the document some other
|
|
3208
|
-
* way.
|
|
3209
|
-
*
|
|
3210
|
-
* The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
|
|
3211
|
-
* Wherever ivy needs the global document, it calls `getDocument()` instead.
|
|
3212
|
-
*
|
|
3213
|
-
* When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
|
|
3214
|
-
* tell ivy what the global `document` is.
|
|
3215
|
-
*
|
|
3216
|
-
* Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
|
|
3217
|
-
* by calling `setDocument()` when providing the `DOCUMENT` token.
|
|
3218
|
-
*/
|
|
3219
|
-
let DOCUMENT = undefined;
|
|
3220
|
-
/**
|
|
3221
|
-
* Tell ivy what the `document` is for this platform.
|
|
3222
|
-
*
|
|
3223
|
-
* It is only necessary to call this if the current platform is not a browser.
|
|
3224
|
-
*
|
|
3225
|
-
* @param document The object representing the global `document` in this environment.
|
|
3226
|
-
*/
|
|
3227
|
-
function setDocument(document) {
|
|
3228
|
-
DOCUMENT = document;
|
|
3229
|
-
}
|
|
3230
|
-
/**
|
|
3231
|
-
* Access the object that represents the `document` for this platform.
|
|
3232
|
-
*
|
|
3233
|
-
* Ivy calls this whenever it needs to access the `document` object.
|
|
3234
|
-
* For example to create the renderer or to do sanitization.
|
|
3235
|
-
*/
|
|
3236
|
-
function getDocument() {
|
|
3237
|
-
if (DOCUMENT !== undefined) {
|
|
3238
|
-
return DOCUMENT;
|
|
3239
|
-
}
|
|
3240
|
-
else if (typeof document !== 'undefined') {
|
|
3241
|
-
return document;
|
|
3242
|
-
}
|
|
3243
|
-
// No "document" can be found. This should only happen if we are running ivy outside Angular and
|
|
3244
|
-
// the current platform is not a browser. Since this is not a supported scenario at the moment
|
|
3245
|
-
// this should not happen in Angular apps.
|
|
3246
|
-
// Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
|
|
3247
|
-
// public API. Meanwhile we just return `undefined` and let the application fail.
|
|
3248
|
-
return undefined;
|
|
3249
|
-
}
|
|
3250
|
-
|
|
3251
|
-
/**
|
|
3252
|
-
* @license
|
|
3253
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3254
|
-
*
|
|
3255
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3256
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3257
|
-
*/
|
|
3258
|
-
// TODO: cleanup once the code is merged in angular/angular
|
|
3259
|
-
var RendererStyleFlags3;
|
|
3260
|
-
(function (RendererStyleFlags3) {
|
|
3261
|
-
RendererStyleFlags3[RendererStyleFlags3["Important"] = 1] = "Important";
|
|
3262
|
-
RendererStyleFlags3[RendererStyleFlags3["DashCase"] = 2] = "DashCase";
|
|
3263
|
-
})(RendererStyleFlags3 || (RendererStyleFlags3 = {}));
|
|
3264
|
-
/** Returns whether the `renderer` is a `ProceduralRenderer3` */
|
|
3265
|
-
function isProceduralRenderer(renderer) {
|
|
3266
|
-
return !!(renderer.listen);
|
|
3267
|
-
}
|
|
3268
|
-
const domRendererFactory3 = {
|
|
3269
|
-
createRenderer: (hostElement, rendererType) => {
|
|
3270
|
-
return getDocument();
|
|
3271
|
-
}
|
|
3272
|
-
};
|
|
3273
|
-
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
|
3274
|
-
// failure based on types.
|
|
3275
|
-
const unusedValueExportToPlacateAjd$6 = 1;
|
|
3276
|
-
|
|
3277
3186
|
/**
|
|
3278
3187
|
* @license
|
|
3279
3188
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -3356,7 +3265,6 @@ function getNativeByTNode(tNode, lView) {
|
|
|
3356
3265
|
ngDevMode && assertTNodeForLView(tNode, lView);
|
|
3357
3266
|
ngDevMode && assertIndexInRange(lView, tNode.index);
|
|
3358
3267
|
const node = unwrapRNode(lView[tNode.index]);
|
|
3359
|
-
ngDevMode && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
|
|
3360
3268
|
return node;
|
|
3361
3269
|
}
|
|
3362
3270
|
/**
|
|
@@ -3372,7 +3280,6 @@ function getNativeByTNodeOrNull(tNode, lView) {
|
|
|
3372
3280
|
if (index !== -1) {
|
|
3373
3281
|
ngDevMode && assertTNodeForLView(tNode, lView);
|
|
3374
3282
|
const node = unwrapRNode(lView[index]);
|
|
3375
|
-
ngDevMode && node !== null && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
|
|
3376
3283
|
return node;
|
|
3377
3284
|
}
|
|
3378
3285
|
return null;
|
|
@@ -4321,7 +4228,7 @@ function isFactory(obj) {
|
|
|
4321
4228
|
}
|
|
4322
4229
|
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
|
4323
4230
|
// failure based on types.
|
|
4324
|
-
const unusedValueExportToPlacateAjd$
|
|
4231
|
+
const unusedValueExportToPlacateAjd$6 = 1;
|
|
4325
4232
|
|
|
4326
4233
|
/**
|
|
4327
4234
|
* Converts `TNodeType` into human readable text.
|
|
@@ -4340,7 +4247,7 @@ function toTNodeTypeAsString(tNodeType) {
|
|
|
4340
4247
|
}
|
|
4341
4248
|
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
|
4342
4249
|
// failure based on types.
|
|
4343
|
-
const unusedValueExportToPlacateAjd$
|
|
4250
|
+
const unusedValueExportToPlacateAjd$5 = 1;
|
|
4344
4251
|
/**
|
|
4345
4252
|
* Returns `true` if the `TNode` has a directive which has `@Input()` for `class` binding.
|
|
4346
4253
|
*
|
|
@@ -4444,7 +4351,6 @@ function assertPureTNodeType(type) {
|
|
|
4444
4351
|
* @returns the index value that was last accessed in the attributes array
|
|
4445
4352
|
*/
|
|
4446
4353
|
function setUpAttributes(renderer, native, attrs) {
|
|
4447
|
-
const isProc = isProceduralRenderer(renderer);
|
|
4448
4354
|
let i = 0;
|
|
4449
4355
|
while (i < attrs.length) {
|
|
4450
4356
|
const value = attrs[i];
|
|
@@ -4461,9 +4367,7 @@ function setUpAttributes(renderer, native, attrs) {
|
|
|
4461
4367
|
const attrName = attrs[i++];
|
|
4462
4368
|
const attrVal = attrs[i++];
|
|
4463
4369
|
ngDevMode && ngDevMode.rendererSetAttribute++;
|
|
4464
|
-
|
|
4465
|
-
renderer.setAttribute(native, attrName, attrVal, namespaceURI) :
|
|
4466
|
-
native.setAttributeNS(namespaceURI, attrName, attrVal);
|
|
4370
|
+
renderer.setAttribute(native, attrName, attrVal, namespaceURI);
|
|
4467
4371
|
}
|
|
4468
4372
|
else {
|
|
4469
4373
|
// attrName is string;
|
|
@@ -4472,14 +4376,10 @@ function setUpAttributes(renderer, native, attrs) {
|
|
|
4472
4376
|
// Standard attributes
|
|
4473
4377
|
ngDevMode && ngDevMode.rendererSetAttribute++;
|
|
4474
4378
|
if (isAnimationProp(attrName)) {
|
|
4475
|
-
|
|
4476
|
-
renderer.setProperty(native, attrName, attrVal);
|
|
4477
|
-
}
|
|
4379
|
+
renderer.setProperty(native, attrName, attrVal);
|
|
4478
4380
|
}
|
|
4479
4381
|
else {
|
|
4480
|
-
|
|
4481
|
-
renderer.setAttribute(native, attrName, attrVal) :
|
|
4482
|
-
native.setAttribute(attrName, attrVal);
|
|
4382
|
+
renderer.setAttribute(native, attrName, attrVal);
|
|
4483
4383
|
}
|
|
4484
4384
|
i++;
|
|
4485
4385
|
}
|
|
@@ -5481,7 +5381,7 @@ function reflectDependency(dep) {
|
|
|
5481
5381
|
}
|
|
5482
5382
|
else if (param instanceof Attribute) {
|
|
5483
5383
|
if (param.attributeName === undefined) {
|
|
5484
|
-
throw new
|
|
5384
|
+
throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, ngDevMode && `Attribute name must be defined.`);
|
|
5485
5385
|
}
|
|
5486
5386
|
meta.attribute = param.attributeName;
|
|
5487
5387
|
}
|
|
@@ -5621,43 +5521,98 @@ function maybeUnwrapFn$1(value) {
|
|
|
5621
5521
|
* found in the LICENSE file at https://angular.io/license
|
|
5622
5522
|
*/
|
|
5623
5523
|
/**
|
|
5624
|
-
*
|
|
5625
|
-
*
|
|
5524
|
+
* Most of the use of `document` in Angular is from within the DI system so it is possible to simply
|
|
5525
|
+
* inject the `DOCUMENT` token and are done.
|
|
5526
|
+
*
|
|
5527
|
+
* Ivy is special because it does not rely upon the DI and must get hold of the document some other
|
|
5528
|
+
* way.
|
|
5529
|
+
*
|
|
5530
|
+
* The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
|
|
5531
|
+
* Wherever ivy needs the global document, it calls `getDocument()` instead.
|
|
5532
|
+
*
|
|
5533
|
+
* When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
|
|
5534
|
+
* tell ivy what the global `document` is.
|
|
5535
|
+
*
|
|
5536
|
+
* Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
|
|
5537
|
+
* by calling `setDocument()` when providing the `DOCUMENT` token.
|
|
5626
5538
|
*/
|
|
5627
|
-
let
|
|
5539
|
+
let DOCUMENT = undefined;
|
|
5628
5540
|
/**
|
|
5629
|
-
*
|
|
5630
|
-
*
|
|
5541
|
+
* Tell ivy what the `document` is for this platform.
|
|
5542
|
+
*
|
|
5543
|
+
* It is only necessary to call this if the current platform is not a browser.
|
|
5544
|
+
*
|
|
5545
|
+
* @param document The object representing the global `document` in this environment.
|
|
5631
5546
|
*/
|
|
5632
|
-
function
|
|
5633
|
-
|
|
5634
|
-
policy$1 = null;
|
|
5635
|
-
if (_global$1.trustedTypes) {
|
|
5636
|
-
try {
|
|
5637
|
-
policy$1 = _global$1.trustedTypes.createPolicy('angular', {
|
|
5638
|
-
createHTML: (s) => s,
|
|
5639
|
-
createScript: (s) => s,
|
|
5640
|
-
createScriptURL: (s) => s,
|
|
5641
|
-
});
|
|
5642
|
-
}
|
|
5643
|
-
catch (_a) {
|
|
5644
|
-
// trustedTypes.createPolicy throws if called with a name that is
|
|
5645
|
-
// already registered, even in report-only mode. Until the API changes,
|
|
5646
|
-
// catch the error not to break the applications functionally. In such
|
|
5647
|
-
// cases, the code will fall back to using strings.
|
|
5648
|
-
}
|
|
5649
|
-
}
|
|
5650
|
-
}
|
|
5651
|
-
return policy$1;
|
|
5547
|
+
function setDocument(document) {
|
|
5548
|
+
DOCUMENT = document;
|
|
5652
5549
|
}
|
|
5653
5550
|
/**
|
|
5654
|
-
*
|
|
5655
|
-
*
|
|
5656
|
-
*
|
|
5657
|
-
*
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5551
|
+
* Access the object that represents the `document` for this platform.
|
|
5552
|
+
*
|
|
5553
|
+
* Ivy calls this whenever it needs to access the `document` object.
|
|
5554
|
+
* For example to create the renderer or to do sanitization.
|
|
5555
|
+
*/
|
|
5556
|
+
function getDocument() {
|
|
5557
|
+
if (DOCUMENT !== undefined) {
|
|
5558
|
+
return DOCUMENT;
|
|
5559
|
+
}
|
|
5560
|
+
else if (typeof document !== 'undefined') {
|
|
5561
|
+
return document;
|
|
5562
|
+
}
|
|
5563
|
+
// No "document" can be found. This should only happen if we are running ivy outside Angular and
|
|
5564
|
+
// the current platform is not a browser. Since this is not a supported scenario at the moment
|
|
5565
|
+
// this should not happen in Angular apps.
|
|
5566
|
+
// Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
|
|
5567
|
+
// public API. Meanwhile we just return `undefined` and let the application fail.
|
|
5568
|
+
return undefined;
|
|
5569
|
+
}
|
|
5570
|
+
|
|
5571
|
+
/**
|
|
5572
|
+
* @license
|
|
5573
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5574
|
+
*
|
|
5575
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
5576
|
+
* found in the LICENSE file at https://angular.io/license
|
|
5577
|
+
*/
|
|
5578
|
+
/**
|
|
5579
|
+
* The Trusted Types policy, or null if Trusted Types are not
|
|
5580
|
+
* enabled/supported, or undefined if the policy has not been created yet.
|
|
5581
|
+
*/
|
|
5582
|
+
let policy$1;
|
|
5583
|
+
/**
|
|
5584
|
+
* Returns the Trusted Types policy, or null if Trusted Types are not
|
|
5585
|
+
* enabled/supported. The first call to this function will create the policy.
|
|
5586
|
+
*/
|
|
5587
|
+
function getPolicy$1() {
|
|
5588
|
+
if (policy$1 === undefined) {
|
|
5589
|
+
policy$1 = null;
|
|
5590
|
+
if (_global$1.trustedTypes) {
|
|
5591
|
+
try {
|
|
5592
|
+
policy$1 = _global$1.trustedTypes.createPolicy('angular', {
|
|
5593
|
+
createHTML: (s) => s,
|
|
5594
|
+
createScript: (s) => s,
|
|
5595
|
+
createScriptURL: (s) => s,
|
|
5596
|
+
});
|
|
5597
|
+
}
|
|
5598
|
+
catch (_a) {
|
|
5599
|
+
// trustedTypes.createPolicy throws if called with a name that is
|
|
5600
|
+
// already registered, even in report-only mode. Until the API changes,
|
|
5601
|
+
// catch the error not to break the applications functionally. In such
|
|
5602
|
+
// cases, the code will fall back to using strings.
|
|
5603
|
+
}
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
return policy$1;
|
|
5607
|
+
}
|
|
5608
|
+
/**
|
|
5609
|
+
* Unsafely promote a string to a TrustedHTML, falling back to strings when
|
|
5610
|
+
* Trusted Types are not available.
|
|
5611
|
+
* @security This is a security-sensitive function; any use of this function
|
|
5612
|
+
* must go through security review. In particular, it must be assured that the
|
|
5613
|
+
* provided string will never cause an XSS vulnerability if used in a context
|
|
5614
|
+
* that will be interpreted as HTML by a browser, e.g. when assigning to
|
|
5615
|
+
* element.innerHTML.
|
|
5661
5616
|
*/
|
|
5662
5617
|
function trustedHTMLFromString(html) {
|
|
5663
5618
|
var _a;
|
|
@@ -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$8 + unusedValueExportToPlacateAjd$
|
|
7339
|
+
const unusedValueToPlacateAjd$2 = unusedValueExportToPlacateAjd$8 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3 + unusedValueExportToPlacateAjd$7;
|
|
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)
|
|
@@ -10129,7 +10028,7 @@ class ReflectiveKey {
|
|
|
10129
10028
|
this.token = token;
|
|
10130
10029
|
this.id = id;
|
|
10131
10030
|
if (!token) {
|
|
10132
|
-
throw new
|
|
10031
|
+
throw new RuntimeError(208 /* RuntimeErrorCode.MISSING_INJECTION_TOKEN */, ngDevMode && 'Token must be defined!');
|
|
10133
10032
|
}
|
|
10134
10033
|
this.displayName = stringify(this.token);
|
|
10135
10034
|
}
|
|
@@ -11820,6 +11719,13 @@ class LContainerDebug {
|
|
|
11820
11719
|
}
|
|
11821
11720
|
}
|
|
11822
11721
|
|
|
11722
|
+
/**
|
|
11723
|
+
* @license
|
|
11724
|
+
* Copyright Google LLC All Rights Reserved.
|
|
11725
|
+
*
|
|
11726
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
11727
|
+
* found in the LICENSE file at https://angular.io/license
|
|
11728
|
+
*/
|
|
11823
11729
|
/**
|
|
11824
11730
|
* A permanent marker promise which signifies that the current CD tree is
|
|
11825
11731
|
* clean.
|
|
@@ -11887,7 +11793,7 @@ function refreshChildComponents(hostLView, components) {
|
|
|
11887
11793
|
/** Renders child components in the current view (creation mode). */
|
|
11888
11794
|
function renderChildComponents(hostLView, components) {
|
|
11889
11795
|
for (let i = 0; i < components.length; i++) {
|
|
11890
|
-
renderComponent
|
|
11796
|
+
renderComponent(hostLView, components[i]);
|
|
11891
11797
|
}
|
|
11892
11798
|
}
|
|
11893
11799
|
function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
|
|
@@ -12405,16 +12311,6 @@ function createViewBlueprint(bindingStartIndex, initialViewLength) {
|
|
|
12405
12311
|
function createError(text, token) {
|
|
12406
12312
|
return new Error(`Renderer: ${text} [${stringifyForError(token)}]`);
|
|
12407
12313
|
}
|
|
12408
|
-
function assertHostNodeExists(rElement, elementOrSelector) {
|
|
12409
|
-
if (!rElement) {
|
|
12410
|
-
if (typeof elementOrSelector === 'string') {
|
|
12411
|
-
throw createError('Host node with selector not found:', elementOrSelector);
|
|
12412
|
-
}
|
|
12413
|
-
else {
|
|
12414
|
-
throw createError('Host node is required:', elementOrSelector);
|
|
12415
|
-
}
|
|
12416
|
-
}
|
|
12417
|
-
}
|
|
12418
12314
|
/**
|
|
12419
12315
|
* Locates the host native element, used for bootstrapping existing nodes into rendering pipeline.
|
|
12420
12316
|
*
|
|
@@ -12423,21 +12319,9 @@ function assertHostNodeExists(rElement, elementOrSelector) {
|
|
|
12423
12319
|
* @param encapsulation View Encapsulation defined for component that requests host element.
|
|
12424
12320
|
*/
|
|
12425
12321
|
function locateHostElement(renderer, elementOrSelector, encapsulation) {
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
return renderer.selectRootElement(elementOrSelector, preserveContent);
|
|
12430
|
-
}
|
|
12431
|
-
let rElement = typeof elementOrSelector === 'string' ?
|
|
12432
|
-
renderer.querySelector(elementOrSelector) :
|
|
12433
|
-
elementOrSelector;
|
|
12434
|
-
ngDevMode && assertHostNodeExists(rElement, elementOrSelector);
|
|
12435
|
-
// Always clear host element's content when Renderer3 is in use. For procedural renderer case we
|
|
12436
|
-
// make it depend on whether ShadowDom encapsulation is used (in which case the content should be
|
|
12437
|
-
// preserved to allow native slot projection). ShadowDom encapsulation requires procedural
|
|
12438
|
-
// renderer, and procedural renderer case is handled above.
|
|
12439
|
-
rElement.textContent = '';
|
|
12440
|
-
return rElement;
|
|
12322
|
+
// When using native Shadow DOM, do not clear host element to allow native slot projection
|
|
12323
|
+
const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
|
|
12324
|
+
return renderer.selectRootElement(elementOrSelector, preserveContent);
|
|
12441
12325
|
}
|
|
12442
12326
|
/**
|
|
12443
12327
|
* Saves context for this cleanup function in LView.cleanupInstances.
|
|
@@ -12652,13 +12536,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
|
|
|
12652
12536
|
// It is assumed that the sanitizer is only added when the compiler determines that the
|
|
12653
12537
|
// property is risky, so sanitization can be done without further checks.
|
|
12654
12538
|
value = sanitizer != null ? sanitizer(value, tNode.value || '', propName) : value;
|
|
12655
|
-
|
|
12656
|
-
renderer.setProperty(element, propName, value);
|
|
12657
|
-
}
|
|
12658
|
-
else if (!isAnimationProp(propName)) {
|
|
12659
|
-
element.setProperty ? element.setProperty(propName, value) :
|
|
12660
|
-
element[propName] = value;
|
|
12661
|
-
}
|
|
12539
|
+
renderer.setProperty(element, propName, value);
|
|
12662
12540
|
}
|
|
12663
12541
|
else if (tNode.type & 12 /* TNodeType.AnyContainer */) {
|
|
12664
12542
|
// If the node is a container and the property didn't
|
|
@@ -12682,23 +12560,15 @@ function setNgReflectProperty(lView, element, type, attrName, value) {
|
|
|
12682
12560
|
const debugValue = normalizeDebugBindingValue(value);
|
|
12683
12561
|
if (type & 3 /* TNodeType.AnyRNode */) {
|
|
12684
12562
|
if (value == null) {
|
|
12685
|
-
|
|
12686
|
-
element.removeAttribute(attrName);
|
|
12563
|
+
renderer.removeAttribute(element, attrName);
|
|
12687
12564
|
}
|
|
12688
12565
|
else {
|
|
12689
|
-
|
|
12690
|
-
renderer.setAttribute(element, attrName, debugValue) :
|
|
12691
|
-
element.setAttribute(attrName, debugValue);
|
|
12566
|
+
renderer.setAttribute(element, attrName, debugValue);
|
|
12692
12567
|
}
|
|
12693
12568
|
}
|
|
12694
12569
|
else {
|
|
12695
12570
|
const textContent = escapeCommentText(`bindings=${JSON.stringify({ [attrName]: debugValue }, null, 2)}`);
|
|
12696
|
-
|
|
12697
|
-
renderer.setValue(element, textContent);
|
|
12698
|
-
}
|
|
12699
|
-
else {
|
|
12700
|
-
element.textContent = textContent;
|
|
12701
|
-
}
|
|
12571
|
+
renderer.setValue(element, textContent);
|
|
12702
12572
|
}
|
|
12703
12573
|
}
|
|
12704
12574
|
function setNgReflectProperties(lView, element, type, dataValue, value) {
|
|
@@ -13052,19 +12922,12 @@ function elementAttributeInternal(tNode, lView, name, value, sanitizer, namespac
|
|
|
13052
12922
|
function setElementAttribute(renderer, element, namespace, tagName, name, value, sanitizer) {
|
|
13053
12923
|
if (value == null) {
|
|
13054
12924
|
ngDevMode && ngDevMode.rendererRemoveAttribute++;
|
|
13055
|
-
|
|
13056
|
-
element.removeAttribute(name);
|
|
12925
|
+
renderer.removeAttribute(element, name, namespace);
|
|
13057
12926
|
}
|
|
13058
12927
|
else {
|
|
13059
12928
|
ngDevMode && ngDevMode.rendererSetAttribute++;
|
|
13060
12929
|
const strValue = sanitizer == null ? renderStringify(value) : sanitizer(value, tagName || '', name);
|
|
13061
|
-
|
|
13062
|
-
renderer.setAttribute(element, name, strValue, namespace);
|
|
13063
|
-
}
|
|
13064
|
-
else {
|
|
13065
|
-
namespace ? element.setAttributeNS(namespace, name, strValue) :
|
|
13066
|
-
element.setAttribute(name, strValue);
|
|
13067
|
-
}
|
|
12930
|
+
renderer.setAttribute(element, name, strValue, namespace);
|
|
13068
12931
|
}
|
|
13069
12932
|
}
|
|
13070
12933
|
/**
|
|
@@ -13156,7 +13019,6 @@ const LContainerArray = class LContainer extends Array {
|
|
|
13156
13019
|
*/
|
|
13157
13020
|
function createLContainer(hostNative, currentView, native, tNode) {
|
|
13158
13021
|
ngDevMode && assertLView(currentView);
|
|
13159
|
-
ngDevMode && !isProceduralRenderer(currentView[RENDERER]) && assertDomNode(native);
|
|
13160
13022
|
// https://jsperf.com/array-literal-vs-new-array-really
|
|
13161
13023
|
const lContainer = new (ngDevMode ? LContainerArray : Array)(hostNative, // host native
|
|
13162
13024
|
true, // Boolean `true` in this position signifies that this is an `LContainer`
|
|
@@ -13272,7 +13134,7 @@ function refreshContainsDirtyView(lView) {
|
|
|
13272
13134
|
}
|
|
13273
13135
|
}
|
|
13274
13136
|
}
|
|
13275
|
-
function renderComponent
|
|
13137
|
+
function renderComponent(hostLView, componentHostIdx) {
|
|
13276
13138
|
ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
|
|
13277
13139
|
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
|
|
13278
13140
|
const componentTView = componentView[TVIEW];
|
|
@@ -13624,720 +13486,116 @@ function computeStaticStyling(tNode, attrs, writeToHost) {
|
|
|
13624
13486
|
* Use of this source code is governed by an MIT-style license that can be
|
|
13625
13487
|
* found in the LICENSE file at https://angular.io/license
|
|
13626
13488
|
*/
|
|
13489
|
+
// TODO: A hack to not pull in the NullInjector from @angular/core.
|
|
13490
|
+
const NULL_INJECTOR = {
|
|
13491
|
+
get: (token, notFoundValue) => {
|
|
13492
|
+
throwProviderNotFoundError(token, 'NullInjector');
|
|
13493
|
+
}
|
|
13494
|
+
};
|
|
13627
13495
|
/**
|
|
13628
|
-
*
|
|
13496
|
+
* Creates the root component view and the root component node.
|
|
13629
13497
|
*
|
|
13630
|
-
*
|
|
13498
|
+
* @param rNode Render host element.
|
|
13499
|
+
* @param def ComponentDef
|
|
13500
|
+
* @param rootView The parent view where the host node is stored
|
|
13501
|
+
* @param rendererFactory Factory to be used for creating child renderers.
|
|
13502
|
+
* @param hostRenderer The current renderer
|
|
13503
|
+
* @param sanitizer The sanitizer, if provided
|
|
13631
13504
|
*
|
|
13632
|
-
* @
|
|
13505
|
+
* @returns Component view created
|
|
13633
13506
|
*/
|
|
13634
|
-
function
|
|
13635
|
-
const
|
|
13636
|
-
|
|
13507
|
+
function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
|
|
13508
|
+
const tView = rootView[TVIEW];
|
|
13509
|
+
const index = HEADER_OFFSET;
|
|
13510
|
+
ngDevMode && assertIndexInRange(rootView, index);
|
|
13511
|
+
rootView[index] = rNode;
|
|
13512
|
+
// '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
|
|
13513
|
+
// the same time we want to communicate the debug `TNode` that this is a special `TNode`
|
|
13514
|
+
// representing a host element.
|
|
13515
|
+
const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
|
|
13516
|
+
const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
|
|
13517
|
+
if (mergedAttrs !== null) {
|
|
13518
|
+
computeStaticStyling(tNode, mergedAttrs, true);
|
|
13519
|
+
if (rNode !== null) {
|
|
13520
|
+
setUpAttributes(hostRenderer, rNode, mergedAttrs);
|
|
13521
|
+
if (tNode.classes !== null) {
|
|
13522
|
+
writeDirectClass(hostRenderer, rNode, tNode.classes);
|
|
13523
|
+
}
|
|
13524
|
+
if (tNode.styles !== null) {
|
|
13525
|
+
writeDirectStyle(hostRenderer, rNode, tNode.styles);
|
|
13526
|
+
}
|
|
13527
|
+
}
|
|
13528
|
+
}
|
|
13529
|
+
const viewRenderer = rendererFactory.createRenderer(rNode, def);
|
|
13530
|
+
const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
|
|
13531
|
+
if (tView.firstCreatePass) {
|
|
13532
|
+
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
|
13533
|
+
markAsComponentHost(tView, tNode);
|
|
13534
|
+
initTNodeFlags(tNode, rootView.length, 1);
|
|
13535
|
+
}
|
|
13536
|
+
addToViewTree(rootView, componentView);
|
|
13537
|
+
// Store component view at node index, with node as the HOST
|
|
13538
|
+
return rootView[index] = componentView;
|
|
13637
13539
|
}
|
|
13638
13540
|
/**
|
|
13639
|
-
*
|
|
13640
|
-
*
|
|
13641
|
-
*
|
|
13642
|
-
* Marking an already dirty component as dirty won't do anything. Only one outstanding change
|
|
13643
|
-
* detection can be scheduled per component tree.
|
|
13644
|
-
*
|
|
13645
|
-
* @param component Component to mark as dirty.
|
|
13541
|
+
* Creates a root component and sets it up with features and host bindings. Shared by
|
|
13542
|
+
* renderComponent() and ViewContainerRef.createComponent().
|
|
13646
13543
|
*/
|
|
13647
|
-
function
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13544
|
+
function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
|
|
13545
|
+
const tView = rootLView[TVIEW];
|
|
13546
|
+
// Create directive instance with factory() and store at next index in viewData
|
|
13547
|
+
const component = instantiateRootComponent(tView, rootLView, componentDef);
|
|
13548
|
+
rootContext.components.push(component);
|
|
13549
|
+
componentView[CONTEXT] = component;
|
|
13550
|
+
if (hostFeatures !== null) {
|
|
13551
|
+
for (const feature of hostFeatures) {
|
|
13552
|
+
feature(component, componentDef);
|
|
13553
|
+
}
|
|
13554
|
+
}
|
|
13555
|
+
// We want to generate an empty QueryList for root content queries for backwards
|
|
13556
|
+
// compatibility with ViewEngine.
|
|
13557
|
+
if (componentDef.contentQueries) {
|
|
13558
|
+
const tNode = getCurrentTNode();
|
|
13559
|
+
ngDevMode && assertDefined(tNode, 'TNode expected');
|
|
13560
|
+
componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
|
|
13561
|
+
}
|
|
13562
|
+
const rootTNode = getCurrentTNode();
|
|
13563
|
+
ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
|
|
13564
|
+
if (tView.firstCreatePass &&
|
|
13565
|
+
(componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
|
|
13566
|
+
setSelectedIndex(rootTNode.index);
|
|
13567
|
+
const rootTView = rootLView[TVIEW];
|
|
13568
|
+
registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
|
|
13569
|
+
invokeHostBindingsInCreationMode(componentDef, component);
|
|
13570
|
+
}
|
|
13571
|
+
return component;
|
|
13572
|
+
}
|
|
13573
|
+
function createRootContext(scheduler, playerHandler) {
|
|
13574
|
+
return {
|
|
13575
|
+
components: [],
|
|
13576
|
+
scheduler: scheduler || defaultScheduler,
|
|
13577
|
+
clean: CLEAN_PROMISE,
|
|
13578
|
+
playerHandler: playerHandler || null,
|
|
13579
|
+
flags: 0 /* RootContextFlags.Empty */
|
|
13580
|
+
};
|
|
13652
13581
|
}
|
|
13653
13582
|
/**
|
|
13654
|
-
* Used to
|
|
13583
|
+
* Used to enable lifecycle hooks on the root component.
|
|
13655
13584
|
*
|
|
13656
|
-
*
|
|
13657
|
-
*
|
|
13658
|
-
*
|
|
13585
|
+
* Include this feature when calling `renderComponent` if the root component
|
|
13586
|
+
* you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
|
|
13587
|
+
* be called properly.
|
|
13659
13588
|
*
|
|
13660
|
-
*
|
|
13661
|
-
*
|
|
13662
|
-
*
|
|
13663
|
-
*
|
|
13589
|
+
* Example:
|
|
13590
|
+
*
|
|
13591
|
+
* ```
|
|
13592
|
+
* renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
|
|
13593
|
+
* ```
|
|
13664
13594
|
*/
|
|
13665
|
-
function
|
|
13666
|
-
const
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
}
|
|
13670
|
-
|
|
13671
|
-
/**
|
|
13672
|
-
* @license
|
|
13673
|
-
* Copyright Google LLC All Rights Reserved.
|
|
13674
|
-
*
|
|
13675
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
13676
|
-
* found in the LICENSE file at https://angular.io/license
|
|
13677
|
-
*/
|
|
13678
|
-
/**
|
|
13679
|
-
* Retrieves the component instance associated with a given DOM element.
|
|
13680
|
-
*
|
|
13681
|
-
* @usageNotes
|
|
13682
|
-
* Given the following DOM structure:
|
|
13683
|
-
*
|
|
13684
|
-
* ```html
|
|
13685
|
-
* <app-root>
|
|
13686
|
-
* <div>
|
|
13687
|
-
* <child-comp></child-comp>
|
|
13688
|
-
* </div>
|
|
13689
|
-
* </app-root>
|
|
13690
|
-
* ```
|
|
13691
|
-
*
|
|
13692
|
-
* Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
|
|
13693
|
-
* associated with this DOM element.
|
|
13694
|
-
*
|
|
13695
|
-
* Calling the function on `<app-root>` will return the `MyApp` instance.
|
|
13696
|
-
*
|
|
13697
|
-
*
|
|
13698
|
-
* @param element DOM element from which the component should be retrieved.
|
|
13699
|
-
* @returns Component instance associated with the element or `null` if there
|
|
13700
|
-
* is no component associated with it.
|
|
13701
|
-
*
|
|
13702
|
-
* @publicApi
|
|
13703
|
-
* @globalApi ng
|
|
13704
|
-
*/
|
|
13705
|
-
function getComponent$1(element) {
|
|
13706
|
-
ngDevMode && assertDomElement(element);
|
|
13707
|
-
const context = getLContext(element);
|
|
13708
|
-
if (context === null)
|
|
13709
|
-
return null;
|
|
13710
|
-
if (context.component === undefined) {
|
|
13711
|
-
const lView = context.lView;
|
|
13712
|
-
if (lView === null) {
|
|
13713
|
-
return null;
|
|
13714
|
-
}
|
|
13715
|
-
context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
|
|
13716
|
-
}
|
|
13717
|
-
return context.component;
|
|
13718
|
-
}
|
|
13719
|
-
/**
|
|
13720
|
-
* If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
|
|
13721
|
-
* view that the element is part of. Otherwise retrieves the instance of the component whose view
|
|
13722
|
-
* owns the element (in this case, the result is the same as calling `getOwningComponent`).
|
|
13723
|
-
*
|
|
13724
|
-
* @param element Element for which to get the surrounding component instance.
|
|
13725
|
-
* @returns Instance of the component that is around the element or null if the element isn't
|
|
13726
|
-
* inside any component.
|
|
13727
|
-
*
|
|
13728
|
-
* @publicApi
|
|
13729
|
-
* @globalApi ng
|
|
13730
|
-
*/
|
|
13731
|
-
function getContext(element) {
|
|
13732
|
-
assertDomElement(element);
|
|
13733
|
-
const context = getLContext(element);
|
|
13734
|
-
const lView = context ? context.lView : null;
|
|
13735
|
-
return lView === null ? null : lView[CONTEXT];
|
|
13736
|
-
}
|
|
13737
|
-
/**
|
|
13738
|
-
* Retrieves the component instance whose view contains the DOM element.
|
|
13739
|
-
*
|
|
13740
|
-
* For example, if `<child-comp>` is used in the template of `<app-comp>`
|
|
13741
|
-
* (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
|
|
13742
|
-
* would return `<app-comp>`.
|
|
13743
|
-
*
|
|
13744
|
-
* @param elementOrDir DOM element, component or directive instance
|
|
13745
|
-
* for which to retrieve the root components.
|
|
13746
|
-
* @returns Component instance whose view owns the DOM element or null if the element is not
|
|
13747
|
-
* part of a component view.
|
|
13748
|
-
*
|
|
13749
|
-
* @publicApi
|
|
13750
|
-
* @globalApi ng
|
|
13751
|
-
*/
|
|
13752
|
-
function getOwningComponent(elementOrDir) {
|
|
13753
|
-
const context = getLContext(elementOrDir);
|
|
13754
|
-
let lView = context ? context.lView : null;
|
|
13755
|
-
if (lView === null)
|
|
13756
|
-
return null;
|
|
13757
|
-
let parent;
|
|
13758
|
-
while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
|
|
13759
|
-
lView = parent;
|
|
13760
|
-
}
|
|
13761
|
-
return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
|
|
13762
|
-
}
|
|
13763
|
-
/**
|
|
13764
|
-
* Retrieves all root components associated with a DOM element, directive or component instance.
|
|
13765
|
-
* Root components are those which have been bootstrapped by Angular.
|
|
13766
|
-
*
|
|
13767
|
-
* @param elementOrDir DOM element, component or directive instance
|
|
13768
|
-
* for which to retrieve the root components.
|
|
13769
|
-
* @returns Root components associated with the target object.
|
|
13770
|
-
*
|
|
13771
|
-
* @publicApi
|
|
13772
|
-
* @globalApi ng
|
|
13773
|
-
*/
|
|
13774
|
-
function getRootComponents(elementOrDir) {
|
|
13775
|
-
const lView = readPatchedLView(elementOrDir);
|
|
13776
|
-
return lView !== null ? [...getRootContext(lView).components] : [];
|
|
13777
|
-
}
|
|
13778
|
-
/**
|
|
13779
|
-
* Retrieves an `Injector` associated with an element, component or directive instance.
|
|
13780
|
-
*
|
|
13781
|
-
* @param elementOrDir DOM element, component or directive instance for which to
|
|
13782
|
-
* retrieve the injector.
|
|
13783
|
-
* @returns Injector associated with the element, component or directive instance.
|
|
13784
|
-
*
|
|
13785
|
-
* @publicApi
|
|
13786
|
-
* @globalApi ng
|
|
13787
|
-
*/
|
|
13788
|
-
function getInjector(elementOrDir) {
|
|
13789
|
-
const context = getLContext(elementOrDir);
|
|
13790
|
-
const lView = context ? context.lView : null;
|
|
13791
|
-
if (lView === null)
|
|
13792
|
-
return Injector.NULL;
|
|
13793
|
-
const tNode = lView[TVIEW].data[context.nodeIndex];
|
|
13794
|
-
return new NodeInjector(tNode, lView);
|
|
13795
|
-
}
|
|
13796
|
-
/**
|
|
13797
|
-
* Retrieve a set of injection tokens at a given DOM node.
|
|
13798
|
-
*
|
|
13799
|
-
* @param element Element for which the injection tokens should be retrieved.
|
|
13800
|
-
*/
|
|
13801
|
-
function getInjectionTokens(element) {
|
|
13802
|
-
const context = getLContext(element);
|
|
13803
|
-
const lView = context ? context.lView : null;
|
|
13804
|
-
if (lView === null)
|
|
13805
|
-
return [];
|
|
13806
|
-
const tView = lView[TVIEW];
|
|
13807
|
-
const tNode = tView.data[context.nodeIndex];
|
|
13808
|
-
const providerTokens = [];
|
|
13809
|
-
const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
|
|
13810
|
-
const endIndex = tNode.directiveEnd;
|
|
13811
|
-
for (let i = startIndex; i < endIndex; i++) {
|
|
13812
|
-
let value = tView.data[i];
|
|
13813
|
-
if (isDirectiveDefHack(value)) {
|
|
13814
|
-
// The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
|
|
13815
|
-
// design flaw. We should always store same type so that we can be monomorphic. The issue
|
|
13816
|
-
// is that for Components/Directives we store the def instead the type. The correct behavior
|
|
13817
|
-
// is that we should always be storing injectable type in this location.
|
|
13818
|
-
value = value.type;
|
|
13819
|
-
}
|
|
13820
|
-
providerTokens.push(value);
|
|
13821
|
-
}
|
|
13822
|
-
return providerTokens;
|
|
13823
|
-
}
|
|
13824
|
-
/**
|
|
13825
|
-
* Retrieves directive instances associated with a given DOM node. Does not include
|
|
13826
|
-
* component instances.
|
|
13827
|
-
*
|
|
13828
|
-
* @usageNotes
|
|
13829
|
-
* Given the following DOM structure:
|
|
13830
|
-
*
|
|
13831
|
-
* ```html
|
|
13832
|
-
* <app-root>
|
|
13833
|
-
* <button my-button></button>
|
|
13834
|
-
* <my-comp></my-comp>
|
|
13835
|
-
* </app-root>
|
|
13836
|
-
* ```
|
|
13837
|
-
*
|
|
13838
|
-
* Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
|
|
13839
|
-
* directive that is associated with the DOM node.
|
|
13840
|
-
*
|
|
13841
|
-
* Calling `getDirectives` on `<my-comp>` will return an empty array.
|
|
13842
|
-
*
|
|
13843
|
-
* @param node DOM node for which to get the directives.
|
|
13844
|
-
* @returns Array of directives associated with the node.
|
|
13845
|
-
*
|
|
13846
|
-
* @publicApi
|
|
13847
|
-
* @globalApi ng
|
|
13848
|
-
*/
|
|
13849
|
-
function getDirectives(node) {
|
|
13850
|
-
// Skip text nodes because we can't have directives associated with them.
|
|
13851
|
-
if (node instanceof Text) {
|
|
13852
|
-
return [];
|
|
13853
|
-
}
|
|
13854
|
-
const context = getLContext(node);
|
|
13855
|
-
const lView = context ? context.lView : null;
|
|
13856
|
-
if (lView === null) {
|
|
13857
|
-
return [];
|
|
13858
|
-
}
|
|
13859
|
-
const tView = lView[TVIEW];
|
|
13860
|
-
const nodeIndex = context.nodeIndex;
|
|
13861
|
-
if (!(tView === null || tView === void 0 ? void 0 : tView.data[nodeIndex])) {
|
|
13862
|
-
return [];
|
|
13863
|
-
}
|
|
13864
|
-
if (context.directives === undefined) {
|
|
13865
|
-
context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
|
|
13866
|
-
}
|
|
13867
|
-
// The `directives` in this case are a named array called `LComponentView`. Clone the
|
|
13868
|
-
// result so we don't expose an internal data structure in the user's console.
|
|
13869
|
-
return context.directives === null ? [] : [...context.directives];
|
|
13870
|
-
}
|
|
13871
|
-
/**
|
|
13872
|
-
* Returns the debug (partial) metadata for a particular directive or component instance.
|
|
13873
|
-
* The function accepts an instance of a directive or component and returns the corresponding
|
|
13874
|
-
* metadata.
|
|
13875
|
-
*
|
|
13876
|
-
* @param directiveOrComponentInstance Instance of a directive or component
|
|
13877
|
-
* @returns metadata of the passed directive or component
|
|
13878
|
-
*
|
|
13879
|
-
* @publicApi
|
|
13880
|
-
* @globalApi ng
|
|
13881
|
-
*/
|
|
13882
|
-
function getDirectiveMetadata(directiveOrComponentInstance) {
|
|
13883
|
-
const { constructor } = directiveOrComponentInstance;
|
|
13884
|
-
if (!constructor) {
|
|
13885
|
-
throw new Error('Unable to find the instance constructor');
|
|
13886
|
-
}
|
|
13887
|
-
// In case a component inherits from a directive, we may have component and directive metadata
|
|
13888
|
-
// To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
|
|
13889
|
-
const componentDef = getComponentDef$1(constructor);
|
|
13890
|
-
if (componentDef) {
|
|
13891
|
-
return {
|
|
13892
|
-
inputs: componentDef.inputs,
|
|
13893
|
-
outputs: componentDef.outputs,
|
|
13894
|
-
encapsulation: componentDef.encapsulation,
|
|
13895
|
-
changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
|
|
13896
|
-
ChangeDetectionStrategy.Default
|
|
13897
|
-
};
|
|
13898
|
-
}
|
|
13899
|
-
const directiveDef = getDirectiveDef(constructor);
|
|
13900
|
-
if (directiveDef) {
|
|
13901
|
-
return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
|
|
13902
|
-
}
|
|
13903
|
-
return null;
|
|
13904
|
-
}
|
|
13905
|
-
/**
|
|
13906
|
-
* Retrieve map of local references.
|
|
13907
|
-
*
|
|
13908
|
-
* The references are retrieved as a map of local reference name to element or directive instance.
|
|
13909
|
-
*
|
|
13910
|
-
* @param target DOM element, component or directive instance for which to retrieve
|
|
13911
|
-
* the local references.
|
|
13912
|
-
*/
|
|
13913
|
-
function getLocalRefs(target) {
|
|
13914
|
-
const context = getLContext(target);
|
|
13915
|
-
if (context === null)
|
|
13916
|
-
return {};
|
|
13917
|
-
if (context.localRefs === undefined) {
|
|
13918
|
-
const lView = context.lView;
|
|
13919
|
-
if (lView === null) {
|
|
13920
|
-
return {};
|
|
13921
|
-
}
|
|
13922
|
-
context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
|
|
13923
|
-
}
|
|
13924
|
-
return context.localRefs || {};
|
|
13925
|
-
}
|
|
13926
|
-
/**
|
|
13927
|
-
* Retrieves the host element of a component or directive instance.
|
|
13928
|
-
* The host element is the DOM element that matched the selector of the directive.
|
|
13929
|
-
*
|
|
13930
|
-
* @param componentOrDirective Component or directive instance for which the host
|
|
13931
|
-
* element should be retrieved.
|
|
13932
|
-
* @returns Host element of the target.
|
|
13933
|
-
*
|
|
13934
|
-
* @publicApi
|
|
13935
|
-
* @globalApi ng
|
|
13936
|
-
*/
|
|
13937
|
-
function getHostElement(componentOrDirective) {
|
|
13938
|
-
return getLContext(componentOrDirective).native;
|
|
13939
|
-
}
|
|
13940
|
-
/**
|
|
13941
|
-
* Retrieves the rendered text for a given component.
|
|
13942
|
-
*
|
|
13943
|
-
* This function retrieves the host element of a component and
|
|
13944
|
-
* and then returns the `textContent` for that element. This implies
|
|
13945
|
-
* that the text returned will include re-projected content of
|
|
13946
|
-
* the component as well.
|
|
13947
|
-
*
|
|
13948
|
-
* @param component The component to return the content text for.
|
|
13949
|
-
*/
|
|
13950
|
-
function getRenderedText(component) {
|
|
13951
|
-
const hostElement = getHostElement(component);
|
|
13952
|
-
return hostElement.textContent || '';
|
|
13953
|
-
}
|
|
13954
|
-
/**
|
|
13955
|
-
* Retrieves a list of event listeners associated with a DOM element. The list does include host
|
|
13956
|
-
* listeners, but it does not include event listeners defined outside of the Angular context
|
|
13957
|
-
* (e.g. through `addEventListener`).
|
|
13958
|
-
*
|
|
13959
|
-
* @usageNotes
|
|
13960
|
-
* Given the following DOM structure:
|
|
13961
|
-
*
|
|
13962
|
-
* ```html
|
|
13963
|
-
* <app-root>
|
|
13964
|
-
* <div (click)="doSomething()"></div>
|
|
13965
|
-
* </app-root>
|
|
13966
|
-
* ```
|
|
13967
|
-
*
|
|
13968
|
-
* Calling `getListeners` on `<div>` will return an object that looks as follows:
|
|
13969
|
-
*
|
|
13970
|
-
* ```ts
|
|
13971
|
-
* {
|
|
13972
|
-
* name: 'click',
|
|
13973
|
-
* element: <div>,
|
|
13974
|
-
* callback: () => doSomething(),
|
|
13975
|
-
* useCapture: false
|
|
13976
|
-
* }
|
|
13977
|
-
* ```
|
|
13978
|
-
*
|
|
13979
|
-
* @param element Element for which the DOM listeners should be retrieved.
|
|
13980
|
-
* @returns Array of event listeners on the DOM element.
|
|
13981
|
-
*
|
|
13982
|
-
* @publicApi
|
|
13983
|
-
* @globalApi ng
|
|
13984
|
-
*/
|
|
13985
|
-
function getListeners(element) {
|
|
13986
|
-
ngDevMode && assertDomElement(element);
|
|
13987
|
-
const lContext = getLContext(element);
|
|
13988
|
-
const lView = lContext === null ? null : lContext.lView;
|
|
13989
|
-
if (lView === null)
|
|
13990
|
-
return [];
|
|
13991
|
-
const tView = lView[TVIEW];
|
|
13992
|
-
const lCleanup = lView[CLEANUP];
|
|
13993
|
-
const tCleanup = tView.cleanup;
|
|
13994
|
-
const listeners = [];
|
|
13995
|
-
if (tCleanup && lCleanup) {
|
|
13996
|
-
for (let i = 0; i < tCleanup.length;) {
|
|
13997
|
-
const firstParam = tCleanup[i++];
|
|
13998
|
-
const secondParam = tCleanup[i++];
|
|
13999
|
-
if (typeof firstParam === 'string') {
|
|
14000
|
-
const name = firstParam;
|
|
14001
|
-
const listenerElement = unwrapRNode(lView[secondParam]);
|
|
14002
|
-
const callback = lCleanup[tCleanup[i++]];
|
|
14003
|
-
const useCaptureOrIndx = tCleanup[i++];
|
|
14004
|
-
// if useCaptureOrIndx is boolean then report it as is.
|
|
14005
|
-
// if useCaptureOrIndx is positive number then it in unsubscribe method
|
|
14006
|
-
// if useCaptureOrIndx is negative number then it is a Subscription
|
|
14007
|
-
const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
|
|
14008
|
-
const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
|
|
14009
|
-
if (element == listenerElement) {
|
|
14010
|
-
listeners.push({ element, name, callback, useCapture, type });
|
|
14011
|
-
}
|
|
14012
|
-
}
|
|
14013
|
-
}
|
|
14014
|
-
}
|
|
14015
|
-
listeners.sort(sortListeners);
|
|
14016
|
-
return listeners;
|
|
14017
|
-
}
|
|
14018
|
-
function sortListeners(a, b) {
|
|
14019
|
-
if (a.name == b.name)
|
|
14020
|
-
return 0;
|
|
14021
|
-
return a.name < b.name ? -1 : 1;
|
|
14022
|
-
}
|
|
14023
|
-
/**
|
|
14024
|
-
* This function should not exist because it is megamorphic and only mostly correct.
|
|
14025
|
-
*
|
|
14026
|
-
* See call site for more info.
|
|
14027
|
-
*/
|
|
14028
|
-
function isDirectiveDefHack(obj) {
|
|
14029
|
-
return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
|
|
14030
|
-
}
|
|
14031
|
-
/**
|
|
14032
|
-
* Returns the attached `DebugNode` instance for an element in the DOM.
|
|
14033
|
-
*
|
|
14034
|
-
* @param element DOM element which is owned by an existing component's view.
|
|
14035
|
-
*/
|
|
14036
|
-
function getDebugNode(element) {
|
|
14037
|
-
if (ngDevMode && !(element instanceof Node)) {
|
|
14038
|
-
throw new Error('Expecting instance of DOM Element');
|
|
14039
|
-
}
|
|
14040
|
-
const lContext = getLContext(element);
|
|
14041
|
-
const lView = lContext ? lContext.lView : null;
|
|
14042
|
-
if (lView === null) {
|
|
14043
|
-
return null;
|
|
14044
|
-
}
|
|
14045
|
-
const nodeIndex = lContext.nodeIndex;
|
|
14046
|
-
if (nodeIndex !== -1) {
|
|
14047
|
-
const valueInLView = lView[nodeIndex];
|
|
14048
|
-
// this means that value in the lView is a component with its own
|
|
14049
|
-
// data. In this situation the TNode is not accessed at the same spot.
|
|
14050
|
-
const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
|
|
14051
|
-
ngDevMode &&
|
|
14052
|
-
assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
|
|
14053
|
-
return buildDebugNode(tNode, lView);
|
|
14054
|
-
}
|
|
14055
|
-
return null;
|
|
14056
|
-
}
|
|
14057
|
-
/**
|
|
14058
|
-
* Retrieve the component `LView` from component/element.
|
|
14059
|
-
*
|
|
14060
|
-
* NOTE: `LView` is a private and should not be leaked outside.
|
|
14061
|
-
* Don't export this method to `ng.*` on window.
|
|
14062
|
-
*
|
|
14063
|
-
* @param target DOM element or component instance for which to retrieve the LView.
|
|
14064
|
-
*/
|
|
14065
|
-
function getComponentLView(target) {
|
|
14066
|
-
const lContext = getLContext(target);
|
|
14067
|
-
const nodeIndx = lContext.nodeIndex;
|
|
14068
|
-
const lView = lContext.lView;
|
|
14069
|
-
ngDevMode && assertLView(lView);
|
|
14070
|
-
const componentLView = lView[nodeIndx];
|
|
14071
|
-
ngDevMode && assertLView(componentLView);
|
|
14072
|
-
return componentLView;
|
|
14073
|
-
}
|
|
14074
|
-
/** Asserts that a value is a DOM Element. */
|
|
14075
|
-
function assertDomElement(value) {
|
|
14076
|
-
if (typeof Element !== 'undefined' && !(value instanceof Element)) {
|
|
14077
|
-
throw new Error('Expecting instance of DOM Element');
|
|
14078
|
-
}
|
|
14079
|
-
}
|
|
14080
|
-
|
|
14081
|
-
/**
|
|
14082
|
-
* @license
|
|
14083
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14084
|
-
*
|
|
14085
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
14086
|
-
* found in the LICENSE file at https://angular.io/license
|
|
14087
|
-
*/
|
|
14088
|
-
/**
|
|
14089
|
-
* Marks a component for check (in case of OnPush components) and synchronously
|
|
14090
|
-
* performs change detection on the application this component belongs to.
|
|
14091
|
-
*
|
|
14092
|
-
* @param component Component to {@link ChangeDetectorRef#markForCheck mark for check}.
|
|
14093
|
-
*
|
|
14094
|
-
* @publicApi
|
|
14095
|
-
* @globalApi ng
|
|
14096
|
-
*/
|
|
14097
|
-
function applyChanges(component) {
|
|
14098
|
-
markDirty(component);
|
|
14099
|
-
getRootComponents(component).forEach(rootComponent => detectChanges(rootComponent));
|
|
14100
|
-
}
|
|
14101
|
-
|
|
14102
|
-
/**
|
|
14103
|
-
* @license
|
|
14104
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14105
|
-
*
|
|
14106
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
14107
|
-
* found in the LICENSE file at https://angular.io/license
|
|
14108
|
-
*/
|
|
14109
|
-
/**
|
|
14110
|
-
* This file introduces series of globally accessible debug tools
|
|
14111
|
-
* to allow for the Angular debugging story to function.
|
|
14112
|
-
*
|
|
14113
|
-
* To see this in action run the following command:
|
|
14114
|
-
*
|
|
14115
|
-
* bazel run //packages/core/test/bundling/todo:devserver
|
|
14116
|
-
*
|
|
14117
|
-
* Then load `localhost:5432` and start using the console tools.
|
|
14118
|
-
*/
|
|
14119
|
-
/**
|
|
14120
|
-
* This value reflects the property on the window where the dev
|
|
14121
|
-
* tools are patched (window.ng).
|
|
14122
|
-
* */
|
|
14123
|
-
const GLOBAL_PUBLISH_EXPANDO_KEY = 'ng';
|
|
14124
|
-
let _published = false;
|
|
14125
|
-
/**
|
|
14126
|
-
* Publishes a collection of default debug tools onto`window.ng`.
|
|
14127
|
-
*
|
|
14128
|
-
* These functions are available globally when Angular is in development
|
|
14129
|
-
* mode and are automatically stripped away from prod mode is on.
|
|
14130
|
-
*/
|
|
14131
|
-
function publishDefaultGlobalUtils() {
|
|
14132
|
-
if (!_published) {
|
|
14133
|
-
_published = true;
|
|
14134
|
-
/**
|
|
14135
|
-
* Warning: this function is *INTERNAL* and should not be relied upon in application's code.
|
|
14136
|
-
* The contract of the function might be changed in any release and/or the function can be
|
|
14137
|
-
* removed completely.
|
|
14138
|
-
*/
|
|
14139
|
-
publishGlobalUtil('ɵsetProfiler', setProfiler);
|
|
14140
|
-
publishGlobalUtil('getDirectiveMetadata', getDirectiveMetadata);
|
|
14141
|
-
publishGlobalUtil('getComponent', getComponent$1);
|
|
14142
|
-
publishGlobalUtil('getContext', getContext);
|
|
14143
|
-
publishGlobalUtil('getListeners', getListeners);
|
|
14144
|
-
publishGlobalUtil('getOwningComponent', getOwningComponent);
|
|
14145
|
-
publishGlobalUtil('getHostElement', getHostElement);
|
|
14146
|
-
publishGlobalUtil('getInjector', getInjector);
|
|
14147
|
-
publishGlobalUtil('getRootComponents', getRootComponents);
|
|
14148
|
-
publishGlobalUtil('getDirectives', getDirectives);
|
|
14149
|
-
publishGlobalUtil('applyChanges', applyChanges);
|
|
14150
|
-
}
|
|
14151
|
-
}
|
|
14152
|
-
/**
|
|
14153
|
-
* Publishes the given function to `window.ng` so that it can be
|
|
14154
|
-
* used from the browser console when an application is not in production.
|
|
14155
|
-
*/
|
|
14156
|
-
function publishGlobalUtil(name, fn) {
|
|
14157
|
-
if (typeof COMPILED === 'undefined' || !COMPILED) {
|
|
14158
|
-
// Note: we can't export `ng` when using closure enhanced optimization as:
|
|
14159
|
-
// - closure declares globals itself for minified names, which sometimes clobber our `ng` global
|
|
14160
|
-
// - we can't declare a closure extern as the namespace `ng` is already used within Google
|
|
14161
|
-
// for typings for AngularJS (via `goog.provide('ng....')`).
|
|
14162
|
-
const w = _global$1;
|
|
14163
|
-
ngDevMode && assertDefined(fn, 'function not defined');
|
|
14164
|
-
if (w) {
|
|
14165
|
-
let container = w[GLOBAL_PUBLISH_EXPANDO_KEY];
|
|
14166
|
-
if (!container) {
|
|
14167
|
-
container = w[GLOBAL_PUBLISH_EXPANDO_KEY] = {};
|
|
14168
|
-
}
|
|
14169
|
-
container[name] = fn;
|
|
14170
|
-
}
|
|
14171
|
-
}
|
|
14172
|
-
}
|
|
14173
|
-
|
|
14174
|
-
/**
|
|
14175
|
-
* @license
|
|
14176
|
-
* Copyright Google LLC All Rights Reserved.
|
|
14177
|
-
*
|
|
14178
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
14179
|
-
* found in the LICENSE file at https://angular.io/license
|
|
14180
|
-
*/
|
|
14181
|
-
// TODO: A hack to not pull in the NullInjector from @angular/core.
|
|
14182
|
-
const NULL_INJECTOR = {
|
|
14183
|
-
get: (token, notFoundValue) => {
|
|
14184
|
-
throwProviderNotFoundError(token, 'NullInjector');
|
|
14185
|
-
}
|
|
14186
|
-
};
|
|
14187
|
-
/**
|
|
14188
|
-
* Bootstraps a Component into an existing host element and returns an instance
|
|
14189
|
-
* of the component.
|
|
14190
|
-
*
|
|
14191
|
-
* Use this function to bootstrap a component into the DOM tree. Each invocation
|
|
14192
|
-
* of this function will create a separate tree of components, injectors and
|
|
14193
|
-
* change detection cycles and lifetimes. To dynamically insert a new component
|
|
14194
|
-
* into an existing tree such that it shares the same injection, change detection
|
|
14195
|
-
* and object lifetime, use {@link ViewContainer#createComponent}.
|
|
14196
|
-
*
|
|
14197
|
-
* @param componentType Component to bootstrap
|
|
14198
|
-
* @param options Optional parameters which control bootstrapping
|
|
14199
|
-
*/
|
|
14200
|
-
function renderComponent(componentType /* Type as workaround for: Microsoft/TypeScript/issues/4881 */, opts = {}) {
|
|
14201
|
-
ngDevMode && publishDefaultGlobalUtils();
|
|
14202
|
-
ngDevMode && assertComponentType(componentType);
|
|
14203
|
-
const rendererFactory = opts.rendererFactory || domRendererFactory3;
|
|
14204
|
-
const sanitizer = opts.sanitizer || null;
|
|
14205
|
-
const componentDef = getComponentDef$1(componentType);
|
|
14206
|
-
if (componentDef.type != componentType)
|
|
14207
|
-
componentDef.type = componentType;
|
|
14208
|
-
// The first index of the first selector is the tag name.
|
|
14209
|
-
const componentTag = componentDef.selectors[0][0];
|
|
14210
|
-
const hostRenderer = rendererFactory.createRenderer(null, null);
|
|
14211
|
-
const hostRNode = locateHostElement(hostRenderer, opts.host || componentTag, componentDef.encapsulation);
|
|
14212
|
-
const rootFlags = componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
|
|
14213
|
-
16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
|
|
14214
|
-
const rootContext = createRootContext(opts.scheduler, opts.playerHandler);
|
|
14215
|
-
const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
|
|
14216
|
-
const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
|
|
14217
|
-
const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null, null);
|
|
14218
|
-
enterView(rootView);
|
|
14219
|
-
let component;
|
|
14220
|
-
try {
|
|
14221
|
-
if (rendererFactory.begin)
|
|
14222
|
-
rendererFactory.begin();
|
|
14223
|
-
const componentView = createRootComponentView(hostRNode, componentDef, rootView, rendererFactory, renderer, sanitizer);
|
|
14224
|
-
component = createRootComponent(componentView, componentDef, rootView, rootContext, opts.hostFeatures || null);
|
|
14225
|
-
// create mode pass
|
|
14226
|
-
renderView(rootTView, rootView, null);
|
|
14227
|
-
// update mode pass
|
|
14228
|
-
refreshView(rootTView, rootView, null, null);
|
|
14229
|
-
}
|
|
14230
|
-
finally {
|
|
14231
|
-
leaveView();
|
|
14232
|
-
if (rendererFactory.end)
|
|
14233
|
-
rendererFactory.end();
|
|
14234
|
-
}
|
|
14235
|
-
return component;
|
|
14236
|
-
}
|
|
14237
|
-
/**
|
|
14238
|
-
* Creates the root component view and the root component node.
|
|
14239
|
-
*
|
|
14240
|
-
* @param rNode Render host element.
|
|
14241
|
-
* @param def ComponentDef
|
|
14242
|
-
* @param rootView The parent view where the host node is stored
|
|
14243
|
-
* @param rendererFactory Factory to be used for creating child renderers.
|
|
14244
|
-
* @param hostRenderer The current renderer
|
|
14245
|
-
* @param sanitizer The sanitizer, if provided
|
|
14246
|
-
*
|
|
14247
|
-
* @returns Component view created
|
|
14248
|
-
*/
|
|
14249
|
-
function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
|
|
14250
|
-
const tView = rootView[TVIEW];
|
|
14251
|
-
const index = HEADER_OFFSET;
|
|
14252
|
-
ngDevMode && assertIndexInRange(rootView, index);
|
|
14253
|
-
rootView[index] = rNode;
|
|
14254
|
-
// '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
|
|
14255
|
-
// the same time we want to communicate the debug `TNode` that this is a special `TNode`
|
|
14256
|
-
// representing a host element.
|
|
14257
|
-
const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
|
|
14258
|
-
const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
|
|
14259
|
-
if (mergedAttrs !== null) {
|
|
14260
|
-
computeStaticStyling(tNode, mergedAttrs, true);
|
|
14261
|
-
if (rNode !== null) {
|
|
14262
|
-
setUpAttributes(hostRenderer, rNode, mergedAttrs);
|
|
14263
|
-
if (tNode.classes !== null) {
|
|
14264
|
-
writeDirectClass(hostRenderer, rNode, tNode.classes);
|
|
14265
|
-
}
|
|
14266
|
-
if (tNode.styles !== null) {
|
|
14267
|
-
writeDirectStyle(hostRenderer, rNode, tNode.styles);
|
|
14268
|
-
}
|
|
14269
|
-
}
|
|
14270
|
-
}
|
|
14271
|
-
const viewRenderer = rendererFactory.createRenderer(rNode, def);
|
|
14272
|
-
const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
|
|
14273
|
-
if (tView.firstCreatePass) {
|
|
14274
|
-
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
|
|
14275
|
-
markAsComponentHost(tView, tNode);
|
|
14276
|
-
initTNodeFlags(tNode, rootView.length, 1);
|
|
14277
|
-
}
|
|
14278
|
-
addToViewTree(rootView, componentView);
|
|
14279
|
-
// Store component view at node index, with node as the HOST
|
|
14280
|
-
return rootView[index] = componentView;
|
|
14281
|
-
}
|
|
14282
|
-
/**
|
|
14283
|
-
* Creates a root component and sets it up with features and host bindings. Shared by
|
|
14284
|
-
* renderComponent() and ViewContainerRef.createComponent().
|
|
14285
|
-
*/
|
|
14286
|
-
function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
|
|
14287
|
-
const tView = rootLView[TVIEW];
|
|
14288
|
-
// Create directive instance with factory() and store at next index in viewData
|
|
14289
|
-
const component = instantiateRootComponent(tView, rootLView, componentDef);
|
|
14290
|
-
rootContext.components.push(component);
|
|
14291
|
-
componentView[CONTEXT] = component;
|
|
14292
|
-
if (hostFeatures !== null) {
|
|
14293
|
-
for (const feature of hostFeatures) {
|
|
14294
|
-
feature(component, componentDef);
|
|
14295
|
-
}
|
|
14296
|
-
}
|
|
14297
|
-
// We want to generate an empty QueryList for root content queries for backwards
|
|
14298
|
-
// compatibility with ViewEngine.
|
|
14299
|
-
if (componentDef.contentQueries) {
|
|
14300
|
-
const tNode = getCurrentTNode();
|
|
14301
|
-
ngDevMode && assertDefined(tNode, 'TNode expected');
|
|
14302
|
-
componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
|
|
14303
|
-
}
|
|
14304
|
-
const rootTNode = getCurrentTNode();
|
|
14305
|
-
ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
|
|
14306
|
-
if (tView.firstCreatePass &&
|
|
14307
|
-
(componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
|
|
14308
|
-
setSelectedIndex(rootTNode.index);
|
|
14309
|
-
const rootTView = rootLView[TVIEW];
|
|
14310
|
-
registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
|
|
14311
|
-
invokeHostBindingsInCreationMode(componentDef, component);
|
|
14312
|
-
}
|
|
14313
|
-
return component;
|
|
14314
|
-
}
|
|
14315
|
-
function createRootContext(scheduler, playerHandler) {
|
|
14316
|
-
return {
|
|
14317
|
-
components: [],
|
|
14318
|
-
scheduler: scheduler || defaultScheduler,
|
|
14319
|
-
clean: CLEAN_PROMISE,
|
|
14320
|
-
playerHandler: playerHandler || null,
|
|
14321
|
-
flags: 0 /* RootContextFlags.Empty */
|
|
14322
|
-
};
|
|
14323
|
-
}
|
|
14324
|
-
/**
|
|
14325
|
-
* Used to enable lifecycle hooks on the root component.
|
|
14326
|
-
*
|
|
14327
|
-
* Include this feature when calling `renderComponent` if the root component
|
|
14328
|
-
* you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
|
|
14329
|
-
* be called properly.
|
|
14330
|
-
*
|
|
14331
|
-
* Example:
|
|
14332
|
-
*
|
|
14333
|
-
* ```
|
|
14334
|
-
* renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
|
|
14335
|
-
* ```
|
|
14336
|
-
*/
|
|
14337
|
-
function LifecycleHooksFeature() {
|
|
14338
|
-
const tNode = getCurrentTNode();
|
|
14339
|
-
ngDevMode && assertDefined(tNode, 'TNode is required');
|
|
14340
|
-
registerPostOrderHooks(getLView()[TVIEW], tNode);
|
|
13595
|
+
function LifecycleHooksFeature() {
|
|
13596
|
+
const tNode = getCurrentTNode();
|
|
13597
|
+
ngDevMode && assertDefined(tNode, 'TNode is required');
|
|
13598
|
+
registerPostOrderHooks(getLView()[TVIEW], tNode);
|
|
14341
13599
|
}
|
|
14342
13600
|
/**
|
|
14343
13601
|
* Wait on component until it is rendered.
|
|
@@ -14387,10 +13645,8 @@ function ɵɵInheritDefinitionFeature(definition) {
|
|
|
14387
13645
|
}
|
|
14388
13646
|
else {
|
|
14389
13647
|
if (superType.ɵcmp) {
|
|
14390
|
-
|
|
14391
|
-
`Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`
|
|
14392
|
-
'';
|
|
14393
|
-
throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, errorMessage);
|
|
13648
|
+
throw new RuntimeError(903 /* RuntimeErrorCode.INVALID_INHERITANCE */, ngDevMode &&
|
|
13649
|
+
`Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}`);
|
|
14394
13650
|
}
|
|
14395
13651
|
// Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
|
|
14396
13652
|
superDef = superType.ɵdir;
|
|
@@ -15326,6 +14582,57 @@ function ɵɵattributeInterpolateV(attrName, values, sanitizer, namespace) {
|
|
|
15326
14582
|
return ɵɵattributeInterpolateV;
|
|
15327
14583
|
}
|
|
15328
14584
|
|
|
14585
|
+
/**
|
|
14586
|
+
* @license
|
|
14587
|
+
* Copyright Google LLC All Rights Reserved.
|
|
14588
|
+
*
|
|
14589
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
14590
|
+
* found in the LICENSE file at https://angular.io/license
|
|
14591
|
+
*/
|
|
14592
|
+
/**
|
|
14593
|
+
* Synchronously perform change detection on a component (and possibly its sub-components).
|
|
14594
|
+
*
|
|
14595
|
+
* This function triggers change detection in a synchronous way on a component.
|
|
14596
|
+
*
|
|
14597
|
+
* @param component The component which the change detection should be performed on.
|
|
14598
|
+
*/
|
|
14599
|
+
function detectChanges(component) {
|
|
14600
|
+
const view = getComponentViewByInstance(component);
|
|
14601
|
+
detectChangesInternal(view[TVIEW], view, component);
|
|
14602
|
+
}
|
|
14603
|
+
/**
|
|
14604
|
+
* Marks the component as dirty (needing change detection). Marking a component dirty will
|
|
14605
|
+
* schedule a change detection on it at some point in the future.
|
|
14606
|
+
*
|
|
14607
|
+
* Marking an already dirty component as dirty won't do anything. Only one outstanding change
|
|
14608
|
+
* detection can be scheduled per component tree.
|
|
14609
|
+
*
|
|
14610
|
+
* @param component Component to mark as dirty.
|
|
14611
|
+
*/
|
|
14612
|
+
function markDirty(component) {
|
|
14613
|
+
ngDevMode && assertDefined(component, 'component');
|
|
14614
|
+
const rootView = markViewDirty(getComponentViewByInstance(component));
|
|
14615
|
+
ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
|
|
14616
|
+
scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
|
|
14617
|
+
}
|
|
14618
|
+
/**
|
|
14619
|
+
* Used to perform change detection on the whole application.
|
|
14620
|
+
*
|
|
14621
|
+
* This is equivalent to `detectChanges`, but invoked on root component. Additionally, `tick`
|
|
14622
|
+
* executes lifecycle hooks and conditionally checks components based on their
|
|
14623
|
+
* `ChangeDetectionStrategy` and dirtiness.
|
|
14624
|
+
*
|
|
14625
|
+
* The preferred way to trigger change detection is to call `markDirty`. `markDirty` internally
|
|
14626
|
+
* schedules `tick` using a scheduler in order to coalesce multiple `markDirty` calls into a
|
|
14627
|
+
* single change detection run. By default, the scheduler is `requestAnimationFrame`, but can
|
|
14628
|
+
* be changed when calling `renderComponent` and providing the `scheduler` option.
|
|
14629
|
+
*/
|
|
14630
|
+
function tick(component) {
|
|
14631
|
+
const rootView = getRootView(component);
|
|
14632
|
+
const rootContext = rootView[CONTEXT];
|
|
14633
|
+
tickRootContext(rootContext);
|
|
14634
|
+
}
|
|
14635
|
+
|
|
15329
14636
|
/**
|
|
15330
14637
|
* @license
|
|
15331
14638
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -15870,51 +15177,42 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
|
|
|
15870
15177
|
tNode.index;
|
|
15871
15178
|
// In order to match current behavior, native DOM event listeners must be added for all
|
|
15872
15179
|
// events (including outputs).
|
|
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
|
-
|
|
15901
|
-
|
|
15902
|
-
processOutputs = false;
|
|
15903
|
-
}
|
|
15904
|
-
else {
|
|
15905
|
-
listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
|
|
15906
|
-
const cleanupFn = renderer.listen(target, eventName, listenerFn);
|
|
15907
|
-
ngDevMode && ngDevMode.rendererAddEventListener++;
|
|
15908
|
-
lCleanup.push(listenerFn, cleanupFn);
|
|
15909
|
-
tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
|
|
15910
|
-
}
|
|
15180
|
+
// There might be cases where multiple directives on the same element try to register an event
|
|
15181
|
+
// handler function for the same event. In this situation we want to avoid registration of
|
|
15182
|
+
// several native listeners as each registration would be intercepted by NgZone and
|
|
15183
|
+
// trigger change detection. This would mean that a single user action would result in several
|
|
15184
|
+
// change detections being invoked. To avoid this situation we want to have only one call to
|
|
15185
|
+
// native handler registration (for the same element and same type of event).
|
|
15186
|
+
//
|
|
15187
|
+
// In order to have just one native event handler in presence of multiple handler functions,
|
|
15188
|
+
// we just register a first handler function as a native event listener and then chain
|
|
15189
|
+
// (coalesce) other handler functions on top of the first native handler function.
|
|
15190
|
+
let existingListener = null;
|
|
15191
|
+
// Please note that the coalescing described here doesn't happen for events specifying an
|
|
15192
|
+
// alternative target (ex. (document:click)) - this is to keep backward compatibility with the
|
|
15193
|
+
// view engine.
|
|
15194
|
+
// Also, we don't have to search for existing listeners is there are no directives
|
|
15195
|
+
// matching on a given node as we can't register multiple event handlers for the same event in
|
|
15196
|
+
// a template (this would mean having duplicate attributes).
|
|
15197
|
+
if (!eventTargetResolver && isTNodeDirectiveHost) {
|
|
15198
|
+
existingListener = findExistingListener(tView, lView, eventName, tNode.index);
|
|
15199
|
+
}
|
|
15200
|
+
if (existingListener !== null) {
|
|
15201
|
+
// Attach a new listener to coalesced listeners list, maintaining the order in which
|
|
15202
|
+
// listeners are registered. For performance reasons, we keep a reference to the last
|
|
15203
|
+
// listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
|
|
15204
|
+
// the entire set each time we need to add a new listener.
|
|
15205
|
+
const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
|
|
15206
|
+
lastListenerFn.__ngNextListenerFn__ = listenerFn;
|
|
15207
|
+
existingListener.__ngLastListenerFn__ = listenerFn;
|
|
15208
|
+
processOutputs = false;
|
|
15911
15209
|
}
|
|
15912
15210
|
else {
|
|
15913
|
-
listenerFn = wrapListener(tNode, lView, context, listenerFn,
|
|
15914
|
-
|
|
15211
|
+
listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
|
|
15212
|
+
const cleanupFn = renderer.listen(target, eventName, listenerFn);
|
|
15915
15213
|
ngDevMode && ngDevMode.rendererAddEventListener++;
|
|
15916
|
-
lCleanup.push(listenerFn);
|
|
15917
|
-
tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex,
|
|
15214
|
+
lCleanup.push(listenerFn, cleanupFn);
|
|
15215
|
+
tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
|
|
15918
15216
|
}
|
|
15919
15217
|
}
|
|
15920
15218
|
else {
|
|
@@ -17988,7 +17286,7 @@ function findStylingValue(tData, tNode, lView, prop, index, isClassBased) {
|
|
|
17988
17286
|
valueAtLViewIndex = isStylingMap ? EMPTY_ARRAY : undefined;
|
|
17989
17287
|
}
|
|
17990
17288
|
let currentValue = isStylingMap ? keyValueArrayGet(valueAtLViewIndex, prop) :
|
|
17991
|
-
key === prop ? valueAtLViewIndex : undefined;
|
|
17289
|
+
(key === prop ? valueAtLViewIndex : undefined);
|
|
17992
17290
|
if (containsStatics && !isStylingValuePresent(currentValue)) {
|
|
17993
17291
|
currentValue = keyValueArrayGet(rawKey, prop);
|
|
17994
17292
|
}
|
|
@@ -19511,7 +18809,7 @@ function findLocaleData(locale) {
|
|
|
19511
18809
|
if (parentLocale === 'en') {
|
|
19512
18810
|
return localeEn;
|
|
19513
18811
|
}
|
|
19514
|
-
throw new
|
|
18812
|
+
throw new RuntimeError(701 /* RuntimeErrorCode.MISSING_LOCALE_DATA */, ngDevMode && `Missing locale data for the locale "${locale}".`);
|
|
19515
18813
|
}
|
|
19516
18814
|
/**
|
|
19517
18815
|
* Retrieves the default currency code for the given locale.
|
|
@@ -21841,7 +21139,7 @@ function noComponentFactoryError(component) {
|
|
|
21841
21139
|
return error;
|
|
21842
21140
|
}
|
|
21843
21141
|
const ERROR_COMPONENT = 'ngComponent';
|
|
21844
|
-
function getComponent(error) {
|
|
21142
|
+
function getComponent$1(error) {
|
|
21845
21143
|
return error[ERROR_COMPONENT];
|
|
21846
21144
|
}
|
|
21847
21145
|
class _NullComponentFactoryResolver {
|
|
@@ -22025,14 +21323,6 @@ class Renderer2 {
|
|
|
22025
21323
|
* @nocollapse
|
|
22026
21324
|
*/
|
|
22027
21325
|
Renderer2.__NG_ELEMENT_ID__ = () => injectRenderer2();
|
|
22028
|
-
/** Returns a Renderer2 (or throws when application was bootstrapped with Renderer3) */
|
|
22029
|
-
function getOrCreateRenderer2(lView) {
|
|
22030
|
-
const renderer = lView[RENDERER];
|
|
22031
|
-
if (ngDevMode && !isProceduralRenderer(renderer)) {
|
|
22032
|
-
throw new Error('Cannot inject Renderer2 when the application uses Renderer3!');
|
|
22033
|
-
}
|
|
22034
|
-
return renderer;
|
|
22035
|
-
}
|
|
22036
21326
|
/** Injects a Renderer2 for the current component. */
|
|
22037
21327
|
function injectRenderer2() {
|
|
22038
21328
|
// We need the Renderer to be based on the component that it's being injected into, however since
|
|
@@ -22040,7 +21330,7 @@ function injectRenderer2() {
|
|
|
22040
21330
|
const lView = getLView();
|
|
22041
21331
|
const tNode = getCurrentTNode();
|
|
22042
21332
|
const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
|
|
22043
|
-
return
|
|
21333
|
+
return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
|
|
22044
21334
|
}
|
|
22045
21335
|
|
|
22046
21336
|
/**
|
|
@@ -22087,7 +21377,7 @@ class Version {
|
|
|
22087
21377
|
/**
|
|
22088
21378
|
* @publicApi
|
|
22089
21379
|
*/
|
|
22090
|
-
const VERSION = new Version('14.0.
|
|
21380
|
+
const VERSION = new Version('14.0.5');
|
|
22091
21381
|
|
|
22092
21382
|
/**
|
|
22093
21383
|
* @license
|
|
@@ -22425,8 +21715,7 @@ class ViewRef {
|
|
|
22425
21715
|
}
|
|
22426
21716
|
attachToViewContainerRef() {
|
|
22427
21717
|
if (this._appRef) {
|
|
22428
|
-
|
|
22429
|
-
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, errorMessage);
|
|
21718
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached directly to the ApplicationRef!');
|
|
22430
21719
|
}
|
|
22431
21720
|
this._attachedToViewContainer = true;
|
|
22432
21721
|
}
|
|
@@ -22436,8 +21725,7 @@ class ViewRef {
|
|
|
22436
21725
|
}
|
|
22437
21726
|
attachToAppRef(appRef) {
|
|
22438
21727
|
if (this._attachedToViewContainer) {
|
|
22439
|
-
|
|
22440
|
-
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, errorMessage);
|
|
21728
|
+
throw new RuntimeError(902 /* RuntimeErrorCode.VIEW_ALREADY_ATTACHED */, ngDevMode && 'This view is already attached to a ViewContainer!');
|
|
22441
21729
|
}
|
|
22442
21730
|
this._appRef = appRef;
|
|
22443
21731
|
}
|
|
@@ -22553,7 +21841,13 @@ class ComponentFactory extends ComponentFactory$1 {
|
|
|
22553
21841
|
realEnvironmentInjector;
|
|
22554
21842
|
}
|
|
22555
21843
|
const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
|
|
22556
|
-
const rendererFactory = rootViewInjector.get(RendererFactory2,
|
|
21844
|
+
const rendererFactory = rootViewInjector.get(RendererFactory2, null);
|
|
21845
|
+
if (rendererFactory === null) {
|
|
21846
|
+
throw new RuntimeError(407 /* RuntimeErrorCode.RENDERER_NOT_FOUND */, ngDevMode &&
|
|
21847
|
+
'Angular was not able to inject a renderer (RendererFactory2). ' +
|
|
21848
|
+
'Likely this is due to a broken DI hierarchy. ' +
|
|
21849
|
+
'Make sure that any injector used to create this component has a correct parent.');
|
|
21850
|
+
}
|
|
22557
21851
|
const sanitizer = rootViewInjector.get(Sanitizer, null);
|
|
22558
21852
|
const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
|
|
22559
21853
|
// Determine a tag name used for creating host elements when this component is created
|
|
@@ -22617,218 +21911,628 @@ class ComponentFactory extends ComponentFactory$1 {
|
|
|
22617
21911
|
finally {
|
|
22618
21912
|
leaveView();
|
|
22619
21913
|
}
|
|
22620
|
-
return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
|
|
21914
|
+
return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
|
|
21915
|
+
}
|
|
21916
|
+
}
|
|
21917
|
+
const componentFactoryResolver = new ComponentFactoryResolver();
|
|
21918
|
+
/**
|
|
21919
|
+
* Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
|
|
21920
|
+
* ComponentFactoryResolver
|
|
21921
|
+
* already exists, retrieves the existing ComponentFactoryResolver.
|
|
21922
|
+
*
|
|
21923
|
+
* @returns The ComponentFactoryResolver instance to use
|
|
21924
|
+
*/
|
|
21925
|
+
function injectComponentFactoryResolver() {
|
|
21926
|
+
return componentFactoryResolver;
|
|
21927
|
+
}
|
|
21928
|
+
/**
|
|
21929
|
+
* Represents an instance of a Component created via a {@link ComponentFactory}.
|
|
21930
|
+
*
|
|
21931
|
+
* `ComponentRef` provides access to the Component Instance as well other objects related to this
|
|
21932
|
+
* Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
|
|
21933
|
+
* method.
|
|
21934
|
+
*
|
|
21935
|
+
*/
|
|
21936
|
+
class ComponentRef extends ComponentRef$1 {
|
|
21937
|
+
constructor(componentType, instance, location, _rootLView, _tNode) {
|
|
21938
|
+
super();
|
|
21939
|
+
this.location = location;
|
|
21940
|
+
this._rootLView = _rootLView;
|
|
21941
|
+
this._tNode = _tNode;
|
|
21942
|
+
this.instance = instance;
|
|
21943
|
+
this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
|
|
21944
|
+
this.componentType = componentType;
|
|
21945
|
+
}
|
|
21946
|
+
get injector() {
|
|
21947
|
+
return new NodeInjector(this._tNode, this._rootLView);
|
|
21948
|
+
}
|
|
21949
|
+
destroy() {
|
|
21950
|
+
this.hostView.destroy();
|
|
21951
|
+
}
|
|
21952
|
+
onDestroy(callback) {
|
|
21953
|
+
this.hostView.onDestroy(callback);
|
|
21954
|
+
}
|
|
21955
|
+
}
|
|
21956
|
+
|
|
21957
|
+
/**
|
|
21958
|
+
* @license
|
|
21959
|
+
* Copyright Google LLC All Rights Reserved.
|
|
21960
|
+
*
|
|
21961
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
21962
|
+
* found in the LICENSE file at https://angular.io/license
|
|
21963
|
+
*/
|
|
21964
|
+
/**
|
|
21965
|
+
* Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
|
|
21966
|
+
* @param ngModule NgModule class.
|
|
21967
|
+
* @param parentInjector Optional injector instance to use as a parent for the module injector. If
|
|
21968
|
+
* not provided, `NullInjector` will be used instead.
|
|
21969
|
+
* @publicApi
|
|
21970
|
+
*/
|
|
21971
|
+
function createNgModuleRef(ngModule, parentInjector) {
|
|
21972
|
+
return new NgModuleRef(ngModule, parentInjector !== null && parentInjector !== void 0 ? parentInjector : null);
|
|
21973
|
+
}
|
|
21974
|
+
class NgModuleRef extends NgModuleRef$1 {
|
|
21975
|
+
constructor(ngModuleType, _parent) {
|
|
21976
|
+
super();
|
|
21977
|
+
this._parent = _parent;
|
|
21978
|
+
// tslint:disable-next-line:require-internal-with-underscore
|
|
21979
|
+
this._bootstrapComponents = [];
|
|
21980
|
+
this.injector = this;
|
|
21981
|
+
this.destroyCbs = [];
|
|
21982
|
+
// When bootstrapping a module we have a dependency graph that looks like this:
|
|
21983
|
+
// ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
|
|
21984
|
+
// module being resolved tries to inject the ComponentFactoryResolver, it'll create a
|
|
21985
|
+
// circular dependency which will result in a runtime error, because the injector doesn't
|
|
21986
|
+
// exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
|
|
21987
|
+
// and providing it, rather than letting the injector resolve it.
|
|
21988
|
+
this.componentFactoryResolver = new ComponentFactoryResolver(this);
|
|
21989
|
+
const ngModuleDef = getNgModuleDef(ngModuleType);
|
|
21990
|
+
ngDevMode &&
|
|
21991
|
+
assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
|
|
21992
|
+
this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
|
|
21993
|
+
this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
|
|
21994
|
+
{ provide: NgModuleRef$1, useValue: this }, {
|
|
21995
|
+
provide: ComponentFactoryResolver$1,
|
|
21996
|
+
useValue: this.componentFactoryResolver
|
|
21997
|
+
}
|
|
21998
|
+
], stringify(ngModuleType), new Set(['environment']));
|
|
21999
|
+
// We need to resolve the injector types separately from the injector creation, because
|
|
22000
|
+
// the module might be trying to use this ref in its constructor for DI which will cause a
|
|
22001
|
+
// circular error that will eventually error out, because the injector isn't created yet.
|
|
22002
|
+
this._r3Injector.resolveInjectorInitializers();
|
|
22003
|
+
this.instance = this.get(ngModuleType);
|
|
22004
|
+
}
|
|
22005
|
+
get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
|
|
22006
|
+
if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
|
|
22007
|
+
return this;
|
|
22008
|
+
}
|
|
22009
|
+
return this._r3Injector.get(token, notFoundValue, injectFlags);
|
|
22010
|
+
}
|
|
22011
|
+
destroy() {
|
|
22012
|
+
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
|
|
22013
|
+
const injector = this._r3Injector;
|
|
22014
|
+
!injector.destroyed && injector.destroy();
|
|
22015
|
+
this.destroyCbs.forEach(fn => fn());
|
|
22016
|
+
this.destroyCbs = null;
|
|
22017
|
+
}
|
|
22018
|
+
onDestroy(callback) {
|
|
22019
|
+
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
|
|
22020
|
+
this.destroyCbs.push(callback);
|
|
22021
|
+
}
|
|
22022
|
+
}
|
|
22023
|
+
class NgModuleFactory extends NgModuleFactory$1 {
|
|
22024
|
+
constructor(moduleType) {
|
|
22025
|
+
super();
|
|
22026
|
+
this.moduleType = moduleType;
|
|
22027
|
+
}
|
|
22028
|
+
create(parentInjector) {
|
|
22029
|
+
return new NgModuleRef(this.moduleType, parentInjector);
|
|
22030
|
+
}
|
|
22031
|
+
}
|
|
22032
|
+
class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
|
|
22033
|
+
constructor(providers, parent, source) {
|
|
22034
|
+
super();
|
|
22035
|
+
this.componentFactoryResolver = new ComponentFactoryResolver(this);
|
|
22036
|
+
this.instance = null;
|
|
22037
|
+
const injector = new R3Injector([
|
|
22038
|
+
...providers,
|
|
22039
|
+
{ provide: NgModuleRef$1, useValue: this },
|
|
22040
|
+
{ provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
|
|
22041
|
+
], parent || getNullInjector(), source, new Set(['environment']));
|
|
22042
|
+
this.injector = injector;
|
|
22043
|
+
injector.resolveInjectorInitializers();
|
|
22044
|
+
}
|
|
22045
|
+
destroy() {
|
|
22046
|
+
this.injector.destroy();
|
|
22047
|
+
}
|
|
22048
|
+
onDestroy(callback) {
|
|
22049
|
+
this.injector.onDestroy(callback);
|
|
22050
|
+
}
|
|
22051
|
+
}
|
|
22052
|
+
/**
|
|
22053
|
+
* Create a new environment injector.
|
|
22054
|
+
*
|
|
22055
|
+
* @publicApi
|
|
22056
|
+
* @developerPreview
|
|
22057
|
+
*/
|
|
22058
|
+
function createEnvironmentInjector(providers, parent = null, debugName = null) {
|
|
22059
|
+
const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
|
|
22060
|
+
return adapter.injector;
|
|
22061
|
+
}
|
|
22062
|
+
|
|
22063
|
+
/**
|
|
22064
|
+
* @license
|
|
22065
|
+
* Copyright Google LLC All Rights Reserved.
|
|
22066
|
+
*
|
|
22067
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
22068
|
+
* found in the LICENSE file at https://angular.io/license
|
|
22069
|
+
*/
|
|
22070
|
+
/**
|
|
22071
|
+
* A service used by the framework to create instances of standalone injectors. Those injectors are
|
|
22072
|
+
* created on demand in case of dynamic component instantiation and contain ambient providers
|
|
22073
|
+
* collected from the imports graph rooted at a given standalone component.
|
|
22074
|
+
*/
|
|
22075
|
+
class StandaloneService {
|
|
22076
|
+
constructor(_injector) {
|
|
22077
|
+
this._injector = _injector;
|
|
22078
|
+
this.cachedInjectors = new Map();
|
|
22079
|
+
}
|
|
22080
|
+
getOrCreateStandaloneInjector(componentDef) {
|
|
22081
|
+
if (!componentDef.standalone) {
|
|
22082
|
+
return null;
|
|
22083
|
+
}
|
|
22084
|
+
if (!this.cachedInjectors.has(componentDef.id)) {
|
|
22085
|
+
const providers = internalImportProvidersFrom(false, componentDef.type);
|
|
22086
|
+
const standaloneInjector = providers.length > 0 ?
|
|
22087
|
+
createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
|
|
22088
|
+
null;
|
|
22089
|
+
this.cachedInjectors.set(componentDef.id, standaloneInjector);
|
|
22090
|
+
}
|
|
22091
|
+
return this.cachedInjectors.get(componentDef.id);
|
|
22092
|
+
}
|
|
22093
|
+
ngOnDestroy() {
|
|
22094
|
+
try {
|
|
22095
|
+
for (const injector of this.cachedInjectors.values()) {
|
|
22096
|
+
if (injector !== null) {
|
|
22097
|
+
injector.destroy();
|
|
22098
|
+
}
|
|
22099
|
+
}
|
|
22100
|
+
}
|
|
22101
|
+
finally {
|
|
22102
|
+
this.cachedInjectors.clear();
|
|
22103
|
+
}
|
|
22104
|
+
}
|
|
22105
|
+
}
|
|
22106
|
+
/** @nocollapse */
|
|
22107
|
+
StandaloneService.ɵprov = ɵɵdefineInjectable({
|
|
22108
|
+
token: StandaloneService,
|
|
22109
|
+
providedIn: 'environment',
|
|
22110
|
+
factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
|
|
22111
|
+
});
|
|
22112
|
+
/**
|
|
22113
|
+
* A feature that acts as a setup code for the {@link StandaloneService}.
|
|
22114
|
+
*
|
|
22115
|
+
* The most important responsaibility of this feature is to expose the "getStandaloneInjector"
|
|
22116
|
+
* function (an entry points to a standalone injector creation) on a component definition object. We
|
|
22117
|
+
* go through the features infrastructure to make sure that the standalone injector creation logic
|
|
22118
|
+
* is tree-shakable and not included in applications that don't use standalone components.
|
|
22119
|
+
*
|
|
22120
|
+
* @codeGenApi
|
|
22121
|
+
*/
|
|
22122
|
+
function ɵɵStandaloneFeature(definition) {
|
|
22123
|
+
definition.getStandaloneInjector = (parentInjector) => {
|
|
22124
|
+
return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
|
|
22125
|
+
};
|
|
22126
|
+
}
|
|
22127
|
+
|
|
22128
|
+
/**
|
|
22129
|
+
* @license
|
|
22130
|
+
* Copyright Google LLC All Rights Reserved.
|
|
22131
|
+
*
|
|
22132
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
22133
|
+
* found in the LICENSE file at https://angular.io/license
|
|
22134
|
+
*/
|
|
22135
|
+
/**
|
|
22136
|
+
* Retrieves the component instance associated with a given DOM element.
|
|
22137
|
+
*
|
|
22138
|
+
* @usageNotes
|
|
22139
|
+
* Given the following DOM structure:
|
|
22140
|
+
*
|
|
22141
|
+
* ```html
|
|
22142
|
+
* <app-root>
|
|
22143
|
+
* <div>
|
|
22144
|
+
* <child-comp></child-comp>
|
|
22145
|
+
* </div>
|
|
22146
|
+
* </app-root>
|
|
22147
|
+
* ```
|
|
22148
|
+
*
|
|
22149
|
+
* Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
|
|
22150
|
+
* associated with this DOM element.
|
|
22151
|
+
*
|
|
22152
|
+
* Calling the function on `<app-root>` will return the `MyApp` instance.
|
|
22153
|
+
*
|
|
22154
|
+
*
|
|
22155
|
+
* @param element DOM element from which the component should be retrieved.
|
|
22156
|
+
* @returns Component instance associated with the element or `null` if there
|
|
22157
|
+
* is no component associated with it.
|
|
22158
|
+
*
|
|
22159
|
+
* @publicApi
|
|
22160
|
+
* @globalApi ng
|
|
22161
|
+
*/
|
|
22162
|
+
function getComponent(element) {
|
|
22163
|
+
ngDevMode && assertDomElement(element);
|
|
22164
|
+
const context = getLContext(element);
|
|
22165
|
+
if (context === null)
|
|
22166
|
+
return null;
|
|
22167
|
+
if (context.component === undefined) {
|
|
22168
|
+
const lView = context.lView;
|
|
22169
|
+
if (lView === null) {
|
|
22170
|
+
return null;
|
|
22171
|
+
}
|
|
22172
|
+
context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
|
|
22621
22173
|
}
|
|
22174
|
+
return context.component;
|
|
22622
22175
|
}
|
|
22623
|
-
const componentFactoryResolver = new ComponentFactoryResolver();
|
|
22624
22176
|
/**
|
|
22625
|
-
*
|
|
22626
|
-
*
|
|
22627
|
-
*
|
|
22177
|
+
* If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
|
|
22178
|
+
* view that the element is part of. Otherwise retrieves the instance of the component whose view
|
|
22179
|
+
* owns the element (in this case, the result is the same as calling `getOwningComponent`).
|
|
22628
22180
|
*
|
|
22629
|
-
* @
|
|
22181
|
+
* @param element Element for which to get the surrounding component instance.
|
|
22182
|
+
* @returns Instance of the component that is around the element or null if the element isn't
|
|
22183
|
+
* inside any component.
|
|
22184
|
+
*
|
|
22185
|
+
* @publicApi
|
|
22186
|
+
* @globalApi ng
|
|
22630
22187
|
*/
|
|
22631
|
-
function
|
|
22632
|
-
|
|
22188
|
+
function getContext(element) {
|
|
22189
|
+
assertDomElement(element);
|
|
22190
|
+
const context = getLContext(element);
|
|
22191
|
+
const lView = context ? context.lView : null;
|
|
22192
|
+
return lView === null ? null : lView[CONTEXT];
|
|
22633
22193
|
}
|
|
22634
22194
|
/**
|
|
22635
|
-
*
|
|
22195
|
+
* Retrieves the component instance whose view contains the DOM element.
|
|
22636
22196
|
*
|
|
22637
|
-
*
|
|
22638
|
-
*
|
|
22639
|
-
*
|
|
22197
|
+
* For example, if `<child-comp>` is used in the template of `<app-comp>`
|
|
22198
|
+
* (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
|
|
22199
|
+
* would return `<app-comp>`.
|
|
22640
22200
|
*
|
|
22201
|
+
* @param elementOrDir DOM element, component or directive instance
|
|
22202
|
+
* for which to retrieve the root components.
|
|
22203
|
+
* @returns Component instance whose view owns the DOM element or null if the element is not
|
|
22204
|
+
* part of a component view.
|
|
22205
|
+
*
|
|
22206
|
+
* @publicApi
|
|
22207
|
+
* @globalApi ng
|
|
22641
22208
|
*/
|
|
22642
|
-
|
|
22643
|
-
|
|
22644
|
-
|
|
22645
|
-
|
|
22646
|
-
|
|
22647
|
-
|
|
22648
|
-
|
|
22649
|
-
|
|
22650
|
-
this.componentType = componentType;
|
|
22651
|
-
}
|
|
22652
|
-
get injector() {
|
|
22653
|
-
return new NodeInjector(this._tNode, this._rootLView);
|
|
22654
|
-
}
|
|
22655
|
-
destroy() {
|
|
22656
|
-
this.hostView.destroy();
|
|
22657
|
-
}
|
|
22658
|
-
onDestroy(callback) {
|
|
22659
|
-
this.hostView.onDestroy(callback);
|
|
22209
|
+
function getOwningComponent(elementOrDir) {
|
|
22210
|
+
const context = getLContext(elementOrDir);
|
|
22211
|
+
let lView = context ? context.lView : null;
|
|
22212
|
+
if (lView === null)
|
|
22213
|
+
return null;
|
|
22214
|
+
let parent;
|
|
22215
|
+
while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
|
|
22216
|
+
lView = parent;
|
|
22660
22217
|
}
|
|
22218
|
+
return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
|
|
22661
22219
|
}
|
|
22662
|
-
|
|
22663
22220
|
/**
|
|
22664
|
-
*
|
|
22665
|
-
*
|
|
22221
|
+
* Retrieves all root components associated with a DOM element, directive or component instance.
|
|
22222
|
+
* Root components are those which have been bootstrapped by Angular.
|
|
22666
22223
|
*
|
|
22667
|
-
*
|
|
22668
|
-
*
|
|
22224
|
+
* @param elementOrDir DOM element, component or directive instance
|
|
22225
|
+
* for which to retrieve the root components.
|
|
22226
|
+
* @returns Root components associated with the target object.
|
|
22227
|
+
*
|
|
22228
|
+
* @publicApi
|
|
22229
|
+
* @globalApi ng
|
|
22669
22230
|
*/
|
|
22231
|
+
function getRootComponents(elementOrDir) {
|
|
22232
|
+
const lView = readPatchedLView(elementOrDir);
|
|
22233
|
+
return lView !== null ? [...getRootContext(lView).components] : [];
|
|
22234
|
+
}
|
|
22670
22235
|
/**
|
|
22671
|
-
*
|
|
22672
|
-
*
|
|
22673
|
-
* @param
|
|
22674
|
-
*
|
|
22236
|
+
* Retrieves an `Injector` associated with an element, component or directive instance.
|
|
22237
|
+
*
|
|
22238
|
+
* @param elementOrDir DOM element, component or directive instance for which to
|
|
22239
|
+
* retrieve the injector.
|
|
22240
|
+
* @returns Injector associated with the element, component or directive instance.
|
|
22241
|
+
*
|
|
22675
22242
|
* @publicApi
|
|
22243
|
+
* @globalApi ng
|
|
22676
22244
|
*/
|
|
22677
|
-
function
|
|
22678
|
-
|
|
22245
|
+
function getInjector(elementOrDir) {
|
|
22246
|
+
const context = getLContext(elementOrDir);
|
|
22247
|
+
const lView = context ? context.lView : null;
|
|
22248
|
+
if (lView === null)
|
|
22249
|
+
return Injector.NULL;
|
|
22250
|
+
const tNode = lView[TVIEW].data[context.nodeIndex];
|
|
22251
|
+
return new NodeInjector(tNode, lView);
|
|
22679
22252
|
}
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
|
|
22697
|
-
|
|
22698
|
-
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
|
|
22702
|
-
|
|
22703
|
-
}
|
|
22704
|
-
], stringify(ngModuleType), new Set(['environment']));
|
|
22705
|
-
// We need to resolve the injector types separately from the injector creation, because
|
|
22706
|
-
// the module might be trying to use this ref in its constructor for DI which will cause a
|
|
22707
|
-
// circular error that will eventually error out, because the injector isn't created yet.
|
|
22708
|
-
this._r3Injector.resolveInjectorInitializers();
|
|
22709
|
-
this.instance = this.get(ngModuleType);
|
|
22710
|
-
}
|
|
22711
|
-
get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
|
|
22712
|
-
if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
|
|
22713
|
-
return this;
|
|
22253
|
+
/**
|
|
22254
|
+
* Retrieve a set of injection tokens at a given DOM node.
|
|
22255
|
+
*
|
|
22256
|
+
* @param element Element for which the injection tokens should be retrieved.
|
|
22257
|
+
*/
|
|
22258
|
+
function getInjectionTokens(element) {
|
|
22259
|
+
const context = getLContext(element);
|
|
22260
|
+
const lView = context ? context.lView : null;
|
|
22261
|
+
if (lView === null)
|
|
22262
|
+
return [];
|
|
22263
|
+
const tView = lView[TVIEW];
|
|
22264
|
+
const tNode = tView.data[context.nodeIndex];
|
|
22265
|
+
const providerTokens = [];
|
|
22266
|
+
const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
|
|
22267
|
+
const endIndex = tNode.directiveEnd;
|
|
22268
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
22269
|
+
let value = tView.data[i];
|
|
22270
|
+
if (isDirectiveDefHack(value)) {
|
|
22271
|
+
// The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
|
|
22272
|
+
// design flaw. We should always store same type so that we can be monomorphic. The issue
|
|
22273
|
+
// is that for Components/Directives we store the def instead the type. The correct behavior
|
|
22274
|
+
// is that we should always be storing injectable type in this location.
|
|
22275
|
+
value = value.type;
|
|
22714
22276
|
}
|
|
22715
|
-
|
|
22277
|
+
providerTokens.push(value);
|
|
22716
22278
|
}
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
|
|
22720
|
-
|
|
22721
|
-
|
|
22722
|
-
|
|
22279
|
+
return providerTokens;
|
|
22280
|
+
}
|
|
22281
|
+
/**
|
|
22282
|
+
* Retrieves directive instances associated with a given DOM node. Does not include
|
|
22283
|
+
* component instances.
|
|
22284
|
+
*
|
|
22285
|
+
* @usageNotes
|
|
22286
|
+
* Given the following DOM structure:
|
|
22287
|
+
*
|
|
22288
|
+
* ```html
|
|
22289
|
+
* <app-root>
|
|
22290
|
+
* <button my-button></button>
|
|
22291
|
+
* <my-comp></my-comp>
|
|
22292
|
+
* </app-root>
|
|
22293
|
+
* ```
|
|
22294
|
+
*
|
|
22295
|
+
* Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
|
|
22296
|
+
* directive that is associated with the DOM node.
|
|
22297
|
+
*
|
|
22298
|
+
* Calling `getDirectives` on `<my-comp>` will return an empty array.
|
|
22299
|
+
*
|
|
22300
|
+
* @param node DOM node for which to get the directives.
|
|
22301
|
+
* @returns Array of directives associated with the node.
|
|
22302
|
+
*
|
|
22303
|
+
* @publicApi
|
|
22304
|
+
* @globalApi ng
|
|
22305
|
+
*/
|
|
22306
|
+
function getDirectives(node) {
|
|
22307
|
+
// Skip text nodes because we can't have directives associated with them.
|
|
22308
|
+
if (node instanceof Text) {
|
|
22309
|
+
return [];
|
|
22723
22310
|
}
|
|
22724
|
-
|
|
22725
|
-
|
|
22726
|
-
|
|
22311
|
+
const context = getLContext(node);
|
|
22312
|
+
const lView = context ? context.lView : null;
|
|
22313
|
+
if (lView === null) {
|
|
22314
|
+
return [];
|
|
22315
|
+
}
|
|
22316
|
+
const tView = lView[TVIEW];
|
|
22317
|
+
const nodeIndex = context.nodeIndex;
|
|
22318
|
+
if (!(tView === null || tView === void 0 ? void 0 : tView.data[nodeIndex])) {
|
|
22319
|
+
return [];
|
|
22320
|
+
}
|
|
22321
|
+
if (context.directives === undefined) {
|
|
22322
|
+
context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
|
|
22323
|
+
}
|
|
22324
|
+
// The `directives` in this case are a named array called `LComponentView`. Clone the
|
|
22325
|
+
// result so we don't expose an internal data structure in the user's console.
|
|
22326
|
+
return context.directives === null ? [] : [...context.directives];
|
|
22327
|
+
}
|
|
22328
|
+
/**
|
|
22329
|
+
* Returns the debug (partial) metadata for a particular directive or component instance.
|
|
22330
|
+
* The function accepts an instance of a directive or component and returns the corresponding
|
|
22331
|
+
* metadata.
|
|
22332
|
+
*
|
|
22333
|
+
* @param directiveOrComponentInstance Instance of a directive or component
|
|
22334
|
+
* @returns metadata of the passed directive or component
|
|
22335
|
+
*
|
|
22336
|
+
* @publicApi
|
|
22337
|
+
* @globalApi ng
|
|
22338
|
+
*/
|
|
22339
|
+
function getDirectiveMetadata(directiveOrComponentInstance) {
|
|
22340
|
+
const { constructor } = directiveOrComponentInstance;
|
|
22341
|
+
if (!constructor) {
|
|
22342
|
+
throw new Error('Unable to find the instance constructor');
|
|
22727
22343
|
}
|
|
22728
|
-
|
|
22729
|
-
|
|
22730
|
-
constructor
|
|
22731
|
-
|
|
22732
|
-
|
|
22344
|
+
// In case a component inherits from a directive, we may have component and directive metadata
|
|
22345
|
+
// To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
|
|
22346
|
+
const componentDef = getComponentDef$1(constructor);
|
|
22347
|
+
if (componentDef) {
|
|
22348
|
+
return {
|
|
22349
|
+
inputs: componentDef.inputs,
|
|
22350
|
+
outputs: componentDef.outputs,
|
|
22351
|
+
encapsulation: componentDef.encapsulation,
|
|
22352
|
+
changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
|
|
22353
|
+
ChangeDetectionStrategy.Default
|
|
22354
|
+
};
|
|
22733
22355
|
}
|
|
22734
|
-
|
|
22735
|
-
|
|
22356
|
+
const directiveDef = getDirectiveDef(constructor);
|
|
22357
|
+
if (directiveDef) {
|
|
22358
|
+
return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
|
|
22736
22359
|
}
|
|
22360
|
+
return null;
|
|
22737
22361
|
}
|
|
22738
|
-
|
|
22739
|
-
|
|
22740
|
-
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
22750
|
-
|
|
22751
|
-
|
|
22752
|
-
|
|
22753
|
-
|
|
22754
|
-
|
|
22755
|
-
|
|
22362
|
+
/**
|
|
22363
|
+
* Retrieve map of local references.
|
|
22364
|
+
*
|
|
22365
|
+
* The references are retrieved as a map of local reference name to element or directive instance.
|
|
22366
|
+
*
|
|
22367
|
+
* @param target DOM element, component or directive instance for which to retrieve
|
|
22368
|
+
* the local references.
|
|
22369
|
+
*/
|
|
22370
|
+
function getLocalRefs(target) {
|
|
22371
|
+
const context = getLContext(target);
|
|
22372
|
+
if (context === null)
|
|
22373
|
+
return {};
|
|
22374
|
+
if (context.localRefs === undefined) {
|
|
22375
|
+
const lView = context.lView;
|
|
22376
|
+
if (lView === null) {
|
|
22377
|
+
return {};
|
|
22378
|
+
}
|
|
22379
|
+
context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
|
|
22756
22380
|
}
|
|
22381
|
+
return context.localRefs || {};
|
|
22757
22382
|
}
|
|
22758
22383
|
/**
|
|
22759
|
-
*
|
|
22384
|
+
* Retrieves the host element of a component or directive instance.
|
|
22385
|
+
* The host element is the DOM element that matched the selector of the directive.
|
|
22386
|
+
*
|
|
22387
|
+
* @param componentOrDirective Component or directive instance for which the host
|
|
22388
|
+
* element should be retrieved.
|
|
22389
|
+
* @returns Host element of the target.
|
|
22760
22390
|
*
|
|
22761
22391
|
* @publicApi
|
|
22762
|
-
* @
|
|
22392
|
+
* @globalApi ng
|
|
22763
22393
|
*/
|
|
22764
|
-
function
|
|
22765
|
-
|
|
22766
|
-
return adapter.injector;
|
|
22394
|
+
function getHostElement(componentOrDirective) {
|
|
22395
|
+
return getLContext(componentOrDirective).native;
|
|
22767
22396
|
}
|
|
22768
|
-
|
|
22769
22397
|
/**
|
|
22770
|
-
*
|
|
22771
|
-
* Copyright Google LLC All Rights Reserved.
|
|
22398
|
+
* Retrieves the rendered text for a given component.
|
|
22772
22399
|
*
|
|
22773
|
-
*
|
|
22774
|
-
*
|
|
22400
|
+
* This function retrieves the host element of a component and
|
|
22401
|
+
* and then returns the `textContent` for that element. This implies
|
|
22402
|
+
* that the text returned will include re-projected content of
|
|
22403
|
+
* the component as well.
|
|
22404
|
+
*
|
|
22405
|
+
* @param component The component to return the content text for.
|
|
22775
22406
|
*/
|
|
22407
|
+
function getRenderedText(component) {
|
|
22408
|
+
const hostElement = getHostElement(component);
|
|
22409
|
+
return hostElement.textContent || '';
|
|
22410
|
+
}
|
|
22776
22411
|
/**
|
|
22777
|
-
*
|
|
22778
|
-
*
|
|
22779
|
-
*
|
|
22412
|
+
* Retrieves a list of event listeners associated with a DOM element. The list does include host
|
|
22413
|
+
* listeners, but it does not include event listeners defined outside of the Angular context
|
|
22414
|
+
* (e.g. through `addEventListener`).
|
|
22415
|
+
*
|
|
22416
|
+
* @usageNotes
|
|
22417
|
+
* Given the following DOM structure:
|
|
22418
|
+
*
|
|
22419
|
+
* ```html
|
|
22420
|
+
* <app-root>
|
|
22421
|
+
* <div (click)="doSomething()"></div>
|
|
22422
|
+
* </app-root>
|
|
22423
|
+
* ```
|
|
22424
|
+
*
|
|
22425
|
+
* Calling `getListeners` on `<div>` will return an object that looks as follows:
|
|
22426
|
+
*
|
|
22427
|
+
* ```ts
|
|
22428
|
+
* {
|
|
22429
|
+
* name: 'click',
|
|
22430
|
+
* element: <div>,
|
|
22431
|
+
* callback: () => doSomething(),
|
|
22432
|
+
* useCapture: false
|
|
22433
|
+
* }
|
|
22434
|
+
* ```
|
|
22435
|
+
*
|
|
22436
|
+
* @param element Element for which the DOM listeners should be retrieved.
|
|
22437
|
+
* @returns Array of event listeners on the DOM element.
|
|
22438
|
+
*
|
|
22439
|
+
* @publicApi
|
|
22440
|
+
* @globalApi ng
|
|
22780
22441
|
*/
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
|
|
22792
|
-
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22798
|
-
|
|
22799
|
-
|
|
22800
|
-
|
|
22801
|
-
|
|
22802
|
-
if
|
|
22803
|
-
|
|
22442
|
+
function getListeners(element) {
|
|
22443
|
+
ngDevMode && assertDomElement(element);
|
|
22444
|
+
const lContext = getLContext(element);
|
|
22445
|
+
const lView = lContext === null ? null : lContext.lView;
|
|
22446
|
+
if (lView === null)
|
|
22447
|
+
return [];
|
|
22448
|
+
const tView = lView[TVIEW];
|
|
22449
|
+
const lCleanup = lView[CLEANUP];
|
|
22450
|
+
const tCleanup = tView.cleanup;
|
|
22451
|
+
const listeners = [];
|
|
22452
|
+
if (tCleanup && lCleanup) {
|
|
22453
|
+
for (let i = 0; i < tCleanup.length;) {
|
|
22454
|
+
const firstParam = tCleanup[i++];
|
|
22455
|
+
const secondParam = tCleanup[i++];
|
|
22456
|
+
if (typeof firstParam === 'string') {
|
|
22457
|
+
const name = firstParam;
|
|
22458
|
+
const listenerElement = unwrapRNode(lView[secondParam]);
|
|
22459
|
+
const callback = lCleanup[tCleanup[i++]];
|
|
22460
|
+
const useCaptureOrIndx = tCleanup[i++];
|
|
22461
|
+
// if useCaptureOrIndx is boolean then report it as is.
|
|
22462
|
+
// if useCaptureOrIndx is positive number then it in unsubscribe method
|
|
22463
|
+
// if useCaptureOrIndx is negative number then it is a Subscription
|
|
22464
|
+
const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
|
|
22465
|
+
const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
|
|
22466
|
+
if (element == listenerElement) {
|
|
22467
|
+
listeners.push({ element, name, callback, useCapture, type });
|
|
22804
22468
|
}
|
|
22805
22469
|
}
|
|
22806
22470
|
}
|
|
22807
|
-
finally {
|
|
22808
|
-
this.cachedInjectors.clear();
|
|
22809
|
-
}
|
|
22810
22471
|
}
|
|
22472
|
+
listeners.sort(sortListeners);
|
|
22473
|
+
return listeners;
|
|
22474
|
+
}
|
|
22475
|
+
function sortListeners(a, b) {
|
|
22476
|
+
if (a.name == b.name)
|
|
22477
|
+
return 0;
|
|
22478
|
+
return a.name < b.name ? -1 : 1;
|
|
22811
22479
|
}
|
|
22812
|
-
/** @nocollapse */
|
|
22813
|
-
StandaloneService.ɵprov = ɵɵdefineInjectable({
|
|
22814
|
-
token: StandaloneService,
|
|
22815
|
-
providedIn: 'environment',
|
|
22816
|
-
factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
|
|
22817
|
-
});
|
|
22818
22480
|
/**
|
|
22819
|
-
*
|
|
22481
|
+
* This function should not exist because it is megamorphic and only mostly correct.
|
|
22820
22482
|
*
|
|
22821
|
-
*
|
|
22822
|
-
|
|
22823
|
-
|
|
22824
|
-
|
|
22483
|
+
* See call site for more info.
|
|
22484
|
+
*/
|
|
22485
|
+
function isDirectiveDefHack(obj) {
|
|
22486
|
+
return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
|
|
22487
|
+
}
|
|
22488
|
+
/**
|
|
22489
|
+
* Returns the attached `DebugNode` instance for an element in the DOM.
|
|
22825
22490
|
*
|
|
22826
|
-
* @
|
|
22491
|
+
* @param element DOM element which is owned by an existing component's view.
|
|
22827
22492
|
*/
|
|
22828
|
-
function
|
|
22829
|
-
|
|
22830
|
-
|
|
22831
|
-
}
|
|
22493
|
+
function getDebugNode(element) {
|
|
22494
|
+
if (ngDevMode && !(element instanceof Node)) {
|
|
22495
|
+
throw new Error('Expecting instance of DOM Element');
|
|
22496
|
+
}
|
|
22497
|
+
const lContext = getLContext(element);
|
|
22498
|
+
const lView = lContext ? lContext.lView : null;
|
|
22499
|
+
if (lView === null) {
|
|
22500
|
+
return null;
|
|
22501
|
+
}
|
|
22502
|
+
const nodeIndex = lContext.nodeIndex;
|
|
22503
|
+
if (nodeIndex !== -1) {
|
|
22504
|
+
const valueInLView = lView[nodeIndex];
|
|
22505
|
+
// this means that value in the lView is a component with its own
|
|
22506
|
+
// data. In this situation the TNode is not accessed at the same spot.
|
|
22507
|
+
const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
|
|
22508
|
+
ngDevMode &&
|
|
22509
|
+
assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
|
|
22510
|
+
return buildDebugNode(tNode, lView);
|
|
22511
|
+
}
|
|
22512
|
+
return null;
|
|
22513
|
+
}
|
|
22514
|
+
/**
|
|
22515
|
+
* Retrieve the component `LView` from component/element.
|
|
22516
|
+
*
|
|
22517
|
+
* NOTE: `LView` is a private and should not be leaked outside.
|
|
22518
|
+
* Don't export this method to `ng.*` on window.
|
|
22519
|
+
*
|
|
22520
|
+
* @param target DOM element or component instance for which to retrieve the LView.
|
|
22521
|
+
*/
|
|
22522
|
+
function getComponentLView(target) {
|
|
22523
|
+
const lContext = getLContext(target);
|
|
22524
|
+
const nodeIndx = lContext.nodeIndex;
|
|
22525
|
+
const lView = lContext.lView;
|
|
22526
|
+
ngDevMode && assertLView(lView);
|
|
22527
|
+
const componentLView = lView[nodeIndx];
|
|
22528
|
+
ngDevMode && assertLView(componentLView);
|
|
22529
|
+
return componentLView;
|
|
22530
|
+
}
|
|
22531
|
+
/** Asserts that a value is a DOM Element. */
|
|
22532
|
+
function assertDomElement(value) {
|
|
22533
|
+
if (typeof Element !== 'undefined' && !(value instanceof Element)) {
|
|
22534
|
+
throw new Error('Expecting instance of DOM Element');
|
|
22535
|
+
}
|
|
22832
22536
|
}
|
|
22833
22537
|
|
|
22834
22538
|
/**
|
|
@@ -24049,7 +23753,7 @@ const unusedValueExportToPlacateAjd = 1;
|
|
|
24049
23753
|
* Use of this source code is governed by an MIT-style license that can be
|
|
24050
23754
|
* found in the LICENSE file at https://angular.io/license
|
|
24051
23755
|
*/
|
|
24052
|
-
const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$
|
|
23756
|
+
const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd;
|
|
24053
23757
|
class LQuery_ {
|
|
24054
23758
|
constructor(queryList) {
|
|
24055
23759
|
this.queryList = queryList;
|
|
@@ -24716,7 +24420,7 @@ function patchModuleCompilation() {
|
|
|
24716
24420
|
function isModuleWithProviders$1(value) {
|
|
24717
24421
|
return value.ngModule !== undefined;
|
|
24718
24422
|
}
|
|
24719
|
-
function isNgModule(value) {
|
|
24423
|
+
function isNgModule$1(value) {
|
|
24720
24424
|
return !!getNgModuleDef(value);
|
|
24721
24425
|
}
|
|
24722
24426
|
|
|
@@ -25139,7 +24843,7 @@ function patchComponentDefWithScope(componentDef, transitiveScopes) {
|
|
|
25139
24843
|
* (either a NgModule or a standalone component / directive / pipe).
|
|
25140
24844
|
*/
|
|
25141
24845
|
function transitiveScopesFor(type) {
|
|
25142
|
-
if (isNgModule(type)) {
|
|
24846
|
+
if (isNgModule$1(type)) {
|
|
25143
24847
|
return transitiveScopesForNgModule(type);
|
|
25144
24848
|
}
|
|
25145
24849
|
else if (isStandalone(type)) {
|
|
@@ -25223,7 +24927,7 @@ function transitiveScopesForNgModule(moduleType) {
|
|
|
25223
24927
|
const exportedType = exported;
|
|
25224
24928
|
// Either the type is a module, a pipe, or a component/directive (which may not have a
|
|
25225
24929
|
// ɵcmp as it might be compiled asynchronously).
|
|
25226
|
-
if (isNgModule(exportedType)) {
|
|
24930
|
+
if (isNgModule$1(exportedType)) {
|
|
25227
24931
|
// When this module exports another, the exported module's exported directives and pipes are
|
|
25228
24932
|
// added to both the compilation and exported scopes of this module.
|
|
25229
24933
|
const exportedScope = transitiveScopesFor(exportedType);
|
|
@@ -25523,7 +25227,7 @@ class R3TestBedCompiler {
|
|
|
25523
25227
|
// module's provider list.
|
|
25524
25228
|
this.providerOverridesByModule = new Map();
|
|
25525
25229
|
this.providerOverridesByToken = new Map();
|
|
25526
|
-
this.
|
|
25230
|
+
this.scopesWithOverriddenProviders = new Set();
|
|
25527
25231
|
this.testModuleRef = null;
|
|
25528
25232
|
class DynamicTestModule {
|
|
25529
25233
|
}
|
|
@@ -25694,7 +25398,7 @@ class R3TestBedCompiler {
|
|
|
25694
25398
|
this.queueTypesFromModulesArray([moduleType]);
|
|
25695
25399
|
this.compileTypesSync();
|
|
25696
25400
|
this.applyProviderOverrides();
|
|
25697
|
-
this.
|
|
25401
|
+
this.applyProviderOverridesInScope(moduleType);
|
|
25698
25402
|
this.applyTransitiveScopes();
|
|
25699
25403
|
}
|
|
25700
25404
|
/**
|
|
@@ -25705,7 +25409,7 @@ class R3TestBedCompiler {
|
|
|
25705
25409
|
this.queueTypesFromModulesArray([moduleType]);
|
|
25706
25410
|
yield this.compileComponents();
|
|
25707
25411
|
this.applyProviderOverrides();
|
|
25708
|
-
this.
|
|
25412
|
+
this.applyProviderOverridesInScope(moduleType);
|
|
25709
25413
|
this.applyTransitiveScopes();
|
|
25710
25414
|
});
|
|
25711
25415
|
}
|
|
@@ -25807,51 +25511,53 @@ class R3TestBedCompiler {
|
|
|
25807
25511
|
this.seenComponents.clear();
|
|
25808
25512
|
this.seenDirectives.clear();
|
|
25809
25513
|
}
|
|
25810
|
-
|
|
25514
|
+
/**
|
|
25515
|
+
* Applies provider overrides to a given type (either an NgModule or a standalone component)
|
|
25516
|
+
* and all imported NgModules and standalone components recursively.
|
|
25517
|
+
*/
|
|
25518
|
+
applyProviderOverridesInScope(type) {
|
|
25811
25519
|
var _a;
|
|
25812
|
-
|
|
25520
|
+
const hasScope = isStandaloneComponent(type) || isNgModule(type);
|
|
25521
|
+
// The function can be re-entered recursively while inspecting dependencies
|
|
25522
|
+
// of an NgModule or a standalone component. Exit early if we come across a
|
|
25523
|
+
// type that can not have a scope (directive or pipe) or the type is already
|
|
25524
|
+
// processed earlier.
|
|
25525
|
+
if (!hasScope || this.scopesWithOverriddenProviders.has(type)) {
|
|
25813
25526
|
return;
|
|
25814
25527
|
}
|
|
25815
|
-
this.
|
|
25528
|
+
this.scopesWithOverriddenProviders.add(type);
|
|
25816
25529
|
// NOTE: the line below triggers JIT compilation of the module injector,
|
|
25817
25530
|
// which also invokes verification of the NgModule semantics, which produces
|
|
25818
25531
|
// detailed error messages. The fact that the code relies on this line being
|
|
25819
25532
|
// present here is suspicious and should be refactored in a way that the line
|
|
25820
25533
|
// below can be moved (for ex. after an early exit check below).
|
|
25821
|
-
const injectorDef =
|
|
25534
|
+
const injectorDef = type[ɵNG_INJ_DEF];
|
|
25822
25535
|
// No provider overrides, exit early.
|
|
25823
25536
|
if (this.providerOverridesByToken.size === 0)
|
|
25824
25537
|
return;
|
|
25825
|
-
if (isStandaloneComponent(
|
|
25538
|
+
if (isStandaloneComponent(type)) {
|
|
25826
25539
|
// Visit all component dependencies and override providers there.
|
|
25827
|
-
const def = getComponentDef(
|
|
25540
|
+
const def = getComponentDef(type);
|
|
25828
25541
|
const dependencies = maybeUnwrapFn((_a = def.dependencies) !== null && _a !== void 0 ? _a : []);
|
|
25829
25542
|
for (const dependency of dependencies) {
|
|
25830
|
-
|
|
25831
|
-
// when a dependency is a standalone component or an NgModule.
|
|
25832
|
-
// In AOT, the `dependencies` might also contain regular (NgModule-based)
|
|
25833
|
-
// Component, Directive and Pipes. Skip them here, they are handled in a
|
|
25834
|
-
// different location (in the `configureTestingModule` function).
|
|
25835
|
-
if (isStandaloneComponent(dependency) || hasNgModuleDef(dependency)) {
|
|
25836
|
-
this.applyProviderOverridesToModule(dependency);
|
|
25837
|
-
}
|
|
25543
|
+
this.applyProviderOverridesInScope(dependency);
|
|
25838
25544
|
}
|
|
25839
25545
|
}
|
|
25840
25546
|
else {
|
|
25841
25547
|
const providers = [
|
|
25842
25548
|
...injectorDef.providers,
|
|
25843
|
-
...(this.providerOverridesByModule.get(
|
|
25549
|
+
...(this.providerOverridesByModule.get(type) || [])
|
|
25844
25550
|
];
|
|
25845
25551
|
if (this.hasProviderOverrides(providers)) {
|
|
25846
|
-
this.maybeStoreNgDef(ɵNG_INJ_DEF,
|
|
25847
|
-
this.storeFieldOfDefOnType(
|
|
25552
|
+
this.maybeStoreNgDef(ɵNG_INJ_DEF, type);
|
|
25553
|
+
this.storeFieldOfDefOnType(type, ɵNG_INJ_DEF, 'providers');
|
|
25848
25554
|
injectorDef.providers = this.getOverriddenProviders(providers);
|
|
25849
25555
|
}
|
|
25850
25556
|
// Apply provider overrides to imported modules recursively
|
|
25851
|
-
const moduleDef =
|
|
25557
|
+
const moduleDef = type[ɵNG_MOD_DEF];
|
|
25852
25558
|
const imports = maybeUnwrapFn(moduleDef.imports);
|
|
25853
25559
|
for (const importedModule of imports) {
|
|
25854
|
-
this.
|
|
25560
|
+
this.applyProviderOverridesInScope(importedModule);
|
|
25855
25561
|
}
|
|
25856
25562
|
// Also override the providers on any ModuleWithProviders imports since those don't appear in
|
|
25857
25563
|
// the moduleDef.
|
|
@@ -26089,7 +25795,7 @@ class R3TestBedCompiler {
|
|
|
26089
25795
|
});
|
|
26090
25796
|
});
|
|
26091
25797
|
this.initialNgDefs.clear();
|
|
26092
|
-
this.
|
|
25798
|
+
this.scopesWithOverriddenProviders.clear();
|
|
26093
25799
|
this.restoreComponentResolutionQueue();
|
|
26094
25800
|
// Restore the locale ID to the default value, this shouldn't be necessary but we never know
|
|
26095
25801
|
ɵsetLocaleId(ɵDEFAULT_LOCALE_ID);
|
|
@@ -26116,7 +25822,7 @@ class R3TestBedCompiler {
|
|
|
26116
25822
|
providers,
|
|
26117
25823
|
}, /* allowDuplicateDeclarationsInRoot */ true);
|
|
26118
25824
|
// clang-format on
|
|
26119
|
-
this.
|
|
25825
|
+
this.applyProviderOverridesInScope(this.testModuleType);
|
|
26120
25826
|
}
|
|
26121
25827
|
get injector() {
|
|
26122
25828
|
if (this._injector !== null) {
|
|
@@ -26217,6 +25923,9 @@ function getComponentDef(value) {
|
|
|
26217
25923
|
function hasNgModuleDef(value) {
|
|
26218
25924
|
return value.hasOwnProperty('ɵmod');
|
|
26219
25925
|
}
|
|
25926
|
+
function isNgModule(value) {
|
|
25927
|
+
return hasNgModuleDef(value);
|
|
25928
|
+
}
|
|
26220
25929
|
function maybeUnwrapFn(maybeFn) {
|
|
26221
25930
|
return maybeFn instanceof Function ? maybeFn() : maybeFn;
|
|
26222
25931
|
}
|