@angular/core 15.0.0-next.1 → 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.1
2
+ * @license Angular v15.0.0-next.2
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -4899,7 +4899,7 @@ function injectAttributeImpl(tNode, attrNameToInject) {
4899
4899
  return null;
4900
4900
  }
4901
4901
  function notFoundValueOrThrow(notFoundValue, token, flags) {
4902
- if (flags & InjectFlags.Optional) {
4902
+ if ((flags & InjectFlags.Optional) || notFoundValue !== undefined) {
4903
4903
  return notFoundValue;
4904
4904
  }
4905
4905
  else {
@@ -4916,7 +4916,7 @@ function notFoundValueOrThrow(notFoundValue, token, flags) {
4916
4916
  * @returns the value from the injector or throws an exception
4917
4917
  */
4918
4918
  function lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue) {
4919
- if (flags & InjectFlags.Optional && notFoundValue === undefined) {
4919
+ if ((flags & InjectFlags.Optional) && notFoundValue === undefined) {
4920
4920
  // This must be set or the NullInjector will throw for optional deps
4921
4921
  notFoundValue = null;
4922
4922
  }
@@ -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.1');
7639
+ const VERSION = new Version('15.0.0-next.2');
7648
7640
 
7649
7641
  /**
7650
7642
  * @license
@@ -7947,7 +7939,7 @@ function getTemplateLocationDetails(lView) {
7947
7939
  * that the `CommonModule` should also be included.
7948
7940
  */
7949
7941
  const KNOWN_CONTROL_FLOW_DIRECTIVES = new Map([
7950
- ['ngIf', 'NgIf'], ['ngFor', 'NgForOf'], ['ngSwitchCase', 'NgSwitchCase'],
7942
+ ['ngIf', 'NgIf'], ['ngFor', 'NgFor'], ['ngSwitchCase', 'NgSwitchCase'],
7951
7943
  ['ngSwitchDefault', 'NgSwitchDefault']
7952
7944
  ]);
7953
7945
  /**
@@ -8696,16 +8688,16 @@ function getRootView(componentOrLView) {
8696
8688
  return lView;
8697
8689
  }
8698
8690
  /**
8699
- * Returns the `RootContext` instance that is associated with
8700
- * the application where the target is situated. It does this by walking the parent views until it
8701
- * gets to the root view, then getting the context off of that.
8691
+ * Returns the context information associated with the application where the target is situated. It
8692
+ * does this by walking the parent views until it gets to the root view, then getting the context
8693
+ * off of that.
8702
8694
  *
8703
8695
  * @param viewOrComponent the `LView` or component to get the root context for.
8704
8696
  */
8705
8697
  function getRootContext(viewOrComponent) {
8706
8698
  const rootView = getRootView(viewOrComponent);
8707
8699
  ngDevMode &&
8708
- assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');
8700
+ assertDefined(rootView[CONTEXT], 'Root view has no context. Perhaps it is disconnected?');
8709
8701
  return rootView[CONTEXT];
8710
8702
  }
8711
8703
  /**
@@ -12409,28 +12401,6 @@ function refreshView(tView, lView, templateFn, context) {
12409
12401
  leaveView();
12410
12402
  }
12411
12403
  }
12412
- function renderComponentOrTemplate(tView, lView, templateFn, context) {
12413
- const rendererFactory = lView[RENDERER_FACTORY];
12414
- // Check no changes mode is a dev only mode used to verify that bindings have not changed
12415
- // since they were assigned. We do not want to invoke renderer factory functions in that mode
12416
- // to avoid any possible side-effects.
12417
- const checkNoChangesMode = !!ngDevMode && isInCheckNoChangesMode();
12418
- const creationModeIsActive = isCreationMode(lView);
12419
- try {
12420
- if (!checkNoChangesMode && !creationModeIsActive && rendererFactory.begin) {
12421
- rendererFactory.begin();
12422
- }
12423
- if (creationModeIsActive) {
12424
- renderView(tView, lView, context);
12425
- }
12426
- refreshView(tView, lView, templateFn, context);
12427
- }
12428
- finally {
12429
- if (!checkNoChangesMode && !creationModeIsActive && rendererFactory.end) {
12430
- rendererFactory.end();
12431
- }
12432
- }
12433
- }
12434
12404
  function executeTemplate(tView, lView, templateFn, rf, context) {
12435
12405
  const prevSelectedIndex = getSelectedIndex();
12436
12406
  const isUpdatePhase = rf & 2 /* RenderFlags.Update */;
@@ -12501,7 +12471,7 @@ function saveResolvedLocalsInData(viewData, tNode, localRefExtractor = getNative
12501
12471
  * @param def ComponentDef
12502
12472
  * @returns TView
12503
12473
  */
12504
- function getOrCreateTComponentView(def) {
12474
+ function getOrCreateComponentTView(def) {
12505
12475
  const tView = def.tView;
12506
12476
  // Create a TView if there isn't one, or recreate it if the first create pass didn't
12507
12477
  // complete successfully since we can't know for sure whether it's in a usable shape.
@@ -13211,7 +13181,7 @@ function configureViewWithDirective(tView, tNode, lView, directiveIndex, def) {
13211
13181
  }
13212
13182
  function addComponentLogic(lView, hostTNode, def) {
13213
13183
  const native = getNativeByTNode(hostTNode, lView);
13214
- const tView = getOrCreateTComponentView(def);
13184
+ const tView = getOrCreateComponentTView(def);
13215
13185
  // Only component views should be added to the view tree directly. Embedded views are
13216
13186
  // accessed through their containers because they may be removed / re-added later.
13217
13187
  const rendererFactory = lView[RENDERER_FACTORY];
@@ -13538,63 +13508,32 @@ function markViewDirty(lView) {
13538
13508
  }
13539
13509
  return null;
13540
13510
  }
13541
- function tickRootContext(rootContext) {
13542
- for (let i = 0; i < rootContext.components.length; i++) {
13543
- const rootComponent = rootContext.components[i];
13544
- const lView = readPatchedLView(rootComponent);
13545
- // We might not have an `LView` if the component was destroyed.
13546
- if (lView !== null) {
13547
- const tView = lView[TVIEW];
13548
- renderComponentOrTemplate(tView, lView, tView.template, rootComponent);
13549
- }
13550
- }
13551
- }
13552
- function detectChangesInternal(tView, lView, context) {
13511
+ function detectChangesInternal(tView, lView, context, notifyErrorHandler = true) {
13553
13512
  const rendererFactory = lView[RENDERER_FACTORY];
13554
- if (rendererFactory.begin)
13513
+ // Check no changes mode is a dev only mode used to verify that bindings have not changed
13514
+ // since they were assigned. We do not want to invoke renderer factory functions in that mode
13515
+ // to avoid any possible side-effects.
13516
+ const checkNoChangesMode = !!ngDevMode && isInCheckNoChangesMode();
13517
+ if (!checkNoChangesMode && rendererFactory.begin)
13555
13518
  rendererFactory.begin();
13556
13519
  try {
13557
13520
  refreshView(tView, lView, tView.template, context);
13558
13521
  }
13559
13522
  catch (error) {
13560
- handleError(lView, error);
13523
+ if (notifyErrorHandler) {
13524
+ handleError(lView, error);
13525
+ }
13561
13526
  throw error;
13562
13527
  }
13563
13528
  finally {
13564
- if (rendererFactory.end)
13529
+ if (!checkNoChangesMode && rendererFactory.end)
13565
13530
  rendererFactory.end();
13566
13531
  }
13567
13532
  }
13568
- /**
13569
- * Synchronously perform change detection on a root view and its components.
13570
- *
13571
- * @param lView The view which the change detection should be performed on.
13572
- */
13573
- function detectChangesInRootView(lView) {
13574
- tickRootContext(lView[CONTEXT]);
13575
- }
13576
- function checkNoChangesInternal(tView, view, context) {
13577
- setIsInCheckNoChangesMode(true);
13578
- try {
13579
- detectChangesInternal(tView, view, context);
13580
- }
13581
- finally {
13582
- setIsInCheckNoChangesMode(false);
13583
- }
13584
- }
13585
- /**
13586
- * Checks the change detector on a root view and its components, and throws if any changes are
13587
- * detected.
13588
- *
13589
- * This is used in development mode to verify that running change detection doesn't
13590
- * introduce other changes.
13591
- *
13592
- * @param lView The view which the change detection should be checked on.
13593
- */
13594
- function checkNoChangesInRootView(lView) {
13533
+ function checkNoChangesInternal(tView, lView, context, notifyErrorHandler = true) {
13595
13534
  setIsInCheckNoChangesMode(true);
13596
13535
  try {
13597
- detectChangesInRootView(lView);
13536
+ detectChangesInternal(tView, lView, context, notifyErrorHandler);
13598
13537
  }
13599
13538
  finally {
13600
13539
  setIsInCheckNoChangesMode(false);
@@ -14087,11 +14026,17 @@ class RootViewRef extends ViewRef {
14087
14026
  this._view = _view;
14088
14027
  }
14089
14028
  detectChanges() {
14090
- detectChangesInRootView(this._view);
14029
+ const lView = this._view;
14030
+ const tView = lView[TVIEW];
14031
+ const context = lView[CONTEXT];
14032
+ detectChangesInternal(tView, lView, context, false);
14091
14033
  }
14092
14034
  checkNoChanges() {
14093
14035
  if (ngDevMode) {
14094
- checkNoChangesInRootView(this._view);
14036
+ const lView = this._view;
14037
+ const tView = lView[TVIEW];
14038
+ const context = lView[CONTEXT];
14039
+ checkNoChangesInternal(tView, lView, context, false);
14095
14040
  }
14096
14041
  }
14097
14042
  get context() {
@@ -14158,7 +14103,7 @@ class ChainedInjector {
14158
14103
  }
14159
14104
  }
14160
14105
  /**
14161
- * Render3 implementation of {@link viewEngine_ComponentFactory}.
14106
+ * ComponentFactory interface implementation.
14162
14107
  */
14163
14108
  class ComponentFactory extends ComponentFactory$1 {
14164
14109
  /**
@@ -14208,10 +14153,9 @@ class ComponentFactory extends ComponentFactory$1 {
14208
14153
  createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
14209
14154
  const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
14210
14155
  16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
14211
- const rootContext = createRootContext();
14212
14156
  // Create the root view. Uses empty TView and ContentTemplate.
14213
14157
  const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
14214
- const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
14158
+ const rootLView = createLView(null, rootTView, null, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
14215
14159
  // rootView is the parent when bootstrapping
14216
14160
  // TODO(misko): it looks like we are entering view here but we don't really need to as
14217
14161
  // `renderView` does that. However as the code is written it is needed because
@@ -14255,7 +14199,8 @@ class ComponentFactory extends ComponentFactory$1 {
14255
14199
  // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
14256
14200
  // executed here?
14257
14201
  // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
14258
- component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
14202
+ component =
14203
+ createRootComponent(componentView, this.componentDef, rootLView, [LifecycleHooksFeature]);
14259
14204
  renderView(rootTView, rootLView, null);
14260
14205
  }
14261
14206
  finally {
@@ -14361,7 +14306,7 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14361
14306
  }
14362
14307
  }
14363
14308
  const viewRenderer = rendererFactory.createRenderer(rNode, def);
14364
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14309
+ const componentView = createLView(rootView, getOrCreateComponentTView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14365
14310
  if (tView.firstCreatePass) {
14366
14311
  diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
14367
14312
  markAsComponentHost(tView, tNode);
@@ -14375,12 +14320,13 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14375
14320
  * Creates a root component and sets it up with features and host bindings.Shared by
14376
14321
  * renderComponent() and ViewContainerRef.createComponent().
14377
14322
  */
14378
- function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
14323
+ function createRootComponent(componentView, componentDef, rootLView, hostFeatures) {
14379
14324
  const tView = rootLView[TVIEW];
14380
14325
  // Create directive instance with factory() and store at next index in viewData
14381
14326
  const component = instantiateRootComponent(tView, rootLView, componentDef);
14382
- rootContext.components.push(component);
14383
- componentView[CONTEXT] = component;
14327
+ // Root view only contains an instance of this component,
14328
+ // so we use a reference to that component instance as a context.
14329
+ componentView[CONTEXT] = rootLView[CONTEXT] = component;
14384
14330
  if (hostFeatures !== null) {
14385
14331
  for (const feature of hostFeatures) {
14386
14332
  feature(component, componentDef);
@@ -14404,9 +14350,6 @@ function createRootComponent(componentView, componentDef, rootLView, rootContext
14404
14350
  }
14405
14351
  return component;
14406
14352
  }
14407
- function createRootContext() {
14408
- return { components: [] };
14409
- }
14410
14353
  /**
14411
14354
  * Used to enable lifecycle hooks on the root component.
14412
14355
  *
@@ -21299,9 +21242,6 @@ function walkIcuTree(tView, tIcu, lView, sharedUpdateOpCodes, create, remove, up
21299
21242
  if (URI_ATTRS[lowerAttrName]) {
21300
21243
  generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, _sanitizeUrl);
21301
21244
  }
21302
- else if (SRCSET_ATTRS[lowerAttrName]) {
21303
- generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, sanitizeSrcset);
21304
- }
21305
21245
  else {
21306
21246
  generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, null);
21307
21247
  }
@@ -22270,7 +22210,7 @@ function getOwningComponent(elementOrDir) {
22270
22210
  */
22271
22211
  function getRootComponents(elementOrDir) {
22272
22212
  const lView = readPatchedLView(elementOrDir);
22273
- return lView !== null ? [...getRootContext(lView).components] : [];
22213
+ return lView !== null ? [getRootContext(lView)] : [];
22274
22214
  }
22275
22215
  /**
22276
22216
  * Retrieves an `Injector` associated with an element, component or directive instance.