@angular/core 9.1.3 → 9.1.4

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 (36) hide show
  1. package/bundles/core-testing.umd.js +1 -1
  2. package/bundles/core-testing.umd.min.js +1 -1
  3. package/bundles/core-testing.umd.min.js.map +1 -1
  4. package/bundles/core.umd.js +68 -28
  5. package/bundles/core.umd.js.map +1 -1
  6. package/bundles/core.umd.min.js +126 -126
  7. package/bundles/core.umd.min.js.map +1 -1
  8. package/core.d.ts +8 -3
  9. package/core.metadata.json +1 -1
  10. package/esm2015/src/render3/instructions/all.js +2 -2
  11. package/esm2015/src/render3/instructions/host_property.js +6 -4
  12. package/esm2015/src/render3/instructions/listener.js +7 -5
  13. package/esm2015/src/render3/instructions/lview_debug.js +6 -2
  14. package/esm2015/src/render3/instructions/shared.js +41 -12
  15. package/esm2015/src/render3/instructions/styling.js +3 -15
  16. package/esm2015/src/render3/interfaces/view.js +7 -1
  17. package/esm2015/src/render3/state.js +23 -2
  18. package/esm2015/src/version.js +1 -1
  19. package/esm5/src/render3/instructions/host_property.js +5 -4
  20. package/esm5/src/render3/instructions/listener.js +5 -4
  21. package/esm5/src/render3/instructions/lview_debug.js +5 -2
  22. package/esm5/src/render3/instructions/shared.js +38 -11
  23. package/esm5/src/render3/instructions/styling.js +3 -13
  24. package/esm5/src/render3/interfaces/view.js +1 -1
  25. package/esm5/src/render3/state.js +20 -2
  26. package/esm5/src/version.js +1 -1
  27. package/fesm2015/core.js +84 -32
  28. package/fesm2015/core.js.map +1 -1
  29. package/fesm2015/testing.js +1 -1
  30. package/fesm5/core.js +68 -28
  31. package/fesm5/core.js.map +1 -1
  32. package/fesm5/testing.js +1 -1
  33. package/package.json +1 -1
  34. package/src/r3_symbols.d.ts +1 -1
  35. package/testing/testing.d.ts +1 -1
  36. package/testing.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v9.1.3
2
+ * @license Angular v9.1.4
3
3
  * (c) 2010-2020 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2678,7 +2678,7 @@
2678
2678
  function setBindingRootForHostBindings(bindingRootIndex, currentDirectiveIndex) {
2679
2679
  var lFrame = instructionState.lFrame;
2680
2680
  lFrame.bindingIndex = lFrame.bindingRootIndex = bindingRootIndex;
2681
- lFrame.currentDirectiveIndex = currentDirectiveIndex;
2681
+ setCurrentDirectiveIndex(currentDirectiveIndex);
2682
2682
  }
2683
2683
  /**
2684
2684
  * When host binding is executing this points to the directive index.
@@ -2688,6 +2688,24 @@
2688
2688
  function getCurrentDirectiveIndex() {
2689
2689
  return instructionState.lFrame.currentDirectiveIndex;
2690
2690
  }
2691
+ /**
2692
+ * Sets an index of a directive whose `hostBindings` are being processed.
2693
+ *
2694
+ * @param currentDirectiveIndex `TData` index where current directive instance can be found.
2695
+ */
2696
+ function setCurrentDirectiveIndex(currentDirectiveIndex) {
2697
+ instructionState.lFrame.currentDirectiveIndex = currentDirectiveIndex;
2698
+ }
2699
+ /**
2700
+ * Retrieve the current `DirectiveDef` which is active when `hostBindings` instruction is being
2701
+ * executed.
2702
+ *
2703
+ * @param tData Current `TData` where the `DirectiveDef` will be looked up at.
2704
+ */
2705
+ function getCurrentDirectiveDef(tData) {
2706
+ var currentDirectiveIndex = instructionState.lFrame.currentDirectiveIndex;
2707
+ return currentDirectiveIndex === -1 ? null : tData[currentDirectiveIndex];
2708
+ }
2691
2709
  function getCurrentQueryIndex() {
2692
2710
  return instructionState.lFrame.currentQueryIndex;
2693
2711
  }
@@ -6660,7 +6678,9 @@
6660
6678
  pipeRegistry, //
6661
6679
  firstChild, //
6662
6680
  schemas, //
6663
- consts) {
6681
+ consts, //
6682
+ incompleteFirstPass //
6683
+ ) {
6664
6684
  this.type = type;
6665
6685
  this.id = id;
6666
6686
  this.blueprint = blueprint;
@@ -6691,6 +6711,7 @@
6691
6711
  this.firstChild = firstChild;
6692
6712
  this.schemas = schemas;
6693
6713
  this.consts = consts;
6714
+ this.incompleteFirstPass = incompleteFirstPass;
6694
6715
  }
