@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
package/fesm2015/core.js CHANGED
@@ -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
  */
@@ -2715,6 +2715,12 @@ if (false) {
2715
2715
  * @type {?}
2716
2716
  */
2717
2717
  TView.prototype.consts;
2718
+ /**
2719
+ * Indicates that there was an error before we managed to complete the first create pass of the
2720
+ * view. This means that the view is likely corrupted and we should try to recover it.
2721
+ * @type {?}
2722
+ */
2723
+ TView.prototype.incompleteFirstPass;
2718
2724
  }
2719
2725
  /** @enum {number} */
2720
2726
  const RootContextFlags = {
@@ -4173,7 +4179,7 @@ function setBindingRootForHostBindings(bindingRootIndex, currentDirectiveIndex)
4173
4179
  /** @type {?} */
4174
4180
  const lFrame = instructionState.lFrame;
4175
4181
  lFrame.bindingIndex = lFrame.bindingRootIndex = bindingRootIndex;
4176
- lFrame.currentDirectiveIndex = currentDirectiveIndex;
4182
+ setCurrentDirectiveIndex(currentDirectiveIndex);
4177
4183
  }
4178
4184
  /**
4179
4185
  * When host binding is executing this points to the directive index.
@@ -4184,6 +4190,27 @@ function setBindingRootForHostBindings(bindingRootIndex, currentDirectiveIndex)
4184
4190
  function getCurrentDirectiveIndex() {
4185
4191
  return instructionState.lFrame.currentDirectiveIndex;
4186
4192
  }
4193
+ /**
4194
+ * Sets an index of a directive whose `hostBindings` are being processed.
4195
+ *
4196
+ * @param {?} currentDirectiveIndex `TData` index where current directive instance can be found.
4197
+ * @return {?}
4198
+ */
4199
+ function setCurrentDirectiveIndex(currentDirectiveIndex) {
4200
+ instructionState.lFrame.currentDirectiveIndex = currentDirectiveIndex;
4201
+ }
4202
+ /**
4203
+ * Retrieve the current `DirectiveDef` which is active when `hostBindings` instruction is being
4204
+ * executed.
4205
+ *
4206
+ * @param {?} tData Current `TData` where the `DirectiveDef` will be looked up at.
4207
+ * @return {?}
4208
+ */
4209
+ function getCurrentDirectiveDef(tData) {
4210
+ /** @type {?} */
4211
+ const currentDirectiveIndex = instructionState.lFrame.currentDirectiveIndex;
4212
+ return currentDirectiveIndex === -1 ? null : (/** @type {?} */ (tData[currentDirectiveIndex]));
4213
+ }
4187
4214
  /**
4188
4215
  * @return {?}
4189
4216
  */
