@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.
package/fesm2020/core.mjs CHANGED
@@ -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
  */
@@ -3262,7 +3262,7 @@ function injectAttributeImpl(tNode, attrNameToInject) {
3262
3262
  return null;
3263
3263
  }
3264
3264
  function notFoundValueOrThrow(notFoundValue, token, flags) {
3265
- if (flags & InjectFlags.Optional) {
3265
+ if ((flags & InjectFlags.Optional) || notFoundValue !== undefined) {
3266
3266
  return notFoundValue;
3267
3267
  }
3268
3268
  else {
@@ -3279,7 +3279,7 @@ function notFoundValueOrThrow(notFoundValue, token, flags) {
3279
3279
  * @returns the value from the injector or throws an exception
3280
3280
  */
3281
3281
  function lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue) {
3282
- if (flags & InjectFlags.Optional && notFoundValue === undefined) {
3282
+ if ((flags & InjectFlags.Optional) && notFoundValue === undefined) {
3283
3283
  // This must be set or the NullInjector will throw for optional deps
3284
3284
  notFoundValue = null;
3285
3285
  }
@@ -5802,10 +5802,6 @@ function _sanitizeUrl(url) {
5802
5802
  }
5803
5803
  return 'unsafe:' + url;
5804
5804
  }
5805
- function sanitizeSrcset(srcset) {
5806
- srcset = String(srcset);
5807
- return srcset.split(',').map((srcset) => _sanitizeUrl(srcset.trim())).join(', ');
5808
- }
5809
5805
 
5810
5806
  /**
5811
5807
  * @license
@@ -5852,12 +5848,10 @@ const INLINE_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, tagSet('a,abbr,a
5852
5848
  const VALID_ELEMENTS = merge(VOID_ELEMENTS, BLOCK_ELEMENTS, INLINE_ELEMENTS, OPTIONAL_END_TAG_ELEMENTS);
5853
5849
  // Attributes that have href and hence need to be sanitized
5854
5850
  const URI_ATTRS = tagSet('background,cite,href,itemtype,longdesc,poster,src,xlink:href');
5855
- // Attributes that have special href set hence need to be sanitized
5856
- const SRCSET_ATTRS = tagSet('srcset');
5857
5851
  const HTML_ATTRS = tagSet('abbr,accesskey,align,alt,autoplay,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,' +
5858
5852
  'compact,controls,coords,datetime,default,dir,download,face,headers,height,hidden,hreflang,hspace,' +
5859
5853
  'ismap,itemscope,itemprop,kind,label,lang,language,loop,media,muted,nohref,nowrap,open,preload,rel,rev,role,rows,rowspan,rules,' +
5860
- 'scope,scrolling,shape,size,sizes,span,srclang,start,summary,tabindex,target,title,translate,type,usemap,' +
5854
+ 'scope,scrolling,shape,size,sizes,span,srclang,srcset,start,summary,tabindex,target,title,translate,type,usemap,' +
5861
5855
  'valign,value,vspace,width');
5862
5856
  // Accessibility attributes as per WAI-ARIA 1.1 (W3C Working Draft 14 December 2018)
5863
5857
  const ARIA_ATTRS = tagSet('aria-activedescendant,aria-atomic,aria-autocomplete,aria-busy,aria-checked,aria-colcount,aria-colindex,' +
@@ -5873,7 +5867,7 @@ const ARIA_ATTRS = tagSet('aria-activedescendant,aria-atomic,aria-autocomplete,a
5873
5867
  // NB: Sanitization does not allow <form> elements or other active elements (<button> etc). Those
5874
5868
  // can be sanitized, but they increase security surface area without a legitimate use case, so they
5875
5869
  // are left out here.
5876
- const VALID_ATTRS = merge(URI_ATTRS, SRCSET_ATTRS, HTML_ATTRS, ARIA_ATTRS);
5870
+ const VALID_ATTRS = merge(URI_ATTRS, HTML_ATTRS, ARIA_ATTRS);
5877
5871
  // Elements whose content should not be traversed/preserved, if the elements themselves are invalid.
5878
5872
  //
5879
5873
  // Typically, `<invalid>Some content</invalid>` would traverse (and in this case preserve)
@@ -5956,8 +5950,6 @@ class SanitizingHtmlSerializer {
5956
5950
  // TODO(martinprobst): Special case image URIs for data:image/...
5957
5951
  if (URI_ATTRS[lower])
5958
5952
  value = _sanitizeUrl(value);
5959
- if (SRCSET_ATTRS[lower])
5960
- value = sanitizeSrcset(value);
5961
5953
  this.buf.push(' ', attrName, '="', encodeEntities(value), '"');
5962
5954
  }
5963
5955
  this.buf.push('>');
@@ -7258,7 +7250,7 @@ class Version {
7258
7250
  /**
7259
7251
  * @publicApi
7260
7252
  */
7261
- const VERSION = new Version('15.0.0-next.0');
7253
+ const VERSION = new Version('15.0.0-next.2');
7262
7254
 
7263
7255
  /**
7264
7256
  * @license
@@ -7561,7 +7553,7 @@ function getTemplateLocationDetails(lView) {
7561
7553
  * that the `CommonModule` should also be included.
7562
7554
  */
7563
7555
  const KNOWN_CONTROL_FLOW_DIRECTIVES = new Map([
7564
- ['ngIf', 'NgIf'], ['ngFor', 'NgForOf'], ['ngSwitchCase', 'NgSwitchCase'],
7556
+ ['ngIf', 'NgIf'], ['ngFor', 'NgFor'], ['ngSwitchCase', 'NgSwitchCase'],
7565
7557
  ['ngSwitchDefault', 'NgSwitchDefault']
7566
7558
  ]);
7567
7559
  /**
@@ -8365,16 +8357,16 @@ function getRootView(componentOrLView) {
8365
8357
  return lView;
8366
8358
  }
8367
8359
  /**
8368
- * Returns the `RootContext` instance that is associated with
8369
- * the application where the target is situated. It does this by walking the parent views until it
8370
- * gets to the root view, then getting the context off of that.
8360
+ * Returns the context information associated with the application where the target is situated. It
8361
+ * does this by walking the parent views until it gets to the root view, then getting the context
8362
+ * off of that.
8371
8363
  *
8372
8364
  * @param viewOrComponent the `LView` or component to get the root context for.
8373
8365
  */
8374
8366
  function getRootContext(viewOrComponent) {
8375
8367
  const rootView = getRootView(viewOrComponent);
8376
8368
  ngDevMode &&
8377
- assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');
8369
+ assertDefined(rootView[CONTEXT], 'Root view has no context. Perhaps it is disconnected?');
8378
8370
  return rootView[CONTEXT];
8379
8371
  }
8380
8372
  /**
@@ -12078,28 +12070,6 @@ function refreshView(tView, lView, templateFn, context) {
12078
12070
  leaveView();
12079
12071
  }
12080
12072
  }
12081
- function renderComponentOrTemplate(tView, lView, templateFn, context) {
12082
- const rendererFactory = lView[RENDERER_FACTORY];
12083
- // Check no changes mode is a dev only mode used to verify that bindings have not changed
12084
- // since they were assigned. We do not want to invoke renderer factory functions in that mode
12085
- // to avoid any possible side-effects.
12086
- const checkNoChangesMode = !!ngDevMode && isInCheckNoChangesMode();
12087
- const creationModeIsActive = isCreationMode(lView);
12088
- try {
12089
- if (!checkNoChangesMode && !creationModeIsActive && rendererFactory.begin) {
12090
- rendererFactory.begin();
12091
- }
12092
- if (creationModeIsActive) {
12093
- renderView(tView, lView, context);
12094
- }
12095
- refreshView(tView, lView, templateFn, context);
12096
- }
12097
- finally {
12098
- if (!checkNoChangesMode && !creationModeIsActive && rendererFactory.end) {
12099
- rendererFactory.end();
12100
- }
12101
- }
12102
- }
12103
12073
  function executeTemplate(tView, lView, templateFn, rf, context) {
12104
12074
  const prevSelectedIndex = getSelectedIndex();
12105
12075
  const isUpdatePhase = rf & 2 /* RenderFlags.Update */;
@@ -12170,7 +12140,7 @@ function saveResolvedLocalsInData(viewData, tNode, localRefExtractor = getNative
12170
12140
  * @param def ComponentDef
12171
12141
  * @returns TView
12172
12142
  */
12173
- function getOrCreateTComponentView(def) {
12143
+ function getOrCreateComponentTView(def) {
12174
12144
  const tView = def.tView;
12175
12145
  // Create a TView if there isn't one, or recreate it if the first create pass didn't
12176
12146
  // complete successfully since we can't know for sure whether it's in a usable shape.
@@ -12880,7 +12850,7 @@ function configureViewWithDirective(tView, tNode, lView, directiveIndex, def) {
12880
12850
  }
12881
12851
  function addComponentLogic(lView, hostTNode, def) {
12882
12852
  const native = getNativeByTNode(hostTNode, lView);
12883
- const tView = getOrCreateTComponentView(def);
12853
+ const tView = getOrCreateComponentTView(def);
12884
12854
  // Only component views should be added to the view tree directly. Embedded views are
12885
12855
  // accessed through their containers because they may be removed / re-added later.
12886
12856
  const rendererFactory = lView[RENDERER_FACTORY];
@@ -13207,63 +13177,32 @@ function markViewDirty(lView) {
13207
13177
  }
13208
13178
  return null;
13209
13179
  }
13210
- function tickRootContext(rootContext) {
13211
- for (let i = 0; i < rootContext.components.length; i++) {
13212
- const rootComponent = rootContext.components[i];
13213
- const lView = readPatchedLView(rootComponent);
13214
- // We might not have an `LView` if the component was destroyed.
13215
- if (lView !== null) {
13216
- const tView = lView[TVIEW];
13217
- renderComponentOrTemplate(tView, lView, tView.template, rootComponent);
13218
- }
13219
- }
13220
- }
13221
- function detectChangesInternal(tView, lView, context) {
13180
+ function detectChangesInternal(tView, lView, context, notifyErrorHandler = true) {
13222
13181
  const rendererFactory = lView[RENDERER_FACTORY];
13223
- if (rendererFactory.begin)
13182
+ // Check no changes mode is a dev only mode used to verify that bindings have not changed
13183
+ // since they were assigned. We do not want to invoke renderer factory functions in that mode
13184
+ // to avoid any possible side-effects.
13185
+ const checkNoChangesMode = !!ngDevMode && isInCheckNoChangesMode();
13186
+ if (!checkNoChangesMode && rendererFactory.begin)
13224
13187
  rendererFactory.begin();
13225
13188
  try {
13226
13189
  refreshView(tView, lView, tView.template, context);
13227
13190
  }
13228
13191
  catch (error) {
13229
- handleError(lView, error);
13192
+ if (notifyErrorHandler) {
13193
+ handleError(lView, error);
13194
+ }
13230
13195
  throw error;
13231
13196
  }
13232
13197
  finally {
13233
- if (rendererFactory.end)
13198
+ if (!checkNoChangesMode && rendererFactory.end)
13234
13199
  rendererFactory.end();
13235
13200
  }
13236
13201
  }
13237
- /**
13238
- * Synchronously perform change detection on a root view and its components.
13239
- *
13240
- * @param lView The view which the change detection should be performed on.
13241
- */
13242
- function detectChangesInRootView(lView) {
13243
- tickRootContext(lView[CONTEXT]);
13244
- }
13245
- function checkNoChangesInternal(tView, view, context) {
13246
- setIsInCheckNoChangesMode(true);
13247
- try {
13248
- detectChangesInternal(tView, view, context);
13249
- }
13250
- finally {
13251
- setIsInCheckNoChangesMode(false);
13252
- }
13253
- }
13254
- /**
13255
- * Checks the change detector on a root view and its components, and throws if any changes are
13256
- * detected.
13257
- *
13258
- * This is used in development mode to verify that running change detection doesn't
13259
- * introduce other changes.
13260
- *
13261
- * @param lView The view which the change detection should be checked on.
13262
- */
13263
- function checkNoChangesInRootView(lView) {
13202
+ function checkNoChangesInternal(tView, lView, context, notifyErrorHandler = true) {
13264
13203
  setIsInCheckNoChangesMode(true);
13265
13204
  try {
13266
- detectChangesInRootView(lView);
13205
+ detectChangesInternal(tView, lView, context, notifyErrorHandler);
13267
13206
  }
13268
13207
  finally {
13269
13208
  setIsInCheckNoChangesMode(false);
@@ -13756,11 +13695,17 @@ class RootViewRef extends ViewRef$1 {
13756
13695
  this._view = _view;
13757
13696
  }
13758
13697
  detectChanges() {
13759
- detectChangesInRootView(this._view);
13698
+ const lView = this._view;
13699
+ const tView = lView[TVIEW];
13700
+ const context = lView[CONTEXT];
13701
+ detectChangesInternal(tView, lView, context, false);
13760
13702
  }
13761
13703
  checkNoChanges() {
13762
13704
  if (ngDevMode) {
13763
- checkNoChangesInRootView(this._view);
13705
+ const lView = this._view;
13706
+ const tView = lView[TVIEW];
13707
+ const context = lView[CONTEXT];
13708
+ checkNoChangesInternal(tView, lView, context, false);
13764
13709
  }
13765
13710
  }
13766
13711
  get context() {
@@ -13827,7 +13772,7 @@ class ChainedInjector {
13827
13772
  }
13828
13773
  }
13829
13774
  /**
13830
- * Render3 implementation of {@link viewEngine_ComponentFactory}.
13775
+ * ComponentFactory interface implementation.
13831
13776
  */
13832
13777
  class ComponentFactory extends ComponentFactory$1 {
13833
13778
  /**
@@ -13877,10 +13822,9 @@ class ComponentFactory extends ComponentFactory$1 {
13877
13822
  createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
13878
13823
  const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
13879
13824
  16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
13880
- const rootContext = createRootContext();
13881
13825
  // Create the root view. Uses empty TView and ContentTemplate.
13882
13826
  const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
13883
- const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
13827
+ const rootLView = createLView(null, rootTView, null, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
13884
13828
  // rootView is the parent when bootstrapping
13885
13829
  // TODO(misko): it looks like we are entering view here but we don't really need to as
13886
13830
  // `renderView` does that. However as the code is written it is needed because
@@ -13924,7 +13868,8 @@ class ComponentFactory extends ComponentFactory$1 {
13924
13868
  // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
13925
13869
  // executed here?
13926
13870
  // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
13927
- component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
13871
+ component =
13872
+ createRootComponent(componentView, this.componentDef, rootLView, [LifecycleHooksFeature]);
13928
13873
  renderView(rootTView, rootLView, null);
13929
13874
  }
13930
13875
  finally {
@@ -14030,7 +13975,7 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14030
13975
  }
14031
13976
  }
14032
13977
  const viewRenderer = rendererFactory.createRenderer(rNode, def);
14033
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
13978
+ const componentView = createLView(rootView, getOrCreateComponentTView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14034
13979
  if (tView.firstCreatePass) {
14035
13980
  diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
14036
13981
  markAsComponentHost(tView, tNode);
@@ -14044,12 +13989,13 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14044
13989
  * Creates a root component and sets it up with features and host bindings.Shared by
14045
13990
  * renderComponent() and ViewContainerRef.createComponent().
14046
13991
  */
14047
- function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
13992
+ function createRootComponent(componentView, componentDef, rootLView, hostFeatures) {
14048
13993
  const tView = rootLView[TVIEW];
14049
13994
  // Create directive instance with factory() and store at next index in viewData
14050
13995
  const component = instantiateRootComponent(tView, rootLView, componentDef);
14051
- rootContext.components.push(component);
14052
- componentView[CONTEXT] = component;
13996
+ // Root view only contains an instance of this component,
13997
+ // so we use a reference to that component instance as a context.
13998
+ componentView[CONTEXT] = rootLView[CONTEXT] = component;
14053
13999
  if (hostFeatures !== null) {
14054
14000
  for (const feature of hostFeatures) {
14055
14001
  feature(component, componentDef);
@@ -14073,9 +14019,6 @@ function createRootComponent(componentView, componentDef, rootLView, rootContext
14073
14019
  }
14074
14020
  return component;
14075
14021
  }
14076
- function createRootContext() {
14077
- return { components: [] };
14078
- }
14079
14022
  /**
14080
14023
  * Used to enable lifecycle hooks on the root component.
14081
14024
  *
@@ -20968,9 +20911,6 @@ function walkIcuTree(tView, tIcu, lView, sharedUpdateOpCodes, create, remove, up
20968
20911
  if (URI_ATTRS[lowerAttrName]) {
20969
20912
  generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, _sanitizeUrl);
20970
20913
  }
20971
- else if (SRCSET_ATTRS[lowerAttrName]) {
20972
- generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, sanitizeSrcset);
20973
- }
20974
20914
  else {
20975
20915
  generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, null);
20976
20916
  }
@@ -21939,7 +21879,7 @@ function getOwningComponent(elementOrDir) {
21939
21879
  */
21940
21880
  function getRootComponents(elementOrDir) {
21941
21881
  const lView = readPatchedLView(elementOrDir);
21942
- return lView !== null ? [...getRootContext(lView).components] : [];
21882
+ return lView !== null ? [getRootContext(lView)] : [];
21943
21883
  }
21944
21884
  /**
21945
21885
  * Retrieves an `Injector` associated with an element, component or directive instance.