@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.
@@ -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
  */
@@ -1225,6 +1225,14 @@
1225
1225
  throwError("Index out of range (expecting " + lower + " <= " + index + " < " + upper + ")");
1226
1226
  }
1227
1227
  }
1228
+ function assertProjectionSlots(lView, errMessage) {
1229
+ assertDefined(lView[DECLARATION_COMPONENT_VIEW], 'Component views should exist.');
1230
+ assertDefined(lView[DECLARATION_COMPONENT_VIEW][T_HOST].projection, errMessage ||
1231
+ 'Components with projection nodes (<ng-content>) must have projection slots defined.');
1232
+ }
1233
+ function assertParentView(lView, errMessage) {
1234
+ assertDefined(lView, errMessage || 'Component views should always have a parent view (component\'s host view)');
1235
+ }
1228
1236
  /**
1229
1237
  * This is a basic sanity check that the `injectorIndex` seems to point to what looks like a
1230
1238
  * NodeInjector data structure.
@@ -7896,12 +7904,14 @@
7896
7904
  return rNode || unwrapRNode(lView[tNode.index]);
7897
7905
  }
7898
7906
  else {
7899
- var componentView = lView[DECLARATION_COMPONENT_VIEW];
7900
- var componentHost = componentView[T_HOST];
7901
- var parentView = getLViewParent(componentView);
7902
- var firstProjectedTNode = componentHost.projection[tNode.projection];
7903
- if (firstProjectedTNode != null) {
7904
- return getFirstNativeNode(parentView, firstProjectedTNode);
7907
+ var projectionNodes = getProjectionNodes(lView, tNode);
7908
+ if (projectionNodes !== null) {
7909
+ if (Array.isArray(projectionNodes)) {
7910
+ return projectionNodes[0];
7911
+ }
7912
+ var parentView = getLViewParent(lView[DECLARATION_COMPONENT_VIEW]);
7913
+ ngDevMode && assertParentView(parentView);
7914
+ return getFirstNativeNode(parentView, projectionNodes);
7905
7915
  }
7906
7916
  else {
7907
7917
  return getFirstNativeNode(lView, tNode.next);
@@ -7910,6 +7920,16 @@
7910
7920
  }
7911
7921
  return null;
7912
7922
  }
7923
+ function getProjectionNodes(lView, tNode) {
7924
+ if (tNode !== null) {
7925
+ var componentView = lView[DECLARATION_COMPONENT_VIEW];
7926
+ var componentHost = componentView[T_HOST];
7927
+ var slotIdx = tNode.projection;
7928
+ ngDevMode && assertProjectionSlots(lView);
7929
+ return componentHost.projection[slotIdx];
7930
+ }
7931
+ return null;
7932
+ }
7913
7933
  function getBeforeNodeForView(viewIndexInContainer, lContainer) {
7914
7934
  var nextViewIndex = CONTAINER_HEADER_OFFSET + viewIndexInContainer + 1;
7915
7935
  if (nextViewIndex < lContainer.length) {
@@ -21933,7 +21953,7 @@
21933
21953
  /**
21934
21954
  * @publicApi
21935
21955
  */
21936
- var VERSION = new Version('11.1.2');
21956
+ var VERSION = new Version('11.2.0');
21937
21957
 
21938
21958
  /**
21939
21959
  * @license
@@ -22193,24 +22213,25 @@
22193
22213
  // Remove the record from the collection since we know it does not match the item.
22194
22214
  this._remove(record);
22195
22215
  }
22196
- // Attempt to see if we have seen the item before.
22197
- record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
22216
+ // See if we have evicted the item, which used to be at some anterior position of _itHead list.
22217
+ record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
22198
22218
  if (record !== null) {
22199
- // We have seen this before, we need to move it forward in the collection.
22200
- // But first we need to check if identity changed, so we can update in view if necessary
22219
+ // It is an item which we have evicted earlier: reinsert it back into the list.
22220
+ // But first we need to check if identity changed, so we can update in view if necessary.
22201
22221
  if (!Object.is(record.item, item))
22202
22222
  this._addIdentityChange(record, item);
22203
- this._moveAfter(record, previousRecord, index);
22223
+ this._reinsertAfter(record, previousRecord, index);
22204
22224
  }
22205
22225
  else {
22206
- // Never seen it, check evicted list.
22207
- record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
22226
+ // Attempt to see if the item is at some posterior position of _itHead list.
22227
+ record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
22208
22228
  if (record !== null) {
22209
- // It is an item which we have evicted earlier: reinsert it back into the list.
22210
- // But first we need to check if identity changed, so we can update in view if necessary
22229
+ // We have the item in _itHead at/after `index` position. We need to move it forward in the
22230
+ // collection.
22231
+ // But first we need to check if identity changed, so we can update in view if necessary.
22211
22232
  if (!Object.is(record.item, item))
22212
22233
  this._addIdentityChange(record, item);
22213
- this._reinsertAfter(record, previousRecord, index);
22234
+ this._moveAfter(record, previousRecord, index);
22214
22235
  }
22215
22236
  else {
22216
22237
  // It is a new item: add it.
@@ -23054,19 +23075,13 @@
23054
23075
  }
23055
23076
  }
23056
23077
  else if (tNodeType & 16 /* Projection */) {
23057
- var componentView = lView[DECLARATION_COMPONENT_VIEW];
23058
- var componentHost = componentView[T_HOST];
23059
- var slotIdx = tNode.projection;
23060
- ngDevMode &&
23061
- assertDefined(componentHost.projection, 'Components with projection nodes (<ng-content>) must have projection slots defined.');
23062
- var nodesInSlot = componentHost.projection[slotIdx];
23078
+ var nodesInSlot = getProjectionNodes(lView, tNode);
23063
23079
  if (Array.isArray(nodesInSlot)) {
23064
23080
  result.push.apply(result, __spread(nodesInSlot));
23065
23081
  }
23066
23082
  else {
23067
- var parentView = getLViewParent(componentView);
23068
- ngDevMode &&
23069
- assertDefined(parentView, 'Component views should always have a parent view (component\'s host view)');
23083
+ var parentView = getLViewParent(lView[DECLARATION_COMPONENT_VIEW]);
23084
+ ngDevMode && assertParentView(parentView);
23070
23085
  collectNativeNodes(parentView[TVIEW], parentView, nodesInSlot, result, true);
23071
23086
  }
23072
23087
  }