@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.
package/fesm2015/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
  */
@@ -6718,8 +6718,10 @@ function maybeUnwrapFn(value) {
6718
6718
  * found in the LICENSE file at https://angular.io/license
6719
6719
  */
6720
6720
  /** Called when there are multiple component selectors that match a given node */
6721
- function throwMultipleComponentError(tNode) {
6722
- throw new RuntimeError(-300 /* MULTIPLE_COMPONENTS_MATCH */, `Multiple components match node with tagname ${tNode.value}`);
6721
+ function throwMultipleComponentError(tNode, first, second) {
6722
+ throw new RuntimeError(-300 /* MULTIPLE_COMPONENTS_MATCH */, `Multiple components match node with tagname ${tNode.value}: ` +
6723
+ `${stringifyForError(first)} and ` +
6724
+ `${stringifyForError(second)}`);
6723
6725
  }
6724
6726
  /** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */
6725
6727
  function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName) {
@@ -10031,9 +10033,9 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
10031
10033
  propName = mapPropName(propName);
10032
10034
  if (ngDevMode) {
10033
10035
  validateAgainstEventProperties(propName);
10034
- if (!validateProperty(tView, element, propName, tNode)) {
10036
+ if (!validateProperty(element, tNode.value, propName, tView.schemas)) {
10035
10037
  // Return here since we only log warnings for unknown properties.
10036
- logUnknownPropertyError(propName, tNode);
10038
+ logUnknownPropertyError(propName, tNode.value);
10037
10039
  return;
10038
10040
  }
10039
10041
  ngDevMode.rendererSetProperty++;
@@ -10053,7 +10055,7 @@ function elementPropertyInternal(tView, tNode, lView, propName, value, renderer,
10053
10055
  // If the node is a container and the property didn't
10054
10056
  // match any of the inputs or schemas we should throw.
10055
10057
  if (ngDevMode && !matchingSchemas(tView.schemas, tNode.value)) {
10056
- logUnknownPropertyError(propName, tNode);
10058
+ logUnknownPropertyError(propName, tNode.value);
10057
10059
  }
10058
10060
  }
10059
10061
  }
@@ -10105,21 +10107,36 @@ function setNgReflectProperties(lView, element, type, dataValue, value) {
10105
10107
  }
10106
10108
  }
10107
10109
  }
10108
- function validateProperty(tView, element, propName, tNode) {
10110
+ /**
10111
+ * Validates that the property of the element is known at runtime and returns
10112
+ * false if it's not the case.
10113
+ * This check is relevant for JIT-compiled components (for AOT-compiled
10114
+ * ones this check happens at build time).
10115
+ *
10116
+ * The property is considered known if either:
10117
+ * - it's a known property of the element
10118
+ * - the element is allowed by one of the schemas
10119
+ * - the property is used for animations
10120
+ *
10121
+ * @param element Element to validate
10122
+ * @param tagName Name of the tag to check
10123
+ * @param propName Name of the property to check
10124
+ * @param schemas Array of schemas
10125
+ */
10126
+ function validateProperty(element, tagName, propName, schemas) {
10109
10127
  // If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
10110
10128
  // mode where this check happens at compile time. In JIT mode, `schemas` is always present and
10111
10129
  // defined as an array (as an empty array in case `schemas` field is not defined) and we should
10112
10130
  // execute the check below.
10113
- if (tView.schemas === null)
10131
+ if (schemas === null)
10114
10132
  return true;
10115
- // The property is considered valid if the element matches the schema, it exists on the element
10133
+ // The property is considered valid if the element matches the schema, it exists on the element,
10116
10134
  // or it is synthetic, and we are in a browser context (web worker nodes should be skipped).
10117
- if (matchingSchemas(tView.schemas, tNode.value) || propName in element ||
10118
- isAnimationProp(propName)) {
10135
+ if (matchingSchemas(schemas, tagName) || propName in element || isAnimationProp(propName)) {
10119
10136
  return true;
10120
10137
  }
10121
10138
  // Note: `typeof Node` returns 'function' in most browsers, but on IE it is 'object' so we
10122
- // need to account for both here, while being careful for `typeof null` also returning 'object'.
10139
+ // need to account for both here, while being careful with `typeof null` also returning 'object'.
10123
10140
  return typeof Node === 'undefined' || Node === null || !(element instanceof Node);
10124
10141
  }
10125
10142
  /**
@@ -10142,10 +10159,10 @@ function matchingSchemas(schemas, tagName) {
10142
10159
  /**
10143
10160
  * Logs an error that a property is not supported on an element.
10144
10161
  * @param propName Name of the invalid property.
10145
- * @param tNode Node on which we encountered the property.
10162
+ * @param tagName Name of the node on which we encountered the property.
10146
10163
  */
10147
- function logUnknownPropertyError(propName, tNode) {
10148
- let message = `Can't bind to '${propName}' since it isn't a known property of '${tNode.value}'.`;
10164
+ function logUnknownPropertyError(propName, tagName) {
10165
+ const message = `Can't bind to '${propName}' since it isn't a known property of '${tagName}'.`;
10149
10166
  console.error(formatRuntimeError(303 /* UNKNOWN_BINDING */, message));
10150
10167
  }
10151
10168
  /**
@@ -10363,8 +10380,11 @@ function findDirectiveDefMatches(tView, viewData, tNode) {
10363
10380
  if (ngDevMode) {
10364
10381
  assertTNodeType(tNode, 2 /* Element */, `"${tNode.value}" tags cannot be used as component hosts. ` +
10365
10382
  `Please use a different tag to activate the ${stringify(def.type)} component.`);
10366
- if (tNode.flags & 2 /* isComponentHost */)
10367
- throwMultipleComponentError(tNode);
10383
+ if (tNode.flags & 2 /* isComponentHost */) {
10384
+ // If another component has been matched previously, it's the first element in the
10385
+ // `matches` array, see how we store components/directives in `matches` below.
10386
+ throwMultipleComponentError(tNode, matches[0].type, def.type);
10387
+ }
10368
10388
  }
10369
10389
  markAsComponentHost(tView, tNode);
10370
10390
  // The component is always stored first with directives after.
@@ -12363,7 +12383,7 @@ function ɵɵInheritDefinitionFeature(definition) {
12363
12383
  else {
12364
12384
  if (superType.ɵcmp) {
12365
12385
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
12366
- 'Directives cannot inherit Components' :
12386
+ `Directives cannot inherit Components. Directive ${stringifyForError(definition.type)} is attempting to extend component ${stringifyForError(superType)}` :
12367
12387
  '';
12368
12388
  throw new RuntimeError(903 /* INVALID_INHERITANCE */, errorMessage);
12369
12389
  }
@@ -21108,7 +21128,7 @@ class Version {
21108
21128
  /**
21109
21129
  * @publicApi
21110
21130
  */
21111
- const VERSION = new Version('13.3.2');
21131
+ const VERSION = new Version('13.3.5');
21112
21132
 
21113
21133
  /**
21114
21134
  * @license
@@ -24877,7 +24897,10 @@ const PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
24877
24897
  * A token that indicates an opaque platform ID.
24878
24898
  * @publicApi
24879
24899
  */
24880
- const PLATFORM_ID = new InjectionToken('Platform ID');
24900
+ const PLATFORM_ID = new InjectionToken('Platform ID', {
24901
+ providedIn: 'platform',
24902
+ factory: () => 'unknown', // set a default platform name, when none set explicitly
24903
+ });
24881
24904
  /**
24882
24905
  * A [DI token](guide/glossary#di-token "DI token definition") that provides a set of callbacks to
24883
24906
  * be called for every component that is bootstrapped.
@@ -24915,10 +24938,11 @@ class Console {
24915
24938
  }
24916
24939
  }
24917
24940
  Console.ɵfac = function Console_Factory(t) { return new (t || Console)(); };
24918
- Console.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: Console, factory: Console.ɵfac });
24941
+ Console.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: Console, factory: Console.ɵfac, providedIn: 'platform' });
24919
24942
  (function () {
24920
24943
  (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(Console, [{
24921
- type: Injectable
24944
+ type: Injectable,
24945
+ args: [{ providedIn: 'platform' }]
24922
24946
  }], null, null);
24923
24947
  })();
24924
24948
 
@@ -25881,10 +25905,11 @@ class TestabilityRegistry {
25881
25905
  }
25882
25906
  }
25883
25907
  TestabilityRegistry.ɵfac = function TestabilityRegistry_Factory(t) { return new (t || TestabilityRegistry)(); };
25884
- TestabilityRegistry.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: TestabilityRegistry, factory: TestabilityRegistry.ɵfac });
25908
+ TestabilityRegistry.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: TestabilityRegistry, factory: TestabilityRegistry.ɵfac, providedIn: 'platform' });
25885
25909
  (function () {
25886
25910
  (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(TestabilityRegistry, [{
25887
- type: Injectable
25911
+ type: Injectable,
25912
+ args: [{ providedIn: 'platform' }]
25888
25913
  }], function () { return []; }, null);
25889
25914
  })();
25890
25915
  class _NoopGetTestability {
@@ -25909,7 +25934,19 @@ let _testabilityGetter = new _NoopGetTestability();
25909
25934
  * Use of this source code is governed by an MIT-style license that can be
25910
25935
  * found in the LICENSE file at https://angular.io/license
25911
25936
  */
25912
- let _platform;
25937
+ let _platformInjector = null;
25938
+ /**
25939
+ * Internal token to indicate whether having multiple bootstrapped platform should be allowed (only
25940
+ * one bootstrapped platform is allowed by default). This token helps to support SSR scenarios.
25941
+ */
25942
+ const ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
25943
+ /**
25944
+ * Internal token that allows to register extra callbacks that should be invoked during the
25945
+ * `PlatformRef.destroy` operation. This token is needed to avoid a direct reference to the
25946
+ * `PlatformRef` class (i.e. register the callback via `PlatformRef.onDestroy`), thus making the
25947
+ * entire class tree-shakeable.
25948
+ */
25949
+ const PLATFORM_ON_DESTROY = new InjectionToken('PlatformOnDestroy');
25913
25950
  function compileNgModuleFactory(injector, options, moduleType) {
25914
25951
  ngDevMode && assertNgModuleType(moduleType);
25915
25952
  const moduleFactory = new NgModuleFactory(moduleType);
@@ -25954,7 +25991,6 @@ function publishDefaultGlobalUtils() {
25954
25991
  function isBoundToModule(cf) {
25955
25992
  return cf.isBoundToModule;
25956
25993
  }
25957
- const ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
25958
25994
  /**
25959
25995
  * A token for third-party components that can register themselves with NgProbe.
25960
25996
  *
@@ -25973,19 +26009,19 @@ class NgProbeToken {
25973
26009
  * @publicApi
25974
26010
  */
25975
26011
  function createPlatform(injector) {
25976
- if (_platform && !_platform.destroyed &&
25977
- !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
26012
+ if (_platformInjector && !_platformInjector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
25978
26013
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
25979
26014
  'There can be only one platform. Destroy the previous one to create a new one.' :
25980
26015
  '';
25981
26016
  throw new RuntimeError(400 /* MULTIPLE_PLATFORMS */, errorMessage);
25982
26017
  }
25983
26018
  publishDefaultGlobalUtils();
25984
- _platform = injector.get(PlatformRef);
26019
+ _platformInjector = injector;
26020
+ const platform = injector.get(PlatformRef);
25985
26021
  const inits = injector.get(PLATFORM_INITIALIZER, null);
25986
26022
  if (inits)
25987
- inits.forEach((init) => init());
25988
- return _platform;
26023
+ inits.forEach(initFn => initFn());
26024
+ return platform;
25989
26025
  }
25990
26026
  /**
25991
26027
  * Creates a factory for a platform. Can be used to provide or override `Providers` specific to
@@ -26004,15 +26040,16 @@ function createPlatformFactory(parentPlatformFactory, name, providers = []) {
26004
26040
  return (extraProviders = []) => {
26005
26041
  let platform = getPlatform();
26006
26042
  if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
26043
+ const platformProviders = [
26044
+ ...providers,
26045
+ ...extraProviders,
26046
+ { provide: marker, useValue: true }
26047
+ ];
26007
26048
  if (parentPlatformFactory) {
26008
- parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
26049
+ parentPlatformFactory(platformProviders);
26009
26050
  }
26010
26051
  else {
26011
- const injectedProviders = providers.concat(extraProviders).concat({ provide: marker, useValue: true }, {
26012
- provide: INJECTOR_SCOPE,
26013
- useValue: 'platform'
26014
- });
26015
- createPlatform(Injector.create({ providers: injectedProviders, name: desc }));
26052
+ createPlatform(createPlatformInjector(platformProviders, desc));
26016
26053
  }
26017
26054
  }
26018
26055
  return assertPlatform(marker);
@@ -26035,6 +26072,20 @@ function assertPlatform(requiredToken) {
26035
26072
  }
26036
26073
  return platform;
26037
26074
  }
26075
+ /**
26076
+ * Helper function to create an instance of a platform injector (that maintains the 'platform'
26077
+ * scope).
26078
+ */
26079
+ function createPlatformInjector(providers = [], name) {
26080
+ return Injector.create({
26081
+ name,
26082
+ providers: [
26083
+ { provide: INJECTOR_SCOPE, useValue: 'platform' },
26084
+ { provide: PLATFORM_ON_DESTROY, useValue: () => _platformInjector = null },
26085
+ ...providers
26086
+ ],
26087
+ });
26088
+ }
26038
26089
  /**
26039
26090
  * Destroys the current Angular platform and all Angular applications on the page.
26040
26091
  * Destroys all modules and listeners registered with the platform.
@@ -26042,9 +26093,8 @@ function assertPlatform(requiredToken) {
26042
26093
  * @publicApi
26043
26094
  */
26044
26095
  function destroyPlatform() {
26045
- if (_platform && !_platform.destroyed) {
26046
- _platform.destroy();
26047
- }
26096
+ var _a;
26097
+ (_a = getPlatform()) === null || _a === void 0 ? void 0 : _a.destroy();
26048
26098
  }
26049
26099
  /**
26050
26100
  * Returns the current platform.
@@ -26052,7 +26102,8 @@ function destroyPlatform() {
26052
26102
  * @publicApi
26053
26103
  */
26054
26104
  function getPlatform() {
26055
- return _platform && !_platform.destroyed ? _platform : null;
26105
+ var _a;
26106
+ return (_a = _platformInjector === null || _platformInjector === void 0 ? void 0 : _platformInjector.get(PlatformRef)) !== null && _a !== void 0 ? _a : null;
26056
26107
  }
26057
26108
  /**
26058
26109
  * The Angular platform is the entry point for Angular on a web page.
@@ -26190,6 +26241,8 @@ class PlatformRef {
26190
26241
  }
26191
26242
  this._modules.slice().forEach(module => module.destroy());
26192
26243
  this._destroyListeners.forEach(listener => listener());
26244
+ const destroyListener = this._injector.get(PLATFORM_ON_DESTROY, null);
26245
+ destroyListener === null || destroyListener === void 0 ? void 0 : destroyListener();
26193
26246
  this._destroyed = true;
26194
26247
  }
26195
26248
  get destroyed() {
@@ -26197,10 +26250,11 @@ class PlatformRef {
26197
26250
  }
26198
26251
  }
26199
26252
  PlatformRef.ɵfac = function PlatformRef_Factory(t) { return new (t || PlatformRef)(ɵɵinject(Injector)); };
26200
- PlatformRef.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: PlatformRef, factory: PlatformRef.ɵfac });
26253
+ PlatformRef.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: PlatformRef, factory: PlatformRef.ɵfac, providedIn: 'platform' });
26201
26254
  (function () {
26202
26255
  (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(PlatformRef, [{
26203
- type: Injectable
26256
+ type: Injectable,
26257
+ args: [{ providedIn: 'platform' }]
26204
26258
  }], function () { return [{ type: Injector }]; }, null);
26205
26259
  })();
26206
26260
  function getNgZone(ngZoneOption, extra) {
@@ -26339,11 +26393,10 @@ function optionsReducer(dst, objs) {
26339
26393
  */
26340
26394
  class ApplicationRef {
26341
26395
  /** @internal */
26342
- constructor(_zone, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
26396
+ constructor(_zone, _injector, _exceptionHandler, _initStatus) {
26343
26397
  this._zone = _zone;
26344
26398
  this._injector = _injector;
26345
26399
  this._exceptionHandler = _exceptionHandler;
26346
- this._componentFactoryResolver = _componentFactoryResolver;
26347
26400
  this._initStatus = _initStatus;
26348
26401
  /** @internal */
26349
26402
  this._bootstrapListeners = [];
@@ -26459,8 +26512,8 @@ class ApplicationRef {
26459
26512
  componentFactory = componentOrFactory;
26460
26513
  }
26461
26514
  else {
26462
- componentFactory =
26463
- this._componentFactoryResolver.resolveComponentFactory(componentOrFactory);
26515
+ const resolver = this._injector.get(ComponentFactoryResolver$1);
26516
+ componentFactory = resolver.resolveComponentFactory(componentOrFactory);
26464
26517
  }
26465
26518
  this.componentTypes.push(componentFactory.componentType);
26466
26519
  // Create a factory associated with the current module if it's not bound to some other
@@ -26561,13 +26614,13 @@ class ApplicationRef {
26561
26614
  return this._views.length;
26562
26615
  }
26563
26616
  }
26564
- ApplicationRef.ɵfac = function ApplicationRef_Factory(t) { return new (t || ApplicationRef)(ɵɵinject(NgZone), ɵɵinject(Injector), ɵɵinject(ErrorHandler), ɵɵinject(ComponentFactoryResolver$1), ɵɵinject(ApplicationInitStatus)); };
26617
+ ApplicationRef.ɵfac = function ApplicationRef_Factory(t) { return new (t || ApplicationRef)(ɵɵinject(NgZone), ɵɵinject(Injector), ɵɵinject(ErrorHandler), ɵɵinject(ApplicationInitStatus)); };
26565
26618
  ApplicationRef.ɵprov = /*@__PURE__*/ ɵɵdefineInjectable({ token: ApplicationRef, factory: ApplicationRef.ɵfac, providedIn: 'root' });
26566
26619
  (function () {
26567
26620
  (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(ApplicationRef, [{
26568
26621
  type: Injectable,
26569
26622
  args: [{ providedIn: 'root' }]
26570
- }], function () { return [{ type: NgZone }, { type: Injector }, { type: ErrorHandler }, { type: ComponentFactoryResolver$1 }, { type: ApplicationInitStatus }]; }, null);
26623
+ }], function () { return [{ type: NgZone }, { type: Injector }, { type: ErrorHandler }, { type: ApplicationInitStatus }]; }, null);
26571
26624
  })();
26572
26625
  function remove(list, el) {
26573
26626
  const index = list.indexOf(el);
@@ -28550,19 +28603,12 @@ const defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
28550
28603
  * Use of this source code is governed by an MIT-style license that can be
28551
28604
  * found in the LICENSE file at https://angular.io/license
28552
28605
  */
28553
- const _CORE_PLATFORM_PROVIDERS = [
28554
- // Set a default platform name for platforms that don't set it explicitly.
28555
- { provide: PLATFORM_ID, useValue: 'unknown' },
28556
- { provide: PlatformRef, deps: [Injector] },
28557
- { provide: TestabilityRegistry, deps: [] },
28558
- { provide: Console, deps: [] },
28559
- ];
28560
28606
  /**
28561
28607
  * This platform has to be included in any other platform
28562
28608
  *
28563
28609
  * @publicApi
28564
28610
  */
28565
- const platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
28611
+ const platformCore = createPlatformFactory(null, 'core', []);
28566
28612
 
28567
28613
  /**
28568
28614
  * Re-exported by `BrowserModule`, which is included automatically in the root