@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/fesm2020/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;
@@ -1559,8 +1576,15 @@ const profiler = function (event, instance, hookOrListener) {
1559
1576
  * Use of this source code is governed by an MIT-style license that can be
1560
1577
  * found in the LICENSE file at https://angular.io/license
1561
1578
  */
1562
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1563
- const MATH_ML_NAMESPACE = 'http://www.w3.org/1998/MathML/';
1579
+ const SVG_NAMESPACE = 'svg';
1580
+ const SVG_NAMESPACE_URI = 'http://www.w3.org/2000/svg';
1581
+ const MATH_ML_NAMESPACE = 'math';
1582
+ const MATH_ML_NAMESPACE_URI = 'http://www.w3.org/1998/MathML/';
1583
+ function getNamespaceUri(namespace) {
1584
+ const name = namespace.toLowerCase();
1585
+ return name === SVG_NAMESPACE ? SVG_NAMESPACE_URI :
1586
+ (name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
1587
+ }
1564
1588
 
1565
1589
  /**
1566
1590
  * @license
@@ -4471,7 +4495,7 @@ const ES2015_INHERITED_CLASS_WITH_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{
4471
4495
  * Regular expression that detects ES2015 classes which extend from other classes
4472
4496
  * and inherit a constructor.
4473
4497
  */
4474
- const ES2015_INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{\s*super\(\.\.\.arguments\)/;
4498
+ const ES2015_INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{[^}]*super\(\.\.\.arguments\)/;
4475
4499
  /**
4476
4500
  * Determine whether a stringified type is a class which delegates its constructor
4477
4501
  * to its parent.
@@ -6988,8 +7012,9 @@ function createElementNode(renderer, name, namespace) {
6988
7012
  return renderer.createElement(name, namespace);
6989
7013
  }
6990
7014
  else {
6991
- return namespace === null ? renderer.createElement(name) :
6992
- renderer.createElementNS(namespace, name);
7015
+ const namespaceUri = namespace !== null ? getNamespaceUri(namespace) : null;
7016
+ return namespaceUri === null ? renderer.createElement(name) :
7017
+ renderer.createElementNS(namespaceUri, name);
6993
7018
  }
6994
7019
  }
6995
7020
  /**
@@ -10384,7 +10409,7 @@ function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
10384
10409
  for (let i = 0; i < localRefs.length; i += 2) {
10385
10410
  const index = exportsMap[localRefs[i + 1]];
10386
10411
  if (index == null)
10387
- throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, `Export of name '${localRefs[i + 1]}' not found!`);
10412
+ throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, ngDevMode && `Export of name '${localRefs[i + 1]}' not found!`);
10388
10413
  localNames.push(localRefs[i], index);
10389
10414
  }
10390
10415
  }
@@ -11310,10 +11335,7 @@ class R3Injector {
11310
11335
  }
11311
11336
  assertNotDestroyed() {
11312
11337
  if (this._destroyed) {
11313
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11314
- 'Injector has already been destroyed.' :
11315
- '';
11316
- throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, errorMessage);
11338
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && 'Injector has already been destroyed.');
11317
11339
  }
11318
11340
  }
11319
11341
  /**
@@ -11477,28 +11499,21 @@ function injectableDefOrInjectorDefFactory(token) {
11477
11499
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11478
11500
  // If it's missing that, it's an error.
11479
11501
  if (token instanceof InjectionToken) {
11480
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11481
- `Token ${stringify(token)} is missing a ɵprov definition.` :
11482
- '';
11483
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11502
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
11484
11503
  }
11485
11504
  // Undecorated types can sometimes be created if they have no constructor arguments.
11486
11505
  if (token instanceof Function) {
11487
11506
  return getUndecoratedInjectableFactory(token);
11488
11507
  }
11489
11508
  // There was no way to resolve a factory for this token.
11490
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'unreachable' : '';
11491
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11509
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && 'unreachable');
11492
11510
  }
11493
11511
  function getUndecoratedInjectableFactory(token) {
11494
11512
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11495
11513
  const paramLength = token.length;
11496
11514
  if (paramLength > 0) {
11497
11515
  const args = newArray(paramLength, '?');
11498
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11499
- `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).` :
11500
- '';
11501
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11516
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
11502
11517
  }
11503
11518
  // The constructor function appears to have no parameters.
11504
11519
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -21075,7 +21090,7 @@ class Version {
21075
21090
  /**
21076
21091
  * @publicApi
21077
21092
  */
21078
- const VERSION = new Version('13.2.0-rc.0');
21093
+ const VERSION = new Version('13.2.2');
21079
21094
 
21080
21095
  /**
21081
21096
  * @license
@@ -21103,37 +21118,6 @@ const VERSION = new Version('13.2.0-rc.0');
21103
21118
  // - mod2.injector.get(token, default)
21104
21119
  const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
21105
21120
 
21106
- /**
21107
- * @license
21108
- * Copyright Google LLC All Rights Reserved.
21109
- *
21110
- * Use of this source code is governed by an MIT-style license that can be
21111
- * found in the LICENSE file at https://angular.io/license
21112
- */
21113
- /**
21114
- * Injector that looks up a value using a specific injector, before falling back to the module
21115
- * injector. Used primarily when creating components or embedded views dynamically.
21116
- */
21117
- class ChainedInjector {
21118
- constructor(injector, parentInjector) {
21119
- this.injector = injector;
21120
- this.parentInjector = parentInjector;
21121
- }
21122
- get(token, notFoundValue, flags) {
21123
- const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21124
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21125
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21126
- // Return the value from the root element injector when
21127
- // - it provides it
21128
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21129
- // - the module injector should not be checked
21130
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21131
- return value;
21132
- }
21133
- return this.parentInjector.get(token, notFoundValue, flags);
21134
- }
21135
- }
21136
-
21137
21121
  /**
21138
21122
  * @license
21139
21123
  * Copyright Google LLC All Rights Reserved.
@@ -21519,6 +21503,23 @@ const SCHEDULER = new InjectionToken('SCHEDULER_TOKEN', {
21519
21503
  providedIn: 'root',
21520
21504
  factory: () => defaultScheduler,
21521
21505
  });
21506
+ function createChainedInjector(rootViewInjector, moduleInjector) {
21507
+ return {
21508
+ get: (token, notFoundValue, flags) => {
21509
+ const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21510
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21511
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21512
+ // Return the value from the root element injector when
21513
+ // - it provides it
21514
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21515
+ // - the module injector should not be checked
21516
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21517
+ return value;
21518
+ }
21519
+ return moduleInjector.get(token, notFoundValue, flags);
21520
+ }
21521
+ };
21522
+ }
21522
21523
  /**
21523
21524
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
21524
21525
  */
@@ -21545,7 +21546,7 @@ class ComponentFactory extends ComponentFactory$1 {
21545
21546
  }
21546
21547
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21547
21548
  ngModule = ngModule || this.ngModule;
21548
- const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21549
+ const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21549
21550
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21550
21551
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21551
21552
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -22680,9 +22681,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22680
22681
  this._declarationTContainer = _declarationTContainer;
22681
22682
  this.elementRef = elementRef;
22682
22683
  }
22683
- createEmbeddedView(context, injector) {
22684
+ createEmbeddedView(context) {
22684
22685
  const embeddedTView = this._declarationTContainer.tViews;
22685
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, createEmbeddedViewInjector(injector, this._declarationLView[INJECTOR$1]));
22686
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22686
22687
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22687
22688
  ngDevMode && assertLContainer(declarationLContainer);
22688
22689
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22694,14 +22695,6 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22694
22695
  return new ViewRef$1(embeddedLView);
22695
22696
  }
22696
22697
  };
