@angular/core 13.3.2 → 13.3.5

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.3.2
2
+ * @license Angular v13.3.5
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
package/fesm2020/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.3.2
2
+ * @license Angular v13.3.5
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -6733,8 +6733,10 @@ function maybeUnwrapFn(value) {
6733
6733
  * found in the LICENSE file at https://angular.io/license
6734
6734
  */
6735
6735
  /** Called when there are multiple component selectors that match a given node */
6736
- function throwMultipleComponentError(tNode) {
6737
- throw new RuntimeError(-300 /* MULTIPLE_COMPONENTS_MATCH */, `Multiple components match node with tagname ${tNode.value}`);
6736
+ function throwMultipleComponentError(tNode, first, second) {
6737
+ throw new RuntimeError(-300 /* MULTIPLE_COMPONENTS_MATCH */, `Multiple components match node with tagname ${tNode.value}: ` +
6738
+ `${stringifyForError(first)} and ` +
6739
+ `${stringifyForError(second)}`);
6738
6740
  }
6739
6741
  /** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */
6740
6742
  function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName) {
@@ -10046,9 +10048,9 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
10046
10048
  propName = mapPropName(propName);
10047
10049
  if (ngDevMode) {
10048
10050
  validateAgainstEventProperties(propName);
10049
- if (!validateProperty(tView, element, propName, tNode)) {
10051
+ if (!validateProperty(element, tNode.value, propName, tView.schemas)) {
10050
10052
  // Return here since we only log warnings for unknown properties.
10051
- logUnknownPropertyError(propName, tNode);
10053
+ logUnknownPropertyError(propName, tNode.value);
10052
10054
  return;
10053
10055
  }
10054
10056
  ngDevMode.rendererSetProperty++;
@@ -10068,7 +10070,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
10068
10070
  // If the node is a container and the property didn't
10069
10071
  // match any of the inputs or schemas we should throw.
10070
10072
  if (ngDevMode && !matchingSchemas(tView.schemas, tNode.value)) {
10071
- logUnknownPropertyError(propName, tNode);
10073
+ logUnknownPropertyError(propName, tNode.value);
10072
10074
  }
10073
10075
  }
10074
10076
  }
@@ -10120,21 +10122,36 @@ function setNgReflectProperties(lView, element, type, dataValue, value) {
10120
10122
  }
10121
10123
  }
10122
10124
  }