6695
6716
  Object.defineProperty(TView.prototype, "template_", {
6696
6717
  get: function () {
@@ -7702,6 +7723,14 @@
7702
7723
  renderChildComponents(lView, components);
7703
7724
  }
7704
7725
  }
7726
+ catch (error) {
7727
+ // If we didn't manage to get past the first template pass due to
7728
+ // an error, mark the view as corrupted so we can try to recover.
7729
+ if (tView.firstCreatePass) {
7730
+ tView.incompleteFirstPass = true;
7731
+ }
7732
+ throw error;
7733
+ }
7705
7734
  finally {
7706
7735
  lView[FLAGS] &= ~4 /* CreationMode */;
7707
7736
  leaveView();
@@ -7907,8 +7936,13 @@
7907
7936
  * @returns TView
7908
7937
  */
7909
7938
  function getOrCreateTComponentView(def) {
7910
- return def.tView ||
7911
- (def.tView = createTView(1 /* Component */, -1, def.template, def.decls, def.vars, def.directiveDefs, def.pipeDefs, def.viewQuery, def.schemas, def.consts));
7939
+ var tView = def.tView;
7940
+ // Create a TView if there isn't one, or recreate it if the first create pass didn't
7941
+ // complete successfuly since we can't know for sure whether it's in a usable shape.
7942
+ if (tView === null || tView.incompleteFirstPass) {
7943
+ return def.tView = createTView(1 /* Component */, -1, def.template, def.decls, def.vars, def.directiveDefs, def.pipeDefs, def.viewQuery, def.schemas, def.consts);
7944
+ }
7945
+ return tView;
7912
7946
  }
7913
7947
  /**
7914
7948
  * Creates a TView instance
@@ -7961,7 +7995,9 @@
7961
7995
  typeof pipes === 'function' ? pipes() : pipes, // pipeRegistry: PipeDefList|null,
7962
7996
  null, // firstChild: TNode|null,
7963
7997
  schemas, // schemas: SchemaMetadata[]|null,
7964
- consts) : // consts: TConstants|null
7998
+ consts, // consts: TConstants|null
7999
+ false // incompleteFirstPass: boolean
8000
+ ) :
7965
8001
  {
7966
8002
  type: type,
7967
8003
  id: viewIndex,
@@ -7993,6 +8029,7 @@
7993
8029
  firstChild: null,
7994
8030
  schemas: schemas,
7995
8031
  consts: consts,
8032
+ incompleteFirstPass: false
7996
8033
  };
7997
8034
  }
7998
8035
  function createViewBlueprint(bindingStartIndex, initialViewLength) {
@@ -8514,11 +8551,13 @@
8514
8551
  var expando = tView.expandoInstructions;
8515
8552
  var firstCreatePass = tView.firstCreatePass;
8516
8553
  var elementIndex = tNode.index - HEADER_OFFSET;
8554
+ var currentDirectiveIndex = getCurrentDirectiveIndex();
8517
8555
  try {
8518
8556
  setSelectedIndex(elementIndex);
8519
- for (var i = start; i < end; i++) {
8520
- var def = tView.data[i];
8521
- var directive = lView[i];
8557
+ for (var dirIndex = start; dirIndex < end; dirIndex++) {
8558
+ var def = tView.data[dirIndex];
8559
+ var directive = lView[dirIndex];
8560
+ setCurrentDirectiveIndex(dirIndex);
8522
8561
  if (def.hostBindings !== null || def.hostVars !== 0 || def.hostAttrs !== null) {
8523
8562
  invokeHostBindingsInCreationMode(def, directive);
8524
8563
  }
@@ -8529,6 +8568,7 @@
8529
8568
  }
8530
8569
  finally {
8531
8570
  setSelectedIndex(-1);
8571
+ setCurrentDirectiveIndex(currentDirectiveIndex);
8532
8572
  }
8533
8573
  }
8534
8574
  /**
@@ -9120,9 +9160,17 @@
9120
9160
  * There are cases where the sub component's renderer needs to be included
9121
9161
  * instead of the current renderer (see the componentSyntheticHost* instructions).
9122
9162
  */
9123
- function loadComponentRenderer(tNode, lView) {
9124
- var componentLView = unwrapLView(lView[tNode.index]);
9125
- return componentLView[RENDERER];
9163
+ function loadComponentRenderer(currentDef, tNode, lView) {
9164
+ // TODO(FW-2043): the `currentDef` is null when host bindings are invoked while creating root
9165
+ // component (see packages/core/src/render3/component.ts). This is not consistent with the process
9166
+ // of creating inner components, when current directive index is available in the state. In order
9167
+ // to avoid relying on current def being `null` (thus special-casing root component creation), the
9168
+ // process of creating root component should be unified with the process of creating inner
9169
+ // components.
9170
+ if (currentDef === null || isComponentDef(currentDef)) {
9171
+ lView = unwrapLView(lView[tNode.index]);
9172
+ }
9173
+ return lView[RENDERER];
9126
9174
  }
9127
9175
  /** Handles an error thrown in an LView. */
9128
9176
  function handleError(lView, error) {
@@ -15040,7 +15088,7 @@
15040
15088
  return ɵɵlistener;
15041
15089
  }
15042
15090
  /**
15043
- * Registers a synthetic host listener (e.g. `(@foo.start)`) on a component.
15091
+ * Registers a synthetic host listener (e.g. `(@foo.start)`) on a component or directive.
15044
15092
  *
15045
15093
  * This instruction is for compatibility purposes and is designed to ensure that a
15046
15094
  * synthetic host listener (e.g. `@HostListener('@foo.start')`) properly gets rendered
@@ -15064,8 +15112,9 @@
15064
15112
  if (useCapture === void 0) { useCapture = false; }
15065
15113
  var tNode = getPreviousOrParentTNode();
15066
15114
  var lView = getLView();
15067
- var renderer = loadComponentRenderer(tNode, lView);
15068
15115
  var tView = getTView();
15116
+ var currentDef = getCurrentDirectiveDef(tView.data);
15117
+ var renderer = loadComponentRenderer(currentDef, tNode, lView);
15069
15118
  listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn, useCapture, eventTargetResolver);
15070
15119
  return ɵɵcomponentHostSyntheticListener;
15071
15120
  }
@@ -16841,7 +16890,7 @@
16841
16890
  * @param isClassBased `true` if `class` (`false` if `style`)
16842
16891
  */
16843
16892
  function wrapInStaticStylingKey(tData, tNode, stylingKey, isClassBased) {
16844
- var hostDirectiveDef = getHostDirectiveDef(tData);
16893
+ var hostDirectiveDef = getCurrentDirectiveDef(tData);
16845
16894
  var residual = isClassBased ? tNode.residualClasses : tNode.residualStyles;
16846
16895
  if (hostDirectiveDef === null) {
16847
16896
  // We are in template node.
@@ -17070,16 +17119,6 @@
17070
17119
  }
17071
17120
  return stylingKey === undefined ? null : stylingKey;
17072
17121
  }
17073
- /**
17074
- * Retrieve the current `DirectiveDef` which is active when `hostBindings` style instruction is
17075
- * being executed (or `null` if we are in `template`.)
17076
- *
17077
- * @param tData Current `TData` where the `DirectiveDef` will be looked up at.
17078
- */
17079
- function getHostDirectiveDef(tData) {
17080
- var currentDirectiveIndex = getCurrentDirectiveIndex();
17081
- return currentDirectiveIndex === -1 ? null : tData[currentDirectiveIndex];
17082
- }
17083
17122
  /**
17084
17123
  * Convert user input to `KeyValueArray`.
17085
17124
  *
@@ -18717,7 +18756,7 @@
18717
18756
  return ɵɵhostProperty;
18718
18757
  }
18719
18758
  /**
18720
- * Updates a synthetic host binding (e.g. `[@foo]`) on a component.
18759
+ * Updates a synthetic host binding (e.g. `[@foo]`) on a component or directive.
18721
18760
  *
18722
18761
  * This instruction is for compatibility purposes and is designed to ensure that a
18723
18762
  * synthetic host binding (e.g. `@HostBinding('@foo')`) properly gets rendered in
@@ -18743,7 +18782,8 @@
18743
18782
  if (bindingUpdated(lView, bindingIndex, value)) {
18744
18783
  var tView = getTView();
18745
18784
  var tNode = getSelectedTNode();
18746
- var renderer = loadComponentRenderer(tNode, lView);
18785
+ var currentDef = getCurrentDirectiveDef(tView.data);
18786
+ var renderer = loadComponentRenderer(currentDef, tNode, lView);
18747
18787
  elementPropertyInternal(tView, tNode, lView, propName, value, renderer, sanitizer, true);
18748
18788
  ngDevMode && storePropertyBindingMetadata(tView.data, tNode, propName, bindingIndex);
18749
18789
  }
@@ -20319,7 +20359,7 @@
20319
20359
  /**
20320
20360
  * @publicApi
20321
20361
  */
20322
- var VERSION = new Version('9.1.3');
20362
+ var VERSION = new Version('9.1.4');
20323
20363
 
20324
20364
  /**
20325
20365
  * @license