@@ -10435,6 +10462,7 @@ const TViewConstructor = class TView {
10435
10462
  * @param {?} firstChild
10436
10463
  * @param {?} schemas
10437
10464
  * @param {?} consts
10465
+ * @param {?} incompleteFirstPass
10438
10466
  */
10439
10467
  constructor(type, //
10440
10468
  id, //
@@ -10465,7 +10493,9 @@ const TViewConstructor = class TView {
10465
10493
  pipeRegistry, //
10466
10494
  firstChild, //
10467
10495
  schemas, //
10468
- consts) {
10496
+ consts, //
10497
+ incompleteFirstPass //
10498
+ ) {
10469
10499
  this.type = type;
10470
10500
  this.id = id;
10471
10501
  this.blueprint = blueprint;
@@ -10496,6 +10526,7 @@ const TViewConstructor = class TView {
10496
10526
  this.firstChild = firstChild;
10497
10527
  this.schemas = schemas;
10498
10528
  this.consts = consts;
10529
+ this.incompleteFirstPass = incompleteFirstPass;
10499
10530
  }
10500
10531
  /**
10501
10532
  * @return {?}
@@ -11871,6 +11902,14 @@ function renderView(tView, lView, context) {
11871
11902
  renderChildComponents(lView, components);
11872
11903
  }
11873
11904
  }
11905
+ catch (error) {
11906
+ // If we didn't manage to get past the first template pass due to
11907
+ // an error, mark the view as corrupted so we can try to recover.
11908
+ if (tView.firstCreatePass) {
11909
+ tView.incompleteFirstPass = true;
11910
+ }
11911
+ throw error;
11912
+ }
11874
11913
  finally {
11875
11914
  lView[FLAGS] &= ~4 /* CreationMode */;
11876
11915
  leaveView();
@@ -12134,8 +12173,14 @@ function saveResolvedLocalsInData(viewData, tNode, localRefExtractor = getNative
12134
12173
  * @return {?} TView
12135
12174
  */
12136
12175
  function getOrCreateTComponentView(def) {
12137
- return def.tView ||
12138
- (def.tView = createTView(1 /* Component */, -1, def.template, def.decls, def.vars, def.directiveDefs, def.pipeDefs, def.viewQuery, def.schemas, def.consts));
12176
+ /** @type {?} */
12177
+ const tView = def.tView;
12178
+ // Create a TView if there isn't one, or recreate it if the first create pass didn't
12179
+ // complete successfuly since we can't know for sure whether it's in a usable shape.
12180
+ if (tView === null || tView.incompleteFirstPass) {
12181
+ return def.tView = createTView(1 /* Component */, -1, def.template, def.decls, def.vars, def.directiveDefs, def.pipeDefs, def.viewQuery, def.schemas, def.consts);
12182
+ }
12183
+ return tView;
12139
12184
  }
12140
12185
  /**
12141
12186
  * Creates a TView instance
@@ -12193,7 +12238,9 @@ function createTView(type, viewIndex, templateFn, decls, vars, directives, pipes
12193
12238
  typeof pipes === 'function' ? pipes() : pipes, // pipeRegistry: PipeDefList|null,
12194
12239
  null, // firstChild: TNode|null,
12195
12240
  schemas, // schemas: SchemaMetadata[]|null,
12196
- consts) : // consts: TConstants|null
12241
+ consts, // consts: TConstants|null
12242
+ false // incompleteFirstPass: boolean
12243
+ ) :
12197
12244
  {
12198
12245
  type: type,
12199
12246
  id: viewIndex,
@@ -12225,6 +12272,7 @@ function createTView(type, viewIndex, templateFn, decls, vars, directives, pipes
12225
12272
  firstChild: null,
12226
12273
  schemas: schemas,
12227
12274
  consts: consts,
12275
+ incompleteFirstPass: false
12228
12276
  };
12229
12277
  }
12230
12278
  /**
@@ -12900,13 +12948,16 @@ function invokeDirectivesHostBindings(tView, lView, tNode) {
12900
12948
  const firstCreatePass = tView.firstCreatePass;
12901
12949
  /** @type {?} */
12902
12950
  const elementIndex = tNode.index - HEADER_OFFSET;
12951
+ /** @type {?} */
12952
+ const currentDirectiveIndex = getCurrentDirectiveIndex();
12903
12953
  try {
12904
12954
  setSelectedIndex(elementIndex);
12905
- for (let i = start; i < end; i++) {
12955
+ for (let dirIndex = start; dirIndex < end; dirIndex++) {
12906
12956
  /** @type {?} */
12907
- const def = (/** @type {?} */ (tView.data[i]));
12957
+ const def = (/** @type {?} */ (tView.data[dirIndex]));
12908
12958
  /** @type {?} */
12909
- const directive = lView[i];
12959
+ const directive = lView[dirIndex];
12960
+ setCurrentDirectiveIndex(dirIndex);
12910
12961
  if (def.hostBindings !== null || def.hostVars !== 0 || def.hostAttrs !== null) {
12911
12962
  invokeHostBindingsInCreationMode(def, directive);
12912
12963
  }
@@ -12917,6 +12968,7 @@ function invokeDirectivesHostBindings(tView, lView, tNode) {
12917
12968
  }
12918
12969
  finally {
12919
12970
  setSelectedIndex(-1);
12971
+ setCurrentDirectiveIndex(currentDirectiveIndex);
12920
12972
  }
12921
12973
  }
12922
12974
  /**
@@ -13664,14 +13716,22 @@ function getTViewCleanup(tView) {
13664
13716
  /**
13665
13717
  * There are cases where the sub component's renderer needs to be included
13666
13718
  * instead of the current renderer (see the componentSyntheticHost* instructions).
13719
+ * @param {?} currentDef
13667
13720
  * @param {?} tNode
13668
13721
  * @param {?} lView
13669
13722
  * @return {?}
13670
13723
  */
13671
- function loadComponentRenderer(tNode, lView) {
13672
- /** @type {?} */
13673
- const componentLView = (/** @type {?} */ (unwrapLView(lView[tNode.index])));
13674
- return componentLView[RENDERER];
13724
+ function loadComponentRenderer(currentDef, tNode, lView) {
13725
+ // TODO(FW-2043): the `currentDef` is null when host bindings are invoked while creating root
13726
+ // component (see packages/core/src/render3/component.ts). This is not consistent with the process
13727
+ // of creating inner components, when current directive index is available in the state. In order
13728
+ // to avoid relying on current def being `null` (thus special-casing root component creation), the
13729
+ // process of creating root component should be unified with the process of creating inner
13730
+ // components.
13731
+ if (currentDef === null || isComponentDef(currentDef)) {
13732
+ lView = (/** @type {?} */ (unwrapLView(lView[tNode.index])));
13733
+ }
13734
+ return lView[RENDERER];
13675
13735
  }
13676
13736
  /**
13677
13737
  * Handles an error thrown in an LView.
@@ -21699,7 +21759,7 @@ function ɵɵlistener(eventName, listenerFn, useCapture = false, eventTargetReso
21699
21759
  return ɵɵlistener;
21700
21760
  }
21701
21761
  /**
21702
- * Registers a synthetic host listener (e.g. `(\@foo.start)`) on a component.
21762
+ * Registers a synthetic host listener (e.g. `(\@foo.start)`) on a component or directive.
21703
21763
  *
21704
21764
  * This instruction is for compatibility purposes and is designed to ensure that a
21705
21765
  * synthetic host listener (e.g. `\@HostListener('\@foo.start')`) properly gets rendered
@@ -21726,9 +21786,11 @@ function ɵɵcomponentHostSyntheticListener(eventName, listenerFn, useCapture =
21726
21786
  /** @type {?} */
21727
21787
  const lView = getLView();
21728
21788
  /** @type {?} */
21729
- const renderer = loadComponentRenderer(tNode, lView);
21730
- /** @type {?} */
21731
21789
  const tView = getTView();
21790
+ /** @type {?} */
21791
+ const currentDef = getCurrentDirectiveDef(tView.data);
21792
+ /** @type {?} */
21793
+ const renderer = loadComponentRenderer(currentDef, tNode, lView);
21732
21794
  listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn, useCapture, eventTargetResolver);
21733
21795
  return ɵɵcomponentHostSyntheticListener;
21734
21796
  }
@@ -23718,7 +23780,7 @@ function stylingFirstUpdatePass(tView, tStylingKey, bindingIndex, isClassBased)
23718
23780
  */
23719
23781
  function wrapInStaticStylingKey(tData, tNode, stylingKey, isClassBased) {
23720
23782
  /** @type {?} */
23721
- const hostDirectiveDef = getHostDirectiveDef(tData);
23783
+ const hostDirectiveDef = getCurrentDirectiveDef(tData);
23722
23784
  /** @type {?} */
23723
23785
  let residual = isClassBased ? tNode.residualClasses : tNode.residualStyles;
23724
23786
  if (hostDirectiveDef === null) {
@@ -23967,18 +24029,6 @@ function collectStylingFromTAttrs(stylingKey, attrs, isClassBased) {
23967
24029
  }
23968
24030
  return stylingKey === undefined ? null : stylingKey;
23969
24031
  }
23970
- /**
23971
- * Retrieve the current `DirectiveDef` which is active when `hostBindings` style instruction is
23972
- * being executed (or `null` if we are in `template`.)
23973
- *
23974
- * @param {?} tData Current `TData` where the `DirectiveDef` will be looked up at.
23975
- * @return {?}
23976
- */
23977
- function getHostDirectiveDef(tData) {
23978
- /** @type {?} */
23979
- const currentDirectiveIndex = getCurrentDirectiveIndex();
23980
- return currentDirectiveIndex === -1 ? null : (/** @type {?} */ (tData[currentDirectiveIndex]));
23981
- }
23982
24032
  /**
23983
24033
  * Convert user input to `KeyValueArray`.
23984
24034
  *
@@ -25798,7 +25848,7 @@ function ɵɵhostProperty(propName, value, sanitizer) {
25798
25848
  return ɵɵhostProperty;
25799
25849
  }
25800
25850
  /**
25801
- * Updates a synthetic host binding (e.g. `[\@foo]`) on a component.
25851
+ * Updates a synthetic host binding (e.g. `[\@foo]`) on a component or directive.
25802
25852
  *
25803
25853
  * This instruction is for compatibility purposes and is designed to ensure that a
25804
25854
  * synthetic host binding (e.g. `\@HostBinding('\@foo')`) properly gets rendered in
@@ -25830,7 +25880,9 @@ function ɵɵupdateSyntheticHostBinding(propName, value, sanitizer) {
25830
25880
  /** @type {?} */
25831
25881
  const tNode = getSelectedTNode();
25832
25882
  /** @type {?} */
25833
- const renderer = loadComponentRenderer(tNode, lView);
25883
+ const currentDef = getCurrentDirectiveDef(tView.data);
25884
+ /** @type {?} */
25885
+ const renderer = loadComponentRenderer(currentDef, tNode, lView);
25834
25886
  elementPropertyInternal(tView, tNode, lView, propName, value, renderer, sanitizer, true);
25835
25887
  ngDevMode && storePropertyBindingMetadata(tView.data, tNode, propName, bindingIndex);
25836
25888
  }
@@ -28288,7 +28340,7 @@ if (false) {
28288
28340
  * \@publicApi
28289
28341
  * @type {?}
28290
28342
  */
28291
- const VERSION = new Version('9.1.3');
28343
+ const VERSION = new Version('9.1.4');
28292
28344
 
28293
28345
  /**
28294
28346
  * @fileoverview added by tsickle