@angular/core 12.0.1 → 12.0.5

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/bundles/core-testing.umd.js +46 -83
  2. package/bundles/core-testing.umd.js.map +1 -1
  3. package/bundles/core.umd.js +43 -30
  4. package/bundles/core.umd.js.map +1 -1
  5. package/core.d.ts +245 -17
  6. package/core.metadata.json +1 -1
  7. package/esm2015/src/change_detection/differs/iterable_differs.js +1 -1
  8. package/esm2015/src/debug/debug_node.js +1 -1
  9. package/esm2015/src/di/injectable.js +1 -1
  10. package/esm2015/src/linker/component_factory_resolver.js +4 -1
  11. package/esm2015/src/metadata/di.js +1 -1
  12. package/esm2015/src/metadata/do_boostrap.js +1 -1
  13. package/esm2015/src/metadata/ng_module.js +1 -1
  14. package/esm2015/src/metadata/schema.js +5 -1
  15. package/esm2015/src/render3/definition.js +16 -16
  16. package/esm2015/src/render3/util/discovery_utils.js +18 -12
  17. package/esm2015/src/render3/view_ref.js +3 -3
  18. package/esm2015/src/version.js +1 -1
  19. package/esm2015/testing/src/fake_async.js +42 -25
  20. package/esm2015/testing/src/test_bed.js +5 -25
  21. package/esm2015/testing/src/testing_internal.js +1 -182
  22. package/fesm2015/core.js +43 -30
  23. package/fesm2015/core.js.map +1 -1
  24. package/fesm2015/testing.js +46 -76
  25. package/fesm2015/testing.js.map +1 -1
  26. package/package.json +2 -2
  27. package/schematics/migrations/deep-shadow-piercing-selector/index.d.ts +10 -0
  28. package/schematics/migrations/deep-shadow-piercing-selector/index.js +49 -0
  29. package/schematics/migrations.json +5 -0
  30. package/src/r3_symbols.d.ts +4 -1
  31. package/testing/testing.d.ts +42 -30
  32. package/testing/testing.metadata.json +1 -1
  33. package/testing.d.ts +1 -1
  34. package/esm2015/testing/src/async_test_completer.js +0 -28
package/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v12.0.1
2
+ * @license Angular v12.0.5
3
3
  * (c) 2010-2021 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1153,6 +1153,9 @@ export { ComponentFactory as ɵComponentFactory }
1153
1153
  * then use the factory's `create()` method to create a component of that type.
1154
1154
  *
1155
1155
  * @see [Dynamic Components](guide/dynamic-component-loader)
