@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/fesm2015/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,12 @@ 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 = {};
956
- const def = {
957
- type: type,
958
- providersResolver: null,
959
- decls: componentDefinition.decls,
960
- vars: componentDefinition.vars,
961
- factory: null,
962
- template: componentDefinition.template || null,
963
- consts: componentDefinition.consts || null,
964
- 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
- onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
974
- directiveDefs: null,
975
- pipeDefs: null,
976
- standalone,
977
- dependencies: standalone && componentDefinition.dependencies || null,
978
- getStandaloneInjector: null,
979
- selectors: componentDefinition.selectors || EMPTY_ARRAY,
980
- viewQuery: componentDefinition.viewQuery || null,
981
- features: componentDefinition.features || null,
982
- data: componentDefinition.data || {},
983
- encapsulation: componentDefinition.encapsulation || ViewEncapsulation$1.Emulated,
984
- id: `c${componentDefCount++}`,
985
- styles: componentDefinition.styles || EMPTY_ARRAY,
986
- _: null,
987
- setInput: null,
988
- schemas: componentDefinition.schemas || null,
989
- tView: null,
990
- findHostDirectiveDefs: null,
991
- hostDirectives: null,
992
- };
953
+ const baseDef = getNgDirectiveDef(componentDefinition);
954
+ const def = Object.assign(Object.assign({}, baseDef), { decls: componentDefinition.decls, vars: componentDefinition.vars, template: componentDefinition.template, consts: componentDefinition.consts || null, ngContentSelectors: componentDefinition.ngContentSelectors, onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush, directiveDefs: null, pipeDefs: null, dependencies: baseDef.standalone && componentDefinition.dependencies || null, getStandaloneInjector: null, data: componentDefinition.data || {}, encapsulation: componentDefinition.encapsulation || ViewEncapsulation$1.Emulated, id: `c${componentDefCount++}`, styles: componentDefinition.styles || EMPTY_ARRAY, _: null, schemas: componentDefinition.schemas || null, tView: null });
955
+ initFeatures(def);
993
956
  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;
957
+ def.directiveDefs = extractDefListOrFactory(dependencies, /* pipeDef */ false);
958
+ def.pipeDefs = extractDefListOrFactory(dependencies, /* pipeDef */ true);
1008
959
  return def;
1009
960
  });
1010
961
  }
@@ -1019,8 +970,8 @@ function ɵɵdefineComponent(componentDefinition) {
1019
970
  */
1020
971
  function ɵɵsetComponentScope(type, directives, pipes) {
1021
972
  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);
973
+ def.directiveDefs = extractDefListOrFactory(directives, /* pipeDef */ false);
974
+ def.pipeDefs = extractDefListOrFactory(pipes, /* pipeDef */ true);
1024
975
  }
1025
976
  function extractDirectiveDef(type) {
1026
977
  return getComponentDef(type) || getDirectiveDef(type);
@@ -1155,7 +1106,13 @@ function invertObject(obj, secondary) {
1155
1106
  *
1156
1107
  * @codeGenApi
1157
1108
  */
1158
- const ɵɵdefineDirective = ɵɵdefineComponent;
1109
+ function ɵɵdefineDirective(directiveDefinition) {
1110
+ return noSideEffects(() => {
1111
+ const def = getNgDirectiveDef(directiveDefinition);
1112
+ initFeatures(def);
1113
+ return def;
1114
+ });
1115
+ }
1159
1116
  /**
1160
1117
  * Create a pipe definition object.
1161
1118
  *
@@ -1215,6 +1172,42 @@ function getNgModuleDef(type, throwNotFound) {
1215
1172
  }
1216
1173
  return ngModuleDef;
1217
1174
  }
1175
+ function getNgDirectiveDef(directiveDefinition) {
1176
+ const declaredInputs = {};
1177
+ return {
1178
+ type: directiveDefinition.type,
1179
+ providersResolver: null,
1180
+ factory: null,
1181
+ hostBindings: directiveDefinition.hostBindings || null,
1182
+ hostVars: directiveDefinition.hostVars || 0,
1183
+ hostAttrs: directiveDefinition.hostAttrs || null,
1184
+ contentQueries: directiveDefinition.contentQueries || null,
1185
+ declaredInputs,
1186
+ exportAs: directiveDefinition.exportAs || null,
1187
+ standalone: directiveDefinition.standalone === true,
1188
+ selectors: directiveDefinition.selectors || EMPTY_ARRAY,
1189
+ viewQuery: directiveDefinition.viewQuery || null,
1190
+ features: directiveDefinition.features || null,
1191
+ setInput: null,
1192
+ findHostDirectiveDefs: null,
1193
+ hostDirectives: null,
1194
+ inputs: invertObject(directiveDefinition.inputs, declaredInputs),
1195
+ outputs: invertObject(directiveDefinition.outputs),
1196
+ };
1197
+ }
1198
+ function initFeatures(definition) {
1199
+ var _a;
1200
+ (_a = definition.features) === null || _a === void 0 ? void 0 : _a.forEach((fn) => fn(definition));
1201
+ }
1202
+ function extractDefListOrFactory(dependencies, pipeDef) {
1203
+ if (!dependencies) {
1204
+ return null;
1205
+ }
1206
+ const defExtractor = pipeDef ? getPipeDef$1 : extractDirectiveDef;
1207
+ return () => (typeof dependencies === 'function' ? dependencies() : dependencies)
1208
+ .map(dep => defExtractor(dep))
1209
+ .filter(nonNull);
1210
+ }
1218
1211
 
1219
1212
  /**
1220
1213
  * Special location which allows easy identification of type. If we have an array which was
@@ -1316,7 +1309,7 @@ function isDirectiveHost(tNode) {
1316
1309
  return (tNode.flags & 1 /* TNodeFlags.isDirectiveHost */) === 1 /* TNodeFlags.isDirectiveHost */;
1317
1310
  }
