@angular/core 11.1.2 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fesm2015/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v11.1.2
2
+ * @license Angular v11.2.0
3
3
  * (c) 2010-2020 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1256,6 +1256,14 @@ function assertBetween(lower, upper, index) {
1256
1256
  throwError(`Index out of range (expecting ${lower} <= ${index} < ${upper})`);
1257
1257
  }
1258
1258
  }
1259
+ function assertProjectionSlots(lView, errMessage) {
1260
+ assertDefined(lView[DECLARATION_COMPONENT_VIEW], 'Component views should exist.');
1261
+ assertDefined(lView[DECLARATION_COMPONENT_VIEW][T_HOST].projection, errMessage ||
1262
+ 'Components with projection nodes (<ng-content>) must have projection slots defined.');
1263
+ }
1264
+ function assertParentView(lView, errMessage) {
1265
+ assertDefined(lView, errMessage || 'Component views should always have a parent view (component\'s host view)');
1266
+ }
1259
1267
  /**
1260
1268
  * This is a basic sanity check that the `injectorIndex` seems to point to what looks like a
1261
1269
  * NodeInjector data structure.
@@ -7572,12 +7580,14 @@ function getFirstNativeNode(lView, tNode) {
7572
7580
  return rNode || unwrapRNode(lView[tNode.index]);
7573
7581
  }
7574
7582
  else {
7575
- const componentView = lView[DECLARATION_COMPONENT_VIEW];
7576
- const componentHost = componentView[T_HOST];
7577
- const parentView = getLViewParent(componentView);
7578
- const firstProjectedTNode = componentHost.projection[tNode.projection];
7579
- if (firstProjectedTNode != null) {
7580
- return getFirstNativeNode(parentView, firstProjectedTNode);
7583
+ const projectionNodes = getProjectionNodes(lView, tNode);
7584
+ if (projectionNodes !== null) {
7585
+ if (Array.isArray(projectionNodes)) {
7586
+ return projectionNodes[0];
7587
+ }
7588
+ const parentView = getLViewParent(lView[DECLARATION_COMPONENT_VIEW]);
7589
+ ngDevMode && assertParentView(parentView);
7590
+ return getFirstNativeNode(parentView, projectionNodes);
7581
7591
  }
7582
7592
  else {
7583
7593
  return getFirstNativeNode(lView, tNode.next);
@@ -7586,6 +7596,16 @@ function getFirstNativeNode(lView, tNode) {
7586
7596
  }
7587
7597
  return null;
7588
7598
  }
7599
+ function getProjectionNodes(lView, tNode) {
7600
+ if (tNode !== null) {
7601
+ const componentView = lView[DECLARATION_COMPONENT_VIEW];
7602
+ const componentHost = componentView[T_HOST];
7603
+ const slotIdx = tNode.projection;
7604
+ ngDevMode && assertProjectionSlots(lView);
7605
+ return componentHost.projection[slotIdx];
7606
+ }
7607
+ return null;
7608
+ }
7589
7609
  function getBeforeNodeForView(viewIndexInContainer, lContainer) {
7590
7610
  const nextViewIndex = CONTAINER_HEADER_OFFSET + viewIndexInContainer + 1;
7591
7611
  if (nextViewIndex < lContainer.length) {
@@ -21369,7 +21389,7 @@ class Version {
21369
21389
  /**
21370
21390
  * @publicApi
21371
21391
  */
21372
- const VERSION = new Version('11.1.2');
21392
+ const VERSION = new Version('11.2.0');
21373
21393
 
21374
21394
  /**
21375
21395
  * @license
@@ -21622,24 +21642,25 @@ class DefaultIterableDiffer {
21622
21642
  // Remove the record from the collection since we know it does not match the item.
21623
21643
  this._remove(record);
21624
21644
  }
21625
- // Attempt to see if we have seen the item before.
21626
- record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
21645
+ // See if we have evicted the item, which used to be at some anterior position of _itHead list.
21646
+ record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
21627
21647
  if (record !== null) {
21628
- // We have seen this before, we need to move it forward in the collection.
21629
- // But first we need to check if identity changed, so we can update in view if necessary
21648
+ // It is an item which we have evicted earlier: reinsert it back into the list.
21649
+ // But first we need to check if identity changed, so we can update in view if necessary.
21630
21650
  if (!Object.is(record.item, item))
21631
21651
  this._addIdentityChange(record, item);
21632
- this._moveAfter(record, previousRecord, index);
21652
+ this._reinsertAfter(record, previousRecord, index);
21633
21653
  }
21634
21654
  else {
21635
- // Never seen it, check evicted list.
21636
- record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
21655
+ // Attempt to see if the item is at some posterior position of _itHead list.
21656
+ record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
21637
21657
  if (record !== null) {
21638
- // It is an item which we have evicted earlier: reinsert it back into the list.
21639
- // But first we need to check if identity changed, so we can update in view if necessary
21658
+ // We have the item in _itHead at/after `index` position. We need to move it forward in the
21659
+ // collection.
21660
+ // But first we need to check if identity changed, so we can update in view if necessary.
21640
21661
  if (!Object.is(record.item, item))
21641
21662
  this._addIdentityChange(record, item);
21642
- this._reinsertAfter(record, previousRecord, index);
21663
+ this._moveAfter(record, previousRecord, index);
21643
21664
  }
21644
21665
  else {
21645
21666
  // It is a new item: add it.
@@ -22470,19 +22491,13 @@ function collectNativeNodes(tView, lView, tNode, result, isProjection = false) {
22470
22491
  }
22471
22492
  }
22472
22493
  else if (tNodeType & 16 /* Projection */) {
22473
- const componentView = lView[DECLARATION_COMPONENT_VIEW];
22474
- const componentHost = componentView[T_HOST];
22475
- const slotIdx = tNode.projection;
22476
- ngDevMode &&
22477
- assertDefined(componentHost.projection, 'Components with projection nodes (<ng-content>) must have projection slots defined.');
22478
- const nodesInSlot = componentHost.projection[slotIdx];
22494
+ const nodesInSlot = getProjectionNodes(lView, tNode);
22479
22495
  if (Array.isArray(nodesInSlot)) {
22480
22496
  result.push(...nodesInSlot);
22481
22497
  }
22482
22498
  else {
22483
- const parentView = getLViewParent(componentView);
22484
- ngDevMode &&
22485
- assertDefined(parentView, 'Component views should always have a parent view (component\'s host view)');
22499
+ const parentView = getLViewParent(lView[DECLARATION_COMPONENT_VIEW]);
22500
+ ngDevMode && assertParentView(parentView);
22486
22501
  collectNativeNodes(parentView[TVIEW], parentView, nodesInSlot, result, true);
22487
22502
  }
22488
22503
  }