@angular/core 15.2.2 → 15.2.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.
package/fesm2020/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v15.2.2
2
+ * @license Angular v15.2.4
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -935,7 +935,7 @@ let componentDefCount = 0;
935
935
  *
936
936
  * # Example
937
937
  * ```
938
- * class MyDirective {
938
+ * class MyComponent {
939
939
  * // Generated by Angular Template Compiler
940
940
  * // [Symbol] syntax will not be supported by TypeScript until v2.7
941
941
  * static ɵcmp = defineComponent({
@@ -950,61 +950,31 @@ function ɵɵdefineComponent(componentDefinition) {
950
950
  // Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent.
951
951
  // See the `initNgDevMode` docstring for more information.
952
952
  (typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
953
- const type = componentDefinition.type;
954
- const standalone = componentDefinition.standalone === true;
955
- const declaredInputs = {};
953
+ const baseDef = getNgDirectiveDef(componentDefinition);
956
954
  const def = {
957
- type: type,
958
- providersResolver: null,
955
+ ...baseDef,
959
956
  decls: componentDefinition.decls,
960
957
  vars: componentDefinition.vars,
961
- factory: null,
962
- template: componentDefinition.template || null,
958
+ template: componentDefinition.template,
963
959
  consts: componentDefinition.consts || null,
964
960
  ngContentSelectors: componentDefinition.ngContentSelectors,
965
- hostBindings: componentDefinition.hostBindings || null,
966
- hostVars: componentDefinition.hostVars || 0,
967
- hostAttrs: componentDefinition.hostAttrs || null,
968
- contentQueries: componentDefinition.contentQueries || null,
969
- declaredInputs: declaredInputs,
970
- inputs: null,
971
- outputs: null,
972
- exportAs: componentDefinition.exportAs || null,
973
961
  onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
974
962
  directiveDefs: null,
975
963
  pipeDefs: null,
976
- standalone,
977
- dependencies: standalone && componentDefinition.dependencies || null,
964
+ dependencies: baseDef.standalone && componentDefinition.dependencies || null,
978
965
  getStandaloneInjector: null,
979
- selectors: componentDefinition.selectors || EMPTY_ARRAY,
980
- viewQuery: componentDefinition.viewQuery || null,
981
- features: componentDefinition.features || null,
982
966
  data: componentDefinition.data || {},
983
967
  encapsulation: componentDefinition.encapsulation || ViewEncapsulation$1.Emulated,
984
968
  id: `c${componentDefCount++}`,
985
969
  styles: componentDefinition.styles || EMPTY_ARRAY,
986
970
  _: null,
987
- setInput: null,
988
971
  schemas: componentDefinition.schemas || null,
989
972
  tView: null,
990
- findHostDirectiveDefs: null,
991
- hostDirectives: null,
992
973
  };
974
+ initFeatures(def);
993
975
  const dependencies = componentDefinition.dependencies;
994
- const feature = componentDefinition.features;
995
- def.inputs = invertObject(componentDefinition.inputs, declaredInputs),
996
- def.outputs = invertObject(componentDefinition.outputs),
997
- feature && feature.forEach((fn) => fn(def));
998
- def.directiveDefs = dependencies ?
999
- (() => (typeof dependencies === 'function' ? dependencies() : dependencies)
1000
- .map(extractDirectiveDef)
1001
- .filter(nonNull)) :
1002
- null;
1003
- def.pipeDefs = dependencies ?
1004
- (() => (typeof dependencies === 'function' ? dependencies() : dependencies)
1005
- .map(getPipeDef$1)
1006
- .filter(nonNull)) :
1007
- null;
976
+ def.directiveDefs = extractDefListOrFactory(dependencies, /* pipeDef */ false);
977
+ def.pipeDefs = extractDefListOrFactory(dependencies, /* pipeDef */ true);
1008
978
  return def;
1009
979
  });
1010
980
  }
@@ -1019,8 +989,8 @@ function ɵɵdefineComponent(componentDefinition) {
1019
989
  */
1020
990
  function ɵɵsetComponentScope(type, directives, pipes) {
1021
991
  const def = type.ɵcmp;
1022
- def.directiveDefs = () => (typeof directives === 'function' ? directives() : directives).map(extractDirectiveDef);
1023
- def.pipeDefs = () => (typeof pipes === 'function' ? pipes() : pipes).map(getPipeDef$1);
992
+ def.directiveDefs = extractDefListOrFactory(directives, /* pipeDef */ false);
993
+ def.pipeDefs = extractDefListOrFactory(pipes, /* pipeDef */ true);
1024
994
  }
1025
995
  function extractDirectiveDef(type) {
1026
996
  return getComponentDef(type) || getDirectiveDef(type);
@@ -1155,7 +1125,13 @@ function invertObject(obj, secondary) {
1155
1125
  *
1156
1126
  * @codeGenApi
1157
1127
  */
1158
- const ɵɵdefineDirective = ɵɵdefineComponent;
1128
+ function ɵɵdefineDirective(directiveDefinition) {
1129
+ return noSideEffects(() => {
1130
+ const def = getNgDirectiveDef(directiveDefinition);
1131
+ initFeatures(def);
1132
+ return def;
1133
+ });
1134
+ }
1159
1135
  /**
1160
1136
  * Create a pipe definition object.
1161
1137
  *
@@ -1215,6 +1191,41 @@ function getNgModuleDef(type, throwNotFound) {
1215
1191
  }
1216
1192
  return ngModuleDef;
1217
1193
  }
1194
+ function getNgDirectiveDef(directiveDefinition) {
1195
+ const declaredInputs = {};
1196
+ return {
1197
+ type: directiveDefinition.type,
1198
+ providersResolver: null,
1199
+ factory: null,
1200
+ hostBindings: directiveDefinition.hostBindings || null,
1201
+ hostVars: directiveDefinition.hostVars || 0,
1202
+ hostAttrs: directiveDefinition.hostAttrs || null,
1203
+ contentQueries: directiveDefinition.contentQueries || null,
1204
+ declaredInputs,
1205
+ exportAs: directiveDefinition.exportAs || null,
1206
+ standalone: directiveDefinition.standalone === true,
1207
+ selectors: directiveDefinition.selectors || EMPTY_ARRAY,
1208
+ viewQuery: directiveDefinition.viewQuery || null,
1209
+ features: directiveDefinition.features || null,
1210
+ setInput: null,
1211
+ findHostDirectiveDefs: null,
1212
+ hostDirectives: null,
1213
+ inputs: invertObject(directiveDefinition.inputs, declaredInputs),
1214
+ outputs: invertObject(directiveDefinition.outputs),
1215
+ };
1216
+ }
1217
+ function initFeatures(definition) {
1218
+ definition.features?.forEach((fn) => fn(definition));
1219
+ }
1220
+ function extractDefListOrFactory(dependencies, pipeDef) {
1221
+ if (!dependencies) {
1222
+ return null;
1223
+ }
1224
+ const defExtractor = pipeDef ? getPipeDef$1 : extractDirectiveDef;
1225
+ return () => (typeof dependencies === 'function' ? dependencies() : dependencies)
1226
+ .map(dep => defExtractor(dep))
1227
+ .filter(nonNull);
1228
+ }
1218
1229
 
1219
1230
  // Below are constants for LView indices to help us look up LView members
1220
1231
  // without having to remember the specific indices.
@@ -1316,7 +1327,7 @@ function isDirectiveHost(tNode) {
1316
1327
  return (tNode.flags & 1 /* TNodeFlags.isDirectiveHost */) === 1 /* TNodeFlags.isDirectiveHost */;
1317
1328
  }
1318
1329
  function isComponentDef(def) {
1319
- return def.template !== null;
1330
+ return !!def.template;
1320
1331
  }
1321
1332
  function isRootView(target) {
1322
1333
  return (target[FLAGS] & 256 /* LViewFlags.IsRoot */) !== 0;
@@ -8336,7 +8347,7 @@ class Version {
8336
8347
  /**
8337
8348
  * @publicApi
8338
8349
  */
8339
- const VERSION = new Version('15.2.2');
8350
+ const VERSION = new Version('15.2.4');
8340
8351
 
8341
8352
  // This default value is when checking the hierarchy for a token.
8342
8353
  //
@@ -8618,12 +8629,19 @@ function isCssClassMatching(attrs, cssClassToMatch, isProjectionMode) {
8618
8629
  ngDevMode &&
8619
8630
  assertEqual(cssClassToMatch, cssClassToMatch.toLowerCase(), 'Class name expected to be lowercase.');
8620
8631
  let i = 0;
8632
+ // Indicates whether we are processing value from the implicit
8633
+ // attribute section (i.e. before the first marker in the array).
8634
+ let isImplicitAttrsSection = true;
8621
8635
  while (i < attrs.length) {
8622
8636
  let item = attrs[i++];
8623
- if (isProjectionMode && item === 'class') {
8624
- item = attrs[i];
8625
- if (classIndexOf(item.toLowerCase(), cssClassToMatch, 0) !== -1) {
8626
- return true;
8637
+ if (typeof item === 'string' && isImplicitAttrsSection) {
8638
+ const value = attrs[i++];
8639
+ if (isProjectionMode && item === 'class') {
8640
+ // We found a `class` attribute in the implicit attribute section,
8641
+ // check if it matches the value of the `cssClassToMatch` argument.
8642
+ if (classIndexOf(value.toLowerCase(), cssClassToMatch, 0) !== -1) {
8643
+ return true;
8644
+ }
8627
8645
  }
8628
8646
  }
8629
8647
  else if (item === 1 /* AttributeMarker.Classes */) {
@@ -8635,6 +8653,11 @@ function isCssClassMatching(attrs, cssClassToMatch, isProjectionMode) {
8635
8653
  }
8636
8654
  return false;
8637
8655
  }
8656
+ else if (typeof item === 'number') {
8657
+ // We've came across a first marker, which indicates
8658
+ // that the implicit attribute section is over.
8659
+ isImplicitAttrsSection = false;
8660
+ }
8638
8661
  }
8639
8662
  return false;
8640
8663
  }
@@ -20261,7 +20284,8 @@ function sortListeners(a, b) {
20261
20284
  * See call site for more info.
20262
20285
  */
20263
20286
  function isDirectiveDefHack(obj) {
20264
- return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
20287
+ return obj.type !== undefined && obj.declaredInputs !== undefined &&
20288
+ obj.findHostDirectiveDefs !== undefined;
20265
20289
  }
20266
20290
  /**
20267
20291
  * Retrieve the component `LView` from component/element.