22697
- function createEmbeddedViewInjector(embeddedViewInjector, declarationViewInjector) {
22698
- if (!embeddedViewInjector) {
22699
- return null;
22700
- }
22701
- return declarationViewInjector ?
22702
- new ChainedInjector(embeddedViewInjector, declarationViewInjector) :
22703
- embeddedViewInjector;
22704
- }
22705
22698
  /**
22706
22699
  * Creates a TemplateRef given a node.
22707
22700
  *
@@ -22806,17 +22799,8 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22806
22799
  get length() {
22807
22800
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22808
22801
  }
22809
- createEmbeddedView(templateRef, context, indexOrOptions) {
22810
- let index;
22811
- let injector;
22812
- if (typeof indexOrOptions === 'number') {
22813
- index = indexOrOptions;
22814
- }
22815
- else if (indexOrOptions != null) {
22816
- index = indexOrOptions.index;
22817
- injector = indexOrOptions.injector;
22818
- }
22819
- const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22802
+ createEmbeddedView(templateRef, context, index) {
22803
+ const viewRef = templateRef.createEmbeddedView(context || {});
22820
22804
  this.insert(viewRef, index);
22821
22805
  return viewRef;
22822
22806
  }
@@ -24597,19 +24581,20 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24597
24581
  *
24598
24582
  * ```
24599
24583
  *
24600
- * The following example registers another DOM event handler that listens for key-press events.
24584
+ * The following example registers another DOM event handler that listens for `Enter` key-press
24585
+ * events on the global `window`.
24601
24586
  * ``` ts
24602
24587
  * import { HostListener, Component } from "@angular/core";
24603
24588
  *
24604
24589
  * @Component({
24605
24590
  * selector: 'app',
24606
- * template: `<h1>Hello, you have pressed keys {{counter}} number of times!</h1> Press any key to
24607
- * increment the counter.
24591
+ * template: `<h1>Hello, you have pressed enter {{counter}} number of times!</h1> Press enter key
24592
+ * to increment the counter.
24608
24593
  * <button (click)="resetCounter()">Reset Counter</button>`
24609
24594
  * })
24610
24595
  * class AppComponent {
24611
24596
  * counter = 0;
24612
- * @HostListener('window:keydown', ['$event'])
24597
+ * @HostListener('window:keydown.enter', ['$event'])
24613
24598
  * handleKeyDown(event: KeyboardEvent) {
24614
24599
  * this.counter++;
24615
24600
  * }
@@ -24618,6 +24603,14 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24618
24603
  * }
24619
24604
  * }
24620
24605
  * ```
24606
+ * The list of valid key names for `keydown` and `keyup` events
24607
+ * can be found here:
24608
+ * https://www.w3.org/TR/DOM-Level-3-Events-key/#named-key-attribute-values
24609
+ *
24610
+ * Note that keys can also be combined, e.g. `@HostListener('keydown.shift.a')`.
24611
+ *
24612
+ * The global target names that can be used to prefix an event name are
24613
+ * `document:`, `window:` and `body:`.
24621
24614
  *
24622
24615
  * @Annotation
24623
24616
  * @publicApi
@@ -25346,7 +25339,8 @@ class NgZone {
25346
25339
  forkInnerZoneWithAngularBehavior(self);
25347
25340
  }
25348
25341
  static isInAngularZone() {
25349
- return Zone.current.get('isAngularZone') === true;
25342
+ // Zone needs to be checked, because this method might be called even when NoopNgZone is used.
25343
+ return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
25350
25344
  }
25351
25345
  static assertInAngularZone() {
25352
25346
  if (!NgZone.isInAngularZone()) {
@@ -26020,26 +26014,7 @@ class PlatformRef {
26020
26014
  this._destroyed = false;
26021
26015
  }
26022
26016
  /**
26023
- * Creates an instance of an `@NgModule` for the given platform for offline compilation.
26024
- *
26025
- * @usageNotes
26026
- *
26027
- * The following example creates the NgModule for a browser platform.
26028
- *
26029
- * ```typescript
26030
- * my_module.ts:
26031
- *
26032
- * @NgModule({
26033
- * imports: [BrowserModule]
26034
- * })
26035
- * class MyModule {}
26036
- *
26037
- * main.ts:
26038
- * import {MyModuleNgFactory} from './my_module.ngfactory';
26039
- * import {platformBrowser} from '@angular/platform-browser';
26040
- *
26041
- * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
26042
- * ```
26017
+ * Creates an instance of an `@NgModule` for the given platform.
26043
26018
  *
26044
26019
  * @deprecated Passing NgModule factories as the `PlatformRef.bootstrapModuleFactory` function
26045
26020
  * argument is deprecated. Use the `PlatformRef.bootstrapModule` API instead.
@@ -26093,7 +26068,7 @@ class PlatformRef {
26093
26068
  });
26094
26069
  }
26095
26070
  /**
26096
- * Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
26071
+ * Creates an instance of an `@NgModule` for a given platform.
26097
26072
  *
26098
26073
  * @usageNotes
26099
26074
  * ### Simple Example
@@ -26836,8 +26811,6 @@ var ng_module_factory_loader_impl = {};
26836
26811
  * Use of this source code is governed by an MIT-style license that can be
26837
26812
  * found in the LICENSE file at https://angular.io/license
26838
26813
  */