10123
- function validateProperty(tView, element, propName, tNode) {
10125
+ /**
10126
+ * Validates that the property of the element is known at runtime and returns
10127
+ * false if it's not the case.
10128
+ * This check is relevant for JIT-compiled components (for AOT-compiled
10129
+ * ones this check happens at build time).
10130
+ *
10131
+ * The property is considered known if either:
10132
+ * - it's a known property of the element
10133
+ * - the element is allowed by one of the schemas
10134
+ * - the property is used for animations
10135
+ *
10136
+ * @param element Element to validate
10137
+ * @param tagName Name of the tag to check
10138
+ * @param propName Name of the property to check
10139
+ * @param schemas Array of schemas
10140
+ */
10141
+ function validateProperty(element, tagName, propName, schemas) {
10124
10142
  // If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
10125
10143
  // mode where this check happens at compile time. In JIT mode, `schemas` is always present and
10126
10144
  // defined as an array (as an empty array in case `schemas` field is not defined) and we should
10127
10145
  // execute the check below.
10128
- if (tView.schemas === null)
10146
+ if (schemas === null)
10129
10147
  return true;
10130
- // The property is considered valid if the element matches the schema, it exists on the element
10148
+ // The property is considered valid if the element matches the schema, it exists on the element,
10131
10149
  // or it is synthetic, and we are in a browser context (web worker nodes should be skipped).
10132
- if (matchingSchemas(tView.schemas, tNode.value) || propName in element ||
10133
- isAnimationProp(propName)) {
10150
+ if (matchingSchemas(schemas, tagName) || propName in element || isAnimationProp(propName)) {
10134
10151
  return true;
10135
10152
  }
10136
10153
  // Note: `typeof Node` returns 'function' in most browsers, but on IE it is 'object' so we
10137
- // need to account for both here, while being careful for `typeof null` also returning 'object'.
10154
+ // need to account for both here, while being careful with `typeof null` also returning 'object'.
10138
10155
  return typeof Node === 'undefined' || Node === null || !(element instanceof Node);
10139
10156
  }
10140
10157
  /**
@@ -10157,10 +10174,10 @@ function matchingSchemas(schemas, tagName) {
10157
10174
  /**
10158
10175
  * Logs an error that a property is not supported on an element.
10159
10176
  * @param propName Name of the invalid property.
10160
- * @param tNode Node on which we encountered the property.
10177
+ * @param tagName Name of the node on which we encountered the property.
10161
10178
  */
10162
- function logUnknownPropertyError(propName, tNode) {
10163
- let message = `Can't bind to '${propName}' since it isn't a known property of '${tNode.value}'.`;
10179
+ function logUnknownPropertyError(propName, tagName) {
10180
+ const message = `Can't bind to '${propName}' since it isn't a known property of '${tagName}'.`;
10164
10181
  console.error(formatRuntimeError(303 /* UNKNOWN_BINDING */, message));
10165
10182
  }
10166
10183
  /**
@@ -10378,8 +10395,11 @@ function findDirectiveDefMatches(tView, viewData, tNode) {
10378
10395
  if (ngDevMode) {
10379
10396
  assertTNodeType(tNode, 2 /* Element */, `"${tNode.value}" tags cannot be used as component hosts. ` +
10380
10397
  `Please use a different tag to activate the ${stringify(def.type)} component.`);
10381
- if (tNode.flags & 2 /* isComponentHost */)
10382
- throwMultipleComponentError(tNode);
10398
+ if (tNode.flags & 2 /* isComponentHost */) {
10399
+ // If another component has been matched previously, it's the first element in the
10400
+ // `matches` array, see how we store components/directives in `matches` below.
10401
+ throwMultipleComponentError(tNode, matches[0].type, def.type);
10402
+ }
10383
10403
  }
10384
10404
  markAsComponentHost(tView, tNode);
10385
10405
  // The component is always stored first with directives after.
@@ -12377,7 +12397,7 @@ function ɵɵInheritDefinitionFeature(definition) {
12377
12397
  else {
12378
12398
  if (superType.ɵcmp) {
12379
12399
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
12380
- 'Directives cannot inherit Components' :
12400
+ `Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}` :
12381
12401
  '';
12382
12402
  throw new RuntimeError(903 /* INVALID_INHERITANCE */, errorMessage);
12383
12403
  }
@@ -21122,7 +21142,7 @@ class Version {
21122
21142
  /**
21123
21143
  * @publicApi
21124
21144
  */
21125
- const VERSION = new Version('13.3.2');
21145
+ const VERSION = new Version('13.3.5');
21126
21146
 
21127
21147
  /**
21128
21148
  * @license
@@ -24907,7 +24927,10 @@ const PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
24907
24927
  * A token that indicates an opaque platform ID.
24908
24928
  * @publicApi
24909
24929
  */
24910
- const PLATFORM_ID = new InjectionToken('Platform ID');
24930
+ const PLATFORM_ID = new InjectionToken('Platform ID', {
24931
+ providedIn: 'platform',
24932
+ factory: () => 'unknown', // set a default platform name, when none set explicitly
24933
+ });
24911
24934
  /**
24912
24935
  * A [DI token](guide/glossary#di-token "DI token definition") that provides a set of callbacks to
24913
24936
  * be called for every component that is bootstrapped.
@@ -24945,9 +24968,10 @@ class Console {
24945
24968
  }
24946
24969
  }
24947
24970
  Console.ɵfac = function Console_Factory(t) { return new (t || Console)(); };
24948
- Console.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: Console, factory: Console.ɵfac });
24971
+ Console.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: Console, factory: Console.ɵfac, providedIn: 'platform' });
24949
24972
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(Console, [{
24950
- type: Injectable
24973
+ type: Injectable,
24974
+ args: [{ providedIn: 'platform' }]
24951
24975
  }], null, null); })();
24952
24976
 
24953
24977
  /**
@@ -25905,9 +25929,10 @@ class TestabilityRegistry {
25905
25929
  }
25906
25930
  }
25907
25931
  TestabilityRegistry.ɵfac = function TestabilityRegistry_Factory(t) { return new (t || TestabilityRegistry)(); };
25908
- TestabilityRegistry.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: TestabilityRegistry, factory: TestabilityRegistry.ɵfac });
25932
+ TestabilityRegistry.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: TestabilityRegistry, factory: TestabilityRegistry.ɵfac, providedIn: 'platform' });
25909
25933
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(TestabilityRegistry, [{
25910
- type: Injectable
25934
+ type: Injectable,
25935
+ args: [{ providedIn: 'platform' }]
25911
25936
  }], function () { return []; }, null); })();
25912
25937
  class _NoopGetTestability {
25913
25938
  addToWindow(registry) { }
@@ -25931,7 +25956,19 @@ let _testabilityGetter = new _NoopGetTestability();
25931
25956
  * Use of this source code is governed by an MIT-style license that can be
25932
25957
  * found in the LICENSE file at https://angular.io/license
25933
25958
  */
25934
- let _platform;
25959
+ let _platformInjector = null;
25960
+ /**
25961
+ * Internal token to indicate whether having multiple bootstrapped platform should be allowed (only
25962
+ * one bootstrapped platform is allowed by default). This token helps to support SSR scenarios.
25963
+ */
25964
+ const ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
25965
+ /**
25966
+ * Internal token that allows to register extra callbacks that should be invoked during the
25967
+ * `PlatformRef.destroy` operation. This token is needed to avoid a direct reference to the
25968
+ * `PlatformRef` class (i.e. register the callback via `PlatformRef.onDestroy`), thus making the
25969
+ * entire class tree-shakeable.
25970
+ */
25971
+ const PLATFORM_ON_DESTROY = new InjectionToken('PlatformOnDestroy');
25935
25972
  function compileNgModuleFactory(injector, options, moduleType) {
25936
25973
  ngDevMode && assertNgModuleType(moduleType);
25937
25974
  const moduleFactory = new NgModuleFactory(moduleType);
@@ -25976,7 +26013,6 @@ function publishDefaultGlobalUtils() {
25976
26013
  function isBoundToModule(cf) {
25977
26014
  return cf.isBoundToModule;
25978
26015
  }
25979
- const ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
25980
26016
  /**
25981
26017
  * A token for third-party components that can register themselves with NgProbe.
25982
26018
  *
@@ -25995,19 +26031,19 @@ class NgProbeToken {
25995
26031
  * @publicApi
25996
26032
  */
25997
26033
  function createPlatform(injector) {
25998
- if (_platform && !_platform.destroyed &&
25999
- !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
26034
+ if (_platformInjector && !_platformInjector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
26000
26035
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
26001
26036
  'There can be only one platform. Destroy the previous one to create a new one.' :
26002
26037
  '';
26003
26038
  throw new RuntimeError(400 /* MULTIPLE_PLATFORMS */, errorMessage);
26004
26039
  }
26005
26040
  publishDefaultGlobalUtils();
26006
- _platform = injector.get(PlatformRef);
26041
+ _platformInjector = injector;
26042
+ const platform = injector.get(PlatformRef);
26007
26043
  const inits = injector.get(PLATFORM_INITIALIZER, null);
26008
26044
  if (inits)
26009
- inits.forEach((init) => init());
26010
- return _platform;
26045
+ inits.forEach(initFn => initFn());
26046
+ return platform;
26011
26047
  }
26012
26048
  /**
26013
26049
  * Creates a factory for a platform. Can be used to provide or override `Providers` specific to
@@ -26026,15 +26062,16 @@ function createPlatformFactory(parentPlatformFactory, name, providers = []) {
26026
26062
  return (extraProviders = []) => {
26027
26063
  let platform = getPlatform();
26028
26064
  if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
26065
+ const platformProviders = [
26066
+ ...providers,
26067
+ ...extraProviders,
26068
+ { provide: marker, useValue: true }
26069
+ ];
26029
26070
  if (parentPlatformFactory) {
26030
- parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
26071
+ parentPlatformFactory(platformProviders);
26031
26072
  }
26032
26073
  else {
26033
- const injectedProviders = providers.concat(extraProviders).concat({ provide: marker, useValue: true }, {
26034
- provide: INJECTOR_SCOPE,
26035
- useValue: 'platform'
26036
- });
26037
- createPlatform(Injector.create({ providers: injectedProviders, name: desc }));
26074
+ createPlatform(createPlatformInjector(platformProviders, desc));
26038
26075
  }
26039
26076
  }
26040
26077
  return assertPlatform(marker);
@@ -26057,6 +26094,20 @@ function assertPlatform(requiredToken) {
26057
26094
  }
26058
26095
  return platform;
26059
26096
  }
26097
+ /**
26098
+ * Helper function to create an instance of a platform injector (that maintains the 'platform'
26099
+ * scope).
26100
+ */
26101
+ function createPlatformInjector(providers = [], name) {
26102
+ return Injector.create({
26103
+ name,
26104
+ providers: [
26105
+ { provide: INJECTOR_SCOPE, useValue: 'platform' },
26106
+ { provide: PLATFORM_ON_DESTROY, useValue: () => _platformInjector = null },
26107
+ ...providers
26108
+ ],
26109
+ });
26110
+ }
26060
26111
  /**
26061
26112
  * Destroys the current Angular platform and all Angular applications on the page.
26062
26113
  * Destroys all modules and listeners registered with the platform.
@@ -26064,9 +26115,7 @@ function assertPlatform(requiredToken) {
26064
26115
  * @publicApi
26065
26116
  */
26066
26117
  function destroyPlatform() {
26067
- if (_platform && !_platform.destroyed) {
26068
- _platform.destroy();
26069
- }
26118
+ getPlatform()?.destroy();
26070
26119
  }
26071
26120
  /**
26072
26121
  * Returns the current platform.
@@ -26074,7 +26123,7 @@ function destroyPlatform() {
26074
26123
  * @publicApi
26075
26124
  */
26076
26125
  function getPlatform() {
26077
- return _platform && !_platform.destroyed ? _platform : null;
26126
+ return _platformInjector?.get(PlatformRef) ?? null;
26078
26127
  }
26079
26128
  /**
26080
26129
  * The Angular platform is the entry point for Angular on a web page.
@@ -26212,6 +26261,8 @@ class PlatformRef {
26212
26261
  }
26213
26262
  this._modules.slice().forEach(module => module.destroy());
26214
26263
  this._destroyListeners.forEach(listener => listener());
26264
+ const destroyListener = this._injector.get(PLATFORM_ON_DESTROY, null);
26265
+ destroyListener?.();
26215
26266
  this._destroyed = true;
26216
26267
  }
26217
26268
  get destroyed() {
@@ -26219,9 +26270,10 @@ class PlatformRef {
26219
26270
  }
26220
26271
  }
26221
26272
  PlatformRef.ɵfac = function PlatformRef_Factory(t) { return new (t || PlatformRef)(ɵɵinject(Injector)); };
26222
- PlatformRef.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: PlatformRef, factory: PlatformRef.ɵfac });
26273
+ PlatformRef.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: PlatformRef, factory: PlatformRef.ɵfac, providedIn: 'platform' });
26223
26274
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(PlatformRef, [{
26224
- type: Injectable
26275
+ type: Injectable,
26276
+ args: [{ providedIn: 'platform' }]
26225
26277
  }], function () { return [{ type: Injector }]; }, null); })();
26226
26278
  function getNgZone(ngZoneOption, extra) {
26227
26279
  let ngZone;
@@ -26359,11 +26411,10 @@ function optionsReducer(dst, objs) {
26359
26411
  */
26360
26412
  class ApplicationRef {
26361
26413
  /** @internal */
26362
- constructor(_zone, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
26414
+ constructor(_zone, _injector, _exceptionHandler, _initStatus) {
26363
26415
  this._zone = _zone;
26364
26416
  this._injector = _injector;
26365
26417
  this._exceptionHandler = _exceptionHandler;
26366
- this._componentFactoryResolver = _componentFactoryResolver;
26367
26418
  this._initStatus = _initStatus;
26368
26419
  /** @internal */
26369
26420
  this._bootstrapListeners = [];
@@ -26479,8 +26530,8 @@ class ApplicationRef {
26479
26530
  componentFactory = componentOrFactory;
26480
26531
  }
26481
26532
  else {
26482
- componentFactory =
26483
- this._componentFactoryResolver.resolveComponentFactory(componentOrFactory);
26533
+ const resolver = this._injector.get(ComponentFactoryResolver$1);
26534
+ componentFactory = resolver.resolveComponentFactory(componentOrFactory);
26484
26535
  }
26485
26536
  this.componentTypes.push(componentFactory.componentType);
26486
26537
  // Create a factory associated with the current module if it's not bound to some other
@@ -26581,12 +26632,12 @@ class ApplicationRef {
26581
26632
  return this._views.length;
26582
26633
  }
26583
26634
  }
26584
- ApplicationRef.ɵfac = function ApplicationRef_Factory(t) { return new (t || ApplicationRef)(ɵɵinject(NgZone), ɵɵinject(Injector), ɵɵinject(ErrorHandler), ɵɵinject(ComponentFactoryResolver$1), ɵɵinject(ApplicationInitStatus)); };
26635
+ ApplicationRef.ɵfac = function ApplicationRef_Factory(t) { return new (t || ApplicationRef)(ɵɵinject(NgZone), ɵɵinject(Injector), ɵɵinject(ErrorHandler), ɵɵinject(ApplicationInitStatus)); };
26585
26636
  ApplicationRef.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: ApplicationRef, factory: ApplicationRef.ɵfac, providedIn: 'root' });
26586
26637
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(ApplicationRef, [{
26587
26638
  type: Injectable,
26588
26639
  args: [{ providedIn: 'root' }]
26589
- }], function () { return [{ type: NgZone }, { type: Injector }, { type: ErrorHandler }, { type: ComponentFactoryResolver$1 }, { type: ApplicationInitStatus }]; }, null); })();
26640
+ }], function () { return [{ type: NgZone }, { type: Injector }, { type: ErrorHandler }, { type: ApplicationInitStatus }]; }, null); })();
26590
26641
  function remove(list, el) {
26591
26642
  const index = list.indexOf(el);
26592
26643
  if (index > -1) {
@@ -28568,19 +28619,12 @@ const defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
28568
28619
  * Use of this source code is governed by an MIT-style license that can be
28569
28620
  * found in the LICENSE file at https://angular.io/license
28570
28621
  */
28571
- const _CORE_PLATFORM_PROVIDERS = [
28572
- // Set a default platform name for platforms that don't set it explicitly.
28573
- { provide: PLATFORM_ID, useValue: 'unknown' },
28574
- { provide: PlatformRef, deps: [Injector] },
28575
- { provide: TestabilityRegistry, deps: [] },
28576
- { provide: Console, deps: [] },
28577
- ];
28578
28622
  /**
28579
28623
  * This platform has to be included in any other platform
28580
28624
  *
28581
28625
  * @publicApi
28582
28626
  */
28583
- const platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
28627
+ const platformCore = createPlatformFactory(null, 'core', []);
28584
28628
 
28585
28629
  /**
28586
28630
  * @license