@angular/core 13.2.0-next.2 → 13.2.1

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 (41) hide show
  1. package/core.d.ts +63 -9
  2. package/esm2020/src/change_detection/differs/default_iterable_differ.mjs +6 -2
  3. package/esm2020/src/change_detection/differs/default_keyvalue_differ.mjs +6 -2
  4. package/esm2020/src/change_detection/differs/iterable_differs.mjs +6 -2
  5. package/esm2020/src/change_detection/differs/keyvalue_differs.mjs +6 -2
  6. package/esm2020/src/di/injector_compatibility.mjs +10 -3
  7. package/esm2020/src/di/r3_injector.mjs +6 -5
  8. package/esm2020/src/di/reflective_injector.mjs +1 -1
  9. package/esm2020/src/errors.mjs +22 -5
  10. package/esm2020/src/linker/compiler.mjs +1 -1
  11. package/esm2020/src/linker/component_factory.mjs +4 -1
  12. package/esm2020/src/linker/component_factory_resolver.mjs +4 -1
  13. package/esm2020/src/linker/ng_module_factory.mjs +1 -1
  14. package/esm2020/src/metadata/directives.mjs +14 -5
  15. package/esm2020/src/reflection/reflection_capabilities.mjs +2 -2
  16. package/esm2020/src/render3/component_ref.mjs +1 -1
  17. package/esm2020/src/render3/features/inherit_definition_feature.mjs +6 -2
  18. package/esm2020/src/render3/i18n/i18n_apply.mjs +5 -2
  19. package/esm2020/src/render3/instructions/shared.mjs +2 -2
  20. package/esm2020/src/render3/namespaces.mjs +10 -3
  21. package/esm2020/src/render3/node_manipulation.mjs +5 -3
  22. package/esm2020/src/render3/view_ref.mjs +6 -3
  23. package/esm2020/src/sanitization/sanitization.mjs +14 -7
  24. package/esm2020/src/version.mjs +1 -1
  25. package/esm2020/src/zone/ng_zone.mjs +3 -2
  26. package/esm2020/testing/src/logger.mjs +3 -3
  27. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  28. package/esm2020/testing/src/r3_test_bed.mjs +6 -1
  29. package/fesm2015/core.mjs +109 -37
  30. package/fesm2015/core.mjs.map +1 -1
  31. package/fesm2015/testing.mjs +6 -1
  32. package/fesm2015/testing.mjs.map +1 -1
  33. package/fesm2020/core.mjs +109 -37
  34. package/fesm2020/core.mjs.map +1 -1
  35. package/fesm2020/testing.mjs +6 -1
  36. package/fesm2020/testing.mjs.map +1 -1
  37. package/package.json +1 -1
  38. package/schematics/migrations/router-link-empty-expression/index.js +1 -1
  39. package/schematics/migrations/typed-forms/index.js +2 -2
  40. package/schematics/migrations.json +0 -5
  41. package/testing/testing.d.ts +1 -1
package/fesm2020/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.2.0-next.2
2
+ * @license Angular v13.2.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -152,20 +152,37 @@ const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
152
152
  * Use of this source code is governed by an MIT-style license that can be
153
153
  * found in the LICENSE file at https://angular.io/license
154
154
  */
155
+ /**
156
+ * Class that represents a runtime error.
157
+ * Formats and outputs the error message in a consistent way.
158
+ *
159
+ * Example:
160
+ * ```
161
+ * throw new RuntimeError(
162
+ * RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
163
+ * ngDevMode && 'Injector has already been destroyed.');
164
+ * ```
165
+ *
166
+ * Note: the `message` argument contains a descriptive error message as a string in development
167
+ * mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
168
+ * `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
169
+ */
155
170
  class RuntimeError extends Error {
156
171
  constructor(code, message) {
157
172
  super(formatRuntimeError(code, message));
158
173
  this.code = code;
159
174
  }
160
175
  }
