@angular/core 15.0.0-next.0 → 15.0.0-next.2

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 v15.0.0-next.0
2
+ * @license Angular v15.0.0-next.2
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -4893,7 +4893,7 @@ function injectAttributeImpl(tNode, attrNameToInject) {
4893
4893
  return null;
4894
4894
  }
4895
4895
  function notFoundValueOrThrow(notFoundValue, token, flags) {
4896
- if (flags & InjectFlags.Optional) {
4896
+ if ((flags & InjectFlags.Optional) || notFoundValue !== undefined) {
4897
4897
  return notFoundValue;
4898
4898
  }
4899
4899
  else {
@@ -4910,7 +4910,7 @@ function notFoundValueOrThrow(notFoundValue, token, flags) {
4910
4910
  * @returns the value from the injector or throws an exception
4911
4911
  */
4912
4912
  function lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue) {
4913
- if (flags & InjectFlags.Optional && notFoundValue === undefined) {
4913
+ if ((flags & InjectFlags.Optional) && notFoundValue === undefined) {
4914
4914
  // This must be set or the NullInjector will throw for optional deps
4915
4915
  notFoundValue = null;
4916
4916
  }
@@ -6102,10 +6102,6 @@ function _sanitizeUrl(url) {
6102
6102
  }
6103
6103
  return 'unsafe:' + url;
6104
6104
  }
6105
- function sanitizeSrcset(srcset) {
6106
- srcset = String(srcset);
6107
- return srcset.split(',').map((srcset) => _sanitizeUrl(srcset.trim())).join(', ');
6108
- }
6109
6105
 
6110
6106
  /**
6111
6107
  * @license
@@ -6152,12 +6148,10 @@ const INLINE_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, tagSet('a,abbr,a
6152
6148
  const VALID_ELEMENTS = merge(VOID_ELEMENTS, BLOCK_ELEMENTS, INLINE_ELEMENTS, OPTIONAL_END_TAG_ELEMENTS);
6153
6149
  // Attributes that have href and hence need to be sanitized
6154
6150
  const URI_ATTRS = tagSet('background,cite,href,itemtype,longdesc,poster,src,xlink:href');
6155
- // Attributes that have special href set hence need to be sanitized
6156
- const SRCSET_ATTRS = tagSet('srcset');
6157
6151
  const HTML_ATTRS = tagSet('abbr,accesskey,align,alt,autoplay,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,' +
6158
6152
  'compact,controls,coords,datetime,default,dir,download,face,headers,height,hidden,hreflang,hspace,' +
6159
6153
  'ismap,itemscope,itemprop,kind,label,lang,language,loop,media,muted,nohref,nowrap,open,preload,rel,rev,role,rows,rowspan,rules,' +
6160
- 'scope,scrolling,shape,size,sizes,span,srclang,start,summary,tabindex,target,title,translate,type,usemap,' +
6154
+ 'scope,scrolling,shape,size,sizes,span,srclang,srcset,start,summary,tabindex,target,title,translate,type,usemap,' +
6161
6155
  'valign,value,vspace,width');
6162
6156
  // Accessibility attributes as per WAI-ARIA 1.1 (W3C Working Draft 14 December 2018)
6163
6157
  const ARIA_ATTRS = tagSet('aria-activedescendant,aria-atomic,aria-autocomplete,aria-busy,aria-checked,aria-colcount,aria-colindex,' +
@@ -6173,7 +6167,7 @@ const ARIA_ATTRS = tagSet('aria-activedescendant,aria-atomic,aria-autocomplete,a
6173
6167
  // NB: Sanitization does not allow <form> elements or other active elements (<button> etc). Those
6174
6168
  // can be sanitized, but they increase security surface area without a legitimate use case, so they
6175
6169
  // are left out here.
6176
- const VALID_ATTRS = merge(URI_ATTRS, SRCSET_ATTRS, HTML_ATTRS, ARIA_ATTRS);
6170
+ const VALID_ATTRS = merge(URI_ATTRS, HTML_ATTRS, ARIA_ATTRS);
6177
6171
  // Elements whose content should not be traversed/preserved, if the elements themselves are invalid.
6178
6172
  //
6179
6173
  // Typically, `<invalid>Some content</invalid>` would traverse (and in this case preserve)
@@ -6256,8 +6250,6 @@ class SanitizingHtmlSerializer {
6256
6250
  // TODO(martinprobst): Special case image URIs for data:image/...
6257
6251
  if (URI_ATTRS[lower])
6258
6252
  value = _sanitizeUrl(value);
6259
- if (SRCSET_ATTRS[lower])
6260
- value = sanitizeSrcset(value);
6261
6253
  this.buf.push(' ', attrName, '="', encodeEntities(value), '"');
6262
6254
  }
6263
6255
  this.buf.push('>');
@@ -7644,7 +7636,7 @@ class Version {
7644
7636
  /**
7645
7637
  * @publicApi
7646
7638
  */
7647
- const VERSION = new Version('15.0.0-next.0');
7639
+ const VERSION = new Version('15.0.0-next.2');
7648
7640
 
7649
7641
  /**
7650
7642
  * @license
@@ -7948,7 +7940,7 @@ function getTemplateLocationDetails(lView) {
7948
7940
  * that the `CommonModule` should also be included.
7949
7941
  */
7950
7942
  const KNOWN_CONTROL_FLOW_DIRECTIVES = new Map([
7951
- ['ngIf', 'NgIf'], ['ngFor', 'NgForOf'], ['ngSwitchCase', 'NgSwitchCase'],
7943
+ ['ngIf', 'NgIf'], ['ngFor', 'NgFor'], ['ngSwitchCase', 'NgSwitchCase'],
7952
7944
  ['ngSwitchDefault', 'NgSwitchDefault']
7953
7945
  ]);
7954
7946
  /**
@@ -8697,16 +8689,16 @@ function getRootView(componentOrLView) {
8697
8689
  return lView;
8698
8690
  }
8699
8691
  /**
8700
- * Returns the `RootContext` instance that is associated with
8701
- * the application where the target is situated. It does this by walking the parent views until it
8702
- * gets to the root view, then getting the context off of that.
8692
+ * Returns the context information associated with the application where the target is situated. It
8693
+ * does this by walking the parent views until it gets to the root view, then getting the context
8694
+ * off of that.
8703
8695
  *
8704
8696
  * @param viewOrComponent the `LView` or component to get the root context for.
8705
8697
  */
8706
8698
  function getRootContext(viewOrComponent) {
8707
8699
  const rootView = getRootView(viewOrComponent);
8708
8700
  ngDevMode &&
8709
- assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');
8701
+ assertDefined(rootView[CONTEXT], 'Root view has no context. Perhaps it is disconnected?');
8710
8702
  return rootView[CONTEXT];
8711
8703
  }
8712
8704
  /**
@@ -12411,28 +12403,6 @@ function refreshView(tView, lView, templateFn, context) {
12411
12403
  leaveView();
12412
12404
  }
12413
12405
  }
12414
- function renderComponentOrTemplate(tView, lView, templateFn, context) {
12415
- const rendererFactory = lView[RENDERER_FACTORY];
12416
- // Check no changes mode is a dev only mode used to verify that bindings have not changed
12417
- // since they were assigned. We do not want to invoke renderer factory functions in that mode
12418
- // to avoid any possible side-effects.
12419
- const checkNoChangesMode = !!ngDevMode && isInCheckNoChangesMode();
12420
- const creationModeIsActive = isCreationMode(lView);
12421
- try {
12422
- if (!checkNoChangesMode && !creationModeIsActive && rendererFactory.begin) {
12423
- rendererFactory.begin();
12424
- }
12425
- if (creationModeIsActive) {
12426
- renderView(tView, lView, context);
12427
- }
12428
- refreshView(tView, lView, templateFn, context);
12429
- }
12430
- finally {
12431
- if (!checkNoChangesMode && !creationModeIsActive && rendererFactory.end) {
12432
- rendererFactory.end();
12433
- }
12434
- }
12435
- }
12436
12406
  function executeTemplate(tView, lView, templateFn, rf, context) {
12437
12407
  const prevSelectedIndex = getSelectedIndex();
12438
12408
  const isUpdatePhase = rf & 2 /* RenderFlags.Update */;
@@ -12503,7 +12473,7 @@ function saveResolvedLocalsInData(viewData, tNode, localRefExtractor = getNative
12503
12473
  * @param def ComponentDef
12504
12474
  * @returns TView
12505
12475
  */
12506
- function getOrCreateTComponentView(def) {
12476
+ function getOrCreateComponentTView(def) {
12507
12477
  const tView = def.tView;
12508
12478
  // Create a TView if there isn't one, or recreate it if the first create pass didn't
12509
12479
  // complete successfully since we can't know for sure whether it's in a usable shape.
@@ -13214,7 +13184,7 @@ function configureViewWithDirective(tView, tNode, lView, directiveIndex, def) {
13214
13184
  }
13215
13185
  function addComponentLogic(lView, hostTNode, def) {
13216
13186
  const native = getNativeByTNode(hostTNode, lView);
13217
- const tView = getOrCreateTComponentView(def);
13187
+ const tView = getOrCreateComponentTView(def);
13218
13188
  // Only component views should be added to the view tree directly. Embedded views are
13219
13189
  // accessed through their containers because they may be removed / re-added later.
13220
13190
  const rendererFactory = lView[RENDERER_FACTORY];
@@ -13541,63 +13511,32 @@ function markViewDirty(lView) {
13541
13511
  }
13542
13512
  return null;
13543
13513
  }
13544
- function tickRootContext(rootContext) {
13545
- for (let i = 0; i < rootContext.components.length; i++) {
13546
- const rootComponent = rootContext.components[i];
13547
- const lView = readPatchedLView(rootComponent);
13548
- // We might not have an `LView` if the component was destroyed.
13549
- if (lView !== null) {
13550
- const tView = lView[TVIEW];
13551
- renderComponentOrTemplate(tView, lView, tView.template, rootComponent);
13552
- }
13553
- }
13554
- }
13555
- function detectChangesInternal(tView, lView, context) {
13514
+ function detectChangesInternal(tView, lView, context, notifyErrorHandler = true) {
13556
13515
  const rendererFactory = lView[RENDERER_FACTORY];
13557
- if (rendererFactory.begin)
13516
+ // Check no changes mode is a dev only mode used to verify that bindings have not changed
13517
+ // since they were assigned. We do not want to invoke renderer factory functions in that mode
13518
+ // to avoid any possible side-effects.
13519
+ const checkNoChangesMode = !!ngDevMode && isInCheckNoChangesMode();
13520
+ if (!checkNoChangesMode && rendererFactory.begin)
13558
13521
  rendererFactory.begin();
13559
13522
  try {
13560
13523
  refreshView(tView, lView, tView.template, context);
13561
13524
  }
13562
13525
  catch (error) {
13563
- handleError(lView, error);
13526
+ if (notifyErrorHandler) {
13527
+ handleError(lView, error);
13528
+ }
13564
13529
  throw error;
13565
13530
  }
13566
13531
  finally {
13567
- if (rendererFactory.end)
13532
+ if (!checkNoChangesMode && rendererFactory.end)
13568
13533
  rendererFactory.end();
13569
13534
  }
13570
13535
  }
13571
- /**
13572
- * Synchronously perform change detection on a root view and its components.
13573
- *
13574
- * @param lView The view which the change detection should be performed on.
13575
- */
13576
- function detectChangesInRootView(lView) {
13577
- tickRootContext(lView[CONTEXT]);
13578
- }
13579
- function checkNoChangesInternal(tView, view, context) {
13580
- setIsInCheckNoChangesMode(true);
13581
- try {
13582
- detectChangesInternal(tView, view, context);
13583
- }
13584
- finally {
13585
- setIsInCheckNoChangesMode(false);
13586
- }
13587
- }
13588
- /**
13589
- * Checks the change detector on a root view and its components, and throws if any changes are
13590
- * detected.
13591
- *
13592
- * This is used in development mode to verify that running change detection doesn't
13593
- * introduce other changes.
13594
- *
13595
- * @param lView The view which the change detection should be checked on.
13596
- */
13597
- function checkNoChangesInRootView(lView) {
13536
+ function checkNoChangesInternal(tView, lView, context, notifyErrorHandler = true) {
13598
13537
  setIsInCheckNoChangesMode(true);
13599
13538
  try {
13600
- detectChangesInRootView(lView);
13539
+ detectChangesInternal(tView, lView, context, notifyErrorHandler);
13601
13540
  }
13602
13541
  finally {
13603
13542
  setIsInCheckNoChangesMode(false);
@@ -14090,11 +14029,17 @@ class RootViewRef extends ViewRef {
14090
14029
  this._view = _view;
14091
14030
  }
14092
14031
  detectChanges() {
14093
- detectChangesInRootView(this._view);
14032
+ const lView = this._view;
14033
+ const tView = lView[TVIEW];
14034
+ const context = lView[CONTEXT];
14035
+ detectChangesInternal(tView, lView, context, false);
14094
14036
  }
14095
14037
  checkNoChanges() {
14096
14038
  if (ngDevMode) {
14097
- checkNoChangesInRootView(this._view);
14039
+ const lView = this._view;
14040
+ const tView = lView[TVIEW];
14041
+ const context = lView[CONTEXT];
14042
+ checkNoChangesInternal(tView, lView, context, false);
14098
14043
  }
14099
14044
  }
14100
14045
  get context() {
@@ -14161,7 +14106,7 @@ class ChainedInjector {
14161
14106
  }
14162
14107
  }
14163
14108
  /**
14164
- * Render3 implementation of {@link viewEngine_ComponentFactory}.
14109
+ * ComponentFactory interface implementation.
14165
14110
  */
14166
14111
  class ComponentFactory extends ComponentFactory$1 {
14167
14112
  /**
@@ -14211,10 +14156,9 @@ class ComponentFactory extends ComponentFactory$1 {
14211
14156
  createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
14212
14157
  const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
14213
14158
  16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
14214
- const rootContext = createRootContext();
14215
14159
  // Create the root view. Uses empty TView and ContentTemplate.
14216
14160
  const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
14217
- const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
14161
+ const rootLView = createLView(null, rootTView, null, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
14218
14162
  // rootView is the parent when bootstrapping
14219
14163
  // TODO(misko): it looks like we are entering view here but we don't really need to as
14220
14164
  // `renderView` does that. However as the code is written it is needed because
@@ -14258,7 +14202,8 @@ class ComponentFactory extends ComponentFactory$1 {
14258
14202
  // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
14259
14203
  // executed here?
14260
14204
  // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
14261
- component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
14205
+ component =
14206
+ createRootComponent(componentView, this.componentDef, rootLView, [LifecycleHooksFeature]);
14262
14207
  renderView(rootTView, rootLView, null);
14263
14208
  }
14264
14209
  finally {
@@ -14364,7 +14309,7 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14364
14309
  }
14365
14310
  }
14366
14311
  const viewRenderer = rendererFactory.createRenderer(rNode, def);
14367
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14312
+ const componentView = createLView(rootView, getOrCreateComponentTView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14368
14313
  if (tView.firstCreatePass) {
14369
14314
  diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
14370
14315
  markAsComponentHost(tView, tNode);
@@ -14378,12 +14323,13 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14378
14323
  * Creates a root component and sets it up with features and host bindings.Shared by
14379
14324
  * renderComponent() and ViewContainerRef.createComponent().
14380
14325
  */
14381
- function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
14326
+ function createRootComponent(componentView, componentDef, rootLView, hostFeatures) {
14382
14327
  const tView = rootLView[TVIEW];
14383
14328
  // Create directive instance with factory() and store at next index in viewData
14384
14329
  const component = instantiateRootComponent(tView, rootLView, componentDef);
14385
- rootContext.components.push(component);
14386
- componentView[CONTEXT] = component;
14330
+ // Root view only contains an instance of this component,
14331
+ // so we use a reference to that component instance as a context.
14332
+ componentView[CONTEXT] = rootLView[CONTEXT] = component;
14387
14333
  if (hostFeatures !== null) {
14388
14334
  for (const feature of hostFeatures) {
14389
14335
  feature(component, componentDef);
@@ -14407,9 +14353,6 @@ function createRootComponent(componentView, componentDef, rootLView, rootContext
14407
14353
  }
14408
14354
  return component;
14409
14355
  }
14410
- function createRootContext() {
14411
- return { components: [] };
14412
- }
14413
14356
  /**
14414
14357
  * Used to enable lifecycle hooks on the root component.
14415
14358
  *
@@ -21302,9 +21245,6 @@ function walkIcuTree(tView, tIcu, lView, sharedUpdateOpCodes, create, remove, up
21302
21245
  if (URI_ATTRS[lowerAttrName]) {
21303
21246
  generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, _sanitizeUrl);
21304
21247
  }
21305
- else if (SRCSET_ATTRS[lowerAttrName]) {
21306
- generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, sanitizeSrcset);
21307
- }
21308
21248
  else {
21309
21249
  generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, null);
21310
21250
  }
@@ -22273,7 +22213,7 @@ function getOwningComponent(elementOrDir) {
22273
22213
  */
22274
22214
  function getRootComponents(elementOrDir) {
22275
22215
  const lView = readPatchedLView(elementOrDir);
22276
- return lView !== null ? [...getRootContext(lView).components] : [];
22216
+ return lView !== null ? [getRootContext(lView)] : [];
22277
22217
  }
22278
22218
  /**
22279
22219
  * Retrieves an `Injector` associated with an element, component or directive instance.