@angular/core 13.2.0-rc.0 → 13.2.2

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 (34) hide show
  1. package/core.d.ts +74 -99
  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 +3 -12
  9. package/esm2020/src/metadata/directives.mjs +14 -5
  10. package/esm2020/src/reflection/reflection_capabilities.mjs +2 -2
  11. package/esm2020/src/render3/component_ref.mjs +20 -3
  12. package/esm2020/src/render3/instructions/shared.mjs +2 -2
  13. package/esm2020/src/render3/interfaces/injector.mjs +1 -1
  14. package/esm2020/src/render3/namespaces.mjs +10 -3
  15. package/esm2020/src/render3/node_manipulation.mjs +5 -3
  16. package/esm2020/src/version.mjs +1 -1
  17. package/esm2020/src/zone/ng_zone.mjs +3 -2
  18. package/esm2020/testing/src/logger.mjs +3 -3
  19. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  20. package/esm2020/testing/src/r3_test_bed.mjs +6 -1
  21. package/fesm2015/core.mjs +207 -149
  22. package/fesm2015/core.mjs.map +1 -1
  23. package/fesm2015/testing.mjs +6 -1
  24. package/fesm2015/testing.mjs.map +1 -1
  25. package/fesm2020/core.mjs +207 -149
  26. package/fesm2020/core.mjs.map +1 -1
  27. package/fesm2020/testing.mjs +6 -1
  28. package/fesm2020/testing.mjs.map +1 -1
  29. package/package.json +1 -1
  30. package/schematics/migrations/router-link-empty-expression/index.js +1 -1
  31. package/schematics/migrations/typed-forms/index.js +2 -2
  32. package/schematics/migrations.json +0 -5
  33. package/testing/testing.d.ts +1 -1
  34. 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.0