161
- /** Called to format a runtime error */
176
+ /**
177
+ * Called to format a runtime error.
178
+ * See additional info on the `message` argument type in the `RuntimeError` class description.
179
+ */
162
180
  function formatRuntimeError(code, message) {
163
- const codeAsNumber = code;
164
181
  // Error code might be a negative number, which is a special marker that instructs the logic to
165
182
  // generate a link to the error details page on angular.io.
166
- const fullCode = `NG0${Math.abs(codeAsNumber)}`;
183
+ const fullCode = `NG0${Math.abs(code)}`;
167
184
  let errorMessage = `${fullCode}${message ? ': ' + message : ''}`;
168
- if (ngDevMode && codeAsNumber < 0) {
185
+ if (ngDevMode && code < 0) {
169
186
  errorMessage = `${errorMessage}. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
170
187
  }
171
188
  return errorMessage;
@@ -1559,8 +1576,15 @@ const profiler = function (event, instance, hookOrListener) {
1559
1576
  * Use of this source code is governed by an MIT-style license that can be
1560
1577
  * found in the LICENSE file at https://angular.io/license
1561
1578
  */
1562
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1563
- const MATH_ML_NAMESPACE = 'http://www.w3.org/1998/MathML/';
1579
+ const SVG_NAMESPACE = 'svg';
1580
+ const SVG_NAMESPACE_URI = 'http://www.w3.org/2000/svg';
1581
+ const MATH_ML_NAMESPACE = 'math';
1582
+ const MATH_ML_NAMESPACE_URI = 'http://www.w3.org/1998/MathML/';
1583
+ function getNamespaceUri(namespace) {
1584
+ const name = namespace.toLowerCase();
1585
+ return name === SVG_NAMESPACE ? SVG_NAMESPACE_URI :
1586
+ (name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
1587
+ }
1564
1588
 
1565
1589
  /**
1566
1590
  * @license
@@ -4471,7 +4495,7 @@ const ES2015_INHERITED_CLASS_WITH_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{
4471
4495
  * Regular expression that detects ES2015 classes which extend from other classes
4472
4496
  * and inherit a constructor.
4473
4497
  */
4474
- const ES2015_INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{\s*super\(\.\.\.arguments\)/;
4498
+ const ES2015_INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{[^}]*super\(\.\.\.arguments\)/;
4475
4499
  /**
4476
4500
  * Determine whether a stringified type is a class which delegates its constructor
4477
4501
  * to its parent.
@@ -4750,7 +4774,10 @@ function setCurrentInjector(injector) {
4750
4774
  }
4751
4775
  function injectInjectorOnly(token, flags = InjectFlags.Default) {
4752
4776
  if (_currentInjector === undefined) {
4753
- throw new Error(`inject() must be called from an injection context`);
4777
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
4778
+ `inject() must be called from an injection context` :
4779
+ '';
4780
+ throw new RuntimeError(203 /* MISSING_INJECTION_CONTEXT */, errorMessage);
4754
4781
  }
4755
4782
  else if (_currentInjector === null) {
4756
4783
  return injectRootLimpMode(token, undefined, flags);
@@ -4814,7 +4841,10 @@ function injectArgs(types) {
4814
4841
  const arg = resolveForwardRef(types[i]);
4815
4842
  if (Array.isArray(arg)) {
4816
4843
  if (arg.length === 0) {
4817
- throw new Error('Arguments array must have arguments.');
4844
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
4845
+ 'Arguments array must have arguments.' :
4846
+ '';
4847
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
4818
4848
  }
4819
4849
  let type = undefined;
4820
4850
  let flags = InjectFlags.Default;
@@ -6005,7 +6035,10 @@ function ɵɵsanitizeResourceUrl(unsafeResourceUrl) {
6005
6035
  if (allowSanitizationBypassAndThrow(unsafeResourceUrl, "ResourceURL" /* ResourceUrl */)) {
6006
6036
  return trustedScriptURLFromStringBypass(unwrapSafeValue(unsafeResourceUrl));
6007
6037
  }
6008
- throw new Error('unsafe value used in a resource URL context (see https://g.co/ng/security#xss)');
6038
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
6039
+ 'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)' :
6040
+ '';
6041
+ throw new RuntimeError(904 /* UNSAFE_VALUE_IN_RESOURCE_URL */, errorMessage);
6009
6042
  }
6010
6043
  /**
6011
6044
  * A `script` sanitizer which only lets trusted javascript through.
@@ -6027,7 +6060,10 @@ function ɵɵsanitizeScript(unsafeScript) {
6027
6060
  if (allowSanitizationBypassAndThrow(unsafeScript, "Script" /* Script */)) {
6028
6061
  return trustedScriptFromStringBypass(unwrapSafeValue(unsafeScript));
6029
6062
  }
6030
- throw new Error('unsafe value used in a script context');
6063
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
6064
+ 'unsafe value used in a script context' :
6065
+ '';
6066
+ throw new RuntimeError(905 /* UNSAFE_VALUE_IN_SCRIPT */, errorMessage);
6031
6067
  }
6032
6068
  /**
6033
6069
  * A template tag function for promoting the associated constant literal to a
@@ -6115,18 +6151,18 @@ function ɵɵsanitizeUrlOrResourceUrl(unsafeUrl, tag, prop) {
6115
6151
  }
6116
6152
  function validateAgainstEventProperties(name) {
6117
6153
  if (name.toLowerCase().startsWith('on')) {
6118
- const msg = `Binding to event property '${name}' is disallowed for security reasons, ` +
6154
+ const errorMessage = `Binding to event property '${name}' is disallowed for security reasons, ` +
6119
6155
  `please use (${name.slice(2)})=...` +
6120
6156
  `\nIf '${name}' is a directive input, make sure the directive is imported by the` +
6121
6157
  ` current module.`;
6122
- throw new Error(msg);
6158
+ throw new RuntimeError(306 /* INVALID_EVENT_BINDING */, errorMessage);
6123
6159
  }
6124
6160
  }
6125
6161
  function validateAgainstEventAttributes(name) {
6126
6162
  if (name.toLowerCase().startsWith('on')) {
6127
- const msg = `Binding to event attribute '${name}' is disallowed for security reasons, ` +
6163
+ const errorMessage = `Binding to event attribute '${name}' is disallowed for security reasons, ` +
6128
6164
  `please use (${name.slice(2)})=...`;
6129
- throw new Error(msg);
6165
+ throw new RuntimeError(306 /* INVALID_EVENT_BINDING */, errorMessage);
6130
6166
  }
6131
6167
  }
6132
6168
  function getSanitizer() {
@@ -6976,8 +7012,9 @@ function createElementNode(renderer, name, namespace) {
6976
7012
  return renderer.createElement(name, namespace);
6977
7013
  }
6978
7014
  else {
6979
- return namespace === null ? renderer.createElement(name) :
6980
- renderer.createElementNS(namespace, name);
7015
+ const namespaceUri = namespace !== null ? getNamespaceUri(namespace) : null;
7016
+ return namespaceUri === null ? renderer.createElement(name) :
7017
+ renderer.createElementNS(namespaceUri, name);
6981
7018
  }
6982
7019
  }
6983
7020
  /**
@@ -10372,7 +10409,7 @@ function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
10372
10409
  for (let i = 0; i < localRefs.length; i += 2) {
10373
10410
  const index = exportsMap[localRefs[i + 1]];
10374
10411
  if (index == null)
10375
- throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, `Export of name '${localRefs[i + 1]}' not found!`);
10412
+ throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, ngDevMode && `Export of name '${localRefs[i + 1]}' not found!`);
10376
10413
  localNames.push(localRefs[i], index);
10377
10414
  }
10378
10415
  }
@@ -11298,7 +11335,7 @@ class R3Injector {
11298
11335
  }
11299
11336
  assertNotDestroyed() {
11300
11337
  if (this._destroyed) {
11301
- throw new Error('Injector has already been destroyed.');
11338
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && 'Injector has already been destroyed.');
11302
11339
  }
11303
11340
  }
11304
11341
  /**
@@ -11462,21 +11499,21 @@ function injectableDefOrInjectorDefFactory(token) {
11462
11499
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11463
11500
  // If it's missing that, it's an error.
11464
11501
  if (token instanceof InjectionToken) {
11465
- throw new Error(`Token ${stringify(token)} is missing a ɵprov definition.`);
11502
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
11466
11503
  }
11467
11504
  // Undecorated types can sometimes be created if they have no constructor arguments.
11468
11505
  if (token instanceof Function) {
11469
11506
  return getUndecoratedInjectableFactory(token);
11470
11507
  }
11471
11508
  // There was no way to resolve a factory for this token.
11472
- throw new Error('unreachable');
11509
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && 'unreachable');
11473
11510
  }
11474
11511
  function getUndecoratedInjectableFactory(token) {
11475
11512
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11476
11513
  const paramLength = token.length;
11477
11514
  if (paramLength > 0) {
11478
11515
  const args = newArray(paramLength, '?');
11479
- throw new Error(`Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
11516
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
11480
11517
  }
11481
11518
  // The constructor function appears to have no parameters.
11482
11519
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -12334,7 +12371,10 @@ function ɵɵInheritDefinitionFeature(definition) {
12334
12371
  }
12335
12372
  else {
12336
12373
  if (superType.ɵcmp) {
12337
- throw new Error('Directives cannot inherit Components');
12374
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
12375
+ 'Directives cannot inherit Components' :
12376
+ '';
12377
+ throw new RuntimeError(903 /* INVALID_INHERITANCE */, errorMessage);
12338
12378
  }
12339
12379
  // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
12340
12380
  superDef = superType.ɵdir;
@@ -19115,7 +19155,9 @@ function applyMutableOpCodes(tView, mutableOpCodes, lView, anchorRNode) {
19115
19155
  setElementAttribute(renderer, getNativeByIndex(elementNodeIndex, lView), null, null, attrName, attrValue, null);
19116
19156
  break;
19117
19157
  default:
19118
- throw new Error(`Unable to determine the type of mutate operation for "${opCode}"`);
19158
+ if (ngDevMode) {
19159
+ throw new RuntimeError(700 /* INVALID_I18N_STRUCTURE */, `Unable to determine the type of mutate operation for "${opCode}"`);
19160
+ }
19119
19161
  }
19120
19162
  }
19121
19163
  else {
@@ -20842,6 +20884,9 @@ class ComponentRef$1 {
20842
20884
  * @see [Dynamic Components](guide/dynamic-component-loader)
20843
20885
  *
20844
20886
  * @publicApi
20887
+ *
20888
+ * @deprecated Angular no longer requires Component factories. Please use other APIs where
20889
+ * Component class can be used directly.
20845
20890
  */
20846
20891
  class ComponentFactory$1 {
20847
20892
  }
@@ -20878,6 +20923,9 @@ class _NullComponentFactoryResolver {
20878
20923
  * does **not** require resolving component factory: component class can be used directly.
20879
20924
  *
20880
20925
  * @publicApi
20926
+ *
20927
+ * @deprecated Angular no longer requires Component factories. Please use other APIs where
20928
+ * Component class can be used directly.
20881
20929
  */
20882
20930
  class ComponentFactoryResolver$1 {
20883
20931
  }
@@ -21042,7 +21090,7 @@ class Version {
21042
21090
  /**
21043
21091
  * @publicApi
21044
21092
  */
21045
- const VERSION = new Version('13.2.0-next.2');
21093
+ const VERSION = new Version('13.2.1');
21046
21094
 
21047
21095
  /**
21048
21096
  * @license
@@ -21378,7 +21426,8 @@ class ViewRef$1 {
21378
21426
  }
21379
21427
  attachToViewContainerRef() {
21380
21428
  if (this._appRef) {
21381
- throw new Error('This view is already attached directly to the ApplicationRef!');
21429
+ const errorMessage = ngDevMode ? 'This view is already attached directly to the ApplicationRef!' : '';
21430
+ throw new RuntimeError(902 /* VIEW_ALREADY_ATTACHED */, errorMessage);
21382
21431
  }
21383
21432
  this._attachedToViewContainer = true;
21384
21433
  }
@@ -21388,7 +21437,8 @@ class ViewRef$1 {
21388
21437
  }
21389
21438
  attachToAppRef(appRef) {
21390
21439
  if (this._attachedToViewContainer) {
21391
- throw new Error('This view is already attached to a ViewContainer!');
21440
+ const errorMessage = ngDevMode ? 'This view is already attached to a ViewContainer!' : '';
21441
+ throw new RuntimeError(902 /* VIEW_ALREADY_ATTACHED */, errorMessage);
21392
21442
  }
21393
21443
  this._appRef = appRef;
21394
21444
  }
@@ -24531,19 +24581,20 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24531
24581
  *
24532
24582
  * ```
24533
24583
  *
24534
- * The following example registers another DOM event handler that listens for key-press events.
24584
+ * The following example registers another DOM event handler that listens for `Enter` key-press
24585
+ * events on the global `window`.
24535
24586
  * ``` ts
24536
24587
  * import { HostListener, Component } from "@angular/core";
24537
24588
  *
24538
24589
  * @Component({
24539
24590
  * selector: 'app',
24540
- * template: `<h1>Hello, you have pressed keys {{counter}} number of times!</h1> Press any key to
24541
- * increment the counter.
24591
+ * template: `<h1>Hello, you have pressed enter {{counter}} number of times!</h1> Press enter key
24592
+ * to increment the counter.
24542
24593
  * <button (click)="resetCounter()">Reset Counter</button>`
24543
24594
  * })
24544
24595
  * class AppComponent {
24545
24596
  * counter = 0;
24546
- * @HostListener('window:keydown', ['$event'])
24597
+ * @HostListener('window:keydown.enter', ['$event'])
24547
24598
  * handleKeyDown(event: KeyboardEvent) {
24548
24599
  * this.counter++;
24549
24600
  * }
@@ -24552,6 +24603,14 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24552
24603
  * }
24553
24604
  * }
24554
24605
  * ```
24606
+ * The list of valid key names for `keydown` and `keyup` events
24607
+ * can be found here:
24608
+ * https://www.w3.org/TR/DOM-Level-3-Events-key/#named-key-attribute-values
24609
+ *
24610
+ * Note that keys can also be combined, e.g. `@HostListener('keydown.shift.a')`.
24611
+ *
24612
+ * The global target names that can be used to prefix an event name are
24613
+ * `document:`, `window:` and `body:`.
24555
24614
  *
24556
24615
  * @Annotation
24557
24616
  * @publicApi
@@ -25280,7 +25339,8 @@ class NgZone {
25280
25339
  forkInnerZoneWithAngularBehavior(self);
25281
25340
  }
25282
25341
  static isInAngularZone() {
25283
- return Zone.current.get('isAngularZone') === true;
25342
+ // Zone needs to be checked, because this method might be called even when NoopNgZone is used.
25343
+ return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
25284
25344
  }
25285
25345
  static assertInAngularZone() {
25286
25346
  if (!NgZone.isInAngularZone()) {
@@ -27390,7 +27450,10 @@ class DefaultIterableDiffer {
27390
27450
  if (collection == null)
27391
27451
  collection = [];
27392
27452
  if (!isListLikeIterable(collection)) {
27393
- throw new Error(`Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed`);
27453
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
27454
+ `Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed` :
27455
+ '';
27456
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
27394
27457
  }
27395
27458
  if (this.check(collection)) {
27396
27459
  return this;
@@ -27991,7 +28054,10 @@ class DefaultKeyValueDiffer {
27991
28054
  map = new Map();
27992
28055
  }
27993
28056
  else if (!(map instanceof Map || isJsObject(map))) {
27994
- throw new Error(`Error trying to diff '${stringify(map)}'. Only maps and objects are allowed`);
28057
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28058
+ `Error trying to diff '${stringify(map)}'. Only maps and objects are allowed` :
28059
+ '';
28060
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
27995
28061
  }
27996
28062
  return this.check(map) ? this : null;
27997
28063
  }
@@ -28238,7 +28304,10 @@ class IterableDiffers {
28238
28304
  return factory;
28239
28305
  }
28240
28306
  else {
28241
- throw new Error(`Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'`);
28307
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28308
+ `Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'` :
28309
+ '';
28310
+ throw new RuntimeError(901 /* NO_SUPPORTING_DIFFER_FACTORY */, errorMessage);
28242
28311
  }
28243
28312
  }
28244
28313
  }
@@ -28312,7 +28381,10 @@ class KeyValueDiffers {
28312
28381
  if (factory) {
28313
28382
  return factory;
28314
28383
  }
28315
- throw new Error(`Cannot find a differ supporting object '${kv}'`);
28384
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28385
+ `Cannot find a differ supporting object '${kv}'` :
28386
+ '';
28387
+ throw new RuntimeError(901 /* NO_SUPPORTING_DIFFER_FACTORY */, errorMessage);
28316
28388
  }
28317
28389
  }
28318
28390
  /** @nocollapse */