@angular/core 13.2.0-rc.1 → 13.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/core.d.ts +86 -105
  2. package/esm2020/src/application_ref.mjs +3 -22
  3. package/esm2020/src/debug/debug_node.mjs +128 -45
  4. package/esm2020/src/di/r3_injector.mjs +5 -15
  5. package/esm2020/src/di/reflective_injector.mjs +1 -1
  6. package/esm2020/src/errors.mjs +22 -5
  7. package/esm2020/src/linker/template_ref.mjs +4 -13
  8. package/esm2020/src/linker/view_container_ref.mjs +26 -17
  9. package/esm2020/src/metadata/directives.mjs +14 -5
  10. package/esm2020/src/render3/component_ref.mjs +20 -3
  11. package/esm2020/src/render3/instructions/element.mjs +7 -1
  12. package/esm2020/src/render3/instructions/element_container.mjs +7 -1
  13. package/esm2020/src/render3/instructions/shared.mjs +2 -2
  14. package/esm2020/src/render3/interfaces/injector.mjs +1 -1
  15. package/esm2020/src/version.mjs +1 -1
  16. package/esm2020/src/zone/ng_zone.mjs +3 -2
  17. package/esm2020/testing/src/logger.mjs +3 -3
  18. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  19. package/esm2020/testing/src/r3_test_bed.mjs +6 -1
  20. package/fesm2015/core.mjs +229 -149
  21. package/fesm2015/core.mjs.map +1 -1
  22. package/fesm2015/testing.mjs +6 -1
  23. package/fesm2015/testing.mjs.map +1 -1
  24. package/fesm2020/core.mjs +229 -149
  25. package/fesm2020/core.mjs.map +1 -1
  26. package/fesm2020/testing.mjs +6 -1
  27. package/fesm2020/testing.mjs.map +1 -1
  28. package/package.json +1 -1
  29. package/schematics/migrations/router-link-empty-expression/index.js +1 -1
  30. package/schematics/migrations/typed-forms/index.js +2 -2
  31. package/schematics/migrations.json +0 -5
  32. package/testing/testing.d.ts +1 -1
  33. package/esm2020/src/render3/chained_injector.mjs +0 -32
package/fesm2015/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.2.0-rc.1
2
+ * @license Angular v13.2.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -152,20 +152,37 @@ const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
152
152
  * Use of this source code is governed by an MIT-style license that can be
153
153
  * found in the LICENSE file at https://angular.io/license
154
154
  */
155
+ /**
156
+ * Class that represents a runtime error.
157
+ * Formats and outputs the error message in a consistent way.
158
+ *
159
+ * Example:
160
+ * ```
161
+ * throw new RuntimeError(
162
+ * RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
163
+ * ngDevMode && 'Injector has already been destroyed.');
164
+ * ```
165
+ *
166
+ * Note: the `message` argument contains a descriptive error message as a string in development
167
+ * mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
168
+ * `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
169
+ */
155
170
  class RuntimeError extends Error {
156
171
  constructor(code, message) {
157
172
  super(formatRuntimeError(code, message));
158
173
  this.code = code;
159
174
  }
160
175
  }
