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