@angular/core 15.0.0-next.2 → 15.0.0-next.3

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 (31) hide show
  1. package/esm2020/src/debug/debug_node.mjs +1 -1
  2. package/esm2020/src/render3/component_ref.mjs +2 -2
  3. package/esm2020/src/render3/context_discovery.mjs +12 -9
  4. package/esm2020/src/render3/definition.mjs +3 -2
  5. package/esm2020/src/render3/features/host_directives_feature.mjs +36 -13
  6. package/esm2020/src/render3/instructions/element.mjs +1 -1
  7. package/esm2020/src/render3/instructions/listener.mjs +2 -4
  8. package/esm2020/src/render3/instructions/lview_debug.mjs +9 -9
  9. package/esm2020/src/render3/instructions/projection.mjs +1 -1
  10. package/esm2020/src/render3/instructions/shared.mjs +60 -25
  11. package/esm2020/src/render3/instructions/styling.mjs +2 -2
  12. package/esm2020/src/render3/interfaces/definition.mjs +1 -1
  13. package/esm2020/src/render3/interfaces/node.mjs +3 -3
  14. package/esm2020/src/render3/interfaces/type_checks.mjs +3 -3
  15. package/esm2020/src/render3/jit/directive.mjs +7 -2
  16. package/esm2020/src/render3/node_manipulation.mjs +6 -5
  17. package/esm2020/src/render3/node_manipulation_i18n.mjs +2 -2
  18. package/esm2020/src/version.mjs +1 -1
  19. package/esm2020/testing/src/logger.mjs +3 -3
  20. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  21. package/fesm2015/core.mjs +137 -73
  22. package/fesm2015/core.mjs.map +1 -1
  23. package/fesm2015/testing.mjs +129 -71
  24. package/fesm2015/testing.mjs.map +1 -1
  25. package/fesm2020/core.mjs +136 -72
  26. package/fesm2020/core.mjs.map +1 -1
  27. package/fesm2020/testing.mjs +129 -70
  28. package/fesm2020/testing.mjs.map +1 -1
  29. package/index.d.ts +41 -29
  30. package/package.json +1 -1
  31. package/testing/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v15.0.0-next.2
2
+ * @license Angular v15.0.0-next.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2568,7 +2568,8 @@ function ɵɵdefineComponent(componentDefinition) {
2568
2568
  setInput: null,
2569
2569
  schemas: componentDefinition.schemas || null,
2570
2570
  tView: null,
2571
- applyHostDirectives: null,
2571
+ findHostDirectiveDefs: null,
2572
+ hostDirectives: null,
2572
2573
  };
2573
2574
  const dependencies = componentDefinition.dependencies;
2574
2575
  const feature = componentDefinition.features;
@@ -2909,10 +2910,10 @@ function isLContainer(value) {
2909
2910
  return Array.isArray(value) && value[TYPE] === true;
2910
2911
  }
2911
2912
  function isContentQueryHost(tNode) {
2912
- return (tNode.flags & 8 /* TNodeFlags.hasContentQuery */) !== 0;
2913
+ return (tNode.flags & 4 /* TNodeFlags.hasContentQuery */) !== 0;
2913
2914
  }
2914
2915
  function isComponentHost(tNode) {
2915
- return (tNode.flags & 2 /* TNodeFlags.isComponentHost */) === 2 /* TNodeFlags.isComponentHost */;
2916
+ return tNode.componentOffset > -1;
2916
2917
  }