161
- /** Called to format a runtime error */
176
+ /**
177
+ * Called to format a runtime error.
178
+ * See additional info on the `message` argument type in the `RuntimeError` class description.
179
+ */
162
180
  function formatRuntimeError(code, message) {
163
- const codeAsNumber = code;
164
181
  // Error code might be a negative number, which is a special marker that instructs the logic to
165
182
  // generate a link to the error details page on angular.io.
166
- const fullCode = `NG0${Math.abs(codeAsNumber)}`;
183
+ const fullCode = `NG0${Math.abs(code)}`;
167
184
  let errorMessage = `${fullCode}${message ? ': ' + message : ''}`;
168
- if (ngDevMode && codeAsNumber < 0) {
185
+ if (ngDevMode && code < 0) {
169
186
  errorMessage = `${errorMessage}. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
170
187
  }
171
188
  return errorMessage;
@@ -10377,7 +10394,7 @@ function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
10377
10394
  for (let i = 0; i < localRefs.length; i += 2) {
10378
10395
  const index = exportsMap[localRefs[i + 1]];
10379
10396
  if (index == null)
10380
- throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, `Export of name '${localRefs[i + 1]}' not found!`);
10397
+ throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, ngDevMode && `Export of name '${localRefs[i + 1]}' not found!`);
10381
10398
  localNames.push(localRefs[i], index);
10382
10399
  }
10383
10400
  }
@@ -11303,10 +11320,7 @@ class R3Injector {
11303
11320
  }
11304
11321
  assertNotDestroyed() {
11305
11322
  if (this._destroyed) {
11306
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11307
- 'Injector has already been destroyed.' :
11308
- '';
11309
- throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, errorMessage);
11323
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && 'Injector has already been destroyed.');
11310
11324
  }
11311
11325
  }
11312
11326
  /**
@@ -11470,28 +11484,21 @@ function injectableDefOrInjectorDefFactory(token) {
11470
11484
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11471
11485
  // If it's missing that, it's an error.
11472
11486
  if (token instanceof InjectionToken) {
11473
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11474
- `Token ${stringify(token)} is missing a ɵprov definition.` :
11475
- '';
11476
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11487
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
11477
11488
  }
11478
11489
  // Undecorated types can sometimes be created if they have no constructor arguments.
11479
11490
  if (token instanceof Function) {
11480
11491
  return getUndecoratedInjectableFactory(token);
11481
11492
  }
11482
11493
  // There was no way to resolve a factory for this token.
11483
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'unreachable' : '';
11484
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11494
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && 'unreachable');
11485
11495
  }
11486
11496
  function getUndecoratedInjectableFactory(token) {
11487
11497
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11488
11498
  const paramLength = token.length;
11489
11499
  if (paramLength > 0) {
11490
11500
  const args = newArray(paramLength, '?');
11491
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11492
- `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).` :
11493
- '';
11494
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11501
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
11495
11502
  }
11496
11503
  // The constructor function appears to have no parameters.
11497
11504
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -14485,6 +14492,7 @@ function elementStartFirstCreatePass(index, tView, lView, native, name, attrsInd
14485
14492
  * @param name Name of the DOM Node
14486
14493
  * @param attrsIndex Index of the element's attributes in the `consts` array.
14487
14494
  * @param localRefsIndex Index of the element's local references in the `consts` array.
14495
+ * @returns This function returns itself so that it may be chained.
14488
14496
  *
14489
14497
  * Attributes and localRefs are passed as an array of strings where elements with an even index
14490
14498
  * hold an attribute name and elements with an odd index hold an attribute value, ex.:
@@ -14536,9 +14544,11 @@ function ɵɵelementStart(index, name, attrsIndex, localRefsIndex) {
14536
14544
  if (localRefsIndex !== null) {
14537
14545
  saveResolvedLocalsInData(lView, tNode);
14538
14546
  }
14547
+ return ɵɵelementStart;
14539
14548
  }
14540
14549
  /**
14541
14550
  * Mark the end of the element.
14551
+ * @returns This function returns itself so that it may be chained.
14542
14552
  *
14543
14553
  * @codeGenApi
14544
14554
  */
@@ -14569,6 +14579,7 @@ function ɵɵelementEnd() {
14569
14579
  if (tNode.stylesWithoutHost != null && hasStyleInput(tNode)) {
14570
14580
  setDirectiveInputsWhichShadowsStyling(tView, tNode, getLView(), tNode.stylesWithoutHost, false);
14571
14581
  }
14582
+ return ɵɵelementEnd;
14572
14583
  }
14573
14584
  /**
14574
14585
  * Creates an empty element using {@link elementStart} and {@link elementEnd}
@@ -14577,12 +14588,14 @@ function ɵɵelementEnd() {
14577
14588
  * @param name Name of the DOM Node
14578
14589
  * @param attrsIndex Index of the element's attributes in the `consts` array.
14579
14590
  * @param localRefsIndex Index of the element's local references in the `consts` array.
14591
+ * @returns This function returns itself so that it may be chained.
14580
14592
  *
14581
14593
  * @codeGenApi
14582
14594
  */
14583
14595
  function ɵɵelement(index, name, attrsIndex, localRefsIndex) {
14584
14596
  ɵɵelementStart(index, name, attrsIndex, localRefsIndex);
14585
14597
  ɵɵelementEnd();
14598
+ return ɵɵelement;
14586
14599
  }
14587
14600
  function logUnknownElementError(tView, element, tNode, hasDirectives) {
14588
14601
  const schemas = tView.schemas;
@@ -14651,6 +14664,7 @@ function elementContainerStartFirstCreatePass(index, tView, lView, attrsIndex, l
14651
14664
  * @param index Index of the element in the LView array
14652
14665
  * @param attrsIndex Index of the container attributes in the `consts` array.
14653
14666
  * @param localRefsIndex Index of the container's local references in the `consts` array.
14667
+ * @returns This function returns itself so that it may be chained.
14654
14668
  *
14655
14669
  * Even if this instruction accepts a set of attributes no actual attribute values are propagated to
14656
14670
  * the DOM (as a comment node can't have attributes). Attributes are here only for directive
@@ -14681,9 +14695,11 @@ function ɵɵelementContainerStart(index, attrsIndex, localRefsIndex) {
14681
14695
  if (localRefsIndex != null) {
14682
14696
  saveResolvedLocalsInData(lView, tNode);
14683
14697
  }
14698
+ return ɵɵelementContainerStart;
14684
14699
  }
14685
14700
  /**
14686
14701
  * Mark the end of the <ng-container>.
14702
+ * @returns This function returns itself so that it may be chained.
14687
14703
  *
14688
14704
  * @codeGenApi
14689
14705
  */
@@ -14705,6 +14721,7 @@ function ɵɵelementContainerEnd() {
14705
14721
  tView.queries.elementEnd(currentTNode);
14706
14722
  }
14707
14723
  }
14724
+ return ɵɵelementContainerEnd;
14708
14725
  }
14709
14726
  /**
14710
14727
  * Creates an empty logical container using {@link elementContainerStart}
@@ -14713,12 +14730,14 @@ function ɵɵelementContainerEnd() {
14713
14730
  * @param index Index of the element in the LView array
14714
14731
  * @param attrsIndex Index of the container attributes in the `consts` array.
14715
14732
  * @param localRefsIndex Index of the container's local references in the `consts` array.
14733
+ * @returns This function returns itself so that it may be chained.
14716
14734
  *
14717
14735
  * @codeGenApi
14718
14736
  */
14719
14737
  function ɵɵelementContainer(index, attrsIndex, localRefsIndex) {
14720
14738
  ɵɵelementContainerStart(index, attrsIndex, localRefsIndex);
14721
14739
  ɵɵelementContainerEnd();
14740
+ return ɵɵelementContainer;
14722
14741
  }
14723
14742
 
14724
14743
  /**
@@ -21069,7 +21088,7 @@ class Version {
21069
21088
  /**
21070
21089
  * @publicApi
21071
21090
  */
21072
- const VERSION = new Version('13.2.0-rc.1');
21091
+ const VERSION = new Version('13.2.3');
21073
21092
 
21074
21093
  /**
21075
21094
  * @license
@@ -21097,37 +21116,6 @@ const VERSION = new Version('13.2.0-rc.1');
21097
21116
  // - mod2.injector.get(token, default)
21098
21117
  const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
21099
21118
 
21100
- /**
21101
- * @license
21102
- * Copyright Google LLC All Rights Reserved.
21103
- *
21104
- * Use of this source code is governed by an MIT-style license that can be
21105
- * found in the LICENSE file at https://angular.io/license
21106
- */
21107
- /**
21108
- * Injector that looks up a value using a specific injector, before falling back to the module
21109
- * injector. Used primarily when creating components or embedded views dynamically.
21110
- */
21111
- class ChainedInjector {
21112
- constructor(injector, parentInjector) {
21113
- this.injector = injector;
21114
- this.parentInjector = parentInjector;
21115
- }
21116
- get(token, notFoundValue, flags) {
21117
- const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21118
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21119
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21120
- // Return the value from the root element injector when
21121
- // - it provides it
21122
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21123
- // - the module injector should not be checked
21124
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21125
- return value;
21126
- }
21127
- return this.parentInjector.get(token, notFoundValue, flags);
21128
- }
21129
- }
21130
-
21131
21119
  /**
21132
21120
  * @license
21133
21121
  * Copyright Google LLC All Rights Reserved.
@@ -21513,6 +21501,23 @@ const SCHEDULER = new InjectionToken('SCHEDULER_TOKEN', {
21513
21501
  providedIn: 'root',
21514
21502
  factory: () => defaultScheduler,
21515
21503
  });
21504
+ function createChainedInjector(rootViewInjector, moduleInjector) {
21505
+ return {
21506
+ get: (token, notFoundValue, flags) => {
21507
+ const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21508
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21509
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21510
+ // Return the value from the root element injector when
21511
+ // - it provides it
21512
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21513
+ // - the module injector should not be checked
21514
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21515
+ return value;
21516
+ }
21517
+ return moduleInjector.get(token, notFoundValue, flags);
21518
+ }
21519
+ };
21520
+ }
21516
21521
  /**
21517
21522
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
21518
21523
  */
@@ -21539,7 +21544,7 @@ class ComponentFactory extends ComponentFactory$1 {
21539
21544
  }
21540
21545
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21541
21546
  ngModule = ngModule || this.ngModule;
21542
- const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21547
+ const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21543
21548
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21544
21549
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21545
21550
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -22675,9 +22680,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22675
22680
  this._declarationTContainer = _declarationTContainer;
22676
22681
  this.elementRef = elementRef;
22677
22682
  }
22678
- createEmbeddedView(context, injector) {
22683
+ createEmbeddedView(context) {
22679
22684
  const embeddedTView = this._declarationTContainer.tViews;
22680
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, createEmbeddedViewInjector(injector, this._declarationLView[INJECTOR$1]));
22685
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22681
22686
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22682
22687
  ngDevMode && assertLContainer(declarationLContainer);
22683
22688
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22689,14 +22694,6 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22689
22694
  return new ViewRef$1(embeddedLView);
22690
22695
  }
22691
22696
  };
22692
- function createEmbeddedViewInjector(embeddedViewInjector, declarationViewInjector) {
22693
- if (!embeddedViewInjector) {
22694
- return null;
22695
- }
22696
- return declarationViewInjector ?
22697
- new ChainedInjector(embeddedViewInjector, declarationViewInjector) :
22698
- embeddedViewInjector;
22699
- }
22700
22697
  /**
22701
22698
  * Creates a TemplateRef given a node.
22702
22699
  *
@@ -22801,17 +22798,8 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22801
22798
  get length() {
22802
22799
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22803
22800
  }
22804
- createEmbeddedView(templateRef, context, indexOrOptions) {
22805
- let index;
22806
- let injector;
22807
- if (typeof indexOrOptions === 'number') {
22808
- index = indexOrOptions;
22809
- }
22810
- else if (indexOrOptions != null) {
22811
- index = indexOrOptions.index;
22812
- injector = indexOrOptions.injector;
22813
- }
22814
- const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22801
+ createEmbeddedView(templateRef, context, index) {
22802
+ const viewRef = templateRef.createEmbeddedView(context || {});
22815
22803
  this.insert(viewRef, index);
22816
22804
  return viewRef;
22817
22805
  }
@@ -22852,11 +22840,29 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22852
22840
  componentFactoryOrType :
22853
22841
  new ComponentFactory(getComponentDef(componentFactoryOrType));
22854
22842
  const contextInjector = injector || this.parentInjector;
22855
- if (!ngModuleRef && componentFactory.ngModule == null && contextInjector) {
22856
- // DO NOT REFACTOR. The code here used to have a `value || undefined` expression
22857
- // which seems to cause internal google apps to fail. This is documented in the
22858
- // following internal bug issue: go/b/142967802
22859
- const result = contextInjector.get(NgModuleRef$1, null);
22843
+ // If an `NgModuleRef` is not provided explicitly, try retrieving it from the DI tree.
22844
+ if (!ngModuleRef && componentFactory.ngModule == null) {
22845
+ // For the `ComponentFactory` case, entering this logic is very unlikely, since we expect that
22846
+ // an instance of a `ComponentFactory`, resolved via `ComponentFactoryResolver` would have an
22847
+ // `ngModule` field. This is possible in some test scenarios and potentially in some JIT-based
22848
+ // use-cases. For the `ComponentFactory` case we preserve backwards-compatibility and try
22849
+ // using a provided injector first, then fall back to the parent injector of this
22850
+ // `ViewContainerRef` instance.
22851
+ //
22852
+ // For the factory-less case, it's critical to establish a connection with the module
22853
+ // injector tree (by retrieving an instance of an `NgModuleRef` and accessing its injector),
22854
+ // so that a component can use DI tokens provided in MgModules. For this reason, we can not
22855
+ // rely on the provided injector, since it might be detached from the DI tree (for example, if
22856
+ // it was created via `Injector.create` without specifying a parent injector, or if an
22857
+ // injector is retrieved from an `NgModuleRef` created via `createNgModuleRef` using an
22858
+ // NgModule outside of a module tree). Instead, we always use `ViewContainerRef`'s parent
22859
+ // injector, which is normally connected to the DI tree, which includes module injector
22860
+ // subtree.
22861
+ const _injector = isComponentFactory ? contextInjector : this.parentInjector;
22862
+ // DO NOT REFACTOR. The code here used to have a `injector.get(NgModuleRef, null) ||
22863
+ // undefined` expression which seems to cause internal google apps to fail. This is documented
22864
+ // in the following internal bug issue: go/b/142967802
22865
+ const result = _injector.get(NgModuleRef$1, null);
22860
22866
  if (result) {
22861
22867
  ngModuleRef = result;
22862
22868
  }
@@ -24579,19 +24585,20 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24579
24585
  *
24580
24586
  * ```
24581
24587
  *
24582
- * The following example registers another DOM event handler that listens for key-press events.
24588
+ * The following example registers another DOM event handler that listens for `Enter` key-press
24589
+ * events on the global `window`.
24583
24590
  * ``` ts
24584
24591
  * import { HostListener, Component } from "@angular/core";
24585
24592
  *
24586
24593
  * @Component({
24587
24594
  * selector: 'app',
24588
- * template: `<h1>Hello, you have pressed keys {{counter}} number of times!</h1> Press any key to
24589
- * increment the counter.
24595
+ * template: `<h1>Hello, you have pressed enter {{counter}} number of times!</h1> Press enter key
24596
+ * to increment the counter.
24590
24597
  * <button (click)="resetCounter()">Reset Counter</button>`
24591
24598
  * })
24592
24599
  * class AppComponent {
24593
24600
  * counter = 0;
24594
- * @HostListener('window:keydown', ['$event'])
24601
+ * @HostListener('window:keydown.enter', ['$event'])
24595
24602
  * handleKeyDown(event: KeyboardEvent) {
24596
24603
  * this.counter++;
24597
24604
  * }
@@ -24600,6 +24607,14 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24600
24607
  * }
24601
24608
  * }
24602
24609
  * ```
24610
+ * The list of valid key names for `keydown` and `keyup` events
24611
+ * can be found here:
24612
+ * https://www.w3.org/TR/DOM-Level-3-Events-key/#named-key-attribute-values
24613
+ *
24614
+ * Note that keys can also be combined, e.g. `@HostListener('keydown.shift.a')`.
24615
+ *
24616
+ * The global target names that can be used to prefix an event name are
24617
+ * `document:`, `window:` and `body:`.
24603
24618
  *
24604
24619
  * @Annotation
24605
24620
  * @publicApi
@@ -25328,7 +25343,8 @@ class NgZone {
25328
25343
  forkInnerZoneWithAngularBehavior(self);
25329
25344
  }
25330
25345
  static isInAngularZone() {
25331
- return Zone.current.get('isAngularZone') === true;
25346
+ // Zone needs to be checked, because this method might be called even when NoopNgZone is used.
25347
+ return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
25332
25348
  }
25333
25349
  static assertInAngularZone() {
25334
25350
  if (!NgZone.isInAngularZone()) {
@@ -26006,26 +26022,7 @@ class PlatformRef {
26006
26022
  this._destroyed = false;
26007
26023
  }
26008
26024
  /**
26009
- * Creates an instance of an `@NgModule` for the given platform for offline compilation.
26010
- *
26011
- * @usageNotes
26012
- *
26013
- * The following example creates the NgModule for a browser platform.
26014
- *
26015
- * ```typescript
26016
- * my_module.ts:
26017
- *
26018
- * @NgModule({
26019
- * imports: [BrowserModule]
26020
- * })
26021
- * class MyModule {}
26022
- *
26023
- * main.ts:
26024
- * import {MyModuleNgFactory} from './my_module.ngfactory';
26025
- * import {platformBrowser} from '@angular/platform-browser';
26026
- *
26027
- * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
26028
- * ```
26025
+ * Creates an instance of an `@NgModule` for the given platform.
26029
26026
  *
26030
26027
  * @deprecated Passing NgModule factories as the `PlatformRef.bootstrapModuleFactory` function
26031
26028
  * argument is deprecated. Use the `PlatformRef.bootstrapModule` API instead.
@@ -26079,7 +26076,7 @@ class PlatformRef {
26079
26076
  });
26080
26077
  }
26081
26078
  /**
26082
- * Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
26079
+ * Creates an instance of an `@NgModule` for a given platform.
26083
26080
  *
26084
26081
  * @usageNotes
26085
26082
  * ### Simple Example
@@ -26826,8 +26823,6 @@ var ng_module_factory_loader_impl = {};
26826
26823
  * Use of this source code is governed by an MIT-style license that can be
26827
26824
  * found in the LICENSE file at https://angular.io/license
26828
26825
  */
26829
- // TODO(alxhub): recombine the interfaces and implementations here and move the docs back onto the
26830
- // original classes.
26831
26826
  /**
26832
26827
  * @publicApi
26833
26828
  */
@@ -26843,43 +26838,88 @@ class DebugEventListener {
26843
26838
  function asNativeElements(debugEls) {
26844
26839
  return debugEls.map((el) => el.nativeElement);
26845
26840
  }
26846
- class DebugNode__POST_R3__ {
26841
+ /**
26842
+ * @publicApi
26843
+ */
26844
+ class DebugNode {
26847
26845
  constructor(nativeNode) {
26848
26846
  this.nativeNode = nativeNode;
26849
26847
  }
26848
+ /**
26849
+ * The `DebugElement` parent. Will be `null` if this is the root element.
26850
+ */
26850
26851
  get parent() {
26851
26852
  const parent = this.nativeNode.parentNode;
26852
- return parent ? new DebugElement__POST_R3__(parent) : null;
26853
+ return parent ? new DebugElement(parent) : null;
26853
26854
  }
26855
+ /**
26856
+ * The host dependency injector. For example, the root element's component instance injector.
26857
+ */
26854
26858
  get injector() {
26855
26859
  return getInjector(this.nativeNode);
26856
26860
  }
26861
+ /**
26862
+ * The element's own component instance, if it has one.
26863
+ */
26857
26864
  get componentInstance() {
26858
26865
  const nativeElement = this.nativeNode;
26859
26866
  return nativeElement &&
26860
26867
  (getComponent$1(nativeElement) || getOwningComponent(nativeElement));
26861
26868
  }
26869
+ /**
26870
+ * An object that provides parent context for this element. Often an ancestor component instance
26871
+ * that governs this element.
26872
+ *
26873
+ * When an element is repeated within *ngFor, the context is an `NgForOf` whose `$implicit`
26874
+ * property is the value of the row instance value. For example, the `hero` in `*ngFor="let hero
26875
+ * of heroes"`.
26876
+ */
26862
26877
  get context() {
26863
26878
  return getComponent$1(this.nativeNode) || getContext(this.nativeNode);
26864
26879
  }
26880
+ /**
26881
+ * The callbacks attached to the component's @Output properties and/or the element's event
26882
+ * properties.
26883
+ */
26865
26884
  get listeners() {
26866
26885
  return getListeners(this.nativeNode).filter(listener => listener.type === 'dom');
26867
26886
  }
26887
+ /**
26888
+ * Dictionary of objects associated with template local variables (e.g. #foo), keyed by the local
26889
+ * variable name.
26890
+ */
26868
26891
  get references() {
26869
26892
  return getLocalRefs(this.nativeNode);
26870
26893
  }
26894
+ /**
26895
+ * This component's injector lookup tokens. Includes the component itself plus the tokens that the
26896
+ * component lists in its providers metadata.
26897
+ */
26871
26898
  get providerTokens() {
26872
26899
  return getInjectionTokens(this.nativeNode);
26873
26900
  }
26874
26901
  }
26875
- class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26902
+ /**
26903
+ * @publicApi
26904
+ *
26905
+ * @see [Component testing scenarios](guide/testing-components-scenarios)
26906
+ * @see [Basics of testing components](guide/testing-components-basics)
26907
+ * @see [Testing utility APIs](guide/testing-utility-apis)
26908
+ */
26909
+ class DebugElement extends DebugNode {
26876
26910
  constructor(nativeNode) {
26877
26911
  ngDevMode && assertDomNode(nativeNode);
26878
26912
  super(nativeNode);
26879
26913
  }
26914
+ /**
26915
+ * The underlying DOM element at the root of the component.
26916
+ */
26880
26917
  get nativeElement() {
26881
26918
  return this.nativeNode.nodeType == Node.ELEMENT_NODE ? this.nativeNode : null;
26882
26919
  }
26920
+ /**
26921
+ * The element tag name, if it is an element.
26922
+ */
26883
26923
  get name() {
26884
26924
  const context = getLContext(this.nativeNode);
26885
26925
  if (context !== null) {
@@ -26920,6 +26960,9 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26920
26960
  collectPropertyBindings(properties, tNode, lView, tData);
26921
26961
  return properties;
26922
26962
  }
26963
+ /**
26964
+ * A map of attribute names to attribute values for an element.
26965
+ */
26923
26966
  get attributes() {
26924
26967
  const attributes = {};
26925
26968
  const element = this.nativeElement;
@@ -26968,12 +27011,29 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26968
27011
  }
26969
27012
  return attributes;
26970
27013
  }
27014
+ /**
27015
+ * The inline styles of the DOM element.
27016
+ *
27017
+ * Will be `null` if there is no `style` property on the underlying DOM element.
27018
+ *
27019
+ * @see [ElementCSSInlineStyle](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style)
27020
+ */
26971
27021
  get styles() {
26972
27022
  if (this.nativeElement && this.nativeElement.style) {
26973
27023
  return this.nativeElement.style;
26974
27024
  }
26975
27025
  return {};
26976
27026
  }
27027
+ /**
27028
+ * A map containing the class names on the element as keys.
27029
+ *
27030
+ * This map is derived from the `className` property of the DOM element.
27031
+ *
27032
+ * Note: The values of this object will always be `true`. The class key will not appear in the KV
27033
+ * object if it does not exist on the element.
27034
+ *
27035
+ * @see [Element.className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className)
27036
+ */
26977
27037
  get classes() {
26978
27038
  const result = {};
26979
27039
  const element = this.nativeElement;
@@ -26983,15 +27043,23 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26983
27043
  classes.forEach((value) => result[value] = true);
26984
27044
  return result;
26985
27045
  }
27046
+ /**
27047
+ * The `childNodes` of the DOM element as a `DebugNode` array.
27048
+ *
27049
+ * @see [Node.childNodes](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes)
27050
+ */
26986
27051
  get childNodes() {
26987
27052
  const childNodes = this.nativeNode.childNodes;
26988
27053
  const children = [];
26989
27054
  for (let i = 0; i < childNodes.length; i++) {
26990
27055
  const element = childNodes[i];
26991
- children.push(getDebugNode__POST_R3__(element));
27056
+ children.push(getDebugNode(element));
26992
27057
  }
26993
27058
  return children;
26994
27059
  }
27060
+ /**
27061
+ * The immediate `DebugElement` children. Walk the tree by descending through `children`.
27062
+ */
26995
27063
  get children() {
26996
27064
  const nativeElement = this.nativeElement;
26997
27065
  if (!nativeElement)
@@ -27000,24 +27068,45 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
27000
27068
  const children = [];
27001
27069
  for (let i = 0; i < childNodes.length; i++) {
27002
27070
  const element = childNodes[i];
27003
- children.push(getDebugNode__POST_R3__(element));
27071
+ children.push(getDebugNode(element));
27004
27072
  }
27005
27073
  return children;
27006
27074
  }
27075
+ /**
27076
+ * @returns the first `DebugElement` that matches the predicate at any depth in the subtree.
27077
+ */
27007
27078
  query(predicate) {
27008
27079
  const results = this.queryAll(predicate);
27009
27080
  return results[0] || null;
27010
27081
  }
27082
+ /**
27083
+ * @returns All `DebugElement` matches for the predicate at any depth in the subtree.
27084
+ */
27011
27085
  queryAll(predicate) {
27012
27086
  const matches = [];
27013
- _queryAllR3(this, predicate, matches, true);
27087
+ _queryAll(this, predicate, matches, true);
27014
27088
  return matches;
27015
27089
  }
27090
+ /**
27091
+ * @returns All `DebugNode` matches for the predicate at any depth in the subtree.
27092
+ */
27016
27093
  queryAllNodes(predicate) {
27017
27094
  const matches = [];
27018
- _queryAllR3(this, predicate, matches, false);
27095
+ _queryAll(this, predicate, matches, false);
27019
27096
  return matches;
27020
27097
  }
27098
+ /**
27099
+ * Triggers the event by its name if there is a corresponding listener in the element's
27100
+ * `listeners` collection.
27101
+ *
27102
+ * If the event lacks a listener or there's some other problem, consider
27103
+ * calling `nativeElement.dispatchEvent(eventObject)`.
27104
+ *
27105
+ * @param eventName The name of the event to trigger
27106
+ * @param eventObj The _event object_ expected by the handler
27107
+ *
27108
+ * @see [Testing components scenarios](guide/testing-components-scenarios#trigger-event-handler)
27109
+ */
27021
27110
  triggerEventHandler(eventName, eventObj) {
27022
27111
  const node = this.nativeNode;
27023
27112
  const invokedListeners = [];
@@ -27076,11 +27165,11 @@ function isPrimitiveValue(value) {
27076
27165
  return typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number' ||
27077
27166
  value === null;
27078
27167
  }
27079
- function _queryAllR3(parentElement, predicate, matches, elementsOnly) {
27168
+ function _queryAll(parentElement, predicate, matches, elementsOnly) {
27080
27169
  const context = getLContext(parentElement.nativeNode);
27081
27170
  if (context !== null) {
27082
27171
  const parentTNode = context.lView[TVIEW].data[context.nodeIndex];
27083
- _queryNodeChildrenR3(parentTNode, context.lView, predicate, matches, elementsOnly, parentElement.nativeNode);
27172
+ _queryNodeChildren(parentTNode, context.lView, predicate, matches, elementsOnly, parentElement.nativeNode);
27084
27173
  }
27085
27174
  else {
27086
27175
  // If the context is null, then `parentElement` was either created with Renderer2 or native DOM
@@ -27098,26 +27187,26 @@ function _queryAllR3(parentElement, predicate, matches, elementsOnly) {
27098
27187
  * @param elementsOnly whether only elements should be searched
27099
27188
  * @param rootNativeNode the root native node on which predicate should not be matched
27100
27189
  */
27101
- function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, rootNativeNode) {
27190
+ function _queryNodeChildren(tNode, lView, predicate, matches, elementsOnly, rootNativeNode) {
27102
27191
  ngDevMode && assertTNodeForLView(tNode, lView);
27103
27192
  const nativeNode = getNativeByTNodeOrNull(tNode, lView);
27104
27193
  // For each type of TNode, specific logic is executed.
27105
27194
  if (tNode.type & (3 /* AnyRNode */ | 8 /* ElementContainer */)) {
27106
27195
  // Case 1: the TNode is an element
27107
27196
  // The native node has to be checked.
27108
- _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27197
+ _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27109
27198
  if (isComponentHost(tNode)) {
27110
27199
  // If the element is the host of a component, then all nodes in its view have to be processed.
27111
27200
  // Note: the component's content (tNode.child) will be processed from the insertion points.
27112
27201
  const componentView = getComponentLViewByIndex(tNode.index, lView);
27113
27202
  if (componentView && componentView[TVIEW].firstChild) {
27114
- _queryNodeChildrenR3(componentView[TVIEW].firstChild, componentView, predicate, matches, elementsOnly, rootNativeNode);
27203
+ _queryNodeChildren(componentView[TVIEW].firstChild, componentView, predicate, matches, elementsOnly, rootNativeNode);
27115
27204
  }
27116
27205
  }
27117
27206
  else {
27118
27207
  if (tNode.child) {
27119
27208
  // Otherwise, its children have to be processed.
27120
- _queryNodeChildrenR3(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27209
+ _queryNodeChildren(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27121
27210
  }
27122
27211
  // We also have to query the DOM directly in order to catch elements inserted through
27123
27212
  // Renderer2. Note that this is __not__ optimal, because we're walking similar trees multiple
@@ -27133,16 +27222,16 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27133
27222
  // processed.
27134
27223
  const nodeOrContainer = lView[tNode.index];
27135
27224
  if (isLContainer(nodeOrContainer)) {
27136
- _queryNodeChildrenInContainerR3(nodeOrContainer, predicate, matches, elementsOnly, rootNativeNode);
27225
+ _queryNodeChildrenInContainer(nodeOrContainer, predicate, matches, elementsOnly, rootNativeNode);
27137
27226
  }
27138
27227
  }
27139
27228
  else if (tNode.type & 4 /* Container */) {
27140
27229
  // Case 2: the TNode is a container
27141
27230
  // The native node has to be checked.
27142
27231
  const lContainer = lView[tNode.index];
27143
- _addQueryMatchR3(lContainer[NATIVE], predicate, matches, elementsOnly, rootNativeNode);
27232
+ _addQueryMatch(lContainer[NATIVE], predicate, matches, elementsOnly, rootNativeNode);
27144
27233
  // Each view inside the container has to be processed.
27145
- _queryNodeChildrenInContainerR3(lContainer, predicate, matches, elementsOnly, rootNativeNode);
27234
+ _queryNodeChildrenInContainer(lContainer, predicate, matches, elementsOnly, rootNativeNode);
27146
27235
  }
27147
27236
  else if (tNode.type & 16 /* Projection */) {
27148
27237
  // Case 3: the TNode is a projection insertion point (i.e. a <ng-content>).
@@ -27152,18 +27241,18 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27152
27241
  const head = componentHost.projection[tNode.projection];
27153
27242
  if (Array.isArray(head)) {
27154
27243
  for (let nativeNode of head) {
27155
- _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27244
+ _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27156
27245
  }
27157
27246
  }
27158
27247
  else if (head) {
27159
27248
  const nextLView = componentView[PARENT];
27160
27249
  const nextTNode = nextLView[TVIEW].data[head.index];
27161
- _queryNodeChildrenR3(nextTNode, nextLView, predicate, matches, elementsOnly, rootNativeNode);
27250
+ _queryNodeChildren(nextTNode, nextLView, predicate, matches, elementsOnly, rootNativeNode);
27162
27251
  }
27163
27252
  }
27164
27253
  else if (tNode.child) {
27165
27254
  // Case 4: the TNode is a view.
27166
- _queryNodeChildrenR3(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27255
+ _queryNodeChildren(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27167
27256
  }
27168
27257
  // We don't want to go to the next sibling of the root node.
27169
27258
  if (rootNativeNode !== nativeNode) {
@@ -27171,7 +27260,7 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27171
27260
  // link, depending on whether the current node has been projected.
27172
27261
  const nextTNode = (tNode.flags & 4 /* isProjected */) ? tNode.projectionNext : tNode.next;
27173
27262
  if (nextTNode) {
27174
- _queryNodeChildrenR3(nextTNode, lView, predicate, matches, elementsOnly, rootNativeNode);
27263
+ _queryNodeChildren(nextTNode, lView, predicate, matches, elementsOnly, rootNativeNode);
27175
27264
  }
27176
27265
  }
27177
27266
  }
@@ -27184,12 +27273,12 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27184
27273
  * @param elementsOnly whether only elements should be searched
27185
27274
  * @param rootNativeNode the root native node on which predicate should not be matched
27186
27275
  */
27187
- function _queryNodeChildrenInContainerR3(lContainer, predicate, matches, elementsOnly, rootNativeNode) {
27276
+ function _queryNodeChildrenInContainer(lContainer, predicate, matches, elementsOnly, rootNativeNode) {
27188
27277
  for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
27189
27278
  const childView = lContainer[i];
27190
27279
  const firstChild = childView[TVIEW].firstChild;
27191
27280
  if (firstChild) {
27192
- _queryNodeChildrenR3(firstChild, childView, predicate, matches, elementsOnly, rootNativeNode);
27281
+ _queryNodeChildren(firstChild, childView, predicate, matches, elementsOnly, rootNativeNode);
27193
27282
  }
27194
27283
  }
27195
27284
  }
@@ -27202,7 +27291,7 @@ function _queryNodeChildrenInContainerR3(lContainer, predicate, matches, element
27202
27291
  * @param elementsOnly whether only elements should be searched
27203
27292
  * @param rootNativeNode the root native node on which predicate should not be matched
27204
27293
  */
27205
- function _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode) {
27294
+ function _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode) {
27206
27295
  if (rootNativeNode !== nativeNode) {
27207
27296
  const debugNode = getDebugNode(nativeNode);
27208
27297
  if (!debugNode) {
@@ -27211,7 +27300,7 @@ function _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNati
27211
27300
  // Type of the "predicate and "matches" array are set based on the value of
27212
27301
  // the "elementsOnly" parameter. TypeScript is not able to properly infer these
27213
27302
  // types with generics, so we manually cast the parameters accordingly.
27214
- if (elementsOnly && debugNode instanceof DebugElement__POST_R3__ && predicate(debugNode) &&
27303
+ if (elementsOnly && (debugNode instanceof DebugElement) && predicate(debugNode) &&
27215
27304
  matches.indexOf(debugNode) === -1) {
27216
27305
  matches.push(debugNode);
27217
27306
  }
@@ -27236,7 +27325,7 @@ function _queryNativeNodeDescendants(parentNode, predicate, matches, elementsOnl
27236
27325
  const node = nodes[i];
27237
27326
  const debugNode = getDebugNode(node);
27238
27327
  if (debugNode) {
27239
- if (elementsOnly && debugNode instanceof DebugElement__POST_R3__ && predicate(debugNode) &&
27328
+ if (elementsOnly && (debugNode instanceof DebugElement) && predicate(debugNode) &&
27240
27329
  matches.indexOf(debugNode) === -1) {
27241
27330
  matches.push(debugNode);
27242
27331
  }
@@ -27277,25 +27366,24 @@ function collectPropertyBindings(properties, tNode, lView, tData) {
27277
27366
  // Need to keep the nodes in a global Map so that multiple angular apps are supported.
27278
27367
  const _nativeNodeToDebugNode = new Map();
27279
27368
  const NG_DEBUG_PROPERTY = '__ng_debug__';
27280
- function getDebugNode__POST_R3__(nativeNode) {
27369
+ /**
27370
+ * @publicApi
27371
+ */
27372
+ function getDebugNode(nativeNode) {
27281
27373
  if (nativeNode instanceof Node) {
27282
27374
  if (!(nativeNode.hasOwnProperty(NG_DEBUG_PROPERTY))) {
27283
27375
  nativeNode[NG_DEBUG_PROPERTY] = nativeNode.nodeType == Node.ELEMENT_NODE ?
27284
- new DebugElement__POST_R3__(nativeNode) :
27285
- new DebugNode__POST_R3__(nativeNode);
27376
+ new DebugElement(nativeNode) :
27377
+ new DebugNode(nativeNode);
27286
27378
  }
27287
27379
  return nativeNode[NG_DEBUG_PROPERTY];
27288
27380
  }
27289
27381
  return null;
27290
27382
  }
27291
- /**
27292
- * @publicApi
27293
- */
27294
- const getDebugNode = getDebugNode__POST_R3__;
27295
- function getDebugNodeR2__POST_R3__(_nativeNode) {
27383
+ // TODO: cleanup all references to this function and remove it.
27384
+ function getDebugNodeR2(_nativeNode) {
27296
27385
  return null;
27297
27386
  }
27298
- const getDebugNodeR2 = getDebugNodeR2__POST_R3__;
27299
27387
  function getAllDebugNodes() {
27300
27388
  return Array.from(_nativeNodeToDebugNode.values());
27301
27389
  }
@@ -27305,14 +27393,6 @@ function indexDebugNode(node) {
27305
27393
  function removeDebugNodeFromIndex(node) {
27306
27394
  _nativeNodeToDebugNode.delete(node.nativeNode);
27307
27395
  }
27308
- /**
27309
- * @publicApi
27310
- */
27311
- const DebugNode = DebugNode__POST_R3__;
27312
- /**
27313
- * @publicApi
27314
- */
27315
- const DebugElement = DebugElement__POST_R3__;
27316
27396
 
27317
27397
  /**
27318
27398
  * @license