@angular/core 14.1.0-next.2 → 14.1.0-rc.0

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.
Files changed (58) hide show
  1. package/esm2020/src/application_ref.mjs +29 -15
  2. package/esm2020/src/change_detection/change_detector_ref.mjs +1 -1
  3. package/esm2020/src/core.mjs +2 -2
  4. package/esm2020/src/core_render3_private_export.mjs +2 -2
  5. package/esm2020/src/debug/debug_node.mjs +3 -4
  6. package/esm2020/src/di/index.mjs +1 -1
  7. package/esm2020/src/di/injector_compatibility.mjs +13 -8
  8. package/esm2020/src/di/injector_token.mjs +2 -2
  9. package/esm2020/src/di/interface/injector.mjs +2 -1
  10. package/esm2020/src/di/jit/util.mjs +3 -2
  11. package/esm2020/src/di/r3_injector.mjs +13 -1
  12. package/esm2020/src/di/reflective_key.mjs +3 -2
  13. package/esm2020/src/errors.mjs +1 -1
  14. package/esm2020/src/i18n/locale_data_api.mjs +3 -2
  15. package/esm2020/src/linker/component_factory.mjs +1 -1
  16. package/esm2020/src/linker/ng_module_factory.mjs +2 -2
  17. package/esm2020/src/linker/view_container_ref.mjs +2 -2
  18. package/esm2020/src/metadata/di.mjs +1 -1
  19. package/esm2020/src/render/api.mjs +2 -11
  20. package/esm2020/src/render3/component.mjs +3 -57
  21. package/esm2020/src/render3/component_ref.mjs +30 -5
  22. package/esm2020/src/render3/features/standalone_feature.mjs +2 -2
  23. package/esm2020/src/render3/index.mjs +4 -4
  24. package/esm2020/src/render3/instructions/change_detection.mjs +2 -20
  25. package/esm2020/src/render3/instructions/element_validation.mjs +4 -1
  26. package/esm2020/src/render3/instructions/listener.mjs +34 -44
  27. package/esm2020/src/render3/instructions/lview_debug.mjs +1 -1
  28. package/esm2020/src/render3/instructions/property_interpolation.mjs +2 -2
  29. package/esm2020/src/render3/instructions/shared.mjs +22 -59
  30. package/esm2020/src/render3/instructions/styling.mjs +2 -2
  31. package/esm2020/src/render3/interfaces/i18n.mjs +2 -2
  32. package/esm2020/src/render3/interfaces/renderer.mjs +1 -17
  33. package/esm2020/src/render3/interfaces/styling.mjs +1 -1
  34. package/esm2020/src/render3/interfaces/view.mjs +1 -1
  35. package/esm2020/src/render3/ng_module_ref.mjs +15 -2
  36. package/esm2020/src/render3/node_manipulation.mjs +24 -87
  37. package/esm2020/src/render3/node_manipulation_i18n.mjs +1 -1
  38. package/esm2020/src/render3/util/attrs_utils.mjs +4 -12
  39. package/esm2020/src/render3/util/view_utils.mjs +3 -6
  40. package/esm2020/src/version.mjs +1 -1
  41. package/esm2020/src/zone/ng_zone.mjs +9 -4
  42. package/esm2020/testing/src/logger.mjs +3 -3
  43. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  44. package/fesm2015/core.mjs +1697 -1830
  45. package/fesm2015/core.mjs.map +1 -1
  46. package/fesm2015/testing.mjs +1037 -1279
  47. package/fesm2015/testing.mjs.map +1 -1
  48. package/fesm2020/core.mjs +1697 -1830
  49. package/fesm2020/core.mjs.map +1 -1
  50. package/fesm2020/testing.mjs +1037 -1279
  51. package/fesm2020/testing.mjs.map +1 -1
  52. package/index.d.ts +169 -144
  53. package/package.json +1 -1
  54. package/schematics/migrations/typed-forms/util.js +2 -2
  55. package/schematics/utils/typescript/symbol.js +2 -2
  56. package/testing/index.d.ts +1 -1
  57. package/schematics/utils/schematics_prompt.d.ts +0 -17
  58. package/schematics/utils/schematics_prompt.js +0 -45
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.1.0-next.2
2
+ * @license Angular v14.1.0-rc.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -365,7 +365,7 @@ function fakeAsync(fn) {
365
365
  *
366
366
  * @publicApi
367
367
  */
368
- function tick$1(millis = 0, tickOptions = {
368
+ function tick(millis = 0, tickOptions = {
369
369
  processNewMacroTasksSynchronously: true
370
370
  }) {
371
371
  if (fakeAsyncTestModule) {
@@ -862,6 +862,68 @@ const NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
862
862
  const NG_INJECTABLE_DEF = getClosureSafeProperty({ ngInjectableDef: getClosureSafeProperty });
863
863
  const NG_INJECTOR_DEF = getClosureSafeProperty({ ngInjectorDef: getClosureSafeProperty });
864
864
 
865
+ /**
866
+ * @license
867
+ * Copyright Google LLC All Rights Reserved.
868
+ *
869
+ * Use of this source code is governed by an MIT-style license that can be
870
+ * found in the LICENSE file at https://angular.io/license
871
+ */
872
+ /**
873
+ * Base URL for the error details page.
874
+ *
875
+ * Keep the files below in full sync:
876
+ * - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
877
+ * - packages/core/src/error_details_base_url.ts
878
+ */
879
+ const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
880
+
881
+ /**
882
+ * @license
883
+ * Copyright Google LLC All Rights Reserved.
884
+ *
885
+ * Use of this source code is governed by an MIT-style license that can be
886
+ * found in the LICENSE file at https://angular.io/license
887
+ */
888
+ /**
889
+ * Class that represents a runtime error.
890
+ * Formats and outputs the error message in a consistent way.
891
+ *
892
+ * Example:
893
+ * ```
894
+ * throw new RuntimeError(
895
+ * RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
896
+ * ngDevMode && 'Injector has already been destroyed.');
897
+ * ```
898
+ *
899
+ * Note: the `message` argument contains a descriptive error message as a string in development
900
+ * mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
901
+ * `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
902
+ */
903
+ class RuntimeError extends Error {
904
+ constructor(code, message) {
905
+ super(formatRuntimeError(code, message));
906
+ this.code = code;
907
+ }
908
+ }
909
+ /**
910
+ * Called to format a runtime error.
911
+ * See additional info on the `message` argument type in the `RuntimeError` class description.
912
+ */
913
+ function formatRuntimeError(code, message) {
914
+ // Error code might be a negative number, which is a special marker that instructs the logic to
915
+ // generate a link to the error details page on angular.io.
916
+ const fullCode = `NG0${Math.abs(code)}`;
917
+ let errorMessage = `${fullCode}${message ? ': ' + message.trim() : ''}`;
918
+ if (ngDevMode && code < 0) {
919
+ const addPeriodSeparator = !errorMessage.match(/[.,;!?]$/);
920
+ const separator = addPeriodSeparator ? '.' : '';
921
+ errorMessage =
922
+ `${errorMessage}${separator} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
923
+ }
924
+ return errorMessage;
925
+ }
926
+
865
927
  /**
866
928
  * @license
867
929
  * Copyright Google LLC All Rights Reserved.
@@ -1790,68 +1852,6 @@ function initNgDevMode() {
1790
1852
  return false;
1791
1853
  }
1792
1854
 
1793
- /**
1794
- * @license
1795
- * Copyright Google LLC All Rights Reserved.
1796
- *
1797
- * Use of this source code is governed by an MIT-style license that can be
1798
- * found in the LICENSE file at https://angular.io/license
1799
- */
1800
- /**
1801
- * Base URL for the error details page.
1802
- *
1803
- * Keep the files below in full sync:
1804
- * - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
1805
- * - packages/core/src/error_details_base_url.ts
1806
- */
1807
- const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
1808
-
1809
- /**
1810
- * @license
1811
- * Copyright Google LLC All Rights Reserved.
1812
- *
1813
- * Use of this source code is governed by an MIT-style license that can be
1814
- * found in the LICENSE file at https://angular.io/license
1815
- */
1816
- /**
1817
- * Class that represents a runtime error.
1818
- * Formats and outputs the error message in a consistent way.
1819
- *
1820
- * Example:
1821
- * ```
1822
- * throw new RuntimeError(
1823
- * RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
1824
- * ngDevMode && 'Injector has already been destroyed.');
1825
- * ```
1826
- *
1827
- * Note: the `message` argument contains a descriptive error message as a string in development
1828
- * mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
1829
- * `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
1830
- */
1831
- class RuntimeError extends Error {
1832
- constructor(code, message) {
1833
- super(formatRuntimeError(code, message));
1834
- this.code = code;
1835
- }
1836
- }
1837
- /**
1838
- * Called to format a runtime error.
1839
- * See additional info on the `message` argument type in the `RuntimeError` class description.
1840
- */
1841
- function formatRuntimeError(code, message) {
1842
- // Error code might be a negative number, which is a special marker that instructs the logic to
1843
- // generate a link to the error details page on angular.io.
1844
- const fullCode = `NG0${Math.abs(code)}`;
1845
- let errorMessage = `${fullCode}${message ? ': ' + message.trim() : ''}`;
1846
- if (ngDevMode && code < 0) {
1847
- const addPeriodSeparator = !errorMessage.match(/[.,;!?]$/);
1848
- const separator = addPeriodSeparator ? '.' : '';
1849
- errorMessage =
1850
- `${errorMessage}${separator} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
1851
- }
1852
- return errorMessage;
1853
- }
1854
-
1855
1855
  /**
1856
1856
  * @license
1857
1857
  * Copyright Google LLC All Rights Reserved.
@@ -1932,6 +1932,7 @@ function throwProviderNotFoundError(token, injectorName) {
1932
1932
  * Injection flags for DI.
1933
1933
  *
1934
1934
  * @publicApi
1935
+ * @deprecated use an options object for `inject` instead.
1935
1936
  */
1936
1937
  var InjectFlags;
1937
1938
  (function (InjectFlags) {
@@ -2062,22 +2063,17 @@ function ɵɵinject(token, flags = InjectFlags.Default) {
2062
2063
  * Throws an error indicating that a factory function could not be generated by the compiler for a
2063
2064
  * particular class.
2064
2065
  *
2065
- * This instruction allows the actual error message to be optimized away when ngDevMode is turned
2066
- * off, saving bytes of generated code while still providing a good experience in dev mode.
2067
- *
2068
2066
  * The name of the class is not mentioned here, but will be in the generated factory function name
2069
2067
  * and thus in the stack trace.
2070
2068
  *
2071
2069
  * @codeGenApi
2072
2070
  */
2073
2071
  function ɵɵinvalidFactoryDep(index) {
2074
- const msg = ngDevMode ?
2072
+ throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, ngDevMode &&
2075
2073
  `This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
2076
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.
2077
2075
 
2078
- 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.` :
2079
- 'invalid';
2080
- 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.`);
2081
2077
  }
2082
2078
  /**
2083
2079
  * Injects a token from the currently active injector.
@@ -2144,6 +2140,16 @@ Please check that 1) the type for the parameter at index ${index} is correct and
2144
2140
  * @publicApi
2145
2141
  */
2146
2142
  function inject$1(token, flags = InjectFlags.Default) {
2143
+ if (typeof flags !== 'number') {
2144
+ // While TypeScript doesn't accept it without a cast, bitwise OR with false-y values in
2145
+ // JavaScript is a no-op. We can use that for a very codesize-efficient conversion from
2146
+ // `InjectOptions` to `InjectFlags`.
2147
+ flags = (0 /* InternalInjectFlags.Default */ | // comment to force a line break in the formatter
2148
+ (flags.optional && 8 /* InternalInjectFlags.Optional */) |
2149
+ (flags.host && 1 /* InternalInjectFlags.Host */) |
2150
+ (flags.self && 2 /* InternalInjectFlags.Self */) |
2151
+ (flags.skipSelf && 4 /* InternalInjectFlags.SkipSelf */));
2152
+ }
2147
2153
  return ɵɵinject(token, flags);
2148
2154
  }
2149
2155
  function injectArgs(types) {
@@ -3194,87 +3200,6 @@ function getNamespaceUri(namespace) {
3194
3200
  (name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
3195
3201
  }
3196
3202
 
3197
- /**
3198
- * @license
3199
- * Copyright Google LLC All Rights Reserved.
3200
- *
3201
- * Use of this source code is governed by an MIT-style license that can be
3202
- * found in the LICENSE file at https://angular.io/license
3203
- */
3204
- /**
3205
- * Most of the use of `document` in Angular is from within the DI system so it is possible to simply
3206
- * inject the `DOCUMENT` token and are done.
3207
- *
3208
- * Ivy is special because it does not rely upon the DI and must get hold of the document some other
3209
- * way.
3210
- *
3211
- * The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
3212
- * Wherever ivy needs the global document, it calls `getDocument()` instead.
3213
- *
3214
- * When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
3215
- * tell ivy what the global `document` is.
3216
- *
3217
- * Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
3218
- * by calling `setDocument()` when providing the `DOCUMENT` token.
3219
- */
3220
- let DOCUMENT = undefined;
3221
- /**
3222
- * Tell ivy what the `document` is for this platform.
3223
- *
3224
- * It is only necessary to call this if the current platform is not a browser.
3225
- *
3226
- * @param document The object representing the global `document` in this environment.
3227
- */
3228
- function setDocument(document) {
3229
- DOCUMENT = document;
3230
- }
3231
- /**
3232
- * Access the object that represents the `document` for this platform.
3233
- *
3234
- * Ivy calls this whenever it needs to access the `document` object.
3235
- * For example to create the renderer or to do sanitization.
3236
- */
3237
- function getDocument() {
3238
- if (DOCUMENT !== undefined) {
3239
- return DOCUMENT;
3240
- }
3241
- else if (typeof document !== 'undefined') {
3242
- return document;
3243
- }
3244
- // No "document" can be found. This should only happen if we are running ivy outside Angular and
3245
- // the current platform is not a browser. Since this is not a supported scenario at the moment
3246
- // this should not happen in Angular apps.
3247
- // Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
3248
- // public API. Meanwhile we just return `undefined` and let the application fail.
3249
- return undefined;
3250
- }
3251
-
3252
- /**
3253
- * @license
3254
- * Copyright Google LLC All Rights Reserved.
3255
- *
3256
- * Use of this source code is governed by an MIT-style license that can be
3257
- * found in the LICENSE file at https://angular.io/license
3258
- */
3259
- // TODO: cleanup once the code is merged in angular/angular
3260
- var RendererStyleFlags3;
3261
- (function (RendererStyleFlags3) {
3262
- RendererStyleFlags3[RendererStyleFlags3["Important"] = 1] = "Important";
3263
- RendererStyleFlags3[RendererStyleFlags3["DashCase"] = 2] = "DashCase";
3264
- })(RendererStyleFlags3 || (RendererStyleFlags3 = {}));
3265
- /** Returns whether the `renderer` is a `ProceduralRenderer3` */
3266
- function isProceduralRenderer(renderer) {
3267
- return !!(renderer.listen);
3268
- }
3269
- const domRendererFactory3 = {
3270
- createRenderer: (hostElement, rendererType) => {
3271
- return getDocument();
3272
- }
3273
- };
3274
- // Note: This hack is necessary so we don't erroneously get a circular dependency
3275
- // failure based on types.
3276
- const unusedValueExportToPlacateAjd$6 = 1;
3277
-
3278
3203
  /**
3279
3204
  * @license
3280
3205
  * Copyright Google LLC All Rights Reserved.
@@ -3357,7 +3282,6 @@ function getNativeByTNode(tNode, lView) {
3357
3282
  ngDevMode && assertTNodeForLView(tNode, lView);
3358
3283
  ngDevMode && assertIndexInRange(lView, tNode.index);
3359
3284
  const node = unwrapRNode(lView[tNode.index]);
3360
- ngDevMode && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
3361
3285
  return node;
3362
3286
  }
3363
3287
  /**
@@ -3373,7 +3297,6 @@ function getNativeByTNodeOrNull(tNode, lView) {
3373
3297
  if (index !== -1) {
3374
3298
  ngDevMode && assertTNodeForLView(tNode, lView);
3375
3299
  const node = unwrapRNode(lView[index]);
3376
- ngDevMode && node !== null && !isProceduralRenderer(lView[RENDERER]) && assertDomNode(node);
3377
3300
  return node;
3378
3301
  }
3379
3302
  return null;
@@ -4322,7 +4245,7 @@ function isFactory(obj) {
4322
4245
  }
4323
4246
  // Note: This hack is necessary so we don't erroneously get a circular dependency
4324
4247
  // failure based on types.
4325
- const unusedValueExportToPlacateAjd$5 = 1;
4248
+ const unusedValueExportToPlacateAjd$6 = 1;
4326
4249
 
4327
4250
  /**
4328
4251
  * Converts `TNodeType` into human readable text.
@@ -4341,7 +4264,7 @@ function toTNodeTypeAsString(tNodeType) {
4341
4264
  }
4342
4265
  // Note: This hack is necessary so we don't erroneously get a circular dependency
4343
4266
  // failure based on types.
4344
- const unusedValueExportToPlacateAjd$4 = 1;
4267
+ const unusedValueExportToPlacateAjd$5 = 1;
4345
4268
  /**
4346
4269
  * Returns `true` if the `TNode` has a directive which has `@Input()` for `class` binding.
4347
4270
  *
@@ -4445,7 +4368,6 @@ function assertPureTNodeType(type) {
4445
4368
  * @returns the index value that was last accessed in the attributes array
4446
4369
  */
4447
4370
  function setUpAttributes(renderer, native, attrs) {
4448
- const isProc = isProceduralRenderer(renderer);
4449
4371
  let i = 0;
4450
4372
  while (i < attrs.length) {
4451
4373
  const value = attrs[i];
@@ -4462,9 +4384,7 @@ function setUpAttributes(renderer, native, attrs) {
4462
4384
  const attrName = attrs[i++];
4463
4385
  const attrVal = attrs[i++];
4464
4386
  ngDevMode && ngDevMode.rendererSetAttribute++;
4465
- isProc ?
4466
- renderer.setAttribute(native, attrName, attrVal, namespaceURI) :
4467
- native.setAttributeNS(namespaceURI, attrName, attrVal);
4387
+ renderer.setAttribute(native, attrName, attrVal, namespaceURI);
4468
4388
  }
4469
4389
  else {
4470
4390
  // attrName is string;
@@ -4473,14 +4393,10 @@ function setUpAttributes(renderer, native, attrs) {
4473
4393
  // Standard attributes
4474
4394
  ngDevMode && ngDevMode.rendererSetAttribute++;
4475
4395
  if (isAnimationProp(attrName)) {
4476
- if (isProc) {
4477
- renderer.setProperty(native, attrName, attrVal);
4478
- }
4396
+ renderer.setProperty(native, attrName, attrVal);
4479
4397
  }
4480
4398
  else {
4481
- isProc ?
4482
- renderer.setAttribute(native, attrName, attrVal) :
4483
- native.setAttribute(attrName, attrVal);
4399
+ renderer.setAttribute(native, attrName, attrVal);
4484
4400
  }
4485
4401
  i++;
4486
4402
  }
@@ -5482,7 +5398,7 @@ function reflectDependency(dep) {
5482
5398
  }
5483
5399
  else if (param instanceof Attribute) {
5484
5400
  if (param.attributeName === undefined) {
5485
- throw new Error(`Attribute name must be defined.`);
5401
+ throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, ngDevMode && `Attribute name must be defined.`);
5486
5402
  }
5487
5403
  meta.attribute = param.attributeName;
5488
5404
  }
@@ -5622,42 +5538,97 @@ function maybeUnwrapFn$1(value) {
5622
5538
  * found in the LICENSE file at https://angular.io/license
5623
5539
  */
5624
5540
  /**
5625
- * The Trusted Types policy, or null if Trusted Types are not
5626
- * enabled/supported, or undefined if the policy has not been created yet.
5541
+ * Most of the use of `document` in Angular is from within the DI system so it is possible to simply
5542
+ * inject the `DOCUMENT` token and are done.
5543
+ *
5544
+ * Ivy is special because it does not rely upon the DI and must get hold of the document some other
5545
+ * way.
5546
+ *
5547
+ * The solution is to define `getDocument()` and `setDocument()` top-level functions for ivy.
5548
+ * Wherever ivy needs the global document, it calls `getDocument()` instead.
5549
+ *
5550
+ * When running ivy outside of a browser environment, it is necessary to call `setDocument()` to
5551
+ * tell ivy what the global `document` is.
5552
+ *
5553
+ * Angular does this for us in each of the standard platforms (`Browser`, `Server`, and `WebWorker`)
5554
+ * by calling `setDocument()` when providing the `DOCUMENT` token.
5627
5555
  */
5628
- let policy$1;
5556
+ let DOCUMENT = undefined;
5629
5557
  /**
5630
- * Returns the Trusted Types policy, or null if Trusted Types are not
5631
- * enabled/supported. The first call to this function will create the policy.
5558
+ * Tell ivy what the `document` is for this platform.
5559
+ *
5560
+ * It is only necessary to call this if the current platform is not a browser.
5561
+ *
5562
+ * @param document The object representing the global `document` in this environment.
5632
5563
  */
5633
- function getPolicy$1() {
5634
- if (policy$1 === undefined) {
5635
- policy$1 = null;
5636
- if (_global$1.trustedTypes) {
5637
- try {
5638
- policy$1 = _global$1.trustedTypes.createPolicy('angular', {
5639
- createHTML: (s) => s,
5640
- createScript: (s) => s,
5641
- createScriptURL: (s) => s,
5642
- });
5643
- }
5644
- catch {
5645
- // trustedTypes.createPolicy throws if called with a name that is
5646
- // already registered, even in report-only mode. Until the API changes,
5647
- // catch the error not to break the applications functionally. In such
5648
- // cases, the code will fall back to using strings.
5649
- }
5650
- }
5651
- }
5652
- return policy$1;
5564
+ function setDocument(document) {
5565
+ DOCUMENT = document;
5653
5566
  }
5654
5567
  /**
5655
- * Unsafely promote a string to a TrustedHTML, falling back to strings when
5656
- * Trusted Types are not available.
5657
- * @security This is a security-sensitive function; any use of this function
5658
- * must go through security review. In particular, it must be assured that the
5659
- * provided string will never cause an XSS vulnerability if used in a context
5660
- * that will be interpreted as HTML by a browser, e.g. when assigning to
5568
+ * Access the object that represents the `document` for this platform.
5569
+ *
5570
+ * Ivy calls this whenever it needs to access the `document` object.
5571
+ * For example to create the renderer or to do sanitization.
5572
+ */
5573
+ function getDocument() {
5574
+ if (DOCUMENT !== undefined) {
5575
+ return DOCUMENT;
5576
+ }
5577
+ else if (typeof document !== 'undefined') {
5578
+ return document;
5579
+ }
5580
+ // No "document" can be found. This should only happen if we are running ivy outside Angular and
5581
+ // the current platform is not a browser. Since this is not a supported scenario at the moment
5582
+ // this should not happen in Angular apps.
5583
+ // Once we support running ivy outside of Angular we will need to publish `setDocument()` as a
5584
+ // public API. Meanwhile we just return `undefined` and let the application fail.
5585
+ return undefined;
5586
+ }
5587
+
5588
+ /**
5589
+ * @license
5590
+ * Copyright Google LLC All Rights Reserved.
5591
+ *
5592
+ * Use of this source code is governed by an MIT-style license that can be
5593
+ * found in the LICENSE file at https://angular.io/license
5594
+ */
5595
+ /**
5596
+ * The Trusted Types policy, or null if Trusted Types are not
5597
+ * enabled/supported, or undefined if the policy has not been created yet.
5598
+ */
5599
+ let policy$1;
5600
+ /**
5601
+ * Returns the Trusted Types policy, or null if Trusted Types are not
5602
+ * enabled/supported. The first call to this function will create the policy.
5603
+ */
5604
+ function getPolicy$1() {
5605
+ if (policy$1 === undefined) {
5606
+ policy$1 = null;
5607
+ if (_global$1.trustedTypes) {
5608
+ try {
5609
+ policy$1 = _global$1.trustedTypes.createPolicy('angular', {
5610
+ createHTML: (s) => s,
5611
+ createScript: (s) => s,
5612
+ createScriptURL: (s) => s,
5613
+ });
5614
+ }
5615
+ catch {
5616
+ // trustedTypes.createPolicy throws if called with a name that is
5617
+ // already registered, even in report-only mode. Until the API changes,
5618
+ // catch the error not to break the applications functionally. In such
5619
+ // cases, the code will fall back to using strings.
5620
+ }
5621
+ }
5622
+ }
5623
+ return policy$1;
5624
+ }
5625
+ /**
5626
+ * Unsafely promote a string to a TrustedHTML, falling back to strings when
5627
+ * Trusted Types are not available.
5628
+ * @security This is a security-sensitive function; any use of this function
5629
+ * must go through security review. In particular, it must be assured that the
5630
+ * provided string will never cause an XSS vulnerability if used in a context
5631
+ * that will be interpreted as HTML by a browser, e.g. when assigning to
5661
5632
  * element.innerHTML.
5662
5633
  */
5663
5634
  function trustedHTMLFromString(html) {
@@ -7283,6 +7254,17 @@ function ensureIcuContainerVisitorLoaded(loader) {
7283
7254
  }
7284
7255
  }
7285
7256
 
7257
+ /**
7258
+ * @license
7259
+ * Copyright Google LLC All Rights Reserved.
7260
+ *
7261
+ * Use of this source code is governed by an MIT-style license that can be
7262
+ * found in the LICENSE file at https://angular.io/license
7263
+ */
7264
+ // Note: This hack is necessary so we don't erroneously get a circular dependency
7265
+ // failure based on types.
7266
+ const unusedValueExportToPlacateAjd$4 = 1;
7267
+
7286
7268
  /**
7287
7269
  * @license
7288
7270
  * Copyright Google LLC All Rights Reserved.
@@ -7365,7 +7347,7 @@ function getNearestLContainer(viewOrContainer) {
7365
7347
  * Use of this source code is governed by an MIT-style license that can be
7366
7348
  * found in the LICENSE file at https://angular.io/license
7367
7349
  */
7368
- const unusedValueToPlacateAjd$2 = unusedValueExportToPlacateAjd$7 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$8;
7350
+ const unusedValueToPlacateAjd$2 = unusedValueExportToPlacateAjd$7 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3 + unusedValueExportToPlacateAjd$8;
7369
7351
  /**
7370
7352
  * NOTE: for performance reasons, the possible actions are inlined within the function instead of
7371
7353
  * being passed as an argument.
@@ -7390,7 +7372,6 @@ function applyToElementOrContainer(action, renderer, parent, lNodeToHandle, befo
7390
7372
  lNodeToHandle = lNodeToHandle[HOST];
7391
7373
  }
7392
7374
  const rNode = unwrapRNode(lNodeToHandle);
7393
- ngDevMode && !isProceduralRenderer(renderer) && assertDomNode(rNode);
7394
7375
  if (action === 0 /* WalkTNodeTreeAction.Create */ && parent !== null) {
7395
7376
  if (beforeNode == null) {
7396
7377
  nativeAppendChild(renderer, parent, rNode);
@@ -7417,17 +7398,14 @@ function applyToElementOrContainer(action, renderer, parent, lNodeToHandle, befo
7417
7398
  function createTextNode(renderer, value) {
7418
7399
  ngDevMode && ngDevMode.rendererCreateTextNode++;
7419
7400
  ngDevMode && ngDevMode.rendererSetText++;
7420
- return isProceduralRenderer(renderer) ? renderer.createText(value) :
7421
- renderer.createTextNode(value);
7401
+ return renderer.createText(value);
7422
7402
  }
7423
7403
  function updateTextNode(renderer, rNode, value) {
7424
7404
  ngDevMode && ngDevMode.rendererSetText++;
7425
- isProceduralRenderer(renderer) ? renderer.setValue(rNode, value) : rNode.textContent = value;
7405
+ renderer.setValue(rNode, value);
7426
7406
  }
7427
7407
  function createCommentNode(renderer, value) {
7428
7408
  ngDevMode && ngDevMode.rendererCreateComment++;
7429
- // isProceduralRenderer check is not needed because both `Renderer2` and `Renderer3` have the same
7430
- // method name.
7431
7409
  return renderer.createComment(escapeCommentText(value));
7432
7410
  }
7433
7411
  /**
@@ -7439,14 +7417,7 @@ function createCommentNode(renderer, value) {
7439
7417
  */
7440
7418
  function createElementNode(renderer, name, namespace) {
7441
7419
  ngDevMode && ngDevMode.rendererCreateElement++;
7442
- if (isProceduralRenderer(renderer)) {
7443
- return renderer.createElement(name, namespace);
7444
- }
7445
- else {
7446
- const namespaceUri = namespace !== null ? getNamespaceUri(namespace) : null;
7447
- return namespaceUri === null ? renderer.createElement(name) :
7448
- renderer.createElementNS(namespaceUri, name);
7449
- }
7420
+ return renderer.createElement(name, namespace);
7450
7421
  }
7451
7422
  /**
7452
7423
  * Removes all DOM elements associated with a view.
@@ -7678,7 +7649,7 @@ function detachView(lContainer, removeIndex) {
7678
7649
  function destroyLView(tView, lView) {
7679
7650
  if (!(lView[FLAGS] & 128 /* LViewFlags.Destroyed */)) {
7680
7651
  const renderer = lView[RENDERER];
7681
- if (isProceduralRenderer(renderer) && renderer.destroyNode) {
7652
+ if (renderer.destroyNode) {
7682
7653
  applyView(tView, lView, renderer, 3 /* WalkTNodeTreeAction.Destroy */, null, null);
7683
7654
  }
7684
7655
  destroyViewTree(lView);
@@ -7706,7 +7677,7 @@ function cleanUpView(tView, lView) {
7706
7677
  executeOnDestroys(tView, lView);
7707
7678
  processCleanups(tView, lView);
7708
7679
  // For component views only, the local renderer is destroyed at clean up time.
7709
- if (lView[TVIEW].type === 1 /* TViewType.Component */ && isProceduralRenderer(lView[RENDERER])) {
7680
+ if (lView[TVIEW].type === 1 /* TViewType.Component */) {
7710
7681
  ngDevMode && ngDevMode.rendererDestroy++;
7711
7682
  lView[RENDERER].destroy();
7712
7683
  }
@@ -7882,30 +7853,17 @@ function getClosestRElement(tView, tNode, lView) {
7882
7853
  }
7883
7854
  }
7884
7855
  /**
7885
- * Inserts a native node before another native node for a given parent using {@link Renderer3}.
7886
- * This is a utility function that can be used when native nodes were determined - it abstracts an
7887
- * actual renderer being used.
7856
+ * Inserts a native node before another native node for a given parent.
7857
+ * This is a utility function that can be used when native nodes were determined.
7888
7858
  */
7889
7859
  function nativeInsertBefore(renderer, parent, child, beforeNode, isMove) {
7890
7860
  ngDevMode && ngDevMode.rendererInsertBefore++;
7891
- if (isProceduralRenderer(renderer)) {
7892
- renderer.insertBefore(parent, child, beforeNode, isMove);
7893
- }
7894
- else {
7895
- const targetParent = isTemplateNode(parent) ? parent.content : parent;
7896
- targetParent.insertBefore(child, beforeNode, isMove);
7897
- }
7861
+ renderer.insertBefore(parent, child, beforeNode, isMove);
7898
7862
  }
7899
7863
  function nativeAppendChild(renderer, parent, child) {
7900
7864
  ngDevMode && ngDevMode.rendererAppendChild++;
7901
7865
  ngDevMode && assertDefined(parent, 'parent node must be defined');
7902
- if (isProceduralRenderer(renderer)) {
7903
- renderer.appendChild(parent, child);
7904
- }
7905
- else {
7906
- const targetParent = isTemplateNode(parent) ? parent.content : parent;
7907
- targetParent.appendChild(child);
7908
- }
7866
+ renderer.appendChild(parent, child);
7909
7867
  }
7910
7868
  function nativeAppendOrInsertBefore(renderer, parent, child, beforeNode, isMove) {
7911
7869
  if (beforeNode !== null) {
@@ -7917,12 +7875,7 @@ function nativeAppendOrInsertBefore(renderer, parent, child, beforeNode, isMove)
7917
7875
  }
7918
7876
  /** Removes a node from the DOM given its native parent. */
7919
7877
  function nativeRemoveChild(renderer, parent, child, isHostElement) {
7920
- if (isProceduralRenderer(renderer)) {
7921
- renderer.removeChild(parent, child, isHostElement);
7922
- }
7923
- else {
7924
- parent.removeChild(child);
7925
- }
7878
+ renderer.removeChild(parent, child, isHostElement);
7926
7879
  }
7927
7880
  /** Checks if an element is a `<template>` node. */
7928
7881
  function isTemplateNode(node) {
@@ -7932,13 +7885,13 @@ function isTemplateNode(node) {
7932
7885
  * Returns a native parent of a given native node.
7933
7886
  */
7934
7887
  function nativeParentNode(renderer, node) {
7935
- return (isProceduralRenderer(renderer) ? renderer.parentNode(node) : node.parentNode);
7888
+ return renderer.parentNode(node);
7936
7889
  }
7937
7890
  /**
7938
7891
  * Returns a native sibling of a given native node.
7939
7892
  */
7940
7893
  function nativeNextSibling(renderer, node) {
7941
- return isProceduralRenderer(renderer) ? renderer.nextSibling(node) : node.nextSibling;
7894
+ return renderer.nextSibling(node);
7942
7895
  }
7943
7896
  /**
7944
7897
  * Find a node in front of which `currentTNode` should be inserted.
@@ -8247,39 +8200,22 @@ function applyContainer(renderer, action, lContainer, parentRElement, beforeNode
8247
8200
  * otherwise).
8248
8201
  */
8249
8202
  function applyStyling(renderer, isClassBased, rNode, prop, value) {
8250
- const isProcedural = isProceduralRenderer(renderer);
8251
8203
  if (isClassBased) {
8252
8204
  // We actually want JS true/false here because any truthy value should add the class
8253
8205
  if (!value) {
8254
8206
  ngDevMode && ngDevMode.rendererRemoveClass++;
8255
- if (isProcedural) {
8256
- renderer.removeClass(rNode, prop);
8257
- }
8258
- else {
8259
- rNode.classList.remove(prop);
8260
- }
8207
+ renderer.removeClass(rNode, prop);
8261
8208
  }
8262
8209
  else {
8263
8210
  ngDevMode && ngDevMode.rendererAddClass++;
8264
- if (isProcedural) {
8265
- renderer.addClass(rNode, prop);
8266
- }
8267
- else {
8268
- ngDevMode && assertDefined(rNode.classList, 'HTMLElement expected');
8269
- rNode.classList.add(prop);
8270
- }
8211
+ renderer.addClass(rNode, prop);
8271
8212
  }
8272
8213
  }
8273
8214
  else {
8274
8215
  let flags = prop.indexOf('-') === -1 ? undefined : RendererStyleFlags2.DashCase;
8275
8216
  if (value == null /** || value === undefined */) {
8276
8217
  ngDevMode && ngDevMode.rendererRemoveStyle++;
8277
- if (isProcedural) {
8278
- renderer.removeStyle(rNode, prop, flags);
8279
- }
8280
- else {
8281
- rNode.style.removeProperty(prop);
8282
- }
8218
+ renderer.removeStyle(rNode, prop, flags);
8283
8219
  }
8284
8220
  else {
8285
8221
  // A value is important if it ends with `!important`. The style
@@ -8291,13 +8227,7 @@ function applyStyling(renderer, isClassBased, rNode, prop, value) {
8291
8227
  flags |= RendererStyleFlags2.Important;
8292
8228
  }
8293
8229
  ngDevMode && ngDevMode.rendererSetStyle++;
8294
- if (isProcedural) {
8295
- renderer.setStyle(rNode, prop, value, flags);
8296
- }
8297
- else {
8298
- ngDevMode && assertDefined(rNode.style, 'HTMLElement expected');
8299
- rNode.style.setProperty(prop, value, isImportant ? 'important' : '');
8300
- }
8230
+ renderer.setStyle(rNode, prop, value, flags);
8301
8231
  }
8302
8232
  }
8303
8233
  }
@@ -8313,12 +8243,7 @@ function applyStyling(renderer, isClassBased, rNode, prop, value) {
8313
8243
  */
8314
8244
  function writeDirectStyle(renderer, element, newValue) {
8315
8245
  ngDevMode && assertString(newValue, '\'newValue\' should be a string');
8316
- if (isProceduralRenderer(renderer)) {
8317
- renderer.setAttribute(element, 'style', newValue);
8318
- }
8319
- else {
8320
- element.style.cssText = newValue;
8321
- }
8246
+ renderer.setAttribute(element, 'style', newValue);
8322
8247
  ngDevMode && ngDevMode.rendererSetStyle++;
8323
8248
  }
8324
8249
  /**
@@ -8333,17 +8258,12 @@ function writeDirectStyle(renderer, element, newValue) {
8333
8258
  */
8334
8259
  function writeDirectClass(renderer, element, newValue) {
8335
8260
  ngDevMode && assertString(newValue, '\'newValue\' should be a string');
8336
- if (isProceduralRenderer(renderer)) {
8337
- if (newValue === '') {
8338
- // There are tests in `google3` which expect `element.getAttribute('class')` to be `null`.
8339
- renderer.removeAttribute(element, 'class');
8340
- }
8341
- else {
8342
- renderer.setAttribute(element, 'class', newValue);
8343
- }
8261
+ if (newValue === '') {
8262
+ // There are tests in `google3` which expect `element.getAttribute('class')` to be `null`.
8263
+ renderer.removeAttribute(element, 'class');
8344
8264
  }
8345
8265
  else {
8346
- element.className = newValue;
8266
+ renderer.setAttribute(element, 'class', newValue);
8347
8267
  }
8348
8268
  ngDevMode && ngDevMode.rendererSetClassName++;
8349
8269
  }
@@ -8393,7 +8313,7 @@ function classIndexOf(className, classToSearch, startingIndex) {
8393
8313
  * Use of this source code is governed by an MIT-style license that can be
8394
8314
  * found in the LICENSE file at https://angular.io/license
8395
8315
  */
8396
- const unusedValueToPlacateAjd$1 = unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd$3;
8316
+ const unusedValueToPlacateAjd$1 = unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4;
8397
8317
  const NG_TEMPLATE_SELECTOR = 'ng-template';
8398
8318
  /**
8399
8319
  * Search the `TAttributes` to see if it contains `cssClassToMatch` (case insensitive)
@@ -9364,7 +9284,7 @@ function isClassProvider(value) {
9364
9284
  * @publicApi
9365
9285
  */
9366
9286
  const INJECTOR = new InjectionToken('INJECTOR',
9367
- // Dissable tslint because this is const enum which gets inlined not top level prop access.
9287
+ // Disable tslint because this is const enum which gets inlined not top level prop access.
9368
9288
  // tslint:disable-next-line: no-toplevel-property-access
9369
9289
  -1 /* InjectorMarkers.Injector */);
9370
9290
 
@@ -9508,6 +9428,18 @@ class R3Injector extends EnvironmentInjector {
9508
9428
  onDestroy(callback) {
9509
9429
  this._onDestroyHooks.push(callback);
9510
9430
  }
9431
+ runInContext(fn) {
9432
+ this.assertNotDestroyed();
9433
+ const previousInjector = setCurrentInjector(this);
9434
+ const previousInjectImplementation = setInjectImplementation(undefined);
9435
+ try {
9436
+ return fn();
9437
+ }
9438
+ finally {
9439
+ setCurrentInjector(previousInjector);
9440
+ setInjectImplementation(previousInjectImplementation);
9441
+ }
9442
+ }
9511
9443
  get(token, notFoundValue = THROW_IF_NOT_FOUND, flags = InjectFlags.Default) {
9512
9444
  this.assertNotDestroyed();
9513
9445
  // Set the injection context.
@@ -10118,7 +10050,7 @@ class ReflectiveKey {
10118
10050
  this.token = token;
10119
10051
  this.id = id;
10120
10052
  if (!token) {
10121
- throw new Error('Token must be defined!');
10053
+ throw new RuntimeError(208 /* RuntimeErrorCode.MISSING_INJECTION_TOKEN */, ngDevMode && 'Token must be defined!');
10122
10054
  }
10123
10055
  this.displayName = stringify(this.token);
10124
10056
  }
@@ -10922,6 +10854,9 @@ function handleUnknownPropertyError(propName, tagName, nodeType, lView) {
10922
10854
  `the ${schemas} of this component.`;
10923
10855
  }
10924
10856
  }
10857
+ reportUnknownPropertyError(message);
10858
+ }
10859
+ function reportUnknownPropertyError(message) {
10925
10860
  if (shouldThrowErrorOnUnknownProperty) {
10926
10861
  throw new RuntimeError(303 /* RuntimeErrorCode.UNKNOWN_BINDING */, message);
10927
10862
  }
@@ -11808,6 +11743,13 @@ class LContainerDebug {
11808
11743
  }
11809
11744
  }
11810
11745
 
11746
+ /**
11747
+ * @license
11748
+ * Copyright Google LLC All Rights Reserved.
11749
+ *
11750
+ * Use of this source code is governed by an MIT-style license that can be
11751
+ * found in the LICENSE file at https://angular.io/license
11752
+ */
11811
11753
  /**
11812
11754
  * A permanent marker promise which signifies that the current CD tree is
11813
11755
  * clean.
@@ -11875,7 +11817,7 @@ function refreshChildComponents(hostLView, components) {
11875
11817
  /** Renders child components in the current view (creation mode). */
11876
11818
  function renderChildComponents(hostLView, components) {
11877
11819
  for (let i = 0; i < components.length; i++) {
11878
- renderComponent$1(hostLView, components[i]);
11820
+ renderComponent(hostLView, components[i]);
11879
11821
  }
11880
11822
  }
11881
11823
  function createLView(parentLView, tView, context, flags, host, tHostNode, rendererFactory, renderer, sanitizer, injector, embeddedViewInjector) {
@@ -12393,16 +12335,6 @@ function createViewBlueprint(bindingStartIndex, initialViewLength) {
12393
12335
  function createError(text, token) {
12394
12336
  return new Error(`Renderer: ${text} [${stringifyForError(token)}]`);
12395
12337
  }
12396
- function assertHostNodeExists(rElement, elementOrSelector) {
12397
- if (!rElement) {
12398
- if (typeof elementOrSelector === 'string') {
12399
- throw createError('Host node with selector not found:', elementOrSelector);
12400
- }
12401
- else {
12402
- throw createError('Host node is required:', elementOrSelector);
12403
- }
12404
- }
12405
- }
12406
12338
  /**
12407
12339
  * Locates the host native element, used for bootstrapping existing nodes into rendering pipeline.
12408
12340
  *
@@ -12411,21 +12343,9 @@ function assertHostNodeExists(rElement, elementOrSelector) {
12411
12343
  * @param encapsulation View Encapsulation defined for component that requests host element.
12412
12344
  */
12413
12345
  function locateHostElement(renderer, elementOrSelector, encapsulation) {
12414
- if (isProceduralRenderer(renderer)) {
12415
- // When using native Shadow DOM, do not clear host element to allow native slot projection
12416
- const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
12417
- return renderer.selectRootElement(elementOrSelector, preserveContent);
12418
- }
12419
- let rElement = typeof elementOrSelector === 'string' ?
12420
- renderer.querySelector(elementOrSelector) :
12421
- elementOrSelector;
12422
- ngDevMode && assertHostNodeExists(rElement, elementOrSelector);
12423
- // Always clear host element's content when Renderer3 is in use. For procedural renderer case we
12424
- // make it depend on whether ShadowDom encapsulation is used (in which case the content should be
12425
- // preserved to allow native slot projection). ShadowDom encapsulation requires procedural
12426
- // renderer, and procedural renderer case is handled above.
12427
- rElement.textContent = '';
12428
- return rElement;
12346
+ // When using native Shadow DOM, do not clear host element to allow native slot projection
12347
+ const preserveContent = encapsulation === ViewEncapsulation.ShadowDom;
12348
+ return renderer.selectRootElement(elementOrSelector, preserveContent);
12429
12349
  }
12430
12350
  /**
12431
12351
  * Saves context for this cleanup function in LView.cleanupInstances.
@@ -12640,13 +12560,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
12640
12560
  // It is assumed that the sanitizer is only added when the compiler determines that the
12641
12561
  // property is risky, so sanitization can be done without further checks.
12642
12562
  value = sanitizer != null ? sanitizer(value, tNode.value || '', propName) : value;
12643
- if (isProceduralRenderer(renderer)) {
12644
- renderer.setProperty(element, propName, value);
12645
- }
12646
- else if (!isAnimationProp(propName)) {
12647
- element.setProperty ? element.setProperty(propName, value) :
12648
- element[propName] = value;
12649
- }
12563
+ renderer.setProperty(element, propName, value);
12650
12564
  }
12651
12565
  else if (tNode.type & 12 /* TNodeType.AnyContainer */) {
12652
12566
  // If the node is a container and the property didn't
@@ -12670,23 +12584,15 @@ function setNgReflectProperty(lView, element, type, attrName, value) {
12670
12584
  const debugValue = normalizeDebugBindingValue(value);
12671
12585
  if (type & 3 /* TNodeType.AnyRNode */) {
12672
12586
  if (value == null) {
12673
- isProceduralRenderer(renderer) ? renderer.removeAttribute(element, attrName) :
12674
- element.removeAttribute(attrName);
12587
+ renderer.removeAttribute(element, attrName);
12675
12588
  }
12676
12589
  else {
12677
- isProceduralRenderer(renderer) ?
12678
- renderer.setAttribute(element, attrName, debugValue) :
12679
- element.setAttribute(attrName, debugValue);
12590
+ renderer.setAttribute(element, attrName, debugValue);
12680
12591
  }
12681
12592
  }
12682
12593
  else {
12683
12594
  const textContent = escapeCommentText(`bindings=${JSON.stringify({ [attrName]: debugValue }, null, 2)}`);
12684
- if (isProceduralRenderer(renderer)) {
12685
- renderer.setValue(element, textContent);
12686
- }
12687
- else {
12688
- element.textContent = textContent;
12689
- }
12595
+ renderer.setValue(element, textContent);
12690
12596
  }
12691
12597
  }
12692
12598
  function setNgReflectProperties(lView, element, type, dataValue, value) {
@@ -12716,6 +12622,7 @@ function instantiateRootComponent(tView, lView, def) {
12716
12622
  ngDevMode &&
12717
12623
  assertEqual(directiveIndex, rootTNode.directiveStart, 'Because this is a root component the allocated expando should match the TNode component.');
12718
12624
  configureViewWithDirective(tView, rootTNode, lView, directiveIndex, def);
12625
+ initializeInputAndOutputAliases(tView, rootTNode);
12719
12626
  }
12720
12627
  const directive = getNodeInjectable(lView, tView, rootTNode.directiveStart, rootTNode);
12721
12628
  attachPatchData(directive, lView);
@@ -13040,19 +12947,12 @@ function elementAttributeInternal(tNode, lView, name, value, sanitizer, namespac
13040
12947
  function setElementAttribute(renderer, element, namespace, tagName, name, value, sanitizer) {
13041
12948
  if (value == null) {
13042
12949
  ngDevMode && ngDevMode.rendererRemoveAttribute++;
13043
- isProceduralRenderer(renderer) ? renderer.removeAttribute(element, name, namespace) :
13044
- element.removeAttribute(name);
12950
+ renderer.removeAttribute(element, name, namespace);
13045
12951
  }
13046
12952
  else {
13047
12953
  ngDevMode && ngDevMode.rendererSetAttribute++;
13048
12954
  const strValue = sanitizer == null ? renderStringify(value) : sanitizer(value, tagName || '', name);
13049
- if (isProceduralRenderer(renderer)) {
13050
- renderer.setAttribute(element, name, strValue, namespace);
13051
- }
13052
- else {
13053
- namespace ? element.setAttributeNS(namespace, name, strValue) :
13054
- element.setAttribute(name, strValue);
13055
- }
12955
+ renderer.setAttribute(element, name, strValue, namespace);
13056
12956
  }
13057
12957
  }
13058
12958
  /**
@@ -13144,7 +13044,6 @@ const LContainerArray = class LContainer extends Array {
13144
13044
  */
13145
13045
  function createLContainer(hostNative, currentView, native, tNode) {
13146
13046
  ngDevMode && assertLView(currentView);
13147
- ngDevMode && !isProceduralRenderer(currentView[RENDERER]) && assertDomNode(native);
13148
13047
  // https://jsperf.com/array-literal-vs-new-array-really
13149
13048
  const lContainer = new (ngDevMode ? LContainerArray : Array)(hostNative, // host native
13150
13049
  true, // Boolean `true` in this position signifies that this is an `LContainer`
@@ -13260,7 +13159,7 @@ function refreshContainsDirtyView(lView) {
13260
13159
  }
13261
13160
  }
13262
13161
  }
13263
- function renderComponent$1(hostLView, componentHostIdx) {
13162
+ function renderComponent(hostLView, componentHostIdx) {
13264
13163
  ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
13265
13164
  const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
13266
13165
  const componentTView = componentView[TVIEW];
@@ -13612,723 +13511,119 @@ function computeStaticStyling(tNode, attrs, writeToHost) {
13612
13511
  * Use of this source code is governed by an MIT-style license that can be
13613
13512
  * found in the LICENSE file at https://angular.io/license
13614
13513
  */
13514
+ // TODO: A hack to not pull in the NullInjector from @angular/core.
13515
+ const NULL_INJECTOR = {
13516
+ get: (token, notFoundValue) => {
13517
+ throwProviderNotFoundError(token, 'NullInjector');
13518
+ }
13519
+ };
13615
13520
  /**
13616
- * Synchronously perform change detection on a component (and possibly its sub-components).
13521
+ * Creates the root component view and the root component node.
13617
13522
  *
13618
- * This function triggers change detection in a synchronous way on a component.
13523
+ * @param rNode Render host element.
13524
+ * @param def ComponentDef
13525
+ * @param rootView The parent view where the host node is stored
13526
+ * @param rendererFactory Factory to be used for creating child renderers.
13527
+ * @param hostRenderer The current renderer
13528
+ * @param sanitizer The sanitizer, if provided
13619
13529
  *
13620
- * @param component The component which the change detection should be performed on.
13530
+ * @returns Component view created
13621
13531
  */
13622
- function detectChanges(component) {
13623
- const view = getComponentViewByInstance(component);
13624
- detectChangesInternal(view[TVIEW], view, component);
13532
+ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
13533
+ const tView = rootView[TVIEW];
13534
+ const index = HEADER_OFFSET;
13535
+ ngDevMode && assertIndexInRange(rootView, index);
13536
+ rootView[index] = rNode;
13537
+ // '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
13538
+ // the same time we want to communicate the debug `TNode` that this is a special `TNode`
13539
+ // representing a host element.
13540
+ const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
13541
+ const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
13542
+ if (mergedAttrs !== null) {
13543
+ computeStaticStyling(tNode, mergedAttrs, true);
13544
+ if (rNode !== null) {
13545
+ setUpAttributes(hostRenderer, rNode, mergedAttrs);
13546
+ if (tNode.classes !== null) {
13547
+ writeDirectClass(hostRenderer, rNode, tNode.classes);
13548
+ }
13549
+ if (tNode.styles !== null) {
13550
+ writeDirectStyle(hostRenderer, rNode, tNode.styles);
13551
+ }
13552
+ }
13553
+ }
13554
+ const viewRenderer = rendererFactory.createRenderer(rNode, def);
13555
+ const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
13556
+ if (tView.firstCreatePass) {
13557
+ diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
13558
+ markAsComponentHost(tView, tNode);
13559
+ initTNodeFlags(tNode, rootView.length, 1);
13560
+ }
13561
+ addToViewTree(rootView, componentView);
13562
+ // Store component view at node index, with node as the HOST
13563
+ return rootView[index] = componentView;
13625
13564
  }
13626
13565
  /**
13627
- * Marks the component as dirty (needing change detection). Marking a component dirty will
13628
- * schedule a change detection on it at some point in the future.
13629
- *
13630
- * Marking an already dirty component as dirty won't do anything. Only one outstanding change
13631
- * detection can be scheduled per component tree.
13632
- *
13633
- * @param component Component to mark as dirty.
13566
+ * Creates a root component and sets it up with features and host bindings. Shared by
13567
+ * renderComponent() and ViewContainerRef.createComponent().
13634
13568
  */
13635
- function markDirty(component) {
13636
- ngDevMode && assertDefined(component, 'component');
13637
- const rootView = markViewDirty(getComponentViewByInstance(component));
13638
- ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
13639
- scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
13569
+ function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
13570
+ const tView = rootLView[TVIEW];
13571
+ // Create directive instance with factory() and store at next index in viewData
13572
+ const component = instantiateRootComponent(tView, rootLView, componentDef);
13573
+ rootContext.components.push(component);
13574
+ componentView[CONTEXT] = component;
13575
+ if (hostFeatures !== null) {
13576
+ for (const feature of hostFeatures) {
13577
+ feature(component, componentDef);
13578
+ }
13579
+ }
13580
+ // We want to generate an empty QueryList for root content queries for backwards
13581
+ // compatibility with ViewEngine.
13582
+ if (componentDef.contentQueries) {
13583
+ const tNode = getCurrentTNode();
13584
+ ngDevMode && assertDefined(tNode, 'TNode expected');
13585
+ componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
13586
+ }
13587
+ const rootTNode = getCurrentTNode();
13588
+ ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
13589
+ if (tView.firstCreatePass &&
13590
+ (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
13591
+ setSelectedIndex(rootTNode.index);
13592
+ const rootTView = rootLView[TVIEW];
13593
+ registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
13594
+ invokeHostBindingsInCreationMode(componentDef, component);
13595
+ }
13596
+ return component;
13597
+ }
13598
+ function createRootContext(scheduler, playerHandler) {
13599
+ return {
13600
+ components: [],
13601
+ scheduler: scheduler || defaultScheduler,
13602
+ clean: CLEAN_PROMISE,
13603
+ playerHandler: playerHandler || null,
13604
+ flags: 0 /* RootContextFlags.Empty */
13605
+ };
13640
13606
  }
13641
13607
  /**
13642
- * Used to perform change detection on the whole application.
13608
+ * Used to enable lifecycle hooks on the root component.
13643
13609
  *
13644
- * This is equivalent to `detectChanges`, but invoked on root component. Additionally, `tick`
13645
- * executes lifecycle hooks and conditionally checks components based on their
13646
- * `ChangeDetectionStrategy` and dirtiness.
13610
+ * Include this feature when calling `renderComponent` if the root component
13611
+ * you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
13612
+ * be called properly.
13613
+ *
13614
+ * Example:
13647
13615
  *
13648
- * The preferred way to trigger change detection is to call `markDirty`. `markDirty` internally
13649
- * schedules `tick` using a scheduler in order to coalesce multiple `markDirty` calls into a
13650
- * single change detection run. By default, the scheduler is `requestAnimationFrame`, but can
13651
- * be changed when calling `renderComponent` and providing the `scheduler` option.
13616
+ * ```
13617
+ * renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
13618
+ * ```
13652
13619
  */
13653
- function tick(component) {
13654
- const rootView = getRootView(component);
13655
- const rootContext = rootView[CONTEXT];
13656
- tickRootContext(rootContext);
13620
+ function LifecycleHooksFeature() {
13621
+ const tNode = getCurrentTNode();
13622
+ ngDevMode && assertDefined(tNode, 'TNode is required');
13623
+ registerPostOrderHooks(getLView()[TVIEW], tNode);
13657
13624
  }
13658
-
13659
13625
  /**
13660
- * @license
13661
- * Copyright Google LLC All Rights Reserved.
13662
- *
13663
- * Use of this source code is governed by an MIT-style license that can be
13664
- * found in the LICENSE file at https://angular.io/license
13665
- */
13666
- /**
13667
- * Retrieves the component instance associated with a given DOM element.
13668
- *
13669
- * @usageNotes
13670
- * Given the following DOM structure:
13671
- *
13672
- * ```html
13673
- * <app-root>
13674
- * <div>
13675
- * <child-comp></child-comp>
13676
- * </div>
13677
- * </app-root>
13678
- * ```
13679
- *
13680
- * Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
13681
- * associated with this DOM element.
13682
- *
13683
- * Calling the function on `<app-root>` will return the `MyApp` instance.
13684
- *
13685
- *
13686
- * @param element DOM element from which the component should be retrieved.
13687
- * @returns Component instance associated with the element or `null` if there
13688
- * is no component associated with it.
13689
- *
13690
- * @publicApi
13691
- * @globalApi ng
13692
- */
13693
- function getComponent$1(element) {
13694
- ngDevMode && assertDomElement(element);
13695
- const context = getLContext(element);
13696
- if (context === null)
13697
- return null;
13698
- if (context.component === undefined) {
13699
- const lView = context.lView;
13700
- if (lView === null) {
13701
- return null;
13702
- }
13703
- context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
13704
- }
13705
- return context.component;
13706
- }
13707
- /**
13708
- * If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
13709
- * view that the element is part of. Otherwise retrieves the instance of the component whose view
13710
- * owns the element (in this case, the result is the same as calling `getOwningComponent`).
13711
- *
13712
- * @param element Element for which to get the surrounding component instance.
13713
- * @returns Instance of the component that is around the element or null if the element isn't
13714
- * inside any component.
13715
- *
13716
- * @publicApi
13717
- * @globalApi ng
13718
- */
13719
- function getContext(element) {
13720
- assertDomElement(element);
13721
- const context = getLContext(element);
13722
- const lView = context ? context.lView : null;
13723
- return lView === null ? null : lView[CONTEXT];
13724
- }
13725
- /**
13726
- * Retrieves the component instance whose view contains the DOM element.
13727
- *
13728
- * For example, if `<child-comp>` is used in the template of `<app-comp>`
13729
- * (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
13730
- * would return `<app-comp>`.
13731
- *
13732
- * @param elementOrDir DOM element, component or directive instance
13733
- * for which to retrieve the root components.
13734
- * @returns Component instance whose view owns the DOM element or null if the element is not
13735
- * part of a component view.
13736
- *
13737
- * @publicApi
13738
- * @globalApi ng
13739
- */
13740
- function getOwningComponent(elementOrDir) {
13741
- const context = getLContext(elementOrDir);
13742
- let lView = context ? context.lView : null;
13743
- if (lView === null)
13744
- return null;
13745
- let parent;
13746
- while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
13747
- lView = parent;
13748
- }
13749
- return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
13750
- }
13751
- /**
13752
- * Retrieves all root components associated with a DOM element, directive or component instance.
13753
- * Root components are those which have been bootstrapped by Angular.
13754
- *
13755
- * @param elementOrDir DOM element, component or directive instance
13756
- * for which to retrieve the root components.
13757
- * @returns Root components associated with the target object.
13758
- *
13759
- * @publicApi
13760
- * @globalApi ng
13761
- */
13762
- function getRootComponents(elementOrDir) {
13763
- const lView = readPatchedLView(elementOrDir);
13764
- return lView !== null ? [...getRootContext(lView).components] : [];
13765
- }
13766
- /**
13767
- * Retrieves an `Injector` associated with an element, component or directive instance.
13768
- *
13769
- * @param elementOrDir DOM element, component or directive instance for which to
13770
- * retrieve the injector.
13771
- * @returns Injector associated with the element, component or directive instance.
13772
- *
13773
- * @publicApi
13774
- * @globalApi ng
13775
- */
13776
- function getInjector(elementOrDir) {
13777
- const context = getLContext(elementOrDir);
13778
- const lView = context ? context.lView : null;
13779
- if (lView === null)
13780
- return Injector.NULL;
13781
- const tNode = lView[TVIEW].data[context.nodeIndex];
13782
- return new NodeInjector(tNode, lView);
13783
- }
13784
- /**
13785
- * Retrieve a set of injection tokens at a given DOM node.
13786
- *
13787
- * @param element Element for which the injection tokens should be retrieved.
13788
- */
13789
- function getInjectionTokens(element) {
13790
- const context = getLContext(element);
13791
- const lView = context ? context.lView : null;
13792
- if (lView === null)
13793
- return [];
13794
- const tView = lView[TVIEW];
13795
- const tNode = tView.data[context.nodeIndex];
13796
- const providerTokens = [];
13797
- const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
13798
- const endIndex = tNode.directiveEnd;
13799
- for (let i = startIndex; i < endIndex; i++) {
13800
- let value = tView.data[i];
13801
- if (isDirectiveDefHack(value)) {
13802
- // The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
13803
- // design flaw. We should always store same type so that we can be monomorphic. The issue
13804
- // is that for Components/Directives we store the def instead the type. The correct behavior
13805
- // is that we should always be storing injectable type in this location.
13806
- value = value.type;
13807
- }
13808
- providerTokens.push(value);
13809
- }
13810
- return providerTokens;
13811
- }
13812
- /**
13813
- * Retrieves directive instances associated with a given DOM node. Does not include
13814
- * component instances.
13815
- *
13816
- * @usageNotes
13817
- * Given the following DOM structure:
13818
- *
13819
- * ```html
13820
- * <app-root>
13821
- * <button my-button></button>
13822
- * <my-comp></my-comp>
13823
- * </app-root>
13824
- * ```
13825
- *
13826
- * Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
13827
- * directive that is associated with the DOM node.
13828
- *
13829
- * Calling `getDirectives` on `<my-comp>` will return an empty array.
13830
- *
13831
- * @param node DOM node for which to get the directives.
13832
- * @returns Array of directives associated with the node.
13833
- *
13834
- * @publicApi
13835
- * @globalApi ng
13836
- */
13837
- function getDirectives(node) {
13838
- // Skip text nodes because we can't have directives associated with them.
13839
- if (node instanceof Text) {
13840
- return [];
13841
- }
13842
- const context = getLContext(node);
13843
- const lView = context ? context.lView : null;
13844
- if (lView === null) {
13845
- return [];
13846
- }
13847
- const tView = lView[TVIEW];
13848
- const nodeIndex = context.nodeIndex;
13849
- if (!tView?.data[nodeIndex]) {
13850
- return [];
13851
- }
13852
- if (context.directives === undefined) {
13853
- context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
13854
- }
13855
- // The `directives` in this case are a named array called `LComponentView`. Clone the
13856
- // result so we don't expose an internal data structure in the user's console.
13857
- return context.directives === null ? [] : [...context.directives];
13858
- }
13859
- /**
13860
- * Returns the debug (partial) metadata for a particular directive or component instance.
13861
- * The function accepts an instance of a directive or component and returns the corresponding
13862
- * metadata.
13863
- *
13864
- * @param directiveOrComponentInstance Instance of a directive or component
13865
- * @returns metadata of the passed directive or component
13866
- *
13867
- * @publicApi
13868
- * @globalApi ng
13869
- */
13870
- function getDirectiveMetadata(directiveOrComponentInstance) {
13871
- const { constructor } = directiveOrComponentInstance;
13872
- if (!constructor) {
13873
- throw new Error('Unable to find the instance constructor');
13874
- }
13875
- // In case a component inherits from a directive, we may have component and directive metadata
13876
- // To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
13877
- const componentDef = getComponentDef$1(constructor);
13878
- if (componentDef) {
13879
- return {
13880
- inputs: componentDef.inputs,
13881
- outputs: componentDef.outputs,
13882
- encapsulation: componentDef.encapsulation,
13883
- changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
13884
- ChangeDetectionStrategy.Default
13885
- };
13886
- }
13887
- const directiveDef = getDirectiveDef(constructor);
13888
- if (directiveDef) {
13889
- return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
13890
- }
13891
- return null;
13892
- }
13893
- /**
13894
- * Retrieve map of local references.
13895
- *
13896
- * The references are retrieved as a map of local reference name to element or directive instance.
13897
- *
13898
- * @param target DOM element, component or directive instance for which to retrieve
13899
- * the local references.
13900
- */
13901
- function getLocalRefs(target) {
13902
- const context = getLContext(target);
13903
- if (context === null)
13904
- return {};
13905
- if (context.localRefs === undefined) {
13906
- const lView = context.lView;
13907
- if (lView === null) {
13908
- return {};
13909
- }
13910
- context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
13911
- }
13912
- return context.localRefs || {};
13913
- }
13914
- /**
13915
- * Retrieves the host element of a component or directive instance.
13916
- * The host element is the DOM element that matched the selector of the directive.
13917
- *
13918
- * @param componentOrDirective Component or directive instance for which the host
13919
- * element should be retrieved.
13920
- * @returns Host element of the target.
13921
- *
13922
- * @publicApi
13923
- * @globalApi ng
13924
- */
13925
- function getHostElement(componentOrDirective) {
13926
- return getLContext(componentOrDirective).native;
13927
- }
13928
- /**
13929
- * Retrieves the rendered text for a given component.
13930
- *
13931
- * This function retrieves the host element of a component and
13932
- * and then returns the `textContent` for that element. This implies
13933
- * that the text returned will include re-projected content of
13934
- * the component as well.
13935
- *
13936
- * @param component The component to return the content text for.
13937
- */
13938
- function getRenderedText(component) {
13939
- const hostElement = getHostElement(component);
13940
- return hostElement.textContent || '';
13941
- }
13942
- /**
13943
- * Retrieves a list of event listeners associated with a DOM element. The list does include host
13944
- * listeners, but it does not include event listeners defined outside of the Angular context
13945
- * (e.g. through `addEventListener`).
13946
- *
13947
- * @usageNotes
13948
- * Given the following DOM structure:
13949
- *
13950
- * ```html
13951
- * <app-root>
13952
- * <div (click)="doSomething()"></div>
13953
- * </app-root>
13954
- * ```
13955
- *
13956
- * Calling `getListeners` on `<div>` will return an object that looks as follows:
13957
- *
13958
- * ```ts
13959
- * {
13960
- * name: 'click',
13961
- * element: <div>,
13962
- * callback: () => doSomething(),
13963
- * useCapture: false
13964
- * }
13965
- * ```
13966
- *
13967
- * @param element Element for which the DOM listeners should be retrieved.
13968
- * @returns Array of event listeners on the DOM element.
13969
- *
13970
- * @publicApi
13971
- * @globalApi ng
13972
- */
13973
- function getListeners(element) {
13974
- ngDevMode && assertDomElement(element);
13975
- const lContext = getLContext(element);
13976
- const lView = lContext === null ? null : lContext.lView;
13977
- if (lView === null)
13978
- return [];
13979
- const tView = lView[TVIEW];
13980
- const lCleanup = lView[CLEANUP];
13981
- const tCleanup = tView.cleanup;
13982
- const listeners = [];
13983
- if (tCleanup && lCleanup) {
13984
- for (let i = 0; i < tCleanup.length;) {
13985
- const firstParam = tCleanup[i++];
13986
- const secondParam = tCleanup[i++];
13987
- if (typeof firstParam === 'string') {
13988
- const name = firstParam;
13989
- const listenerElement = unwrapRNode(lView[secondParam]);
13990
- const callback = lCleanup[tCleanup[i++]];
13991
- const useCaptureOrIndx = tCleanup[i++];
13992
- // if useCaptureOrIndx is boolean then report it as is.
13993
- // if useCaptureOrIndx is positive number then it in unsubscribe method
13994
- // if useCaptureOrIndx is negative number then it is a Subscription
13995
- const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
13996
- const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
13997
- if (element == listenerElement) {
13998
- listeners.push({ element, name, callback, useCapture, type });
13999
- }
14000
- }
14001
- }
14002
- }
14003
- listeners.sort(sortListeners);
14004
- return listeners;
14005
- }
14006
- function sortListeners(a, b) {
14007
- if (a.name == b.name)
14008
- return 0;
14009
- return a.name < b.name ? -1 : 1;
14010
- }
14011
- /**
14012
- * This function should not exist because it is megamorphic and only mostly correct.
14013
- *
14014
- * See call site for more info.
14015
- */
14016
- function isDirectiveDefHack(obj) {
14017
- return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
14018
- }
14019
- /**
14020
- * Returns the attached `DebugNode` instance for an element in the DOM.
14021
- *
14022
- * @param element DOM element which is owned by an existing component's view.
14023
- */
14024
- function getDebugNode(element) {
14025
- if (ngDevMode && !(element instanceof Node)) {
14026
- throw new Error('Expecting instance of DOM Element');
14027
- }
14028
- const lContext = getLContext(element);
14029
- const lView = lContext ? lContext.lView : null;
14030
- if (lView === null) {
14031
- return null;
14032
- }
14033
- const nodeIndex = lContext.nodeIndex;
14034
- if (nodeIndex !== -1) {
14035
- const valueInLView = lView[nodeIndex];
14036
- // this means that value in the lView is a component with its own
14037
- // data. In this situation the TNode is not accessed at the same spot.
14038
- const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
14039
- ngDevMode &&
14040
- assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
14041
- return buildDebugNode(tNode, lView);
14042
- }
14043
- return null;
14044
- }
14045
- /**
14046
- * Retrieve the component `LView` from component/element.
14047
- *
14048
- * NOTE: `LView` is a private and should not be leaked outside.
14049
- * Don't export this method to `ng.*` on window.
14050
- *
14051
- * @param target DOM element or component instance for which to retrieve the LView.
14052
- */
14053
- function getComponentLView(target) {
14054
- const lContext = getLContext(target);
14055
- const nodeIndx = lContext.nodeIndex;
14056
- const lView = lContext.lView;
14057
- ngDevMode && assertLView(lView);
14058
- const componentLView = lView[nodeIndx];
14059
- ngDevMode && assertLView(componentLView);
14060
- return componentLView;
14061
- }
14062
- /** Asserts that a value is a DOM Element. */
14063
- function assertDomElement(value) {
14064
- if (typeof Element !== 'undefined' && !(value instanceof Element)) {
14065
- throw new Error('Expecting instance of DOM Element');
14066
- }
14067
- }
14068
-
14069
- /**
14070
- * @license
14071
- * Copyright Google LLC All Rights Reserved.
14072
- *
14073
- * Use of this source code is governed by an MIT-style license that can be
14074
- * found in the LICENSE file at https://angular.io/license
14075
- */
14076
- /**
14077
- * Marks a component for check (in case of OnPush components) and synchronously
14078
- * performs change detection on the application this component belongs to.
14079
- *
14080
- * @param component Component to {@link ChangeDetectorRef#markForCheck mark for check}.
14081
- *
14082
- * @publicApi
14083
- * @globalApi ng
14084
- */
14085
- function applyChanges(component) {
14086
- markDirty(component);
14087
- getRootComponents(component).forEach(rootComponent => detectChanges(rootComponent));
14088
- }
14089
-
14090
- /**
14091
- * @license
14092
- * Copyright Google LLC All Rights Reserved.
14093
- *
14094
- * Use of this source code is governed by an MIT-style license that can be
14095
- * found in the LICENSE file at https://angular.io/license
14096
- */
14097
- /**
14098
- * This file introduces series of globally accessible debug tools
14099
- * to allow for the Angular debugging story to function.
14100
- *
14101
- * To see this in action run the following command:
14102
- *
14103
- * bazel run //packages/core/test/bundling/todo:devserver
14104
- *
14105
- * Then load `localhost:5432` and start using the console tools.
14106
- */
14107
- /**
14108
- * This value reflects the property on the window where the dev
14109
- * tools are patched (window.ng).
14110
- * */
14111
- const GLOBAL_PUBLISH_EXPANDO_KEY = 'ng';
14112
- let _published = false;
14113
- /**
14114
- * Publishes a collection of default debug tools onto`window.ng`.
14115
- *
14116
- * These functions are available globally when Angular is in development
14117
- * mode and are automatically stripped away from prod mode is on.
14118
- */
14119
- function publishDefaultGlobalUtils() {
14120
- if (!_published) {
14121
- _published = true;
14122
- /**
14123
- * Warning: this function is *INTERNAL* and should not be relied upon in application's code.
14124
- * The contract of the function might be changed in any release and/or the function can be
14125
- * removed completely.
14126
- */
14127
- publishGlobalUtil('ɵsetProfiler', setProfiler);
14128
- publishGlobalUtil('getDirectiveMetadata', getDirectiveMetadata);
14129
- publishGlobalUtil('getComponent', getComponent$1);
14130
- publishGlobalUtil('getContext', getContext);
14131
- publishGlobalUtil('getListeners', getListeners);
14132
- publishGlobalUtil('getOwningComponent', getOwningComponent);
14133
- publishGlobalUtil('getHostElement', getHostElement);
14134
- publishGlobalUtil('getInjector', getInjector);
14135
- publishGlobalUtil('getRootComponents', getRootComponents);
14136
- publishGlobalUtil('getDirectives', getDirectives);
14137
- publishGlobalUtil('applyChanges', applyChanges);
14138
- }
14139
- }
14140
- /**
14141
- * Publishes the given function to `window.ng` so that it can be
14142
- * used from the browser console when an application is not in production.
14143
- */
14144
- function publishGlobalUtil(name, fn) {
14145
- if (typeof COMPILED === 'undefined' || !COMPILED) {
14146
- // Note: we can't export `ng` when using closure enhanced optimization as:
14147
- // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
14148
- // - we can't declare a closure extern as the namespace `ng` is already used within Google
14149
- // for typings for AngularJS (via `goog.provide('ng....')`).
14150
- const w = _global$1;
14151
- ngDevMode && assertDefined(fn, 'function not defined');
14152
- if (w) {
14153
- let container = w[GLOBAL_PUBLISH_EXPANDO_KEY];
14154
- if (!container) {
14155
- container = w[GLOBAL_PUBLISH_EXPANDO_KEY] = {};
14156
- }
14157
- container[name] = fn;
14158
- }
14159
- }
14160
- }
14161
-
14162
- /**
14163
- * @license
14164
- * Copyright Google LLC All Rights Reserved.
14165
- *
14166
- * Use of this source code is governed by an MIT-style license that can be
14167
- * found in the LICENSE file at https://angular.io/license
14168
- */
14169
- // TODO: A hack to not pull in the NullInjector from @angular/core.
14170
- const NULL_INJECTOR = {
14171
- get: (token, notFoundValue) => {
14172
- throwProviderNotFoundError(token, 'NullInjector');
14173
- }
14174
- };
14175
- /**
14176
- * Bootstraps a Component into an existing host element and returns an instance
14177
- * of the component.
14178
- *
14179
- * Use this function to bootstrap a component into the DOM tree. Each invocation
14180
- * of this function will create a separate tree of components, injectors and
14181
- * change detection cycles and lifetimes. To dynamically insert a new component
14182
- * into an existing tree such that it shares the same injection, change detection
14183
- * and object lifetime, use {@link ViewContainer#createComponent}.
14184
- *
14185
- * @param componentType Component to bootstrap
14186
- * @param options Optional parameters which control bootstrapping
14187
- */
14188
- function renderComponent(componentType /* Type as workaround for: Microsoft/TypeScript/issues/4881 */, opts = {}) {
14189
- ngDevMode && publishDefaultGlobalUtils();
14190
- ngDevMode && assertComponentType(componentType);
14191
- const rendererFactory = opts.rendererFactory || domRendererFactory3;
14192
- const sanitizer = opts.sanitizer || null;
14193
- const componentDef = getComponentDef$1(componentType);
14194
- if (componentDef.type != componentType)
14195
- componentDef.type = componentType;
14196
- // The first index of the first selector is the tag name.
14197
- const componentTag = componentDef.selectors[0][0];
14198
- const hostRenderer = rendererFactory.createRenderer(null, null);
14199
- const hostRNode = locateHostElement(hostRenderer, opts.host || componentTag, componentDef.encapsulation);
14200
- const rootFlags = componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
14201
- 16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
14202
- const rootContext = createRootContext(opts.scheduler, opts.playerHandler);
14203
- const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
14204
- const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
14205
- const rootView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, renderer, null, opts.injector || null, null);
14206
- enterView(rootView);
14207
- let component;
14208
- try {
14209
- if (rendererFactory.begin)
14210
- rendererFactory.begin();
14211
- const componentView = createRootComponentView(hostRNode, componentDef, rootView, rendererFactory, renderer, sanitizer);
14212
- component = createRootComponent(componentView, componentDef, rootView, rootContext, opts.hostFeatures || null);
14213
- // create mode pass
14214
- renderView(rootTView, rootView, null);
14215
- // update mode pass
14216
- refreshView(rootTView, rootView, null, null);
14217
- }
14218
- finally {
14219
- leaveView();
14220
- if (rendererFactory.end)
14221
- rendererFactory.end();
14222
- }
14223
- return component;
14224
- }
14225
- /**
14226
- * Creates the root component view and the root component node.
14227
- *
14228
- * @param rNode Render host element.
14229
- * @param def ComponentDef
14230
- * @param rootView The parent view where the host node is stored
14231
- * @param rendererFactory Factory to be used for creating child renderers.
14232
- * @param hostRenderer The current renderer
14233
- * @param sanitizer The sanitizer, if provided
14234
- *
14235
- * @returns Component view created
14236
- */
14237
- function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
14238
- const tView = rootView[TVIEW];
14239
- const index = HEADER_OFFSET;
14240
- ngDevMode && assertIndexInRange(rootView, index);
14241
- rootView[index] = rNode;
14242
- // '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
14243
- // the same time we want to communicate the debug `TNode` that this is a special `TNode`
14244
- // representing a host element.
14245
- const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
14246
- const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
14247
- if (mergedAttrs !== null) {
14248
- computeStaticStyling(tNode, mergedAttrs, true);
14249
- if (rNode !== null) {
14250
- setUpAttributes(hostRenderer, rNode, mergedAttrs);
14251
- if (tNode.classes !== null) {
14252
- writeDirectClass(hostRenderer, rNode, tNode.classes);
14253
- }
14254
- if (tNode.styles !== null) {
14255
- writeDirectStyle(hostRenderer, rNode, tNode.styles);
14256
- }
14257
- }
14258
- }
14259
- const viewRenderer = rendererFactory.createRenderer(rNode, def);
14260
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14261
- if (tView.firstCreatePass) {
14262
- diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
14263
- markAsComponentHost(tView, tNode);
14264
- initTNodeFlags(tNode, rootView.length, 1);
14265
- }
14266
- addToViewTree(rootView, componentView);
14267
- // Store component view at node index, with node as the HOST
14268
- return rootView[index] = componentView;
14269
- }
14270
- /**
14271
- * Creates a root component and sets it up with features and host bindings. Shared by
14272
- * renderComponent() and ViewContainerRef.createComponent().
14273
- */
14274
- function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
14275
- const tView = rootLView[TVIEW];
14276
- // Create directive instance with factory() and store at next index in viewData
14277
- const component = instantiateRootComponent(tView, rootLView, componentDef);
14278
- rootContext.components.push(component);
14279
- componentView[CONTEXT] = component;
14280
- if (hostFeatures !== null) {
14281
- for (const feature of hostFeatures) {
14282
- feature(component, componentDef);
14283
- }
14284
- }
14285
- // We want to generate an empty QueryList for root content queries for backwards
14286
- // compatibility with ViewEngine.
14287
- if (componentDef.contentQueries) {
14288
- const tNode = getCurrentTNode();
14289
- ngDevMode && assertDefined(tNode, 'TNode expected');
14290
- componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
14291
- }
14292
- const rootTNode = getCurrentTNode();
14293
- ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
14294
- if (tView.firstCreatePass &&
14295
- (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
14296
- setSelectedIndex(rootTNode.index);
14297
- const rootTView = rootLView[TVIEW];
14298
- registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
14299
- invokeHostBindingsInCreationMode(componentDef, component);
14300
- }
14301
- return component;
14302
- }
14303
- function createRootContext(scheduler, playerHandler) {
14304
- return {
14305
- components: [],
14306
- scheduler: scheduler || defaultScheduler,
14307
- clean: CLEAN_PROMISE,
14308
- playerHandler: playerHandler || null,
14309
- flags: 0 /* RootContextFlags.Empty */
14310
- };
14311
- }
14312
- /**
14313
- * Used to enable lifecycle hooks on the root component.
14314
- *
14315
- * Include this feature when calling `renderComponent` if the root component
14316
- * you are rendering has lifecycle hooks defined. Otherwise, the hooks won't
14317
- * be called properly.
14318
- *
14319
- * Example:
14320
- *
14321
- * ```
14322
- * renderComponent(AppComponent, {hostFeatures: [LifecycleHooksFeature]});
14323
- * ```
14324
- */
14325
- function LifecycleHooksFeature() {
14326
- const tNode = getCurrentTNode();
14327
- ngDevMode && assertDefined(tNode, 'TNode is required');
14328
- registerPostOrderHooks(getLView()[TVIEW], tNode);
14329
- }
14330
- /**
14331
- * Wait on component until it is rendered.
13626
+ * Wait on component until it is rendered.
14332
13627
  *
14333
13628
  * This function returns a `Promise` which is resolved when the component's
14334
13629
  * change detection is executed. This is determined by finding the scheduler
@@ -15312,6 +14607,40 @@ function ɵɵattributeInterpolateV(attrName, values, sanitizer, namespace) {
15312
14607
  return ɵɵattributeInterpolateV;
15313
14608
  }
15314
14609
 
14610
+ /**
14611
+ * @license
14612
+ * Copyright Google LLC All Rights Reserved.
14613
+ *
14614
+ * Use of this source code is governed by an MIT-style license that can be
14615
+ * found in the LICENSE file at https://angular.io/license
14616
+ */
14617
+ /**
14618
+ * Synchronously perform change detection on a component (and possibly its sub-components).
14619
+ *
14620
+ * This function triggers change detection in a synchronous way on a component.
14621
+ *
14622
+ * @param component The component which the change detection should be performed on.
14623
+ */
14624
+ function detectChanges(component) {
14625
+ const view = getComponentViewByInstance(component);
14626
+ detectChangesInternal(view[TVIEW], view, component);
14627
+ }
14628
+ /**
14629
+ * Marks the component as dirty (needing change detection). Marking a component dirty will
14630
+ * schedule a change detection on it at some point in the future.
14631
+ *
14632
+ * Marking an already dirty component as dirty won't do anything. Only one outstanding change
14633
+ * detection can be scheduled per component tree.
14634
+ *
14635
+ * @param component Component to mark as dirty.
14636
+ */
14637
+ function markDirty(component) {
14638
+ ngDevMode && assertDefined(component, 'component');
14639
+ const rootView = markViewDirty(getComponentViewByInstance(component));
14640
+ ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
14641
+ scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
14642
+ }
14643
+
15315
14644
  /**
15316
14645
  * @license
15317
14646
  * Copyright Google LLC All Rights Reserved.
@@ -15854,53 +15183,44 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
15854
15183
  const idxOrTargetGetter = eventTargetResolver ?
15855
15184
  (_lView) => eventTargetResolver(unwrapRNode(_lView[tNode.index])) :
15856
15185
  tNode.index;
15857
- // In order to match current behavior, native DOM event listeners must be added for all
15858
- // events (including outputs).
15859
- if (isProceduralRenderer(renderer)) {
15860
- // There might be cases where multiple directives on the same element try to register an event
15861
- // handler function for the same event. In this situation we want to avoid registration of
15862
- // several native listeners as each registration would be intercepted by NgZone and
15863
- // trigger change detection. This would mean that a single user action would result in several
15864
- // change detections being invoked. To avoid this situation we want to have only one call to
15865
- // native handler registration (for the same element and same type of event).
15866
- //
15867
- // In order to have just one native event handler in presence of multiple handler functions,
15868
- // we just register a first handler function as a native event listener and then chain
15869
- // (coalesce) other handler functions on top of the first native handler function.
15870
- let existingListener = null;
15871
- // Please note that the coalescing described here doesn't happen for events specifying an
15872
- // alternative target (ex. (document:click)) - this is to keep backward compatibility with the
15873
- // view engine.
15874
- // Also, we don't have to search for existing listeners is there are no directives
15875
- // matching on a given node as we can't register multiple event handlers for the same event in
15876
- // a template (this would mean having duplicate attributes).
15877
- if (!eventTargetResolver && isTNodeDirectiveHost) {
15878
- existingListener = findExistingListener(tView, lView, eventName, tNode.index);
15879
- }
15880
- if (existingListener !== null) {
15881
- // Attach a new listener to coalesced listeners list, maintaining the order in which
15882
- // listeners are registered. For performance reasons, we keep a reference to the last
15883
- // listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
15884
- // the entire set each time we need to add a new listener.
15885
- const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
15886
- lastListenerFn.__ngNextListenerFn__ = listenerFn;
15887
- existingListener.__ngLastListenerFn__ = listenerFn;
15888
- processOutputs = false;
15889
- }
15890
- else {
15891
- listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15892
- const cleanupFn = renderer.listen(target, eventName, listenerFn);
15893
- ngDevMode && ngDevMode.rendererAddEventListener++;
15894
- lCleanup.push(listenerFn, cleanupFn);
15895
- tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
15896
- }
15186
+ // In order to match current behavior, native DOM event listeners must be added for all
15187
+ // events (including outputs).
15188
+ // There might be cases where multiple directives on the same element try to register an event
15189
+ // handler function for the same event. In this situation we want to avoid registration of
15190
+ // several native listeners as each registration would be intercepted by NgZone and
15191
+ // trigger change detection. This would mean that a single user action would result in several
15192
+ // change detections being invoked. To avoid this situation we want to have only one call to
15193
+ // native handler registration (for the same element and same type of event).
15194
+ //
15195
+ // In order to have just one native event handler in presence of multiple handler functions,
15196
+ // we just register a first handler function as a native event listener and then chain
15197
+ // (coalesce) other handler functions on top of the first native handler function.
15198
+ let existingListener = null;
15199
+ // Please note that the coalescing described here doesn't happen for events specifying an
15200
+ // alternative target (ex. (document:click)) - this is to keep backward compatibility with the
15201
+ // view engine.
15202
+ // Also, we don't have to search for existing listeners is there are no directives
15203
+ // matching on a given node as we can't register multiple event handlers for the same event in
15204
+ // a template (this would mean having duplicate attributes).
15205
+ if (!eventTargetResolver && isTNodeDirectiveHost) {
15206
+ existingListener = findExistingListener(tView, lView, eventName, tNode.index);
15207
+ }
15208
+ if (existingListener !== null) {
15209
+ // Attach a new listener to coalesced listeners list, maintaining the order in which
15210
+ // listeners are registered. For performance reasons, we keep a reference to the last
15211
+ // listener in that list (in `__ngLastListenerFn__` field), so we can avoid going through
15212
+ // the entire set each time we need to add a new listener.
15213
+ const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
15214
+ lastListenerFn.__ngNextListenerFn__ = listenerFn;
15215
+ existingListener.__ngLastListenerFn__ = listenerFn;
15216
+ processOutputs = false;
15897
15217
  }
15898
15218
  else {
15899
- listenerFn = wrapListener(tNode, lView, context, listenerFn, true /** preventDefault */);
15900
- target.addEventListener(eventName, listenerFn, useCapture);
15219
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15220
+ const cleanupFn = renderer.listen(target, eventName, listenerFn);
15901
15221
  ngDevMode && ngDevMode.rendererAddEventListener++;
15902
- lCleanup.push(listenerFn);
15903
- tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, useCapture);
15222
+ lCleanup.push(listenerFn, cleanupFn);
15223
+ tCleanup && tCleanup.push(eventName, idxOrTargetGetter, lCleanupIndex, lCleanupIndex + 1);
15904
15224
  }
15905
15225
  }
15906
15226
  else {
@@ -16569,7 +15889,7 @@ function ɵɵpropertyInterpolate8(propName, prefix, v0, i0, v1, i1, v2, i2, v3,
16569
15889
  * be conducted at runtime so child components that add new `@Inputs` don't have to be re-compiled.
16570
15890
  *
16571
15891
  * @param propName The name of the property to update.
16572
- * @param values The collection of values and the strings inbetween those values, beginning with a
15892
+ * @param values The collection of values and the strings in between those values, beginning with a
16573
15893
  * string prefix and ending with a string suffix.
16574
15894
  * (e.g. `['prefix', value0, '-', value1, '-', value2, ..., value99, 'suffix']`)
16575
15895
  * @param sanitizer An optional sanitizer function
@@ -17974,7 +17294,7 @@ function findStylingValue(tData, tNode, lView, prop, index, isClassBased) {
17974
17294
  valueAtLViewIndex = isStylingMap ? EMPTY_ARRAY : undefined;
17975
17295
  }
17976
17296
  let currentValue = isStylingMap ? keyValueArrayGet(valueAtLViewIndex, prop) :
17977
- key === prop ? valueAtLViewIndex : undefined;
17297
+ (key === prop ? valueAtLViewIndex : undefined);
17978
17298
  if (containsStatics && !isStylingValuePresent(currentValue)) {
17979
17299
  currentValue = keyValueArrayGet(rawKey, prop);
17980
17300
  }
@@ -19497,7 +18817,7 @@ function findLocaleData(locale) {
19497
18817
  if (parentLocale === 'en') {
19498
18818
  return localeEn;
19499
18819
  }
19500
- throw new Error(`Missing locale data for the locale "${locale}".`);
18820
+ throw new RuntimeError(701 /* RuntimeErrorCode.MISSING_LOCALE_DATA */, ngDevMode && `Missing locale data for the locale "${locale}".`);
19501
18821
  }
19502
18822
  /**
19503
18823
  * Retrieves the default currency code for the given locale.
@@ -19636,7 +18956,7 @@ var I18nCreateOpCode;
19636
18956
  */
19637
18957
  I18nCreateOpCode[I18nCreateOpCode["SHIFT"] = 2] = "SHIFT";
19638
18958
  /**
19639
- * Should the node be appended to parent imedditatly after creation.
18959
+ * Should the node be appended to parent immediately after creation.
19640
18960
  */
19641
18961
  I18nCreateOpCode[I18nCreateOpCode["APPEND_EAGERLY"] = 1] = "APPEND_EAGERLY";
19642
18962
  /**
@@ -21827,7 +21147,7 @@ function noComponentFactoryError(component) {
21827
21147
  return error;
21828
21148
  }
21829
21149
  const ERROR_COMPONENT = 'ngComponent';
21830
- function getComponent(error) {
21150
+ function getComponent$1(error) {
21831
21151
  return error[ERROR_COMPONENT];
21832
21152
  }
21833
21153
  class _NullComponentFactoryResolver {
@@ -21877,7 +21197,7 @@ class NgModuleRef$1 {
21877
21197
  * JIT mode. See [JIT API changes due to ViewEngine deprecation](guide/deprecations#jit-api-changes)
21878
21198
  * for additional context. Angular provides APIs that accept NgModule classes directly (such as
21879
21199
  * [PlatformRef.bootstrapModule](api/core/PlatformRef#bootstrapModule) and
21880
- * [createNgModuleRef](api/core/createNgModuleRef)), consider switching to those APIs instead of
21200
+ * [createNgModule](api/core/createNgModule)), consider switching to those APIs instead of
21881
21201
  * using factory-based ones.
21882
21202
  */
21883
21203
  class NgModuleFactory$1 {
@@ -22011,14 +21331,6 @@ class Renderer2 {
22011
21331
  * @nocollapse
22012
21332
  */
22013
21333
  Renderer2.__NG_ELEMENT_ID__ = () => injectRenderer2();
22014
- /** Returns a Renderer2 (or throws when application was bootstrapped with Renderer3) */
22015
- function getOrCreateRenderer2(lView) {
22016
- const renderer = lView[RENDERER];
22017
- if (ngDevMode && !isProceduralRenderer(renderer)) {
22018
- throw new Error('Cannot inject Renderer2 when the application uses Renderer3!');
22019
- }
22020
- return renderer;
22021
- }
22022
21334
  /** Injects a Renderer2 for the current component. */
22023
21335
  function injectRenderer2() {
22024
21336
  // We need the Renderer to be based on the component that it's being injected into, however since
@@ -22026,7 +21338,7 @@ function injectRenderer2() {
22026
21338
  const lView = getLView();
22027
21339
  const tNode = getCurrentTNode();
22028
21340
  const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
22029
- return getOrCreateRenderer2(isLView(nodeAtIndex) ? nodeAtIndex : lView);
21341
+ return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
22030
21342
  }
22031
21343
 
22032
21344
  /**
@@ -22073,7 +21385,7 @@ class Version {
22073
21385
  /**
22074
21386
  * @publicApi
22075
21387
  */
22076
- const VERSION = new Version('14.1.0-next.2');
21388
+ const VERSION = new Version('14.1.0-rc.0');
22077
21389
 
22078
21390
  /**
22079
21391
  * @license
@@ -22537,7 +21849,13 @@ class ComponentFactory extends ComponentFactory$1 {
22537
21849
  realEnvironmentInjector;
22538
21850
  }
22539
21851
  const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
22540
- const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21852
+ const rendererFactory = rootViewInjector.get(RendererFactory2, null);
21853
+ if (rendererFactory === null) {
21854
+ throw new RuntimeError(407 /* RuntimeErrorCode.RENDERER_NOT_FOUND */, ngDevMode &&
21855
+ 'Angular was not able to inject a renderer (RendererFactory2). ' +
21856
+ 'Likely this is due to a broken DI hierarchy. ' +
21857
+ 'Make sure that any injector used to create this component has a correct parent.');
21858
+ }
22541
21859
  const sanitizer = rootViewInjector.get(Sanitizer, null);
22542
21860
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
22543
21861
  // Determine a tag name used for creating host elements when this component is created
@@ -22601,226 +21919,666 @@ class ComponentFactory extends ComponentFactory$1 {
22601
21919
  finally {
22602
21920
  leaveView();
22603
21921
  }
22604
- return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
21922
+ return new ComponentRef(this.componentType, component, createElementRef(tElementNode, rootLView), rootLView, tElementNode);
21923
+ }
21924
+ }
21925
+ const componentFactoryResolver = new ComponentFactoryResolver();
21926
+ /**
21927
+ * Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
21928
+ * ComponentFactoryResolver
21929
+ * already exists, retrieves the existing ComponentFactoryResolver.
21930
+ *
21931
+ * @returns The ComponentFactoryResolver instance to use
21932
+ */
21933
+ function injectComponentFactoryResolver() {
21934
+ return componentFactoryResolver;
21935
+ }
21936
+ /**
21937
+ * Represents an instance of a Component created via a {@link ComponentFactory}.
21938
+ *
21939
+ * `ComponentRef` provides access to the Component Instance as well other objects related to this
21940
+ * Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
21941
+ * method.
21942
+ *
21943
+ */
21944
+ class ComponentRef extends ComponentRef$1 {
21945
+ constructor(componentType, instance, location, _rootLView, _tNode) {
21946
+ super();
21947
+ this.location = location;
21948
+ this._rootLView = _rootLView;
21949
+ this._tNode = _tNode;
21950
+ this.instance = instance;
21951
+ this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
21952
+ this.componentType = componentType;
21953
+ }
21954
+ setInput(name, value) {
21955
+ const inputData = this._tNode.inputs;
21956
+ let dataValue;
21957
+ if (inputData !== null && (dataValue = inputData[name])) {
21958
+ const lView = this._rootLView;
21959
+ setInputsForProperty(lView[TVIEW], lView, dataValue, name, value);
21960
+ markDirtyIfOnPush(lView, this._tNode.index);
21961
+ }
21962
+ else {
21963
+ if (ngDevMode) {
21964
+ const cmpNameForError = stringifyForError(this.componentType);
21965
+ let message = `Can't set value of the '${name}' input on the '${cmpNameForError}' component. `;
21966
+ message += `Make sure that the '${name}' property is annotated with @Input() or a mapped @Input('${name}') exists.`;
21967
+ reportUnknownPropertyError(message);
21968
+ }
21969
+ }
21970
+ }
21971
+ get injector() {
21972
+ return new NodeInjector(this._tNode, this._rootLView);
21973
+ }
21974
+ destroy() {
21975
+ this.hostView.destroy();
21976
+ }
21977
+ onDestroy(callback) {
21978
+ this.hostView.onDestroy(callback);
21979
+ }
21980
+ }
21981
+
21982
+ /**
21983
+ * @license
21984
+ * Copyright Google LLC All Rights Reserved.
21985
+ *
21986
+ * Use of this source code is governed by an MIT-style license that can be
21987
+ * found in the LICENSE file at https://angular.io/license
21988
+ */
21989
+ /**
21990
+ * Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
21991
+ *
21992
+ * @param ngModule NgModule class.
21993
+ * @param parentInjector Optional injector instance to use as a parent for the module injector. If
21994
+ * not provided, `NullInjector` will be used instead.
21995
+ * @returns NgModuleRef that represents an NgModule instance.
21996
+ *
21997
+ * @publicApi
21998
+ */
21999
+ function createNgModule(ngModule, parentInjector) {
22000
+ return new NgModuleRef(ngModule, parentInjector ?? null);
22001
+ }
22002
+ /**
22003
+ * The `createNgModule` function alias for backwards-compatibility.
22004
+ * Please avoid using it directly and use `createNgModule` instead.
22005
+ *
22006
+ * @deprecated Use `createNgModule` instead.
22007
+ */
22008
+ const createNgModuleRef = createNgModule;
22009
+ class NgModuleRef extends NgModuleRef$1 {
22010
+ constructor(ngModuleType, _parent) {
22011
+ super();
22012
+ this._parent = _parent;
22013
+ // tslint:disable-next-line:require-internal-with-underscore
22014
+ this._bootstrapComponents = [];
22015
+ this.injector = this;
22016
+ this.destroyCbs = [];
22017
+ // When bootstrapping a module we have a dependency graph that looks like this:
22018
+ // ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
22019
+ // module being resolved tries to inject the ComponentFactoryResolver, it'll create a
22020
+ // circular dependency which will result in a runtime error, because the injector doesn't
22021
+ // exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
22022
+ // and providing it, rather than letting the injector resolve it.
22023
+ this.componentFactoryResolver = new ComponentFactoryResolver(this);
22024
+ const ngModuleDef = getNgModuleDef(ngModuleType);
22025
+ ngDevMode &&
22026
+ assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
22027
+ this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
22028
+ this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
22029
+ { provide: NgModuleRef$1, useValue: this }, {
22030
+ provide: ComponentFactoryResolver$1,
22031
+ useValue: this.componentFactoryResolver
22032
+ }
22033
+ ], stringify(ngModuleType), new Set(['environment']));
22034
+ // We need to resolve the injector types separately from the injector creation, because
22035
+ // the module might be trying to use this ref in its constructor for DI which will cause a
22036
+ // circular error that will eventually error out, because the injector isn't created yet.
22037
+ this._r3Injector.resolveInjectorInitializers();
22038
+ this.instance = this.get(ngModuleType);
22039
+ }
22040
+ get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
22041
+ if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
22042
+ return this;
22043
+ }
22044
+ return this._r3Injector.get(token, notFoundValue, injectFlags);
22045
+ }
22046
+ runInContext(fn) {
22047
+ return this.injector.runInContext(fn);
22048
+ }
22049
+ destroy() {
22050
+ ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22051
+ const injector = this._r3Injector;
22052
+ !injector.destroyed && injector.destroy();
22053
+ this.destroyCbs.forEach(fn => fn());
22054
+ this.destroyCbs = null;
22055
+ }
22056
+ onDestroy(callback) {
22057
+ ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22058
+ this.destroyCbs.push(callback);
22059
+ }
22060
+ }
22061
+ class NgModuleFactory extends NgModuleFactory$1 {
22062
+ constructor(moduleType) {
22063
+ super();
22064
+ this.moduleType = moduleType;
22065
+ }
22066
+ create(parentInjector) {
22067
+ return new NgModuleRef(this.moduleType, parentInjector);
22068
+ }
22069
+ }
22070
+ class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
22071
+ constructor(providers, parent, source) {
22072
+ super();
22073
+ this.componentFactoryResolver = new ComponentFactoryResolver(this);
22074
+ this.instance = null;
22075
+ const injector = new R3Injector([
22076
+ ...providers,
22077
+ { provide: NgModuleRef$1, useValue: this },
22078
+ { provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
22079
+ ], parent || getNullInjector(), source, new Set(['environment']));
22080
+ this.injector = injector;
22081
+ injector.resolveInjectorInitializers();
22082
+ }
22083
+ destroy() {
22084
+ this.injector.destroy();
22085
+ }
22086
+ onDestroy(callback) {
22087
+ this.injector.onDestroy(callback);
22088
+ }
22089
+ }
22090
+ /**
22091
+ * Create a new environment injector.
22092
+ *
22093
+ * Learn more about environment injectors in
22094
+ * [this guide](guide/standalone-components#environment-injectors).
22095
+ *
22096
+ * @param providers An array of providers.
22097
+ * @param parent A parent environment injector.
22098
+ * @param debugName An optional name for this injector instance, which will be used in error
22099
+ * messages.
22100
+ *
22101
+ * @publicApi
22102
+ * @developerPreview
22103
+ */
22104
+ function createEnvironmentInjector(providers, parent, debugName = null) {
22105
+ const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
22106
+ return adapter.injector;
22107
+ }
22108
+
22109
+ /**
22110
+ * @license
22111
+ * Copyright Google LLC All Rights Reserved.
22112
+ *
22113
+ * Use of this source code is governed by an MIT-style license that can be
22114
+ * found in the LICENSE file at https://angular.io/license
22115
+ */
22116
+ /**
22117
+ * A service used by the framework to create instances of standalone injectors. Those injectors are
22118
+ * created on demand in case of dynamic component instantiation and contain ambient providers
22119
+ * collected from the imports graph rooted at a given standalone component.
22120
+ */
22121
+ class StandaloneService {
22122
+ constructor(_injector) {
22123
+ this._injector = _injector;
22124
+ this.cachedInjectors = new Map();
22125
+ }
22126
+ getOrCreateStandaloneInjector(componentDef) {
22127
+ if (!componentDef.standalone) {
22128
+ return null;
22129
+ }
22130
+ if (!this.cachedInjectors.has(componentDef.id)) {
22131
+ const providers = internalImportProvidersFrom(false, componentDef.type);
22132
+ const standaloneInjector = providers.length > 0 ?
22133
+ createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
22134
+ null;
22135
+ this.cachedInjectors.set(componentDef.id, standaloneInjector);
22136
+ }
22137
+ return this.cachedInjectors.get(componentDef.id);
22138
+ }
22139
+ ngOnDestroy() {
22140
+ try {
22141
+ for (const injector of this.cachedInjectors.values()) {
22142
+ if (injector !== null) {
22143
+ injector.destroy();
22144
+ }
22145
+ }
22146
+ }
22147
+ finally {
22148
+ this.cachedInjectors.clear();
22149
+ }
22150
+ }
22151
+ }
22152
+ /** @nocollapse */
22153
+ StandaloneService.ɵprov = ɵɵdefineInjectable({
22154
+ token: StandaloneService,
22155
+ providedIn: 'environment',
22156
+ factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
22157
+ });
22158
+ /**
22159
+ * A feature that acts as a setup code for the {@link StandaloneService}.
22160
+ *
22161
+ * The most important responsibility of this feature is to expose the "getStandaloneInjector"
22162
+ * function (an entry points to a standalone injector creation) on a component definition object. We
22163
+ * go through the features infrastructure to make sure that the standalone injector creation logic
22164
+ * is tree-shakable and not included in applications that don't use standalone components.
22165
+ *
22166
+ * @codeGenApi
22167
+ */
22168
+ function ɵɵStandaloneFeature(definition) {
22169
+ definition.getStandaloneInjector = (parentInjector) => {
22170
+ return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
22171
+ };
22172
+ }
22173
+
22174
+ /**
22175
+ * @license
22176
+ * Copyright Google LLC All Rights Reserved.
22177
+ *
22178
+ * Use of this source code is governed by an MIT-style license that can be
22179
+ * found in the LICENSE file at https://angular.io/license
22180
+ */
22181
+ /**
22182
+ * Retrieves the component instance associated with a given DOM element.
22183
+ *
22184
+ * @usageNotes
22185
+ * Given the following DOM structure:
22186
+ *
22187
+ * ```html
22188
+ * <app-root>
22189
+ * <div>
22190
+ * <child-comp></child-comp>
22191
+ * </div>
22192
+ * </app-root>
22193
+ * ```
22194
+ *
22195
+ * Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
22196
+ * associated with this DOM element.
22197
+ *
22198
+ * Calling the function on `<app-root>` will return the `MyApp` instance.
22199
+ *
22200
+ *
22201
+ * @param element DOM element from which the component should be retrieved.
22202
+ * @returns Component instance associated with the element or `null` if there
22203
+ * is no component associated with it.
22204
+ *
22205
+ * @publicApi
22206
+ * @globalApi ng
22207
+ */
22208
+ function getComponent(element) {
22209
+ ngDevMode && assertDomElement(element);
22210
+ const context = getLContext(element);
22211
+ if (context === null)
22212
+ return null;
22213
+ if (context.component === undefined) {
22214
+ const lView = context.lView;
22215
+ if (lView === null) {
22216
+ return null;
22217
+ }
22218
+ context.component = getComponentAtNodeIndex(context.nodeIndex, lView);
22605
22219
  }
22220
+ return context.component;
22606
22221
  }
22607
- const componentFactoryResolver = new ComponentFactoryResolver();
22608
22222
  /**
22609
- * Creates a ComponentFactoryResolver and stores it on the injector. Or, if the
22610
- * ComponentFactoryResolver
22611
- * already exists, retrieves the existing ComponentFactoryResolver.
22223
+ * If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded
22224
+ * view that the element is part of. Otherwise retrieves the instance of the component whose view
22225
+ * owns the element (in this case, the result is the same as calling `getOwningComponent`).
22612
22226
  *
22613
- * @returns The ComponentFactoryResolver instance to use
22227
+ * @param element Element for which to get the surrounding component instance.
22228
+ * @returns Instance of the component that is around the element or null if the element isn't
22229
+ * inside any component.
22230
+ *
22231
+ * @publicApi
22232
+ * @globalApi ng
22614
22233
  */
22615
- function injectComponentFactoryResolver() {
22616
- return componentFactoryResolver;
22234
+ function getContext(element) {
22235
+ assertDomElement(element);
22236
+ const context = getLContext(element);
22237
+ const lView = context ? context.lView : null;
22238
+ return lView === null ? null : lView[CONTEXT];
22617
22239
  }
22618
22240
  /**
22619
- * Represents an instance of a Component created via a {@link ComponentFactory}.
22241
+ * Retrieves the component instance whose view contains the DOM element.
22620
22242
  *
22621
- * `ComponentRef` provides access to the Component Instance as well other objects related to this
22622
- * Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
22623
- * method.
22243
+ * For example, if `<child-comp>` is used in the template of `<app-comp>`
22244
+ * (i.e. a `ViewChild` of `<app-comp>`), calling `getOwningComponent` on `<child-comp>`
22245
+ * would return `<app-comp>`.
22246
+ *
22247
+ * @param elementOrDir DOM element, component or directive instance
22248
+ * for which to retrieve the root components.
22249
+ * @returns Component instance whose view owns the DOM element or null if the element is not
22250
+ * part of a component view.
22624
22251
  *
22252
+ * @publicApi
22253
+ * @globalApi ng
22625
22254
  */
22626
- class ComponentRef extends ComponentRef$1 {
22627
- constructor(componentType, instance, location, _rootLView, _tNode) {
22628
- super();
22629
- this.location = location;
22630
- this._rootLView = _rootLView;
22631
- this._tNode = _tNode;
22632
- this.instance = instance;
22633
- this.hostView = this.changeDetectorRef = new RootViewRef(_rootLView);
22634
- this.componentType = componentType;
22635
- }
22636
- get injector() {
22637
- return new NodeInjector(this._tNode, this._rootLView);
22638
- }
22639
- destroy() {
22640
- this.hostView.destroy();
22641
- }
22642
- onDestroy(callback) {
22643
- this.hostView.onDestroy(callback);
22255
+ function getOwningComponent(elementOrDir) {
22256
+ const context = getLContext(elementOrDir);
22257
+ let lView = context ? context.lView : null;
22258
+ if (lView === null)
22259
+ return null;
22260
+ let parent;
22261
+ while (lView[TVIEW].type === 2 /* TViewType.Embedded */ && (parent = getLViewParent(lView))) {
22262
+ lView = parent;
22644
22263
  }
22264
+ return lView[FLAGS] & 256 /* LViewFlags.IsRoot */ ? null : lView[CONTEXT];
22645
22265
  }
22646
-
22647
22266
  /**
22648
- * @license
22649
- * Copyright Google LLC All Rights Reserved.
22267
+ * Retrieves all root components associated with a DOM element, directive or component instance.
22268
+ * Root components are those which have been bootstrapped by Angular.
22650
22269
  *
22651
- * Use of this source code is governed by an MIT-style license that can be
22652
- * found in the LICENSE file at https://angular.io/license
22270
+ * @param elementOrDir DOM element, component or directive instance
22271
+ * for which to retrieve the root components.
22272
+ * @returns Root components associated with the target object.
22273
+ *
22274
+ * @publicApi
22275
+ * @globalApi ng
22653
22276
  */
22277
+ function getRootComponents(elementOrDir) {
22278
+ const lView = readPatchedLView(elementOrDir);
22279
+ return lView !== null ? [...getRootContext(lView).components] : [];
22280
+ }
22654
22281
  /**
22655
- * Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.
22656
- * @param ngModule NgModule class.
22657
- * @param parentInjector Optional injector instance to use as a parent for the module injector. If
22658
- * not provided, `NullInjector` will be used instead.
22282
+ * Retrieves an `Injector` associated with an element, component or directive instance.
22283
+ *
22284
+ * @param elementOrDir DOM element, component or directive instance for which to
22285
+ * retrieve the injector.
22286
+ * @returns Injector associated with the element, component or directive instance.
22287
+ *
22659
22288
  * @publicApi
22289
+ * @globalApi ng
22660
22290
  */
22661
- function createNgModuleRef(ngModule, parentInjector) {
22662
- return new NgModuleRef(ngModule, parentInjector ?? null);
22291
+ function getInjector(elementOrDir) {
22292
+ const context = getLContext(elementOrDir);
22293
+ const lView = context ? context.lView : null;
22294
+ if (lView === null)
22295
+ return Injector.NULL;
22296
+ const tNode = lView[TVIEW].data[context.nodeIndex];
22297
+ return new NodeInjector(tNode, lView);
22663
22298
  }
22664
- class NgModuleRef extends NgModuleRef$1 {
22665
- constructor(ngModuleType, _parent) {
22666
- super();
22667
- this._parent = _parent;
22668
- // tslint:disable-next-line:require-internal-with-underscore
22669
- this._bootstrapComponents = [];
22670
- this.injector = this;
22671
- this.destroyCbs = [];
22672
- // When bootstrapping a module we have a dependency graph that looks like this:
22673
- // ApplicationRef -> ComponentFactoryResolver -> NgModuleRef. The problem is that if the
22674
- // module being resolved tries to inject the ComponentFactoryResolver, it'll create a
22675
- // circular dependency which will result in a runtime error, because the injector doesn't
22676
- // exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves
22677
- // and providing it, rather than letting the injector resolve it.
22678
- this.componentFactoryResolver = new ComponentFactoryResolver(this);
22679
- const ngModuleDef = getNgModuleDef(ngModuleType);
22680
- ngDevMode &&
22681
- assertDefined(ngModuleDef, `NgModule '${stringify(ngModuleType)}' is not a subtype of 'NgModuleType'.`);
22682
- this._bootstrapComponents = maybeUnwrapFn$1(ngModuleDef.bootstrap);
22683
- this._r3Injector = createInjectorWithoutInjectorInstances(ngModuleType, _parent, [
22684
- { provide: NgModuleRef$1, useValue: this }, {
22685
- provide: ComponentFactoryResolver$1,
22686
- useValue: this.componentFactoryResolver
22687
- }
22688
- ], stringify(ngModuleType), new Set(['environment']));
22689
- // We need to resolve the injector types separately from the injector creation, because
22690
- // the module might be trying to use this ref in its constructor for DI which will cause a
22691
- // circular error that will eventually error out, because the injector isn't created yet.
22692
- this._r3Injector.resolveInjectorInitializers();
22693
- this.instance = this.get(ngModuleType);
22694
- }
22695
- get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, injectFlags = InjectFlags.Default) {
22696
- if (token === Injector || token === NgModuleRef$1 || token === INJECTOR) {
22697
- return this;
22299
+ /**
22300
+ * Retrieve a set of injection tokens at a given DOM node.
22301
+ *
22302
+ * @param element Element for which the injection tokens should be retrieved.
22303
+ */
22304
+ function getInjectionTokens(element) {
22305
+ const context = getLContext(element);
22306
+ const lView = context ? context.lView : null;
22307
+ if (lView === null)
22308
+ return [];
22309
+ const tView = lView[TVIEW];
22310
+ const tNode = tView.data[context.nodeIndex];
22311
+ const providerTokens = [];
22312
+ const startIndex = tNode.providerIndexes & 1048575 /* TNodeProviderIndexes.ProvidersStartIndexMask */;
22313
+ const endIndex = tNode.directiveEnd;
22314
+ for (let i = startIndex; i < endIndex; i++) {
22315
+ let value = tView.data[i];
22316
+ if (isDirectiveDefHack(value)) {
22317
+ // The fact that we sometimes store Type and sometimes DirectiveDef in this location is a
22318
+ // design flaw. We should always store same type so that we can be monomorphic. The issue
22319
+ // is that for Components/Directives we store the def instead the type. The correct behavior
22320
+ // is that we should always be storing injectable type in this location.
22321
+ value = value.type;
22698
22322
  }
22699
- return this._r3Injector.get(token, notFoundValue, injectFlags);
22323
+ providerTokens.push(value);
22700
22324
  }
22701
- destroy() {
22702
- ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22703
- const injector = this._r3Injector;
22704
- !injector.destroyed && injector.destroy();
22705
- this.destroyCbs.forEach(fn => fn());
22706
- this.destroyCbs = null;
22325
+ return providerTokens;
22326
+ }
22327
+ /**
22328
+ * Retrieves directive instances associated with a given DOM node. Does not include
22329
+ * component instances.
22330
+ *
22331
+ * @usageNotes
22332
+ * Given the following DOM structure:
22333
+ *
22334
+ * ```html
22335
+ * <app-root>
22336
+ * <button my-button></button>
22337
+ * <my-comp></my-comp>
22338
+ * </app-root>
22339
+ * ```
22340
+ *
22341
+ * Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
22342
+ * directive that is associated with the DOM node.
22343
+ *
22344
+ * Calling `getDirectives` on `<my-comp>` will return an empty array.
22345
+ *
22346
+ * @param node DOM node for which to get the directives.
22347
+ * @returns Array of directives associated with the node.
22348
+ *
22349
+ * @publicApi
22350
+ * @globalApi ng
22351
+ */
22352
+ function getDirectives(node) {
22353
+ // Skip text nodes because we can't have directives associated with them.
22354
+ if (node instanceof Text) {
22355
+ return [];
22707
22356
  }
22708
- onDestroy(callback) {
22709
- ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
22710
- this.destroyCbs.push(callback);
22357
+ const context = getLContext(node);
22358
+ const lView = context ? context.lView : null;
22359
+ if (lView === null) {
22360
+ return [];
22361
+ }
22362
+ const tView = lView[TVIEW];
22363
+ const nodeIndex = context.nodeIndex;
22364
+ if (!tView?.data[nodeIndex]) {
22365
+ return [];
22366
+ }
22367
+ if (context.directives === undefined) {
22368
+ context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
22369
+ }
22370
+ // The `directives` in this case are a named array called `LComponentView`. Clone the
22371
+ // result so we don't expose an internal data structure in the user's console.
22372
+ return context.directives === null ? [] : [...context.directives];
22373
+ }
22374
+ /**
22375
+ * Returns the debug (partial) metadata for a particular directive or component instance.
22376
+ * The function accepts an instance of a directive or component and returns the corresponding
22377
+ * metadata.
22378
+ *
22379
+ * @param directiveOrComponentInstance Instance of a directive or component
22380
+ * @returns metadata of the passed directive or component
22381
+ *
22382
+ * @publicApi
22383
+ * @globalApi ng
22384
+ */
22385
+ function getDirectiveMetadata(directiveOrComponentInstance) {
22386
+ const { constructor } = directiveOrComponentInstance;
22387
+ if (!constructor) {
22388
+ throw new Error('Unable to find the instance constructor');
22711
22389
  }
22712
- }
22713
- class NgModuleFactory extends NgModuleFactory$1 {
22714
- constructor(moduleType) {
22715
- super();
22716
- this.moduleType = moduleType;
22390
+ // In case a component inherits from a directive, we may have component and directive metadata
22391
+ // To ensure we don't get the metadata of the directive, we want to call `getComponentDef` first.
22392
+ const componentDef = getComponentDef$1(constructor);
22393
+ if (componentDef) {
22394
+ return {
22395
+ inputs: componentDef.inputs,
22396
+ outputs: componentDef.outputs,
22397
+ encapsulation: componentDef.encapsulation,
22398
+ changeDetection: componentDef.onPush ? ChangeDetectionStrategy.OnPush :
22399
+ ChangeDetectionStrategy.Default
22400
+ };
22717
22401
  }
22718
- create(parentInjector) {
22719
- return new NgModuleRef(this.moduleType, parentInjector);
22402
+ const directiveDef = getDirectiveDef(constructor);
22403
+ if (directiveDef) {
22404
+ return { inputs: directiveDef.inputs, outputs: directiveDef.outputs };
22720
22405
  }
22406
+ return null;
22721
22407
  }
22722
- class EnvironmentNgModuleRefAdapter extends NgModuleRef$1 {
22723
- constructor(providers, parent, source) {
22724
- super();
22725
- this.componentFactoryResolver = new ComponentFactoryResolver(this);
22726
- this.instance = null;
22727
- const injector = new R3Injector([
22728
- ...providers,
22729
- { provide: NgModuleRef$1, useValue: this },
22730
- { provide: ComponentFactoryResolver$1, useValue: this.componentFactoryResolver },
22731
- ], parent || getNullInjector(), source, new Set(['environment']));
22732
- this.injector = injector;
22733
- injector.resolveInjectorInitializers();
22734
- }
22735
- destroy() {
22736
- this.injector.destroy();
22737
- }
22738
- onDestroy(callback) {
22739
- this.injector.onDestroy(callback);
22408
+ /**
22409
+ * Retrieve map of local references.
22410
+ *
22411
+ * The references are retrieved as a map of local reference name to element or directive instance.
22412
+ *
22413
+ * @param target DOM element, component or directive instance for which to retrieve
22414
+ * the local references.
22415
+ */
22416
+ function getLocalRefs(target) {
22417
+ const context = getLContext(target);
22418
+ if (context === null)
22419
+ return {};
22420
+ if (context.localRefs === undefined) {
22421
+ const lView = context.lView;
22422
+ if (lView === null) {
22423
+ return {};
22424
+ }
22425
+ context.localRefs = discoverLocalRefs(lView, context.nodeIndex);
22740
22426
  }
22427
+ return context.localRefs || {};
22741
22428
  }
22742
22429
  /**
22743
- * Create a new environment injector.
22744
- *
22745
- * Learn more about environment injectors in
22746
- * [this guide](guide/standalone-components#environment-injectors).
22430
+ * Retrieves the host element of a component or directive instance.
22431
+ * The host element is the DOM element that matched the selector of the directive.
22747
22432
  *
22748
- * @param providers An array of providers.
22749
- * @param parent A parent environment injector.
22750
- * @param debugName An optional name for this injector instance, which will be used in error
22751
- * messages.
22433
+ * @param componentOrDirective Component or directive instance for which the host
22434
+ * element should be retrieved.
22435
+ * @returns Host element of the target.
22752
22436
  *
22753
22437
  * @publicApi
22754
- * @developerPreview
22438
+ * @globalApi ng
22755
22439
  */
22756
- function createEnvironmentInjector(providers, parent, debugName = null) {
22757
- const adapter = new EnvironmentNgModuleRefAdapter(providers, parent, debugName);
22758
- return adapter.injector;
22440
+ function getHostElement(componentOrDirective) {
22441
+ return getLContext(componentOrDirective).native;
22759
22442
  }
22760
-
22761
22443
  /**
22762
- * @license
22763
- * Copyright Google LLC All Rights Reserved.
22444
+ * Retrieves the rendered text for a given component.
22764
22445
  *
22765
- * Use of this source code is governed by an MIT-style license that can be
22766
- * found in the LICENSE file at https://angular.io/license
22446
+ * This function retrieves the host element of a component and
22447
+ * and then returns the `textContent` for that element. This implies
22448
+ * that the text returned will include re-projected content of
22449
+ * the component as well.
22450
+ *
22451
+ * @param component The component to return the content text for.
22767
22452
  */
22453
+ function getRenderedText(component) {
22454
+ const hostElement = getHostElement(component);
22455
+ return hostElement.textContent || '';
22456
+ }
22768
22457
  /**
22769
- * A service used by the framework to create instances of standalone injectors. Those injectors are
22770
- * created on demand in case of dynamic component instantiation and contain ambient providers
22771
- * collected from the imports graph rooted at a given standalone component.
22458
+ * Retrieves a list of event listeners associated with a DOM element. The list does include host
22459
+ * listeners, but it does not include event listeners defined outside of the Angular context
22460
+ * (e.g. through `addEventListener`).
22461
+ *
22462
+ * @usageNotes
22463
+ * Given the following DOM structure:
22464
+ *
22465
+ * ```html
22466
+ * <app-root>
22467
+ * <div (click)="doSomething()"></div>
22468
+ * </app-root>
22469
+ * ```
22470
+ *
22471
+ * Calling `getListeners` on `<div>` will return an object that looks as follows:
22472
+ *
22473
+ * ```ts
22474
+ * {
22475
+ * name: 'click',
22476
+ * element: <div>,
22477
+ * callback: () => doSomething(),
22478
+ * useCapture: false
22479
+ * }
22480
+ * ```
22481
+ *
22482
+ * @param element Element for which the DOM listeners should be retrieved.
22483
+ * @returns Array of event listeners on the DOM element.
22484
+ *
22485
+ * @publicApi
22486
+ * @globalApi ng
22772
22487
  */
22773
- class StandaloneService {
22774
- constructor(_injector) {
22775
- this._injector = _injector;
22776
- this.cachedInjectors = new Map();
22777
- }
22778
- getOrCreateStandaloneInjector(componentDef) {
22779
- if (!componentDef.standalone) {
22780
- return null;
22781
- }
22782
- if (!this.cachedInjectors.has(componentDef.id)) {
22783
- const providers = internalImportProvidersFrom(false, componentDef.type);
22784
- const standaloneInjector = providers.length > 0 ?
22785
- createEnvironmentInjector([providers], this._injector, `Standalone[${componentDef.type.name}]`) :
22786
- null;
22787
- this.cachedInjectors.set(componentDef.id, standaloneInjector);
22788
- }
22789
- return this.cachedInjectors.get(componentDef.id);
22790
- }
22791
- ngOnDestroy() {
22792
- try {
22793
- for (const injector of this.cachedInjectors.values()) {
22794
- if (injector !== null) {
22795
- injector.destroy();
22488
+ function getListeners(element) {
22489
+ ngDevMode && assertDomElement(element);
22490
+ const lContext = getLContext(element);
22491
+ const lView = lContext === null ? null : lContext.lView;
22492
+ if (lView === null)
22493
+ return [];
22494
+ const tView = lView[TVIEW];
22495
+ const lCleanup = lView[CLEANUP];
22496
+ const tCleanup = tView.cleanup;
22497
+ const listeners = [];
22498
+ if (tCleanup && lCleanup) {
22499
+ for (let i = 0; i < tCleanup.length;) {
22500
+ const firstParam = tCleanup[i++];
22501
+ const secondParam = tCleanup[i++];
22502
+ if (typeof firstParam === 'string') {
22503
+ const name = firstParam;
22504
+ const listenerElement = unwrapRNode(lView[secondParam]);
22505
+ const callback = lCleanup[tCleanup[i++]];
22506
+ const useCaptureOrIndx = tCleanup[i++];
22507
+ // if useCaptureOrIndx is boolean then report it as is.
22508
+ // if useCaptureOrIndx is positive number then it in unsubscribe method
22509
+ // if useCaptureOrIndx is negative number then it is a Subscription
22510
+ const type = (typeof useCaptureOrIndx === 'boolean' || useCaptureOrIndx >= 0) ? 'dom' : 'output';
22511
+ const useCapture = typeof useCaptureOrIndx === 'boolean' ? useCaptureOrIndx : false;
22512
+ if (element == listenerElement) {
22513
+ listeners.push({ element, name, callback, useCapture, type });
22796
22514
  }
22797
22515
  }
22798
22516
  }
22799
- finally {
22800
- this.cachedInjectors.clear();
22801
- }
22802
22517
  }
22518
+ listeners.sort(sortListeners);
22519
+ return listeners;
22520
+ }
22521
+ function sortListeners(a, b) {
22522
+ if (a.name == b.name)
22523
+ return 0;
22524
+ return a.name < b.name ? -1 : 1;
22803
22525
  }
22804
- /** @nocollapse */
22805
- StandaloneService.ɵprov = ɵɵdefineInjectable({
22806
- token: StandaloneService,
22807
- providedIn: 'environment',
22808
- factory: () => new StandaloneService(ɵɵinject(EnvironmentInjector)),
22809
- });
22810
22526
  /**
22811
- * A feature that acts as a setup code for the {@link StandaloneService}.
22527
+ * This function should not exist because it is megamorphic and only mostly correct.
22812
22528
  *
22813
- * The most important responsaibility of this feature is to expose the "getStandaloneInjector"
22814
- * function (an entry points to a standalone injector creation) on a component definition object. We
22815
- * go through the features infrastructure to make sure that the standalone injector creation logic
22816
- * is tree-shakable and not included in applications that don't use standalone components.
22529
+ * See call site for more info.
22530
+ */
22531
+ function isDirectiveDefHack(obj) {
22532
+ return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
22533
+ }
22534
+ /**
22535
+ * Returns the attached `DebugNode` instance for an element in the DOM.
22817
22536
  *
22818
- * @codeGenApi
22537
+ * @param element DOM element which is owned by an existing component's view.
22819
22538
  */
22820
- function ɵɵStandaloneFeature(definition) {
22821
- definition.getStandaloneInjector = (parentInjector) => {
22822
- return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
22823
- };
22539
+ function getDebugNode(element) {
22540
+ if (ngDevMode && !(element instanceof Node)) {
22541
+ throw new Error('Expecting instance of DOM Element');
22542
+ }
22543
+ const lContext = getLContext(element);
22544
+ const lView = lContext ? lContext.lView : null;
22545
+ if (lView === null) {
22546
+ return null;
22547
+ }
22548
+ const nodeIndex = lContext.nodeIndex;
22549
+ if (nodeIndex !== -1) {
22550
+ const valueInLView = lView[nodeIndex];
22551
+ // this means that value in the lView is a component with its own
22552
+ // data. In this situation the TNode is not accessed at the same spot.
22553
+ const tNode = isLView(valueInLView) ? valueInLView[T_HOST] : getTNode(lView[TVIEW], nodeIndex);
22554
+ ngDevMode &&
22555
+ assertEqual(tNode.index, nodeIndex, 'Expecting that TNode at index is same as index');
22556
+ return buildDebugNode(tNode, lView);
22557
+ }
22558
+ return null;
22559
+ }
22560
+ /**
22561
+ * Retrieve the component `LView` from component/element.
22562
+ *
22563
+ * NOTE: `LView` is a private and should not be leaked outside.
22564
+ * Don't export this method to `ng.*` on window.
22565
+ *
22566
+ * @param target DOM element or component instance for which to retrieve the LView.
22567
+ */
22568
+ function getComponentLView(target) {
22569
+ const lContext = getLContext(target);
22570
+ const nodeIndx = lContext.nodeIndex;
22571
+ const lView = lContext.lView;
22572
+ ngDevMode && assertLView(lView);
22573
+ const componentLView = lView[nodeIndx];
22574
+ ngDevMode && assertLView(componentLView);
22575
+ return componentLView;
22576
+ }
22577
+ /** Asserts that a value is a DOM Element. */
22578
+ function assertDomElement(value) {
22579
+ if (typeof Element !== 'undefined' && !(value instanceof Element)) {
22580
+ throw new Error('Expecting instance of DOM Element');
22581
+ }
22824
22582
  }
22825
22583
 
22826
22584
  /**
@@ -23861,7 +23619,7 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
23861
23619
  // so that a component can use DI tokens provided in MgModules. For this reason, we can not
23862
23620
  // rely on the provided injector, since it might be detached from the DI tree (for example, if
23863
23621
  // it was created via `Injector.create` without specifying a parent injector, or if an
23864
- // injector is retrieved from an `NgModuleRef` created via `createNgModuleRef` using an
23622
+ // injector is retrieved from an `NgModuleRef` created via `createNgModule` using an
23865
23623
  // NgModule outside of a module tree). Instead, we always use `ViewContainerRef`'s parent
23866
23624
  // injector, which is normally connected to the DI tree, which includes module injector
23867
23625
  // subtree.
@@ -24040,7 +23798,7 @@ const unusedValueExportToPlacateAjd = 1;
24040
23798
  * Use of this source code is governed by an MIT-style license that can be
24041
23799
  * found in the LICENSE file at https://angular.io/license
24042
23800
  */
24043
- const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd$4 + unusedValueExportToPlacateAjd;
23801
+ const unusedValueToPlacateAjd = unusedValueExportToPlacateAjd$1 + unusedValueExportToPlacateAjd$6 + unusedValueExportToPlacateAjd$5 + unusedValueExportToPlacateAjd;
24044
23802
  class LQuery_ {
24045
23803
  constructor(queryList) {
24046
23804
  this.queryList = queryList;
@@ -26897,5 +26655,5 @@ const __core_private_testing_placeholder__ = '';
26897
26655
  * Generated bundle index. Do not edit.
26898
26656
  */
26899
26657
 
26900
- export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, async, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick$1 as tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider };
26658
+ export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, async, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider };
26901
26659
  //# sourceMappingURL=testing.mjs.map