2917
2918
  function isDirectiveHost(tNode) {
2918
2919
  return (tNode.flags & 1 /* TNodeFlags.isDirectiveHost */) === 1 /* TNodeFlags.isDirectiveHost */;
@@ -4322,7 +4323,7 @@ const unusedValueExportToPlacateAjd$5 = 1;
4322
4323
  * @param tNode
4323
4324
  */
4324
4325
  function hasClassInput(tNode) {
4325
- return (tNode.flags & 16 /* TNodeFlags.hasClassInput */) !== 0;
4326
+ return (tNode.flags & 8 /* TNodeFlags.hasClassInput */) !== 0;
4326
4327
  }
4327
4328
  /**
4328
4329
  * Returns `true` if the `TNode` has a directive which has `@Input()` for `style` binding.
@@ -4346,7 +4347,7 @@ function hasClassInput(tNode) {
4346
4347
  * @param tNode
4347
4348
  */
4348
4349
  function hasStyleInput(tNode) {
4349
- return (tNode.flags & 32 /* TNodeFlags.hasStyleInput */) !== 0;
4350
+ return (tNode.flags & 16 /* TNodeFlags.hasStyleInput */) !== 0;
4350
4351
  }
4351
4352
 
4352
4353
  /**
@@ -7636,7 +7637,7 @@ class Version {
7636
7637
  /**
7637
7638
  * @publicApi
7638
7639
  */
7639
- const VERSION = new Version('15.0.0-next.2');
7640
+ const VERSION = new Version('15.0.0-next.3');
7640
7641
 
7641
7642
  /**
7642
7643
  * @license
@@ -8455,18 +8456,21 @@ function findViaDirective(lView, directiveInstance) {
8455
8456
  */
8456
8457
  function getDirectivesAtNodeIndex(nodeIndex, lView, includeComponents) {
8457
8458
  const tNode = lView[TVIEW].data[nodeIndex];
8458
- let directiveStartIndex = tNode.directiveStart;
8459
- if (directiveStartIndex == 0)
8459
+ if (tNode.directiveStart === 0)
8460
8460
  return EMPTY_ARRAY;
8461
- const directiveEndIndex = tNode.directiveEnd;
8462
- if (!includeComponents && tNode.flags & 2 /* TNodeFlags.isComponentHost */)
8463
- directiveStartIndex++;
8464
- return lView.slice(directiveStartIndex, directiveEndIndex);
8461
+ const results = [];
8462
+ for (let i = tNode.directiveStart; i < tNode.directiveEnd; i++) {
8463
+ const directiveInstance = lView[i];
8464
+ if (!isComponentInstance(directiveInstance) || includeComponents) {
8465
+ results.push(directiveInstance);
8466
+ }
8467
+ }
8468
+ return results;
8465
8469
  }
8466
8470
  function getComponentAtNodeIndex(nodeIndex, lView) {
8467
8471
  const tNode = lView[TVIEW].data[nodeIndex];
8468
- let directiveStartIndex = tNode.directiveStart;
8469
- return tNode.flags & 2 /* TNodeFlags.isComponentHost */ ? lView[directiveStartIndex] : null;
8472
+ const { directiveStart, componentOffset } = tNode;
8473
+ return componentOffset > -1 ? lView[directiveStart + componentOffset] : null;
8470
8474
  }
8471
8475
  /**
8472
8476
  * Returns a map of local references (local reference name => element or directive instance) that
@@ -9214,9 +9218,10 @@ function getClosestRElement(tView, tNode, lView) {
9214
9218
  }
9215
9219
  else {
9216
9220
  ngDevMode && assertTNodeType(parentTNode, 3 /* TNodeType.AnyRNode */ | 4 /* TNodeType.Container */);