2
+ * @license Angular v13.2.2
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;
@@ -1552,8 +1569,15 @@ const profiler = function (event, instance, hookOrListener) {
1552
1569
  * Use of this source code is governed by an MIT-style license that can be
1553
1570
  * found in the LICENSE file at https://angular.io/license
1554
1571
  */
1555
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1556
- const MATH_ML_NAMESPACE = 'http://www.w3.org/1998/MathML/';
1572
+ const SVG_NAMESPACE = 'svg';
1573
+ const SVG_NAMESPACE_URI = 'http://www.w3.org/2000/svg';
1574
+ const MATH_ML_NAMESPACE = 'math';
1575
+ const MATH_ML_NAMESPACE_URI = 'http://www.w3.org/1998/MathML/';
1576
+ function getNamespaceUri(namespace) {
1577
+ const name = namespace.toLowerCase();
1578
+ return name === SVG_NAMESPACE ? SVG_NAMESPACE_URI :
1579
+ (name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
1580
+ }
1557
1581
 
1558
1582
  /**
1559
1583
  * @license
@@ -4450,7 +4474,7 @@ const ES2015_INHERITED_CLASS_WITH_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{
4450
4474
  * Regular expression that detects ES2015 classes which extend from other classes
4451
4475
  * and inherit a constructor.
4452
4476
  */
4453
- const ES2015_INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{\s*super\(\.\.\.arguments\)/;
4477
+ const ES2015_INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{[^}]*super\(\.\.\.arguments\)/;
4454
4478
  /**
4455
4479
  * Determine whether a stringified type is a class which delegates its constructor
4456
4480
  * to its parent.
@@ -6973,8 +6997,9 @@ function createElementNode(renderer, name, namespace) {
6973
6997
  return renderer.createElement(name, namespace);
6974
6998
  }
6975
6999
  else {
6976
- return namespace === null ? renderer.createElement(name) :
6977
- renderer.createElementNS(namespace, name);
7000
+ const namespaceUri = namespace !== null ? getNamespaceUri(namespace) : null;
7001
+ return namespaceUri === null ? renderer.createElement(name) :
7002
+ renderer.createElementNS(namespaceUri, name);
6978
7003
  }
6979
7004
  }
6980
7005
  /**
@@ -10369,7 +10394,7 @@ function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
10369
10394
  for (let i = 0; i < localRefs.length; i += 2) {
10370
10395
  const index = exportsMap[localRefs[i + 1]];
10371
10396
  if (index == null)
10372
- 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!`);
10373
10398
  localNames.push(localRefs[i], index);
10374
10399
  }
10375
10400
  }
@@ -11295,10 +11320,7 @@ class R3Injector {
11295
11320
  }
11296
11321
  assertNotDestroyed() {
11297
11322
  if (this._destroyed) {
11298
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11299
- 'Injector has already been destroyed.' :
11300
- '';
11301
- throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, errorMessage);
11323
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && 'Injector has already been destroyed.');
11302
11324
  }
11303
11325
  }
11304
11326
  /**
@@ -11462,28 +11484,21 @@ function injectableDefOrInjectorDefFactory(token) {
11462
11484
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11463
11485
  // If it's missing that, it's an error.
11464
11486
  if (token instanceof InjectionToken) {
11465
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11466
- `Token ${stringify(token)} is missing a ɵprov definition.` :
11467
- '';
11468
- 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.`);
11469
11488
  }
11470
11489
  // Undecorated types can sometimes be created if they have no constructor arguments.
11471
11490
  if (token instanceof Function) {
11472
11491
  return getUndecoratedInjectableFactory(token);
11473
11492
  }
11474
11493
  // There was no way to resolve a factory for this token.
11475
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'unreachable' : '';
11476
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11494
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && 'unreachable');
11477
11495
  }
11478
11496
  function getUndecoratedInjectableFactory(token) {
11479
11497
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11480
11498
  const paramLength = token.length;
11481
11499
  if (paramLength > 0) {
11482
11500
  const args = newArray(paramLength, '?');
11483
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11484
- `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).` :
11485
- '';
11486
- 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(', ')}).`);
11487
11502
  }
11488
11503
  // The constructor function appears to have no parameters.
11489
11504
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -21061,7 +21076,7 @@ class Version {
21061
21076
  /**
21062
21077
  * @publicApi
21063
21078
  */
21064
- const VERSION = new Version('13.2.0-rc.0');
21079
+ const VERSION = new Version('13.2.2');
21065
21080
 
21066
21081
  /**
21067
21082
  * @license
@@ -21089,37 +21104,6 @@ const VERSION = new Version('13.2.0-rc.0');
21089
21104
  // - mod2.injector.get(token, default)
21090
21105
  const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
21091
21106
 
21092
- /**
21093
- * @license
21094
- * Copyright Google LLC All Rights Reserved.
21095
- *
21096
- * Use of this source code is governed by an MIT-style license that can be
21097
- * found in the LICENSE file at https://angular.io/license
21098
- */
21099
- /**
21100
- * Injector that looks up a value using a specific injector, before falling back to the module
21101
- * injector. Used primarily when creating components or embedded views dynamically.
21102
- */
21103
- class ChainedInjector {
21104
- constructor(injector, parentInjector) {
21105
- this.injector = injector;
21106
- this.parentInjector = parentInjector;
21107
- }
21108
- get(token, notFoundValue, flags) {
21109
- const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21110
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21111
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21112
- // Return the value from the root element injector when
21113
- // - it provides it
21114
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21115
- // - the module injector should not be checked
21116
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21117
- return value;
21118
- }
21119
- return this.parentInjector.get(token, notFoundValue, flags);
21120
- }
21121
- }
21122
-
21123
21107
  /**
21124
21108
  * @license
21125
21109
  * Copyright Google LLC All Rights Reserved.
@@ -21505,6 +21489,23 @@ const SCHEDULER = new InjectionToken('SCHEDULER_TOKEN', {
21505
21489
  providedIn: 'root',
21506
21490
  factory: () => defaultScheduler,
21507
21491
  });
21492
+ function createChainedInjector(rootViewInjector, moduleInjector) {
21493
+ return {
21494
+ get: (token, notFoundValue, flags) => {
21495
+ const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21496
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21497
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21498
+ // Return the value from the root element injector when
21499
+ // - it provides it
21500
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21501
+ // - the module injector should not be checked
21502
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21503
+ return value;
21504
+ }
21505
+ return moduleInjector.get(token, notFoundValue, flags);
21506
+ }
21507
+ };
21508
+ }
21508
21509
  /**
21509
21510
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
21510
21511
  */
@@ -21531,7 +21532,7 @@ class ComponentFactory extends ComponentFactory$1 {
21531
21532
  }
21532
21533
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21533
21534
  ngModule = ngModule || this.ngModule;
21534
- const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21535
+ const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21535
21536
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21536
21537
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21537
21538
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -22667,9 +22668,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22667
22668
  this._declarationTContainer = _declarationTContainer;
22668
22669
  this.elementRef = elementRef;
22669
22670
  }
22670
- createEmbeddedView(context, injector) {
22671
+ createEmbeddedView(context) {
22671
22672
  const embeddedTView = this._declarationTContainer.tViews;
22672
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, createEmbeddedViewInjector(injector, this._declarationLView[INJECTOR$1]));
22673
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22673
22674
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22674
22675
  ngDevMode && assertLContainer(declarationLContainer);
22675
22676
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22681,14 +22682,6 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22681
22682
  return new ViewRef$1(embeddedLView);
22682
22683
  }
22683
22684
  };