26839
- // TODO(alxhub): recombine the interfaces and implementations here and move the docs back onto the
26840
- // original classes.
26841
26814
  /**
26842
26815
  * @publicApi
26843
26816
  */
@@ -26853,43 +26826,88 @@ class DebugEventListener {
26853
26826
  function asNativeElements(debugEls) {
26854
26827
  return debugEls.map((el) => el.nativeElement);
26855
26828
  }
26856
- class DebugNode__POST_R3__ {
26829
+ /**
26830
+ * @publicApi
26831
+ */
26832
+ class DebugNode {
26857
26833
  constructor(nativeNode) {
26858
26834
  this.nativeNode = nativeNode;
26859
26835
  }
26836
+ /**
26837
+ * The `DebugElement` parent. Will be `null` if this is the root element.
26838
+ */
26860
26839
  get parent() {
26861
26840
  const parent = this.nativeNode.parentNode;
26862
- return parent ? new DebugElement__POST_R3__(parent) : null;
26841
+ return parent ? new DebugElement(parent) : null;
26863
26842
  }
26843
+ /**
26844
+ * The host dependency injector. For example, the root element's component instance injector.
26845
+ */
26864
26846
  get injector() {
26865
26847
  return getInjector(this.nativeNode);
26866
26848
  }
26849
+ /**
26850
+ * The element's own component instance, if it has one.
26851
+ */
26867
26852
  get componentInstance() {
26868
26853
  const nativeElement = this.nativeNode;
26869
26854
  return nativeElement &&
26870
26855
  (getComponent$1(nativeElement) || getOwningComponent(nativeElement));
26871
26856
  }
26857
+ /**
26858
+ * An object that provides parent context for this element. Often an ancestor component instance
26859
+ * that governs this element.
26860
+ *
26861
+ * When an element is repeated within *ngFor, the context is an `NgForOf` whose `$implicit`
26862
+ * property is the value of the row instance value. For example, the `hero` in `*ngFor="let hero
26863
+ * of heroes"`.
26864
+ */
26872
26865
  get context() {
26873
26866
  return getComponent$1(this.nativeNode) || getContext(this.nativeNode);
26874
26867
  }
26868
+ /**
26869
+ * The callbacks attached to the component's @Output properties and/or the element's event
26870
+ * properties.
26871
+ */
26875
26872
  get listeners() {
26876
26873
  return getListeners(this.nativeNode).filter(listener => listener.type === 'dom');
26877
26874
  }
26875
+ /**
26876
+ * Dictionary of objects associated with template local variables (e.g. #foo), keyed by the local
26877
+ * variable name.
26878
+ */
26878
26879
  get references() {
26879
26880
  return getLocalRefs(this.nativeNode);
26880
26881
  }
26882
+ /**
26883
+ * This component's injector lookup tokens. Includes the component itself plus the tokens that the
26884
+ * component lists in its providers metadata.
26885
+ */
26881
26886
  get providerTokens() {
26882
26887
  return getInjectionTokens(this.nativeNode);
26883
26888
  }
26884
26889
  }
26885
- class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26890
+ /**
26891
+ * @publicApi
26892
+ *
26893
+ * @see [Component testing scenarios](guide/testing-components-scenarios)
26894
+ * @see [Basics of testing components](guide/testing-components-basics)
26895
+ * @see [Testing utility APIs](guide/testing-utility-apis)
26896
+ */
26897
+ class DebugElement extends DebugNode {
26886
26898
  constructor(nativeNode) {
26887
26899
  ngDevMode && assertDomNode(nativeNode);
26888
26900
  super(nativeNode);
26889
26901
  }
26902
+ /**
26903
+ * The underlying DOM element at the root of the component.
26904
+ */
26890
26905
  get nativeElement() {
26891
26906
  return this.nativeNode.nodeType == Node.ELEMENT_NODE ? this.nativeNode : null;
26892
26907
  }
26908
+ /**
26909
+ * The element tag name, if it is an element.
26910
+ */
26893
26911
  get name() {
26894
26912
  const context = getLContext(this.nativeNode);
26895
26913
  if (context !== null) {
@@ -26930,6 +26948,9 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26930
26948
  collectPropertyBindings(properties, tNode, lView, tData);
26931
26949
  return properties;
26932
26950
  }
26951
+ /**
26952
+ * A map of attribute names to attribute values for an element.
26953
+ */
26933
26954
  get attributes() {
26934
26955
  const attributes = {};
26935
26956
  const element = this.nativeElement;
@@ -26978,12 +26999,29 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26978
26999
  }
26979
27000
  return attributes;
26980
27001
  }
27002
+ /**
27003
+ * The inline styles of the DOM element.
27004
+ *
27005
+ * Will be `null` if there is no `style` property on the underlying DOM element.
27006
+ *
27007
+ * @see [ElementCSSInlineStyle](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style)
27008
+ */
26981
27009
  get styles() {
26982
27010
  if (this.nativeElement && this.nativeElement.style) {
26983
27011
  return this.nativeElement.style;
26984
27012
  }
26985
27013
  return {};
26986
27014
  }
27015
+ /**
27016
+ * A map containing the class names on the element as keys.
27017
+ *
27018
+ * This map is derived from the `className` property of the DOM element.
27019
+ *
27020
+ * Note: The values of this object will always be `true`. The class key will not appear in the KV
27021
+ * object if it does not exist on the element.
27022
+ *
27023
+ * @see [Element.className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className)
27024
+ */
26987
27025
  get classes() {
26988
27026
  const result = {};
26989
27027
  const element = this.nativeElement;
@@ -26993,15 +27031,23 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
26993
27031
  classes.forEach((value) => result[value] = true);
26994
27032
  return result;
26995
27033
  }
27034
+ /**
27035
+ * The `childNodes` of the DOM element as a `DebugNode` array.
27036
+ *
27037
+ * @see [Node.childNodes](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes)
27038
+ */
26996
27039
  get childNodes() {
26997
27040
  const childNodes = this.nativeNode.childNodes;
26998
27041
  const children = [];
26999
27042
  for (let i = 0; i < childNodes.length; i++) {
27000
27043
  const element = childNodes[i];
27001
- children.push(getDebugNode__POST_R3__(element));
27044
+ children.push(getDebugNode(element));
27002
27045
  }
27003
27046
  return children;
27004
27047
  }
27048
+ /**
27049
+ * The immediate `DebugElement` children. Walk the tree by descending through `children`.
27050
+ */
27005
27051
  get children() {
27006
27052
  const nativeElement = this.nativeElement;
27007
27053
  if (!nativeElement)
@@ -27010,24 +27056,45 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ {
27010
27056
  const children = [];
27011
27057
  for (let i = 0; i < childNodes.length; i++) {
27012
27058
  const element = childNodes[i];
27013
- children.push(getDebugNode__POST_R3__(element));
27059
+ children.push(getDebugNode(element));
27014
27060
  }
27015
27061
  return children;
27016
27062
  }
27063
+ /**
27064
+ * @returns the first `DebugElement` that matches the predicate at any depth in the subtree.
27065
+ */
27017
27066
  query(predicate) {
27018
27067
  const results = this.queryAll(predicate);
27019
27068
  return results[0] || null;
27020
27069
  }
27070
+ /**
27071
+ * @returns All `DebugElement` matches for the predicate at any depth in the subtree.
27072
+ */
27021
27073
  queryAll(predicate) {
27022
27074
  const matches = [];
27023
- _queryAllR3(this, predicate, matches, true);
27075
+ _queryAll(this, predicate, matches, true);
27024
27076
  return matches;
27025
27077
  }
27078
+ /**
27079
+ * @returns All `DebugNode` matches for the predicate at any depth in the subtree.
27080
+ */
27026
27081
  queryAllNodes(predicate) {
27027
27082
  const matches = [];
27028
- _queryAllR3(this, predicate, matches, false);
27083
+ _queryAll(this, predicate, matches, false);
27029
27084
  return matches;
27030
27085
  }
27086
+ /**
27087
+ * Triggers the event by its name if there is a corresponding listener in the element's
27088
+ * `listeners` collection.
27089
+ *
27090
+ * If the event lacks a listener or there's some other problem, consider
27091
+ * calling `nativeElement.dispatchEvent(eventObject)`.
27092
+ *
27093
+ * @param eventName The name of the event to trigger
27094
+ * @param eventObj The _event object_ expected by the handler
27095
+ *
27096
+ * @see [Testing components scenarios](guide/testing-components-scenarios#trigger-event-handler)
27097
+ */
27031
27098
  triggerEventHandler(eventName, eventObj) {
27032
27099
  const node = this.nativeNode;
27033
27100
  const invokedListeners = [];
@@ -27086,11 +27153,11 @@ function isPrimitiveValue(value) {
27086
27153
  return typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number' ||
27087
27154
  value === null;
27088
27155
  }
27089
- function _queryAllR3(parentElement, predicate, matches, elementsOnly) {
27156
+ function _queryAll(parentElement, predicate, matches, elementsOnly) {
27090
27157
  const context = getLContext(parentElement.nativeNode);
27091
27158
  if (context !== null) {
27092
27159
  const parentTNode = context.lView[TVIEW].data[context.nodeIndex];
27093
- _queryNodeChildrenR3(parentTNode, context.lView, predicate, matches, elementsOnly, parentElement.nativeNode);
27160
+ _queryNodeChildren(parentTNode, context.lView, predicate, matches, elementsOnly, parentElement.nativeNode);
27094
27161
  }
27095
27162
  else {
27096
27163
  // If the context is null, then `parentElement` was either created with Renderer2 or native DOM
@@ -27108,26 +27175,26 @@ function _queryAllR3(parentElement, predicate, matches, elementsOnly) {
27108
27175
  * @param elementsOnly whether only elements should be searched
27109
27176
  * @param rootNativeNode the root native node on which predicate should not be matched
27110
27177
  */
27111
- function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, rootNativeNode) {
27178
+ function _queryNodeChildren(tNode, lView, predicate, matches, elementsOnly, rootNativeNode) {
27112
27179
  ngDevMode && assertTNodeForLView(tNode, lView);
27113
27180
  const nativeNode = getNativeByTNodeOrNull(tNode, lView);
27114
27181
  // For each type of TNode, specific logic is executed.
27115
27182
  if (tNode.type & (3 /* AnyRNode */ | 8 /* ElementContainer */)) {
27116
27183
  // Case 1: the TNode is an element
27117
27184
  // The native node has to be checked.
27118
- _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27185
+ _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27119
27186
  if (isComponentHost(tNode)) {
27120
27187
  // If the element is the host of a component, then all nodes in its view have to be processed.
27121
27188
  // Note: the component's content (tNode.child) will be processed from the insertion points.
27122
27189
  const componentView = getComponentLViewByIndex(tNode.index, lView);
27123
27190
  if (componentView && componentView[TVIEW].firstChild) {
27124
- _queryNodeChildrenR3(componentView[TVIEW].firstChild, componentView, predicate, matches, elementsOnly, rootNativeNode);
27191
+ _queryNodeChildren(componentView[TVIEW].firstChild, componentView, predicate, matches, elementsOnly, rootNativeNode);
27125
27192
  }
27126
27193
  }
27127
27194
  else {
27128
27195
  if (tNode.child) {
27129
27196
  // Otherwise, its children have to be processed.
27130
- _queryNodeChildrenR3(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27197
+ _queryNodeChildren(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27131
27198
  }
27132
27199
  // We also have to query the DOM directly in order to catch elements inserted through
27133
27200
  // Renderer2. Note that this is __not__ optimal, because we're walking similar trees multiple
@@ -27143,16 +27210,16 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27143
27210
  // processed.
27144
27211
  const nodeOrContainer = lView[tNode.index];
27145
27212
  if (isLContainer(nodeOrContainer)) {
27146
- _queryNodeChildrenInContainerR3(nodeOrContainer, predicate, matches, elementsOnly, rootNativeNode);
27213
+ _queryNodeChildrenInContainer(nodeOrContainer, predicate, matches, elementsOnly, rootNativeNode);
27147
27214
  }
27148
27215
  }
27149
27216
  else if (tNode.type & 4 /* Container */) {
27150
27217
  // Case 2: the TNode is a container
27151
27218
  // The native node has to be checked.
27152
27219
  const lContainer = lView[tNode.index];
27153
- _addQueryMatchR3(lContainer[NATIVE], predicate, matches, elementsOnly, rootNativeNode);
27220
+ _addQueryMatch(lContainer[NATIVE], predicate, matches, elementsOnly, rootNativeNode);
27154
27221
  // Each view inside the container has to be processed.
27155
- _queryNodeChildrenInContainerR3(lContainer, predicate, matches, elementsOnly, rootNativeNode);
27222
+ _queryNodeChildrenInContainer(lContainer, predicate, matches, elementsOnly, rootNativeNode);
27156
27223
  }
27157
27224
  else if (tNode.type & 16 /* Projection */) {
27158
27225
  // Case 3: the TNode is a projection insertion point (i.e. a <ng-content>).
@@ -27162,18 +27229,18 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27162
27229
  const head = componentHost.projection[tNode.projection];
27163
27230
  if (Array.isArray(head)) {
27164
27231
  for (let nativeNode of head) {
27165
- _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27232
+ _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode);
27166
27233
  }
27167
27234
  }
27168
27235
  else if (head) {
27169
27236
  const nextLView = componentView[PARENT];
27170
27237
  const nextTNode = nextLView[TVIEW].data[head.index];
27171
- _queryNodeChildrenR3(nextTNode, nextLView, predicate, matches, elementsOnly, rootNativeNode);
27238
+ _queryNodeChildren(nextTNode, nextLView, predicate, matches, elementsOnly, rootNativeNode);
27172
27239
  }
27173
27240
  }
27174
27241
  else if (tNode.child) {
27175
27242
  // Case 4: the TNode is a view.
27176
- _queryNodeChildrenR3(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27243
+ _queryNodeChildren(tNode.child, lView, predicate, matches, elementsOnly, rootNativeNode);
27177
27244
  }
27178
27245
  // We don't want to go to the next sibling of the root node.
27179
27246
  if (rootNativeNode !== nativeNode) {
@@ -27181,7 +27248,7 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
27181
27248
  // link, depending on whether the current node has been projected.
27182
27249
  const nextTNode = (tNode.flags & 4 /* isProjected */) ? tNode.projectionNext : tNode.next;
27183
27250
  if (nextTNode) {
27184
- _queryNodeChildrenR3(nextTNode, lView, predicate, matches, elementsOnly, rootNativeNode);
27251
+ _queryNodeChildren(nextTNode, lView, predicate, matches, elementsOnly, rootNativeNode);
27185
27252
  }
27186
27253
  }
27187
27254
  }
@@ -27194,12 +27261,12 @@ function _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly, ro
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 _queryNodeChildrenInContainerR3(lContainer, predicate, matches, elementsOnly, rootNativeNode) {
27264
+ function _queryNodeChildrenInContainer(lContainer, predicate, matches, elementsOnly, rootNativeNode) {
27198
27265
  for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
27199
27266
  const childView = lContainer[i];
27200
27267
  const firstChild = childView[TVIEW].firstChild;
27201
27268
  if (firstChild) {
27202
- _queryNodeChildrenR3(firstChild, childView, predicate, matches, elementsOnly, rootNativeNode);
27269
+ _queryNodeChildren(firstChild, childView, predicate, matches, elementsOnly, rootNativeNode);
27203
27270
  }
27204
27271
  }
27205
27272
  }
@@ -27212,7 +27279,7 @@ function _queryNodeChildrenInContainerR3(lContainer, predicate, matches, element
27212
27279
  * @param elementsOnly whether only elements should be searched
27213
27280
  * @param rootNativeNode the root native node on which predicate should not be matched
27214
27281
  */
27215
- function _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNativeNode) {
27282
+ function _addQueryMatch(nativeNode, predicate, matches, elementsOnly, rootNativeNode) {
27216
27283
  if (rootNativeNode !== nativeNode) {
27217
27284
  const debugNode = getDebugNode(nativeNode);
27218
27285
  if (!debugNode) {
@@ -27221,7 +27288,7 @@ function _addQueryMatchR3(nativeNode, predicate, matches, elementsOnly, rootNati
27221
27288
  // Type of the "predicate and "matches" array are set based on the value of
27222
27289
  // the "elementsOnly" parameter. TypeScript is not able to properly infer these
27223
27290
  // types with generics, so we manually cast the parameters accordingly.
27224
- if (elementsOnly && debugNode instanceof DebugElement__POST_R3__ && predicate(debugNode) &&
27291
+ if (elementsOnly && (debugNode instanceof DebugElement) && predicate(debugNode) &&
27225
27292
  matches.indexOf(debugNode) === -1) {
27226
27293
  matches.push(debugNode);
27227
27294
  }
@@ -27246,7 +27313,7 @@ function _queryNativeNodeDescendants(parentNode, predicate, matches, elementsOnl
27246
27313
  const node = nodes[i];
27247
27314
  const debugNode = getDebugNode(node);
27248
27315
  if (debugNode) {
27249
- if (elementsOnly && debugNode instanceof DebugElement__POST_R3__ && predicate(debugNode) &&
27316
+ if (elementsOnly && (debugNode instanceof DebugElement) && predicate(debugNode) &&
27250
27317
  matches.indexOf(debugNode) === -1) {
27251
27318
  matches.push(debugNode);
27252
27319
  }
@@ -27287,25 +27354,24 @@ function collectPropertyBindings(properties, tNode, lView, tData) {
27287
27354
  // Need to keep the nodes in a global Map so that multiple angular apps are supported.
27288
27355
  const _nativeNodeToDebugNode = new Map();
27289
27356
  const NG_DEBUG_PROPERTY = '__ng_debug__';
27290
- function getDebugNode__POST_R3__(nativeNode) {
27357
+ /**
27358
+ * @publicApi
27359
+ */
27360
+ function getDebugNode(nativeNode) {
27291
27361
  if (nativeNode instanceof Node) {
27292
27362
  if (!(nativeNode.hasOwnProperty(NG_DEBUG_PROPERTY))) {
27293
27363
  nativeNode[NG_DEBUG_PROPERTY] = nativeNode.nodeType == Node.ELEMENT_NODE ?
27294
- new DebugElement__POST_R3__(nativeNode) :
27295
- new DebugNode__POST_R3__(nativeNode);
27364
+ new DebugElement(nativeNode) :
27365
+ new DebugNode(nativeNode);
27296
27366
  }
27297
27367
  return nativeNode[NG_DEBUG_PROPERTY];
27298
27368
  }
27299
27369
  return null;
27300
27370
  }
27301
- /**
27302
- * @publicApi
27303
- */
27304
- const getDebugNode = getDebugNode__POST_R3__;
27305
- function getDebugNodeR2__POST_R3__(_nativeNode) {
27371
+ // TODO: cleanup all references to this function and remove it.
27372
+ function getDebugNodeR2(_nativeNode) {
27306
27373
  return null;
27307
27374
  }
27308
- const getDebugNodeR2 = getDebugNodeR2__POST_R3__;
27309
27375
  function getAllDebugNodes() {
27310
27376
  return Array.from(_nativeNodeToDebugNode.values());
27311
27377
  }
@@ -27315,14 +27381,6 @@ function indexDebugNode(node) {
27315
27381
  function removeDebugNodeFromIndex(node) {
27316
27382
  _nativeNodeToDebugNode.delete(node.nativeNode);
27317
27383
  }
27318
- /**
27319
- * @publicApi
27320
- */
27321
- const DebugNode = DebugNode__POST_R3__;
27322
- /**
27323
- * @publicApi
27324
- */
27325
- const DebugElement = DebugElement__POST_R3__;
27326
27384
 
27327
27385
  /**
27328
27386
  * @license