9217
- if (parentTNode.flags & 2 /* TNodeFlags.isComponentHost */) {
9221
+ const { componentOffset } = parentTNode;
9222
+ if (componentOffset > -1) {
9218
9223
  ngDevMode && assertTNodeForLView(parentTNode, lView);
9219
- const encapsulation = tView.data[parentTNode.directiveStart].encapsulation;
9224
+ const { encapsulation } = tView.data[parentTNode.directiveStart + componentOffset];
9220
9225
  // We've got a parent which is an element in the current view. We just need to verify if the
9221
9226
  // parent element is not a component. Component's content nodes are not inserted immediately
9222
9227
  // because they will be projected, and so doing insert at this point would be wasteful.
@@ -9449,10 +9454,10 @@ function applyNodes(renderer, action, tNode, lView, parentRElement, beforeNode,
9449
9454
  if (isProjection) {
9450
9455
  if (action === 0 /* WalkTNodeTreeAction.Create */) {
9451
9456
  rawSlotValue && attachPatchData(unwrapRNode(rawSlotValue), lView);
9452
- tNode.flags |= 4 /* TNodeFlags.isProjected */;
9457
+ tNode.flags |= 2 /* TNodeFlags.isProjected */;
9453
9458
  }
9454
9459
  }
9455
- if ((tNode.flags & 64 /* TNodeFlags.isDetached */) !== 64 /* TNodeFlags.isDetached */) {
9460
+ if ((tNode.flags & 32 /* TNodeFlags.isDetached */) !== 32 /* TNodeFlags.isDetached */) {
9456
9461
  if (tNodeType & 8 /* TNodeType.ElementContainer */) {
9457
9462
  applyNodes(renderer, action, tNode.child, lView, parentRElement, beforeNode, false);
9458
9463
  applyToElementOrContainer(action, renderer, parentRElement, rawSlotValue, beforeNode);
@@ -11506,6 +11511,7 @@ class TNode {
11506
11511
  index, //
11507
11512
  insertBeforeIndex, //
11508
11513
  injectorIndex, //
11514
+ componentOffset, //
11509
11515
  directiveStart, //
11510
11516
  directiveEnd, //
11511
11517
  directiveStylingLast, //
@@ -11538,6 +11544,7 @@ class TNode {
11538
11544
  this.index = index;
11539
11545
  this.insertBeforeIndex = insertBeforeIndex;
11540
11546
  this.injectorIndex = injectorIndex;
11547
+ this.componentOffset = componentOffset;
11541
11548
  this.directiveStart = directiveStart;
11542
11549
  this.directiveEnd = directiveEnd;
11543
11550
  this.directiveStylingLast = directiveStylingLast;
@@ -11615,21 +11622,19 @@ class TNode {
11615
11622
  }
11616
11623
  get flags_() {
11617
11624
  const flags = [];
11618
- if (this.flags & 16 /* TNodeFlags.hasClassInput */)
11625
+ if (this.flags & 8 /* TNodeFlags.hasClassInput */)
11619
11626
  flags.push('TNodeFlags.hasClassInput');
11620
- if (this.flags & 8 /* TNodeFlags.hasContentQuery */)
11627
+ if (this.flags & 4 /* TNodeFlags.hasContentQuery */)
11621
11628
  flags.push('TNodeFlags.hasContentQuery');
11622
- if (this.flags & 32 /* TNodeFlags.hasStyleInput */)
11629
+ if (this.flags & 16 /* TNodeFlags.hasStyleInput */)
11623
11630
  flags.push('TNodeFlags.hasStyleInput');
11624
- if (this.flags & 128 /* TNodeFlags.hasHostBindings */)
11631
+ if (this.flags & 64 /* TNodeFlags.hasHostBindings */)
11625
11632
  flags.push('TNodeFlags.hasHostBindings');
11626
- if (this.flags & 2 /* TNodeFlags.isComponentHost */)
11627
- flags.push('TNodeFlags.isComponentHost');
11628
11633
  if (this.flags & 1 /* TNodeFlags.isDirectiveHost */)
11629
11634
  flags.push('TNodeFlags.isDirectiveHost');
11630
- if (this.flags & 64 /* TNodeFlags.isDetached */)
11635
+ if (this.flags & 32 /* TNodeFlags.isDetached */)
11631
11636
  flags.push('TNodeFlags.isDetached');
11632
- if (this.flags & 4 /* TNodeFlags.isProjected */)
11637
+ if (this.flags & 2 /* TNodeFlags.isProjected */)
11633
11638
  flags.push('TNodeFlags.isProjected');
11634
11639
  return flags.join('|');
11635
11640
  }
@@ -12139,7 +12144,7 @@ function getOrCreateTNode(tView, index, type, name, attrs) {
12139
12144
  // See `TNodeType.Placeholder` and `LFrame.inI18n` for more context.
12140
12145
  // If the `TNode` was not pre-declared than it means it was not mentioned which means it was
12141
12146
  // removed, so we mark it as detached.
12142
- tNode.flags |= 64 /* TNodeFlags.isDetached */;
12147
+ tNode.flags |= 32 /* TNodeFlags.isDetached */;
12143
12148
  }
12144
12149
  }
12145
12150
  else if (tNode.type & 64 /* TNodeType.Placeholder */) {
@@ -12443,7 +12448,7 @@ function createDirectivesInstances(tView, lView, tNode) {
12443
12448
  if (!getBindingsEnabled())
12444
12449
  return;
12445
12450
  instantiateAllDirectives(tView, lView, tNode, getNativeByTNode(tNode, lView));
12446
- if ((tNode.flags & 128 /* TNodeFlags.hasHostBindings */) === 128 /* TNodeFlags.hasHostBindings */) {
12451
+ if ((tNode.flags & 64 /* TNodeFlags.hasHostBindings */) === 64 /* TNodeFlags.hasHostBindings */) {
12447
12452
  invokeDirectivesHostBindings(tView, lView, tNode);
12448
12453
  }
12449
12454
  }
@@ -12643,6 +12648,7 @@ function createTNode(tView, tParent, type, index, value, attrs) {
12643
12648
  index, // index: number
12644
12649
  null, // insertBeforeIndex: null|-1|number|number[]
12645
12650
  injectorIndex, // injectorIndex: number
12651
+ -1, // componentOffset: number
12646
12652
  -1, // directiveStart: number
12647
12653
  -1, // directiveEnd: number
12648
12654
  -1, // directiveStylingLast: number
@@ -12678,6 +12684,7 @@ function createTNode(tView, tParent, type, index, value, attrs) {
12678
12684
  directiveStart: -1,
12679
12685
  directiveEnd: -1,
12680
12686
  directiveStylingLast: -1,
12687
+ componentOffset: -1,
12681
12688
  propertyBindings: null,
12682
12689
  flags: 0,
12683
12690
  providerIndexes: 0,
@@ -12741,24 +12748,23 @@ function initializeInputAndOutputAliases(tView, tNode) {
12741
12748
  let outputsStore = null;
12742
12749
  for (let i = start; i < end; i++) {
12743
12750
  const directiveDef = tViewData[i];
12744
- const directiveInputs = directiveDef.inputs;
12751
+ inputsStore = generatePropertyAliases(directiveDef.inputs, i, inputsStore);
12752
+ outputsStore = generatePropertyAliases(directiveDef.outputs, i, outputsStore);
12745
12753
  // Do not use unbound attributes as inputs to structural directives, since structural
12746
12754
  // directive inputs can only be set using microsyntax (e.g. `<div *dir="exp">`).
12747
12755
  // TODO(FW-1930): microsyntax expressions may also contain unbound/static attributes, which
12748
12756
  // should be set for inline templates.
12749
- const initialInputs = (tNodeAttrs !== null && !isInlineTemplate(tNode)) ?
12750
- generateInitialInputs(directiveInputs, tNodeAttrs) :
12757
+ const initialInputs = (inputsStore !== null && tNodeAttrs !== null && !isInlineTemplate(tNode)) ?
12758
+ generateInitialInputs(inputsStore, i, tNodeAttrs) :
12751
12759
  null;
12752
12760
  inputsFromAttrs.push(initialInputs);
12753
- inputsStore = generatePropertyAliases(directiveInputs, i, inputsStore);
12754
- outputsStore = generatePropertyAliases(directiveDef.outputs, i, outputsStore);
12755
12761
  }
12756
12762
  if (inputsStore !== null) {
12757
12763
  if (inputsStore.hasOwnProperty('class')) {
12758
- tNode.flags |= 16 /* TNodeFlags.hasClassInput */;
12764
+ tNode.flags |= 8 /* TNodeFlags.hasClassInput */;
12759
12765
  }
12760
12766
  if (inputsStore.hasOwnProperty('style')) {
12761
- tNode.flags |= 32 /* TNodeFlags.hasStyleInput */;
12767
+ tNode.flags |= 16 /* TNodeFlags.hasStyleInput */;
12762
12768
  }
12763
12769
  }
12764
12770
  tNode.initialInputs = inputsFromAttrs;
@@ -12879,7 +12885,7 @@ function instantiateRootComponent(tView, lView, def) {
12879
12885
  configureViewWithDirective(tView, rootTNode, lView, directiveIndex, def);
12880
12886
  initializeInputAndOutputAliases(tView, rootTNode);
12881
12887
  }
12882
- const directive = getNodeInjectable(lView, tView, rootTNode.directiveStart, rootTNode);
12888
+ const directive = getNodeInjectable(lView, tView, rootTNode.directiveStart + rootTNode.componentOffset, rootTNode);
12883
12889
  attachPatchData(directive, lView);
12884
12890
  const native = getNativeByTNode(rootTNode, lView);
12885
12891
  if (native) {
@@ -12896,7 +12902,10 @@ function resolveDirectives(tView, lView, tNode, localRefs) {
12896
12902
  ngDevMode && assertFirstCreatePass(tView);
12897
12903
  let hasDirectives = false;
12898
12904
  if (getBindingsEnabled()) {
12899
- const directiveDefs = findDirectiveDefMatches(tView, lView, tNode);
12905
+ const directiveDefsMatchedBySelectors = findDirectiveDefMatches(tView, lView, tNode);
12906
+ const directiveDefs = directiveDefsMatchedBySelectors ?
12907
+ findHostDirectiveDefs$1(directiveDefsMatchedBySelectors, tView, lView, tNode) :
12908
+ null;
12900
12909
  const exportsMap = localRefs === null ? null : { '': -1 };
12901
12910
  if (directiveDefs !== null) {
12902
12911
  hasDirectives = true;
@@ -12925,9 +12934,9 @@ function resolveDirectives(tView, lView, tNode, localRefs) {
12925
12934
  configureViewWithDirective(tView, tNode, lView, directiveIdx, def);
12926
12935
  saveNameToExportMap(directiveIdx, def, exportsMap);
12927
12936
  if (def.contentQueries !== null)
12928
- tNode.flags |= 8 /* TNodeFlags.hasContentQuery */;
12937
+ tNode.flags |= 4 /* TNodeFlags.hasContentQuery */;
12929
12938
  if (def.hostBindings !== null || def.hostAttrs !== null || def.hostVars !== 0)
12930
- tNode.flags |= 128 /* TNodeFlags.hasHostBindings */;
12939
+ tNode.flags |= 64 /* TNodeFlags.hasHostBindings */;
12931
12940
  const lifeCycleHooks = def.type.prototype;
12932
12941
  // Only push a node index into the preOrderHooks array if this is the first
12933
12942
  // pre-order hook found on this node.
@@ -13080,20 +13089,19 @@ function findDirectiveDefMatches(tView, viewData, tNode) {
13080
13089
  if (ngDevMode) {
13081
13090
  assertTNodeType(tNode, 2 /* TNodeType.Element */, `"${tNode.value}" tags cannot be used as component hosts. ` +
13082
13091
  `Please use a different tag to activate the ${stringify(def.type)} component.`);
13083
- if (tNode.flags & 2 /* TNodeFlags.isComponentHost */) {
13092
+ if (isComponentHost(tNode)) {
13084
13093
  // If another component has been matched previously, it's the first element in the
13085
13094
  // `matches` array, see how we store components/directives in `matches` below.
13086
13095
  throwMultipleComponentError(tNode, matches[0].type, def.type);
13087
13096
  }
13088
13097
  }
13089
- markAsComponentHost(tView, tNode);
13098
+ markAsComponentHost(tView, tNode, 0);
13090
13099
  // The component is always stored first with directives after.
13091
13100
  matches.unshift(def);
13092
13101
  }
13093
13102
  else {
13094
13103
  matches.push(def);
13095
13104
  }
13096
- def.applyHostDirectives?.(tView, viewData, tNode, matches);
13097
13105
  }
13098
13106
  }
13099
13107
  }
@@ -13101,15 +13109,36 @@ function findDirectiveDefMatches(tView, viewData, tNode) {
13101
13109
  }
13102
13110
  /**
13103
13111
  * Marks a given TNode as a component's host. This consists of:
13104
- * - setting appropriate TNode flags;
13112
+ * - setting the component offset on the TNode.
13105
13113
  * - storing index of component's host element so it will be queued for view refresh during CD.
13106
13114
  */
13107
- function markAsComponentHost(tView, hostTNode) {
13115
+ function markAsComponentHost(tView, hostTNode, componentOffset) {
13108
13116
  ngDevMode && assertFirstCreatePass(tView);
13109
- hostTNode.flags |= 2 /* TNodeFlags.isComponentHost */;
13117
+ ngDevMode && assertGreaterThan(componentOffset, -1, 'componentOffset must be great than -1');
13118
+ hostTNode.componentOffset = componentOffset;
13110
13119
  (tView.components || (tView.components = ngDevMode ? new TViewComponents() : []))
13111
13120
  .push(hostTNode.index);
13112
13121
  }
13122
+ /**
13123
+ * Given an array of directives that were matched by their selectors, this function
13124
+ * produces a new array that also includes any host directives that have to be applied.
13125
+ * @param selectorMatches Directives matched in a template based on their selectors.
13126
+ * @param tView Current TView.
13127
+ * @param lView Current LView.
13128
+ * @param tNode Current TNode that is being matched.
13129
+ */
13130
+ function findHostDirectiveDefs$1(selectorMatches, tView, lView, tNode) {
13131
+ const matches = [];
13132
+ for (const def of selectorMatches) {
13133
+ if (def.findHostDirectiveDefs === null) {
13134
+ matches.push(def);
13135
+ }
13136
+ else {
13137
+ def.findHostDirectiveDefs(matches, def, tView, lView, tNode);
13138
+ }
13139
+ }
13140
+ return matches;
13141
+ }
13113
13142
  /** Caches local names and their matching directive indices for query and template lookups. */
13114
13143
  function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
13115
13144
  if (localRefs) {
@@ -13252,10 +13281,11 @@ function setInputsFromAttrs(lView, directiveIndex, instance, def, tNode, initial
13252
13281
  *
13253
13282
  * <my-component name="Bess"></my-component>
13254
13283
  *
13255
- * @param inputs The list of inputs from the directive def
13256
- * @param attrs The static attrs on this node
13284
+ * @param inputs Input alias map that was generated from the directive def inputs.
13285
+ * @param directiveIndex Index of the directive that is currently being processed.
13286
+ * @param attrs Static attrs on this node.
13257
13287
  */
13258
- function generateInitialInputs(inputs, attrs) {
13288
+ function generateInitialInputs(inputs, directiveIndex, attrs) {
13259
13289
  let inputsToStore = null;
13260
13290
  let i = 0;
13261
13291
  while (i < attrs.length) {
@@ -13276,7 +13306,17 @@ function generateInitialInputs(inputs, attrs) {
13276
13306
  if (inputs.hasOwnProperty(attrName)) {
13277
13307
  if (inputsToStore === null)
13278
13308
  inputsToStore = [];
13279
- inputsToStore.push(attrName, inputs[attrName], attrs[i + 1]);
13309
+ // Find the input's public name from the input store. Note that we can be found easier
13310
+ // through the directive def, but we want to do it using the inputs store so that it can
13311
+ // account for host directive aliases.
13312
+ const inputConfig = inputs[attrName];
13313
+ for (let j = 0; j < inputConfig.length; j += 2) {
13314
+ if (inputConfig[j] === directiveIndex) {
13315
+ inputsToStore.push(attrName, inputConfig[j + 1], attrs[i + 1]);
13316
+ // A directive can't have multiple inputs with the same name so we can break here.
13317
+ break;
13318
+ }
13319
+ }
13280
13320
  }
13281
13321
  i += 2;
13282
13322
  }
@@ -14309,7 +14349,7 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14309
14349
  const componentView = createLView(rootView, getOrCreateComponentTView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14310
14350
  if (tView.firstCreatePass) {
14311
14351
  diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
14312
- markAsComponentHost(tView, tNode);
14352
+ markAsComponentHost(tView, tNode, 0);
14313
14353
  initTNodeFlags(tNode, rootView.length, 1);
14314
14354
  }
14315
14355
  addToViewTree(rootView, componentView);
@@ -14606,6 +14646,13 @@ function ɵɵCopyDefinitionFeature(definition) {
14606
14646
  }
14607
14647
  }
14608
14648
 
14649
+ /**
14650
+ * @license
14651
+ * Copyright Google LLC All Rights Reserved.
14652
+ *
14653
+ * Use of this source code is governed by an MIT-style license that can be
14654
+ * found in the LICENSE file at https://angular.io/license
14655
+ */
14609
14656
  /**
14610
14657
  * This feature add the host directives behavior to a directive definition by patching a
14611
14658
  * function onto it. The expectation is that the runtime will invoke the function during
@@ -14627,29 +14674,43 @@ function ɵɵCopyDefinitionFeature(definition) {
14627
14674
  * @codeGenApi
14628
14675
  */
14629
14676
  function ɵɵHostDirectivesFeature(rawHostDirectives) {
14630
- const unwrappedHostDirectives = Array.isArray(rawHostDirectives) ? rawHostDirectives : rawHostDirectives();
14631
- const hostDirectives = unwrappedHostDirectives.map(dir => typeof dir === 'function' ? { directive: dir, inputs: EMPTY_OBJ, outputs: EMPTY_OBJ } : {
14632
- directive: dir.directive,
14633
- inputs: bindingArrayToMap(dir.inputs),
14634
- outputs: bindingArrayToMap(dir.outputs)
14635
- });
14636
14677
  return (definition) => {
14637
- // TODO(crisbeto): implement host directive matching logic.
14638
- definition.applyHostDirectives =
14639
- (tView, viewData, tNode, matches) => { };
14678
+ definition.findHostDirectiveDefs = findHostDirectiveDefs;
14679
+ definition.hostDirectives =
14680
+ (Array.isArray(rawHostDirectives) ? rawHostDirectives : rawHostDirectives()).map(dir => {
14681
+ return typeof dir === 'function' ?
14682
+ { directive: resolveForwardRef(dir), inputs: EMPTY_OBJ, outputs: EMPTY_OBJ } :
14683
+ {
14684
+ directive: resolveForwardRef(dir.directive),
14685
+ inputs: bindingArrayToMap(dir.inputs),
14686
+ outputs: bindingArrayToMap(dir.outputs)
14687
+ };
14688
+ });
14640
14689
  };
14641
14690
  }
14691
+ function findHostDirectiveDefs(matches, def, tView, lView, tNode) {
14692
+ if (def.hostDirectives !== null) {
14693
+ for (const hostDirectiveConfig of def.hostDirectives) {
14694
+ const hostDirectiveDef = getDirectiveDef(hostDirectiveConfig.directive);
14695
+ // TODO(crisbeto): assert that the def exists.
14696
+ // Host directives execute before the host so that its host bindings can be overwritten.
14697
+ findHostDirectiveDefs(matches, hostDirectiveDef, tView, lView, tNode);
14698
+ }
14699
+ }
14700
+ // Push the def itself at the end since it needs to execute after the host directives.
14701
+ matches.push(def);
14702
+ }
14642
14703
  /**
14643
14704
  * Converts an array in the form of `['publicName', 'alias', 'otherPublicName', 'otherAlias']` into
14644
14705
  * a map in the form of `{publicName: 'alias', otherPublicName: 'otherAlias'}`.
14645
14706
  */
14646
14707
  function bindingArrayToMap(bindings) {
14647
- if (!bindings || bindings.length === 0) {
14708
+ if (bindings === undefined || bindings.length === 0) {
14648
14709
  return EMPTY_OBJ;
14649
14710
  }
14650
14711
  const result = {};
14651
- for (let i = 1; i < bindings.length; i += 2) {
14652
- result[bindings[i - 1]] = bindings[i];
14712
+ for (let i = 0; i < bindings.length; i += 2) {
14713
+ result[bindings[i]] = bindings[i + 1];
14653
14714
  }
14654
14715
  return result;
14655
14716
  }
@@ -15608,7 +15669,7 @@ function ɵɵelementStart(index, name, attrsIndex, localRefsIndex) {
15608
15669
  if (styles !== null) {
15609
15670
  writeDirectStyle(renderer, native, styles);
15610
15671
  }
15611
- if ((tNode.flags & 64 /* TNodeFlags.isDetached */) !== 64 /* TNodeFlags.isDetached */) {
15672
+ if ((tNode.flags & 32 /* TNodeFlags.isDetached */) !== 32 /* TNodeFlags.isDetached */) {
15612
15673
  // In the i18n case, the translation may have removed this element, so only add it if it is not
15613
15674
  // detached. See `TNodeType.Placeholder` and `LFrame.inI18n` for more context.
15614
15675
  appendChild(tView, lView, native, tNode);
@@ -16046,9 +16107,7 @@ function wrapListener(tNode, lView, context, listenerFn, wrapWithPreventDefault)
16046
16107
  }
16047
16108
  // In order to be backwards compatible with View Engine, events on component host nodes
16048
16109
  // must also mark the component view itself dirty (i.e. the view that it owns).
16049
- const startView = tNode.flags & 2 /* TNodeFlags.isComponentHost */ ?
16050
- getComponentLViewByIndex(tNode.index, lView) :
16051
- lView;
16110
+ const startView = tNode.componentOffset > -1 ? getComponentLViewByIndex(tNode.index, lView) : lView;
16052
16111
  markViewDirty(startView);
16053
16112
  let result = executeListenerWithErrorHandling(lView, context, listenerFn, e);
16054
16113
  // A just-invoked listener function might have coalesced listeners so we need to check for
@@ -16205,7 +16264,7 @@ function ɵɵprojection(nodeIndex, selectorIndex = 0, attrs) {
16205
16264
  tProjectionNode.projection = selectorIndex;
16206
16265
  // `<ng-content>` has no content
16207
16266
  setCurrentTNodeAsNotParent();
16208
- if ((tProjectionNode.flags & 64 /* TNodeFlags.isDetached */) !== 64 /* TNodeFlags.isDetached */) {
16267
+ if ((tProjectionNode.flags & 32 /* TNodeFlags.isDetached */) !== 32 /* TNodeFlags.isDetached */) {
16209
16268
  // re-distribution of projectable nodes is stored on a component's view level
16210
16269
  applyProjection(tView, lView, tProjectionNode);
16211
16270
  }
@@ -18119,7 +18178,7 @@ function normalizeSuffix(value, suffix) {
18119
18178
  * @param isClassBased `true` if `class` (`false` if `style`)
18120
18179
  */
18121
18180
  function hasStylingInputShadow(tNode, isClassBased) {
18122
- return (tNode.flags & (isClassBased ? 16 /* TNodeFlags.hasClassInput */ : 32 /* TNodeFlags.hasStyleInput */)) !== 0;
18181
+ return (tNode.flags & (isClassBased ? 8 /* TNodeFlags.hasClassInput */ : 16 /* TNodeFlags.hasStyleInput */)) !== 0;
18123
18182
  }
18124
18183
 
18125
18184
  /**
@@ -19811,7 +19870,7 @@ function processI18nInsertBefore(renderer, childTNode, lView, childRNode, parent
19811
19870
  anchorRNode = i18nParent;
19812
19871
  i18nParent = parentRElement;
19813
19872
  }
19814
- if (i18nParent !== null && (childTNode.flags & 2 /* TNodeFlags.isComponentHost */) === 0) {
19873
+ if (i18nParent !== null && childTNode.componentOffset === -1) {
19815
19874
  for (let i = 1; i < tNodeInsertBeforeIndex.length; i++) {
19816
19875
  // No need to `unwrapRNode` because all of the indexes point to i18n text nodes.
19817
19876
  // see `assertDomNode` below.