22684
- function createEmbeddedViewInjector(embeddedViewInjector, declarationViewInjector) {
22685
- if (!embeddedViewInjector) {
22686
- return null;
22687
- }
22688
- return declarationViewInjector ?
22689
- new ChainedInjector(embeddedViewInjector, declarationViewInjector) :
22690
- embeddedViewInjector;
22691
- }
22692
22685
  /**
22693
22686
  * Creates a TemplateRef given a node.
22694
22687
  *
@@ -22793,17 +22786,8 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22793
22786
  get length() {
22794
22787
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22795
22788
  }
22796
- createEmbeddedView(templateRef, context, indexOrOptions) {
22797
- let index;
22798
- let injector;
22799
- if (typeof indexOrOptions === 'number') {
22800
- index = indexOrOptions;
22801
- }
22802
- else if (indexOrOptions != null) {
22803
- index = indexOrOptions.index;
22804
- injector = indexOrOptions.injector;
22805
- }
22806
- const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22789
+ createEmbeddedView(templateRef, context, index) {
22790
+ const viewRef = templateRef.createEmbeddedView(context || {});
22807
22791
  this.insert(viewRef, index);
22808
22792
  return viewRef;
22809
22793
  }
@@ -24571,19 +24555,20 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24571
24555
  *
24572
24556
  * ```
24573
24557
  *
24574
- * The following example registers another DOM event handler that listens for key-press events.
24558
+ * The following example registers another DOM event handler that listens for `Enter` key-press
24559
+ * events on the global `window`.
24575
24560
  * ``` ts
24576
24561
  * import { HostListener, Component } from "@angular/core";
24577
24562
  *
24578
24563
  * @Component({
24579
24564
  * selector: 'app',
24580
- * template: `<h1>Hello, you have pressed keys {{counter}} number of times!</h1> Press any key to
24581
- * increment the counter.
24565
+ * template: `<h1>Hello, you have pressed enter {{counter}} number of times!</h1> Press enter key
24566
+ * to increment the counter.
24582
24567
  * <button (click)="resetCounter()">Reset Counter</button>`
24583
24568
  * })
24584
24569
  * class AppComponent {
24585
24570
  * counter = 0;
24586
- * @HostListener('window:keydown', ['$event'])
24571
+ * @HostListener('window:keydown.enter', ['$event'])
24587
24572
  * handleKeyDown(event: KeyboardEvent) {
24588
24573
  * this.counter++;
24589
24574
  * }
@@ -24592,6 +24577,14 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24592
24577
  * }
24593
24578
  * }
24594
24579
  * ```
24580
+ * The list of valid key names for `keydown` and `keyup` events
24581
+ * can be found here:
24582
+ * https://www.w3.org/TR/DOM-Level-3-Events-key/#named-key-attribute-values
24583
+ *
24584
+ * Note that keys can also be combined, e.g. `@HostListener('keydown.shift.a')`.
24585
+ *
24586
+ * The global target names that can be used to prefix an event name are
24587
+ * `document:`, `window:` and `body:`.
24595
24588
  *
24596
24589
  * @Annotation
24597
24590
  * @publicApi
@@ -25320,7 +25313,8 @@ class NgZone {
25320
25313
  forkInnerZoneWithAngularBehavior(self);
25321
25314
  }
25322
25315
  static isInAngularZone() {
25323
- return Zone.current.get('isAngularZone') === true;
25316
+ // Zone needs to be checked, because this method might be called even when NoopNgZone is used.
25317
+ return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
25324
25318
  }
25325
25319
  static assertInAngularZone() {
25326
25320
  if (!NgZone.isInAngularZone()) {
@@ -25998,26 +25992,7 @@ class PlatformRef {
25998
25992
  this._destroyed = false;
25999
25993
  }
26000
25994
  /**
26001
- * Creates an instance of an `@NgModule` for the given platform for offline compilation.
26002
- *
26003
- * @usageNotes
26004
- *
26005
- * The following example creates the NgModule for a browser platform.
26006
- *
26007
- * ```typescript
26008
- * my_module.ts:
26009
- *
26010
- * @NgModule({
26011
- * imports: [BrowserModule]
26012
- * })
26013
- * class MyModule {}
26014
- *
26015
- * main.ts:
26016
- * import {MyModuleNgFactory} from './my_module.ngfactory';
26017
- * import {platformBrowser} from '@angular/platform-browser';
26018
- *
26019
- * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
26020
- * ```
25995
+ * Creates an instance of an `@NgModule` for the given platform.
26021
25996
  *
26022
25997
  * @deprecated Passing NgModule factories as the `PlatformRef.bootstrapModuleFactory` function
26023
25998
  * argument is deprecated. Use the `PlatformRef.bootstrapModule` API instead.
@@ -26071,7 +26046,7 @@ class PlatformRef {
26071
26046
  });
26072
26047
  }
26073
26048
  /**
26074
- * Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
26049
+ * Creates an instance of an `@NgModule` for a given platform.
26075
26050
  *
26076
26051
  * @usageNotes
26077
26052
  * ### Simple Example
@@ -26818,8 +26793,6 @@ var ng_module_factory_loader_impl = {};
26818
26793
  * Use of this source code is governed by an MIT-style license that can be
26819
26794
  * found in the LICENSE file at https://angular.io/license
26820
26795
  */