1156
+ * @see [Usage Example](guide/dynamic-component-loader#resolving-components)
1157
+ * @see <live-example name="dynamic-component-loader" noDownload></live-example>
1158
+ of the code in this cookbook
1156
1159
  * @publicApi
1157
1160
  */
1158
1161
  export declare abstract class ComponentFactoryResolver {
@@ -1318,6 +1321,24 @@ export declare interface ContentChildDecorator {
1318
1321
  * * **static** - True to resolve query results before change detection runs,
1319
1322
  * false to resolve after change detection. Defaults to false.
1320
1323
  *
1324
+ * The following selectors are supported.
1325
+ * * Any class with the `@Component` or `@Directive` decorator
1326
+ * * A template reference variable as a string (e.g. query `<my-component #cmp></my-component>`
1327
+ * with `@ContentChild('cmp')`)
1328
+ * * Any provider defined in the child component tree of the current component (e.g.
1329
+ * `@ContentChild(SomeService) someService: SomeService`)
1330
+ * * Any provider defined through a string token (e.g. `@ContentChild('someToken') someTokenVal:
1331
+ * any`)
1332
+ * * A `TemplateRef` (e.g. query `<ng-template></ng-template>` with `@ContentChild(TemplateRef)
1333
+ * template;`)
1334
+ *
1335
+ * The following values are supported by `read`:
1336
+ * * Any class with the `@Component` or `@Directive` decorator
1337
+ * * Any provider defined on the injector of the component that is matched by the `selector` of
1338
+ * this query
1339
+ * * Any provider defined through a string token (e.g. `{provide: 'token', useValue: 'val'}`)
1340
+ * * `TemplateRef`, `ElementRef`, and `ViewContainerRef`
1341
+ *
1321
1342
  * @usageNotes
1322
1343
  *
1323
1344
  * {@example core/di/ts/contentChild/content_child_howto.ts region='HowTo'}
@@ -1387,6 +1408,27 @@ export declare interface ContentChildrenDecorator {
1387
1408
  * removed in future versions of Angular.
1388
1409
  * * **read** - Used to read a different token from the queried elements.
1389
1410
  *
1411
+ * The following selectors are supported.
1412
+ * * Any class with the `@Component` or `@Directive` decorator
1413
+ * * A template reference variable as a string (e.g. query `<my-component #cmp></my-component>`
1414
+ * with `@ContentChildren('cmp')`)
1415
+ * * Any provider defined in the child component tree of the current component (e.g.
1416
+ * `@ContentChildren(SomeService) someService: SomeService`)
1417
+ * * Any provider defined through a string token (e.g. `@ContentChildren('someToken')
1418
+ * someTokenVal: any`)
1419
+ * * A `TemplateRef` (e.g. query `<ng-template></ng-template>` with
1420
+ * `@ContentChildren(TemplateRef) template;`)
1421
+ *
1422
+ * In addition, multiple string selectors can be separated with a comma (e.g.
1423
+ * `@ContentChildren('cmp1,cmp2')`)
1424
+ *
1425
+ * The following values are supported by `read`:
1426
+ * * Any class with the `@Component` or `@Directive` decorator
1427
+ * * Any provider defined on the injector of the component that is matched by the `selector` of
1428
+ * this query
1429
+ * * Any provider defined through a string token (e.g. `{provide: 'token', useValue: 'val'}`)
1430
+ * * `TemplateRef`, `ElementRef`, and `ViewContainerRef`
1431
+ *
1390
1432
  * @usageNotes
1391
1433
  *
1392
1434
  * Here is a simple demonstration of how the `ContentChildren` decorator can be used.
@@ -1560,27 +1602,98 @@ export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
1560
1602
 
1561
1603
  /**
1562
1604
  * @publicApi
1605
+ *
1606
+ * @see [Component testing scenarios](guide/testing-components-scenarios)
1607
+ * @see [Basics of testing components](guide/testing-components-basics)
1608
+ * @see [Testing utility APIs](guide/testing-utility-apis)
1563
1609
  */
1564
1610
  export declare interface DebugElement extends DebugNode {
1611
+ /**
1612
+ * The element tag name, if it is an element.
1613
+ */
1565
1614
  readonly name: string;
1615
+ /**
1616
+ * A map of property names to property values for an element.
1617
+ *
1618
+ * This map includes:
1619
+ * - Regular property bindings (e.g. `[id]="id"`)
1620
+ * - Host property bindings (e.g. `host: { '[id]': "id" }`)
1621
+ * - Interpolated property bindings (e.g. `id="{{ value }}")
1622
+ *
1623
+ * It does not include:
1624
+ * - input property bindings (e.g. `[myCustomInput]="value"`)
1625
+ * - attribute bindings (e.g. `[attr.role]="menu"`)
1626
+ */
1566
1627
  readonly properties: {
1567
1628
  [key: string]: any;
1568
1629
  };
1630
+ /**
1631
+ * A map of attribute names to attribute values for an element.
1632
+ */
1569
1633
  readonly attributes: {
1570
1634
  [key: string]: string | null;
1571
1635
  };
1636
+ /**
1637
+ * A map containing the class names on the element as keys.
1638
+ *
1639
+ * This map is derived from the `className` property of the DOM element.
1640
+ *
1641
+ * Note: The values of this object will always be `true`. The class key will not appear in the KV
1642
+ * object if it does not exist on the element.
1643
+ *
1644
+ * @see [Element.className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className)
1645
+ */
1572
1646
  readonly classes: {
1573
1647
  [key: string]: boolean;
1574
1648
  };
1649
+ /**
1650
+ * The inline styles of the DOM element.
1651
+ *
1652
+ * Will be `null` if there is no `style` property on the underlying DOM element.
1653
+ *
1654
+ * @see [ElementCSSInlineStyle](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style)
1655
+ */
1575
1656
  readonly styles: {
1576
1657
  [key: string]: string | null;
1577
1658
  };
1659
+ /**
1660
+ * The `childNodes` of the DOM element as a `DebugNode` array.
1661
+ *
1662
+ * @see [Node.childNodes](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes)
1663
+ */
1578
1664
  readonly childNodes: DebugNode[];
1665
+ /**
1666
+ * The underlying DOM element at the root of the component.
1667
+ */
1579
1668
  readonly nativeElement: any;
1669
+ /**
1670
+ * The immediate `DebugElement` children. Walk the tree by descending through `children`.
1671
+ */
1580
1672
  readonly children: DebugElement[];
1673
+ /**
1674
+ * @returns the first `DebugElement` that matches the predicate at any depth in the subtree.
1675
+ */
1581
1676
  query(predicate: Predicate<DebugElement>): DebugElement;
1677
+ /**
1678
+ * @returns All `DebugElement` matches for the predicate at any depth in the subtree.
1679
+ */
1582
1680
  queryAll(predicate: Predicate<DebugElement>): DebugElement[];
1681
+ /**
1682
+ * @returns All `DebugNode` matches for the predicate at any depth in the subtree.
1683
+ */
1583
1684
  queryAllNodes(predicate: Predicate<DebugNode>): DebugNode[];
1685
+ /**
1686
+ * Triggers the event by its name if there is a corresponding listener in the element's
1687
+ * `listeners` collection.
1688
+ *
1689
+ * If the event lacks a listener or there's some other problem, consider
1690
+ * calling `nativeElement.dispatchEvent(eventObject)`.
1691
+ *
1692
+ * @param eventName The name of the event to trigger
1693
+ * @param eventObj The _event object_ expected by the handler
1694
+ *
1695
+ * @see [Testing components scenarios](guide/testing-components-scenarios#trigger-event-handler)
1696
+ */
1584
1697
  triggerEventHandler(eventName: string, eventObj: any): void;
1585
1698
  }
1586
1699
 
@@ -1640,15 +1753,47 @@ export declare class DebugEventListener {
1640
1753
  * @publicApi
1641
1754
  */
1642
1755
  export declare interface DebugNode {
1756
+ /**
1757
+ * The callbacks attached to the component's @Output properties and/or the element's event
1758
+ * properties.
1759
+ */
1643
1760
  readonly listeners: DebugEventListener[];
1761
+ /**
1762
+ * The `DebugElement` parent. Will be `null` if this is the root element.
1763
+ */
1644
1764
  readonly parent: DebugElement | null;
1765
+ /**
1766
+ * The underlying DOM node.
1767
+ */
1645
1768
  readonly nativeNode: any;
1769
+ /**
1770
+ * The host dependency injector. For example, the root element's component instance injector.
1771
+ */
1646
1772
  readonly injector: Injector;
1773
+ /**
1774
+ * The element's own component instance, if it has one.
1775
+ */
1647
1776
  readonly componentInstance: any;
1777
+ /**
1778
+ * An object that provides parent context for this element. Often an ancestor component instance
1779
+ * that governs this element.
1780
+ *
1781
+ * When an element is repeated within *ngFor, the context is an `NgForOf` whose `$implicit`
1782
+ * property is the value of the row instance value. For example, the `hero` in `*ngFor="let hero
1783
+ * of heroes"`.
1784
+ */
1648
1785
  readonly context: any;
1786
+ /**
1787
+ * Dictionary of objects associated with template local variables (e.g. #foo), keyed by the local
1788
+ * variable name.
1789
+ */
1649
1790
  readonly references: {
1650
1791
  [key: string]: any;
1651
1792
  };
1793
+ /**
1794
+ * This component's injector lookup tokens. Includes the component itself plus the tokens that the
1795
+ * component lists in its providers metadata.
1796
+ */
1652
1797
  readonly providerTokens: any[];
1653
1798
  }
1654
1799
 
@@ -2162,8 +2307,8 @@ declare interface DisposableFn {
2162
2307
 
2163
2308
  /**
2164
2309
  * @description
2165
- * Hook for manual bootstrapping of the application instead of using bootstrap array in @NgModule
2166
- * annotation.
2310
+ * Hook for manual bootstrapping of the application instead of using `bootstrap` array in @NgModule
2311
+ * annotation. This hook is invoked only when the `bootstrap` array is empty or not provided.
2167
2312
  *
2168
2313
  * Reference to the current application is provided as a parameter.
2169
2314
  *
@@ -3256,9 +3401,15 @@ export declare const inject: typeof ɵɵinject;
3256
3401
  */
3257
3402
  export declare interface Injectable {
3258
3403
  /**
3259
- * Determines which injectors will provide the injectable,
3260
- * by either associating it with an `@NgModule` or other `InjectorType`,
3261
- * or by specifying that this injectable should be provided in one of the following injectors:
3404
+ * Determines which injectors will provide the injectable.
3405
+ *
3406
+ * - `Type<any>` - associates the injectable with an `@NgModule` or other `InjectorType`,
3407
+ * - 'null' : Equivalent to `undefined`. The injectable is not provided in any scope automatically
3408
+ * and must be added to a `providers` array of an [@NgModule](api/core/NgModule#providers),
3409
+ * [@Component](api/core/Directive#providers) or [@Directive](api/core/Directive#providers).
3410
+ *
3411
+ * The following options specify that this injectable should be provided in one of the following
3412
+ * injectors:
3262
3413
  * - 'root' : The application-level injector in most apps.
3263
3414
  * - 'platform' : A special singleton platform injector shared by all
3264
3415
  * applications on the page.
@@ -4507,7 +4658,10 @@ export declare interface NgModule {
4507
4658
  * using one of the imperative techniques, such as `ViewContainerRef.createComponent()`.
4508
4659
  *
4509
4660
  * @see [Entry Components](guide/entry-components)
4510
- * @deprecated Since 9.0.0. With Ivy, this property is no longer necessary.
4661
+ * @deprecated
4662
+ * Since 9.0.0. With Ivy, this property is no longer necessary.
4663
+ * (You may need to keep these if building a library that will be consumed by a View Engine
4664
+ * application.)
4511
4665
  */
4512
4666
  entryComponents?: Array<Type<any> | any[]>;
4513
4667
  /**
@@ -4800,6 +4954,10 @@ export declare class NgZone {
4800
4954
  /**
4801
4955
  * Defines a schema that allows any property on any element.
4802
4956
  *
4957
+ * This schema allows you to ignore the errors related to any unknown elements or properties in a
4958
+ * template. The usage of this schema is generally discouraged because it prevents useful validation
4959
+ * and may hide real errors in your template. Consider using the `CUSTOM_ELEMENTS_SCHEMA` instead.
4960
+ *
4803
4961
  * @publicApi
4804
4962
  */
4805
4963
  export declare const NO_ERRORS_SCHEMA: SchemaMetadata;
@@ -7837,15 +7995,55 @@ declare interface TQueryMetadata {
7837
7995
  }
7838
7996
 
7839
7997
  /**
7840
- * An optional function passed into the `NgForOf` directive that defines how to track
7841
- * changes for items in an iterable.
7842
- * The function takes the iteration index and item ID.
7843
- * When supplied, Angular tracks changes by the return value of the function.
7998
+ * A function optionally passed into the `NgForOf` directive to customize how `NgForOf` uniquely
7999
+ * identifies items in an iterable.
8000
+ *
8001
+ * `NgForOf` needs to uniquely identify items in the iterable to correctly perform DOM updates
8002
+ * when items in the iterable are reordered, new items are added, or existing items are removed.
8003
+ *
8004
+ *
8005
+ * In all of these scenarios it is usually desirable to only update the DOM elements associated
8006
+ * with the items affected by the change. This behavior is important to:
8007
+ *
8008
+ * - preserve any DOM-specific UI state (like cursor position, focus, text selection) when the
8009
+ * iterable is modified
8010
+ * - enable animation of item addition, removal, and iterable reordering
8011
+ * - preserve the value of the `<select>` element when nested `<option>` elements are dynamically
8012
+ * populated using `NgForOf` and the bound iterable is updated
8013
+ *
8014
+ * A common use for custom `trackBy` functions is when the model that `NgForOf` iterates over
8015
+ * contains a property with a unique identifier. For example, given a model:
7844
8016
  *
8017
+ * ```ts
8018
+ * class User {
8019
+ * id: number;
8020
+ * name: string;
8021
+ * ...
8022
+ * }
8023
+ * ```
8024
+ * a custom `trackBy` function could look like the following:
8025
+ * ```ts
8026
+ * function userTrackBy(index, user) {
8027
+ * return user.id;
8028
+ * }
8029
+ * ```
8030
+ *
8031
+ * A custom `trackBy` function must have several properties:
8032
+ *
8033
+ * - be [idempotent](https://en.wikipedia.org/wiki/Idempotence) (be without side effects, and always
8034
+ * return the same value for a given input)
8035
+ * - return unique value for all unique inputs
8036
+ * - be fast
8037
+ *
8038
+ * @see [`NgForOf#ngForTrackBy`](api/common/NgForOf#ngForTrackBy)
7845
8039
  * @publicApi
7846
8040
  */
7847
8041
  export declare interface TrackByFunction<T> {
7848
- (index: number, item: T): any;
8042
+ /**
8043
+ * @param index The index of the item within the iterable.
8044
+ * @param item The item in the iterable.
8045
+ */
8046
+ <U extends T>(index: number, item: U): any;
7849
8047
  }
7850
8048
 
7851
8049
  /**
@@ -8488,6 +8686,13 @@ export declare interface ViewChildDecorator {
8488
8686
  * * A `TemplateRef` (e.g. query `<ng-template></ng-template>` with `@ViewChild(TemplateRef)
8489
8687
  * template;`)
8490
8688
  *
8689
+ * The following values are supported by `read`:
8690
+ * * Any class with the `@Component` or `@Directive` decorator
8691
+ * * Any provider defined on the injector of the component that is matched by the `selector` of
8692
+ * this query
8693
+ * * Any provider defined through a string token (e.g. `{provide: 'token', useValue: 'val'}`)
8694
+ * * `TemplateRef`, `ElementRef`, and `ViewContainerRef`
8695
+ *
8491
8696
  * @usageNotes
8492
8697
  *
8493
8698
  * {@example core/di/ts/viewChild/view_child_example.ts region='Component'}
@@ -8550,6 +8755,27 @@ export declare interface ViewChildrenDecorator {
8550
8755
  * ** Note: *** This config option is **deprecated**, it will be permanently set to `true` and
8551
8756
  * removed in future versions of Angular.
8552
8757
  *
8758
+ * The following selectors are supported.
8759
+ * * Any class with the `@Component` or `@Directive` decorator
8760
+ * * A template reference variable as a string (e.g. query `<my-component #cmp></my-component>`
8761
+ * with `@ViewChildren('cmp')`)
8762
+ * * Any provider defined in the child component tree of the current component (e.g.
8763
+ * `@ViewChildren(SomeService) someService: SomeService`)
8764
+ * * Any provider defined through a string token (e.g. `@ViewChildren('someToken') someTokenVal:
8765
+ * any`)
8766
+ * * A `TemplateRef` (e.g. query `<ng-template></ng-template>` with `@ViewChildren(TemplateRef)
8767
+ * template;`)
8768
+ *
8769
+ * In addition, multiple string selectors can be separated with a comma (e.g.
8770
+ * `@ViewChildren('cmp1,cmp2')`)
8771
+ *
8772
+ * The following values are supported by `read`:
8773
+ * * Any class with the `@Component` or `@Directive` decorator
8774
+ * * Any provider defined on the injector of the component that is matched by the `selector` of
8775
+ * this query
8776
+ * * Any provider defined through a string token (e.g. `{provide: 'token', useValue: 'val'}`)
8777
+ * * `TemplateRef`, `ElementRef`, and `ViewContainerRef`
8778
+ *
8553
8779
  * @usageNotes
8554
8780
  *
8555
8781
  * {@example core/di/ts/viewChildren/view_children_howto.ts region='HowTo'}
@@ -8839,7 +9065,7 @@ declare class ViewRef_2<T> implements EmbeddedViewRef<T>, InternalViewRef, viewE
8839
9065
  *
8840
9066
  * ```typescript
8841
9067
  * @Component({
8842
- * selector: 'my-app',
9068
+ * selector: 'app-root',
8843
9069
  * template: `Number of ticks: {{numberOfTicks}}`
8844
9070
  * changeDetection: ChangeDetectionStrategy.OnPush,
8845
9071
  * })
@@ -8955,7 +9181,7 @@ declare class ViewRef_2<T> implements EmbeddedViewRef<T>, InternalViewRef, viewE
8955
9181
  * }
8956
9182
  *
8957
9183
  * @Component({
8958
- * selector: 'my-app',
9184
+ * selector: 'app-root',
8959
9185
  * providers: [DataProvider],
8960
9186
  * template: `
8961
9187
  * Live Update: <input type="checkbox" [(ngModel)]="live">
@@ -10520,12 +10746,14 @@ export declare const ɵgetDebugNodeR2: (nativeNode: any) => DebugNode | null;
10520
10746
  *
10521
10747
  * @usageNotes
10522
10748
  * Given the following DOM structure:
10523
- * ```
10524
- * <my-app>
10749
+ *
10750
+ * ```html
10751
+ * <app-root>
10525
10752
  * <button my-button></button>
10526
10753
  * <my-comp></my-comp>
10527
- * </my-app>
10754
+ * </app-root>
10528
10755
  * ```
10756
+ *
10529
10757
  * Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
10530
10758
  * directive that is associated with the DOM node.
10531
10759
  *