@angular/core 11.0.5 → 11.0.9

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.0.5
2
+ * @license Angular v11.0.9
3
3
  * (c) 2010-2020 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2713,8 +2713,9 @@
2713
2713
  (currentView[PREORDER_HOOK_FLAGS] & 65535 /* IndexOfTheNextPreOrderHookMaskMask */) :
2714
2714
  0;
2715
2715
  var nodeIndexLimit = currentNodeIndex != null ? currentNodeIndex : -1;
2716
+ var max = arr.length - 1; // Stop the loop at length - 1, because we look for the hook at i + 1
2716
2717
  var lastNodeIndexFound = 0;
2717
- for (var i = startIndex; i < arr.length; i++) {
2718
+ for (var i = startIndex; i < max; i++) {
2718
2719
  var hook = arr[i + 1];
2719
2720
  if (typeof hook === 'number') {
2720
2721
  lastNodeIndexFound = arr[i];
@@ -2751,8 +2752,7 @@
2751
2752
  var directive = currentView[directiveIndex];
2752
2753
  if (isInitHook) {
2753
2754
  var indexWithintInitPhase = currentView[FLAGS] >> 11 /* IndexWithinInitPhaseShift */;
2754
- // The init phase state must be always checked here as it may have been recursively
2755
- // updated
2755
+ // The init phase state must be always checked here as it may have been recursively updated.
2756
2756
  if (indexWithintInitPhase <
2757
2757
  (currentView[PREORDER_HOOK_FLAGS] >> 16 /* NumberOfInitHooksCalledShift */) &&
2758
2758
  (currentView[FLAGS] & 3 /* InitPhaseStateMask */) === initPhase) {
@@ -5274,6 +5274,9 @@
5274
5274
  else if (meta instanceof Self || meta.ngMetadataName === 'Self' || meta === Self) {
5275
5275
  flags |= exports.InjectFlags.Self;
5276
5276
  }
5277
+ else if (meta instanceof Host || meta.ngMetadataName === 'Host' || meta === Host) {
5278
+ flags |= exports.InjectFlags.Host;
5279
+ }
5277
5280
  else if (meta instanceof Inject || meta === Inject) {
5278
5281
  type = meta.token;
5279
5282
  }
@@ -5590,14 +5593,16 @@
5590
5593
  * Fallback: InertDocument strategy
5591
5594
  */
5592
5595
  function getInertBodyHelper(defaultDoc) {
5593
- return isDOMParserAvailable() ? new DOMParserHelper() : new InertDocumentHelper(defaultDoc);
5596
+ var inertDocumentHelper = new InertDocumentHelper(defaultDoc);
5597
+ return isDOMParserAvailable() ? new DOMParserHelper(inertDocumentHelper) : inertDocumentHelper;
5594
5598
  }
5595
5599
  /**
5596
5600
  * Uses DOMParser to create and fill an inert body element.
5597
5601
  * This is the default strategy used in browsers that support it.
5598
5602
  */
5599
5603
  var DOMParserHelper = /** @class */ (function () {
5600
- function DOMParserHelper() {
5604
+ function DOMParserHelper(inertDocumentHelper) {
5605
+ this.inertDocumentHelper = inertDocumentHelper;
5601
5606
  }
5602
5607
  DOMParserHelper.prototype.getInertBodyElement = function (html) {
5603
5608
  // We add these extra elements to ensure that the rest of the content is parsed as expected
@@ -5609,6 +5614,12 @@
5609
5614
  var body = new window.DOMParser()
5610
5615
  .parseFromString(trustedHTMLFromString(html), 'text/html')
5611
5616
  .body;
5617
+ if (body === null) {
5618
+ // In some browsers (e.g. Mozilla/5.0 iPad AppleWebKit Mobile) the `body` property only
5619
+ // becomes available in the following tick of the JS engine. In that case we fall back to
5620
+ // the `inertDocumentHelper` instead.
5621
+ return this.inertDocumentHelper.getInertBodyElement(html);
5622
+ }
5612
5623
  body.removeChild(body.firstChild);
5613
5624
  return body;
5614
5625
  }
@@ -7447,12 +7458,12 @@
7447
7458
  tCleanup[i].call(context);
7448
7459
  }
7449
7460
  }
7450
- if (lCleanup !== null) {
7451
- for (var i = lastLCleanupIndex + 1; i < lCleanup.length; i++) {
7452
- var instanceCleanupFn = lCleanup[i];
7453
- ngDevMode && assertFunction(instanceCleanupFn, 'Expecting instance cleanup function.');
7454
- instanceCleanupFn();
7455
- }
7461
+ }
7462
+ if (lCleanup !== null) {
7463
+ for (var i = lastLCleanupIndex + 1; i < lCleanup.length; i++) {
7464
+ var instanceCleanupFn = lCleanup[i];
7465
+ ngDevMode && assertFunction(instanceCleanupFn, 'Expecting instance cleanup function.');
7466
+ instanceCleanupFn();
7456
7467
  }
7457
7468
  lView[CLEANUP] = null;
7458
7469
  }
@@ -10016,19 +10027,19 @@
10016
10027
  * is `null` and the function is store in `LView` (rather than it `TView`).
10017
10028
  */
10018
10029
  function storeCleanupWithContext(tView, lView, context, cleanupFn) {
10019
- var lCleanup = getLCleanup(lView);
10030
+ var lCleanup = getOrCreateLViewCleanup(lView);
10020
10031
  if (context === null) {
10021
10032
  // If context is null that this is instance specific callback. These callbacks can only be
10022
10033
  // inserted after template shared instances. For this reason in ngDevMode we freeze the TView.
10023
10034
  if (ngDevMode) {
10024
- Object.freeze(getTViewCleanup(tView));
10035
+ Object.freeze(getOrCreateTViewCleanup(tView));
10025
10036
  }
10026
10037
  lCleanup.push(cleanupFn);
10027
10038
  }
10028
10039
  else {
10029
10040
  lCleanup.push(context);
10030
10041
  if (tView.firstCreatePass) {
10031
- getTViewCleanup(tView).push(cleanupFn, lCleanup.length - 1);
10042
+ getOrCreateTViewCleanup(tView).push(cleanupFn, lCleanup.length - 1);
10032
10043
  }
10033
10044
  }
10034
10045
  }
@@ -11111,11 +11122,11 @@
11111
11122
  }
11112
11123
  }
11113
11124
  var CLEAN_PROMISE = _CLEAN_PROMISE;
11114
- function getLCleanup(view) {
11125
+ function getOrCreateLViewCleanup(view) {
11115
11126
  // top level variables should not be exported for performance reasons (PERF_NOTES.md)
11116
11127
  return view[CLEANUP] || (view[CLEANUP] = ngDevMode ? new LCleanup() : []);
11117
11128
  }
11118
- function getTViewCleanup(tView) {
11129
+ function getOrCreateTViewCleanup(tView) {
11119
11130
  return tView.cleanup || (tView.cleanup = ngDevMode ? new TCleanup() : []);
11120
11131
  }
11121
11132
  /**
@@ -15416,11 +15427,11 @@
15416
15427
  if (useCapture === void 0) { useCapture = false; }
15417
15428
  var isTNodeDirectiveHost = isDirectiveHost(tNode);
15418
15429
  var firstCreatePass = tView.firstCreatePass;
15419
- var tCleanup = firstCreatePass && getTViewCleanup(tView);
15430
+ var tCleanup = firstCreatePass && getOrCreateTViewCleanup(tView);
15420
15431
  // When the ɵɵlistener instruction was generated and is executed we know that there is either a
15421
15432
  // native listener or a directive output on this element. As such we we know that we will have to
15422
15433
  // register a listener and store its cleanup function on LView.
15423
- var lCleanup = getLCleanup(lView);
15434
+ var lCleanup = getOrCreateLViewCleanup(lView);
15424
15435
  ngDevMode && assertTNodeType(tNode, 3 /* AnyRNode */ | 12 /* AnyContainer */);
15425
15436
  var processOutputs = true;
15426
15437
  // add native event listener - applicable to elements only
@@ -21714,7 +21725,7 @@
21714
21725
  /**
21715
21726
  * @publicApi
21716
21727
  */
21717
- var VERSION = new Version('11.0.5');
21728
+ var VERSION = new Version('11.0.9');
21718
21729
 
21719
21730
  /**
21720
21731
  * @license
@@ -22887,7 +22898,7 @@
22887
22898
  this._lView = _lView;
22888
22899
  this._cdRefInjectingView = _cdRefInjectingView;
22889
22900
  this._appRef = null;
22890
- this._viewContainerRef = null;
22901
+ this._attachedToViewContainer = false;
22891
22902
  }
22892
22903
  Object.defineProperty(ViewRef.prototype, "rootNodes", {
22893
22904
  get: function () {
@@ -22916,12 +22927,19 @@
22916
22927
  if (this._appRef) {
22917
22928
  this._appRef.detachView(this);
22918
22929
  }
22919
- else if (this._viewContainerRef) {
22920
- var index = this._viewContainerRef.indexOf(this);
22921
- if (index > -1) {
22922
- this._viewContainerRef.detach(index);
22930
+ else if (this._attachedToViewContainer) {
22931
+ var parent = this._lView[PARENT];
22932
+ if (isLContainer(parent)) {
22933
+ var viewRefs = parent[VIEW_REFS];
22934
+ var index = viewRefs ? viewRefs.indexOf(this) : -1;
22935
+ if (index > -1) {
22936
+ ngDevMode &&
22937
+ assertEqual(index, parent.indexOf(this._lView) - CONTAINER_HEADER_OFFSET, 'An attached view should be in the same position within its container as its ViewRef in the VIEW_REFS array.');
22938
+ detachView(parent, index);
22939
+ removeFromArray(viewRefs, index);
22940
+ }
22923
22941
  }
22924
- this._viewContainerRef = null;
22942
+ this._attachedToViewContainer = false;
22925
22943
  }
22926
22944
  destroyLView(this._lView[TVIEW], this._lView);
22927
22945
  };
@@ -23113,18 +23131,18 @@
23113
23131
  ViewRef.prototype.checkNoChanges = function () {
23114
23132
  checkNoChangesInternal(this._lView[TVIEW], this._lView, this.context);
23115
23133
  };
23116
- ViewRef.prototype.attachToViewContainerRef = function (vcRef) {
23134
+ ViewRef.prototype.attachToViewContainerRef = function () {
23117
23135
  if (this._appRef) {
23118
23136
  throw new Error('This view is already attached directly to the ApplicationRef!');
23119
23137
  }
23120
- this._viewContainerRef = vcRef;
23138
+ this._attachedToViewContainer = true;
23121
23139
  };
23122
23140
  ViewRef.prototype.detachFromAppRef = function () {
23123
23141
  this._appRef = null;
23124
23142
  renderDetachView(this._lView[TVIEW], this._lView);
23125
23143
  };
23126
23144
  ViewRef.prototype.attachToAppRef = function (appRef) {
23127
- if (this._viewContainerRef) {
23145
+ if (this._attachedToViewContainer) {
23128
23146
  throw new Error('This view is already attached to a ViewContainer!');
23129
23147
  }
23130
23148
  this._appRef = appRef;
@@ -23536,7 +23554,7 @@
23536
23554
  if (parentRNode !== null) {
23537
23555
  addViewToContainer(tView, lContainer[T_HOST], renderer, lView, parentRNode, beforeNode);
23538
23556
  }
23539
- viewRef.attachToViewContainerRef(this);
23557
+ viewRef.attachToViewContainerRef();
23540
23558
  addToArray(getOrCreateViewRefs(lContainer), adjustedIdx, viewRef);
23541
23559
  return viewRef;
23542
23560
  };
@@ -29428,7 +29446,7 @@
29428
29446
  }
29429
29447
  /**
29430
29448
  * Creates a factory for a platform. Can be used to provide or override `Providers` specific to
29431
- * your applciation's runtime needs, such as `PLATFORM_INITIALIZER` and `PLATFORM_ID`.
29449
+ * your application's runtime needs, such as `PLATFORM_INITIALIZER` and `PLATFORM_ID`.
29432
29450
  * @param parentPlatformFactory Another platform factory to modify. Allows you to compose factories
29433
29451
  * to build up configurations that might be required by different libraries or parts of the
29434
29452
  * application.