26821
- // TODO(alxhub): recombine the interfaces and implementations here and move the docs back onto the
26822
- // original classes.
26823
26796
  /**
26824
26797
  * @publicApi
26825
26798
  */
@@ -26835,43 +26808,88 @@ class DebugEventListener {
26835
26808
  function asNativeElements(debugEls) {
26836
26809
  return debugEls.map((el) => el.nativeElement);
26837
26810
  }
26838
- class DebugNode__POST_R3__ {
26811
+ /**
26812
+ * @publicApi
26813
+ */
26814
+ class DebugNode {
26839
26815
  constructor(nativeNode) {
26840
26816
  this.nativeNode = nativeNode;
26841
26817
  }
26818
+ /**
26819
+ * The `DebugElement` parent. Will be `null` if this is the root element.
26820
+ */
26842
26821
  get parent() {
26843
26822
  const parent = this.nativeNode.parentNode;
26844
- return parent ? new DebugElement__POST_R3__(parent) : null;
26823
+ return parent ? new DebugElement(parent) : null;
26845
26824
  }
26825
+ /**
26826
+ * The host dependency injector. For example, the root element's component instance injector.
26827
+ */
26846
26828
  get injector() {
26847
26829
  return getInjector(this.nativeNode);
26848
26830
  }
26831
+ /**
26832
+ * The element's own component instance, if it has one.
26833
+ */
26849
26834
  get componentInstance() {
26850
26835
  const nativeElement = this.nativeNode;
26851
26836
  return nativeElement &&
26852
26837
  (getComponent$1(nativeElement) || getOwningComponent(nativeElement));
26853
26838
  }
26839
+ /**
26840
+ * An object that provides parent context for this element. Often an ancestor component instance
26841
+ * that governs this element.
26842
+ *
26843
+ * When an element is repeated within *ngFor, the context is an `NgForOf` whose `$implicit`
26844
+ * property is the value of the row instance value. For example, the `hero` in `*ngFor="let hero
26845
+ * of heroes"`.
26846
+ */
26854
26847
  get context() {
26855
26848
  return getComponent$1(this.nativeNode) || getContext(this.nativeNode);
26856
26849
  }
26850
+ /**
26851
+ * The callbacks attached to the component's @Output properties and/or the element's event
26852
+ * properties.
26853
+ */
26857
26854
  get listeners() {
26858
26855
  return getListeners(this.nativeNode).filter(listener => listener.type === 'dom');
26859
26856
  }
26857
+ /**
26858
+ * Dictionary of objects associated with template local variables (e.g. #foo), keyed by the local
26859
+ * variable name.
26860
+ */
26860
26861
  get references() {
26861
26862
  return getLocalRefs(this.nativeNode);
26862
26863
  }
26864
+ /**
26865
+ * This component's injector lookup tokens. Includes the component itself plus the tokens that the
26866
+ * component lists in its providers metadata.
26867
+ */
26863
26868
  get providerTokens() {
26864
26869
  return getInjectionTokens(this.nativeNode);
26865
26870
  }
26866
26871
  }
26867
- class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26872
+ /**
26873
+ * @publicApi
26874
+ *
26875
+ * @see [Component testing scenarios](guide/testing-components-scenarios)
26876
+ * @see [Basics of testing components](guide/testing-components-basics)
26877
+ * @see [Testing utility APIs](guide/testing-utility-apis)
26878
+ */
26879
+ class DebugElement extends DebugNode {
26868
26880
  constructor(nativeNode) {
26869
26881
  ngDevMode && assertDomNode(nativeNode);
26870
26882
  super(nativeNode);
26871
26883
  }
26884
+ /**
26885
+ * The underlying DOM element at the root of the component.
26886
+ */
26872
26887
  get nativeElement() {
26873
26888
  return this.nativeNode.nodeType == Node.ELEMENT_NODE ? this.nativeNode : null;
26874
26889
  }
26890
+ /**
26891
+ * The element tag name, if it is an element.
26892
+ */
26875
26893
  get name() {
26876
26894
  const context = getLContext(this.nativeNode);
26877
26895
  if (context !== null) {
@@ -26912,6 +26930,9 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26912
26930
  collectPropertyBindings(properties, tNode, lView, tData);
26913
26931
  return properties;
26914
26932
  }
26933
+ /**
26934
+ * A map of attribute names to attribute values for an element.
26935
+ */
26915
26936
  get attributes() {
26916
26937
  const attributes = {};
26917
26938
  const element = this.nativeElement;
@@ -26960,12 +26981,29 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26960
26981
  }
26961
26982
  return attributes;
26962
26983
  }
26984
+ /**
26985
+ * The inline styles of the DOM element.
26986
+ *
26987
+ * Will be `null` if there is no `style` property on the underlying DOM element.
26988
+ *
26989
+ * @see [ElementCSSInlineStyle](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style)
26990
+ */
26963
26991
  get styles() {
26964
26992
  if (this.nativeElement && this.nativeElement.style) {
26965
26993
  return this.nativeElement.style;
26966
26994
  }
26967
26995
  return {};
26968
26996
  }
26997
+ /**
26998
+ * A map containing the class names on the element as keys.
26999
+ *
27000
+ * This map is derived from the `className` property of the DOM element.
27001
+ *
27002
+ * Note: The values of this object will always be `true`. The class key will not appear in the KV
27003
+ * object if it does not exist on the element.
27004
+ *
27005
+ * @see [Element.className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className)
27006
+ */
26969
27007
  get classes() {
26970
27008
  const result = {};
26971
27009
  const element = this.nativeElement;
@@ -26975,15 +27013,23 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26975
27013
  classes.forEach((value) => result[value] = true);
26976
27014
  return result;
26977
27015
  }
27016
+ /**
27017
+ * The `childNodes` of the DOM element as a `DebugNode` array.
27018
+ *
27019
+ * @see [Node.childNodes](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes)
27020
+ */
26978
27021
  get childNodes() {
26979
27022
  const childNodes = this.nativeNode.childNodes;
26980
27023
  const children = [];
26981
27024
  for (let i = 0; i < childNodes.length; i++) {
26982
27025
  const element = childNodes[i];
26983
- children.push(getDebugNode__POST_R3__(element));
27026
+ children.push(getDebugNode(element));
26984
27027
  }
26985
27028
  return children;
26986
27029
  }
27030
+ /**
27031
+ * The immediate `DebugElement` children. Walk the tree by descending through `children`.
27032
+ */
26987
27033
  get children() {
26988
27034
  const nativeElement = this.nativeElement;
26989
27035
  if (!nativeElement)
@@ -26992,24 +27038,45 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26992
27038
  const children = [];
26993
27039
  for (let i = 0; i < childNodes.length; i++) {
26994
27040
  const element = childNodes[i];
26995
- children.push(getDebugNode__POST_R3__(element));
27041
+ children.push(getDebugNode(element));
26996
27042
  }
26997
27043
  return children;
26998
27044
  }
27045
+ /**
27046
+ * @returns the first `DebugElement` that matches the predicate at any depth in the subtree.
27047
+ */
26999
27048
  query(predicate) {
27000
27049
  const results = this.queryAll(predicate);
27001
27050
  return results[0] || null;
27002
27051
  }
27052
+ /**
27053
+ * @returns All `DebugElement` matches for the predicate at any depth in the subtree.
27054
+ */
27003
27055
  queryAll(predicate) {
27004
27056
  const matches = [];
27005
- _queryAllR3(this, predicate, matches, true);
27057
+ _queryAll(this, predicate, matches, true);
27006
27058
  return matches;
27007
27059
  }
27060
+ /**
27061
+ * @returns All `DebugNode` matches for the predicate at any depth in the subtree.
27062
+ */
27008
27063
  queryAllNodes(predicate) {
27009
27064
  const matches = [];
27010
- _queryAllR3(this, predicate, matches, false);
27065
+ _queryAll(this, predicate, matches, false);
27011
27066
  return matches;
27012
27067
  }
27068
+ /**
27069
+ * Triggers the event by its name if there is a corresponding listener in the element's
27070
+ * `listeners` collection.
27071
+ *
27072
+ * If the event lacks a listener or there's some other problem, consider
27073
+ * calling `nativeElement.dispatchEvent(eventObject)`.
27074
+ *
27075
+ * @param eventName The name of the event to trigger
27076
+ * @param eventObj The _event object_ expected by the handler
27077
+ *
27078
+ * @see [Testing components scenarios](guide/testing-components-scenarios#trigger-event-handler)
27079
+ */
27013
27080
  triggerEventHandler(eventName, eventObj) {
27014
27081
  const node = this.nativeNode;
27015
27082
  const invokedListeners = [];
@@ -27068,11 +27135,11 @@ function isPrimitiveValue(value) {
27068
27135
  return typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number' ||
27069
27136
  value === null;
27070
27137
  }
27071
- function _queryAllR3(parentElement, predicate, matches, elementsOnly) {
27138
+ function _queryAll(parentElement, predicate, matches, elementsOnly) {
27072
27139
  const context = getLContext(parentElement.nativeNode);
27073
27140
  if (context !== null) {
27074
27141
  const parentTNode = context.lView[TVIEW].data[context.nodeIndex];
27075
- _queryNodeChildrenR3(parentTNode, context.lView, predicate, matches, elementsOnly, parentElement.nativeNode);
27142
+ _queryNodeChildren(parentTNode, context.lView, predicate, matches, elementsOnly, parentElement.nativeNode);
27076
27143
  }
27077
27144
  else {
27078
27145
  // If the context is null, then `parentElement` was either created with Renderer2 or native DOM
@@ -27090,26 +27157,26 @@ function _queryAllR3(parentElement, predicate, matches, elementsOnly) {
27090
27157
  * @param elementsOnly whether only elements should be searched
27091
27158
  * @param rootNativeNode the root native node on which predicate should not be matched
27092
27159
  */
27093
- function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, rootNativeNode) {
27160
+ function _queryNodeChildren(tNode, lView, predicate, matches, elementsOnly, rootNativeNode) {
27094
27161
  ngDevMode && assertTNodeForLView(tNode, lView);
27095
27162
  const nativeNode = getNativeByTNodeOrNull(tNode, lView);
27096
27163
  // For each type of TNode, specific logic is executed.
27097
27164
  if (tNode.type & (3 /* AnyRNode */ | 8 /* ElementContainer */)) {
27098
27165
  // Case 1: the TNode is an element
27099
27166
  // The native node has to be checked.
27100
- _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27167
+ _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27101
27168
  if (isComponentHost(tNode)) {
27102
27169
  // If the element is the host of a component, then all nodes in its view have to be processed.
27103
27170
  // Note: the component's content (tNode.child) will be processed from the insertion points.
27104
27171
  const componentView = getComponentLViewByIndex(tNode.index, lView);
27105
27172
  if (componentView && componentView[TVIEW].firstChild) {
27106
- _queryNodeChildrenR3(componentView[TVIEW].firstChild, componentView, predicate, matches, elementsOnly, rootNativeNode);
27173
+ _queryNodeChildren(componentView[TVIEW].firstChild, componentView, predicate, matches, elementsOnly, rootNativeNode);
27107
27174
  }
27108
27175
  }
27109
27176
  else {
27110
27177
  if (tNode.child) {
27111
27178
  // Otherwise, its children have to be processed.
27112
- _queryNodeChildrenR3(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27179
+ _queryNodeChildren(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27113
27180
  }
27114
27181
  // We also have to query the DOM directly in order to catch elements inserted through
27115
27182
  // Renderer2. Note that this is __not__ optimal, because we're walking similar trees multiple
@@ -27125,16 +27192,16 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27125
27192
  // processed.
27126
27193
  const nodeOrContainer = lView[tNode.index];
27127
27194
  if (isLContainer(nodeOrContainer)) {
27128
- _queryNodeChildrenInContainerR3(nodeOrContainer, predicate, matches, elementsOnly, rootNativeNode);
27195
+ _queryNodeChildrenInContainer(nodeOrContainer, predicate, matches, elementsOnly, rootNativeNode);
27129
27196
  }
27130
27197
  }
27131
27198
  else if (tNode.type & 4 /* Container */) {
27132
27199
  // Case 2: the TNode is a container
27133
27200
  // The native node has to be checked.
27134
27201
  const lContainer = lView[tNode.index];
27135
- _addQueryMatchR3(lContainer[NATIVE], predicate, matches, elementsOnly, rootNativeNode);
27202
+ _addQueryMatch(lContainer[NATIVE], predicate, matches, elementsOnly, rootNativeNode);
27136
27203
  // Each view inside the container has to be processed.
27137
- _queryNodeChildrenInContainerR3(lContainer, predicate, matches, elementsOnly, rootNativeNode);
27204
+ _queryNodeChildrenInContainer(lContainer, predicate, matches, elementsOnly, rootNativeNode);
27138
27205
  }
27139
27206
  else if (tNode.type & 16 /* Projection */) {
27140
27207
  // Case 3: the TNode is a projection insertion point (i.e. a <ng-content>).
@@ -27144,18 +27211,18 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27144
27211
  const head = componentHost.projection[tNode.projection];
27145
27212
  if (Array.isArray(head)) {
27146
27213
  for (let nativeNode of head) {
27147
- _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27214
+ _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27148
27215
  }
27149
27216
  }
27150
27217
  else if (head) {
27151
27218
  const nextLView = componentView[PARENT];
27152
27219
  const nextTNode = nextLView[TVIEW].data[head.index];
27153
- _queryNodeChildrenR3(nextTNode, nextLView, predicate, matches, elementsOnly, rootNativeNode);
27220
+ _queryNodeChildren(nextTNode, nextLView, predicate, matches, elementsOnly, rootNativeNode);
27154
27221
  }
27155
27222
  }
27156
27223
  else if (tNode.child) {
27157
27224
  // Case 4: the TNode is a view.
27158
- _queryNodeChildrenR3(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27225
+ _queryNodeChildren(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27159
27226
  }
27160
27227
  // We don't want to go to the next sibling of the root node.
27161
27228
  if (rootNativeNode !== nativeNode) {
@@ -27163,7 +27230,7 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27163
27230
  // link, depending on whether the current node has been projected.
27164
27231
  const nextTNode = (tNode.flags & 4 /* isProjected */) ? tNode.projectionNext : tNode.next;
27165
27232
  if (nextTNode) {
27166
- _queryNodeChildrenR3(nextTNode, lView, predicate, matches, elementsOnly, rootNativeNode);
27233
+ _queryNodeChildren(nextTNode, lView, predicate, matches, elementsOnly, rootNativeNode);
27167
27234
  }
27168
27235
  }
27169
27236
  }
@@ -27176,12 +27243,12 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27176
27243
  * @param elementsOnly whether only elements should be searched
27177
27244
  * @param rootNativeNode the root native node on which predicate should not be matched
27178
27245
  */
27179
- function _queryNodeChildrenInContainerR3(lContainer, predicate, matches, elementsOnly, rootNativeNode) {
27246
+ function _queryNodeChildrenInContainer(lContainer, predicate, matches, elementsOnly, rootNativeNode) {
27180
27247
  for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
27181
27248
  const childView = lContainer[i];
27182
27249
  const firstChild = childView[TVIEW].firstChild;
27183
27250
  if (firstChild) {
27184
- _queryNodeChildrenR3(firstChild, childView, predicate, matches, elementsOnly, rootNativeNode);
27251
+ _queryNodeChildren(firstChild, childView, predicate, matches, elementsOnly, rootNativeNode);
27185
27252
  }
27186
27253
  }
27187
27254
  }
@@ -27194,7 +27261,7 @@ function _queryNodeChildrenInContainerR3(lContainer, predicate, matches, element
27194
27261
  * @param elementsOnly whether only elements should be searched
27195
27262
  * @param rootNativeNode the root native node on which predicate should not be matched
27196
27263
  */
27197
- function _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode) {
27264
+ function _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode) {
27198
27265
  if (rootNativeNode !== nativeNode) {
27199
27266
  const debugNode = getDebugNode(nativeNode);
27200
27267
  if (!debugNode) {
@@ -27203,7 +27270,7 @@ function _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNati
27203
27270
  // Type of the "predicate and "matches" array are set based on the value of
27204
27271
  // the "elementsOnly" parameter. TypeScript is not able to properly infer these
27205
27272
  // types with generics, so we manually cast the parameters accordingly.
27206
- if (elementsOnly && debugNode instanceof DebugElement__POST_R3__ && predicate(debugNode) &&
27273
+ if (elementsOnly && (debugNode instanceof DebugElement) && predicate(debugNode) &&
27207
27274
  matches.indexOf(debugNode) === -1) {
27208
27275
  matches.push(debugNode);
27209
27276
  }
@@ -27228,7 +27295,7 @@ function _queryNativeNodeDescendants(parentNode, predicate, matches, elementsOnl
27228
27295
  const node = nodes[i];
27229
27296
  const debugNode = getDebugNode(node);
27230
27297
  if (debugNode) {
27231
- if (elementsOnly && debugNode instanceof DebugElement__POST_R3__ && predicate(debugNode) &&
27298
+ if (elementsOnly && (debugNode instanceof DebugElement) && predicate(debugNode) &&
27232
27299
  matches.indexOf(debugNode) === -1) {
27233
27300
  matches.push(debugNode);
27234
27301
  }
@@ -27269,25 +27336,24 @@ function collectPropertyBindings(properties, tNode, lView, tData) {
27269
27336
  // Need to keep the nodes in a global Map so that multiple angular apps are supported.
27270
27337
  const _nativeNodeToDebugNode = new Map();
27271
27338
  const NG_DEBUG_PROPERTY = '__ng_debug__';
27272
- function getDebugNode__POST_R3__(nativeNode) {
27339
+ /**
27340
+ * @publicApi
27341
+ */
27342
+ function getDebugNode(nativeNode) {
27273
27343
  if (nativeNode instanceof Node) {
27274
27344
  if (!(nativeNode.hasOwnProperty(NG_DEBUG_PROPERTY))) {
27275
27345
  nativeNode[NG_DEBUG_PROPERTY] = nativeNode.nodeType == Node.ELEMENT_NODE ?
27276
- new DebugElement__POST_R3__(nativeNode) :
27277
- new DebugNode__POST_R3__(nativeNode);
27346
+ new DebugElement(nativeNode) :
27347
+ new DebugNode(nativeNode);
27278
27348
  }
27279
27349
  return nativeNode[NG_DEBUG_PROPERTY];
27280
27350
  }
27281
27351
  return null;
27282
27352
  }
27283
- /**
27284
- * @publicApi
27285
- */
27286
- const getDebugNode = getDebugNode__POST_R3__;
27287
- function getDebugNodeR2__POST_R3__(_nativeNode) {
27353
+ // TODO: cleanup all references to this function and remove it.
27354
+ function getDebugNodeR2(_nativeNode) {
27288
27355
  return null;
27289
27356
  }
27290
- const getDebugNodeR2 = getDebugNodeR2__POST_R3__;
27291
27357
  function getAllDebugNodes() {
27292
27358
  return Array.from(_nativeNodeToDebugNode.values());
27293
27359
  }
@@ -27297,14 +27363,6 @@ function indexDebugNode(node) {
27297
27363
  function removeDebugNodeFromIndex(node) {
27298
27364
  _nativeNodeToDebugNode.delete(node.nativeNode);
27299
27365
  }
27300
- /**
27301
- * @publicApi
27302
- */
27303
- const DebugNode = DebugNode__POST_R3__;
27304
- /**
27305
- * @publicApi
27306
- */
27307
- const DebugElement = DebugElement__POST_R3__;
27308
27366
 
27309
27367
  /**
27310
27368
  * @license