1318
1311
  function isComponentDef(def) {
1319
- return def.template !== null;
1312
+ return !!def.template;
1320
1313
  }
1321
1314
  function isRootView(target) {
1322
1315
  return (target[FLAGS] & 256 /* LViewFlags.IsRoot */) !== 0;
@@ -8329,7 +8322,7 @@ class Version {
8329
8322
  /**
8330
8323
  * @publicApi
8331
8324
  */
8332
- const VERSION = new Version('15.2.2');
8325
+ const VERSION = new Version('15.2.4');
8333
8326
 
8334
8327
  // This default value is when checking the hierarchy for a token.
8335
8328
  //
@@ -8611,12 +8604,19 @@ function isCssClassMatching(attrs, cssClassToMatch, isProjectionMode) {
8611
8604
  ngDevMode &&
8612
8605
  assertEqual(cssClassToMatch, cssClassToMatch.toLowerCase(), 'Class name expected to be lowercase.');
8613
8606
  let i = 0;
8607
+ // Indicates whether we are processing value from the implicit
8608
+ // attribute section (i.e. before the first marker in the array).
8609
+ let isImplicitAttrsSection = true;
8614
8610
  while (i < attrs.length) {
8615
8611
  let item = attrs[i++];
8616
- if (isProjectionMode && item === 'class') {
8617
- item = attrs[i];
8618
- if (classIndexOf(item.toLowerCase(), cssClassToMatch, 0) !== -1) {
8619
- return true;
8612
+ if (typeof item === 'string' && isImplicitAttrsSection) {
8613
+ const value = attrs[i++];
8614
+ if (isProjectionMode && item === 'class') {
8615
+ // We found a `class` attribute in the implicit attribute section,
8616
+ // check if it matches the value of the `cssClassToMatch` argument.
8617
+ if (classIndexOf(value.toLowerCase(), cssClassToMatch, 0) !== -1) {
8618
+ return true;
8619
+ }
8620
8620
  }
8621
8621
  }
8622
8622
  else if (item === 1 /* AttributeMarker.Classes */) {
@@ -8628,6 +8628,11 @@ function isCssClassMatching(attrs, cssClassToMatch, isProjectionMode) {
8628
8628
  }
8629
8629
  return false;
8630
8630
  }
8631
+ else if (typeof item === 'number') {
8632
+ // We've came across a first marker, which indicates
8633
+ // that the implicit attribute section is over.
8634
+ isImplicitAttrsSection = false;
8635
+ }
8631
8636
  }
8632
8637
  return false;
8633
8638
  }
@@ -20256,7 +20261,8 @@ function sortListeners(a, b) {
20256
20261
  * See call site for more info.
20257
20262
  */
20258
20263
  function isDirectiveDefHack(obj) {
20259
- return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
20264
+ return obj.type !== undefined && obj.declaredInputs !== undefined &&
20265
+ obj.findHostDirectiveDefs !== undefined;
20260
20266
  }
20261
20267
  /**
20262
20268
  * Retrieve the component `LView` from component/element.