@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/fesm2015/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
  */
@@ -3255,7 +3255,7 @@ function injectAttributeImpl(tNode, attrNameToInject) {
3255
3255
  return null;
3256
3256
  }
3257
3257
  function notFoundValueOrThrow(notFoundValue, token, flags) {
3258
- if (flags & InjectFlags.Optional) {
3258
+ if ((flags & InjectFlags.Optional) || notFoundValue !== undefined) {
3259
3259
  return notFoundValue;
3260
3260
  }
3261
3261
  else {
@@ -3272,7 +3272,7 @@ function notFoundValueOrThrow(notFoundValue, token, flags) {
3272
3272
  * @returns the value from the injector or throws an exception
3273
3273
  */
3274
3274
  function lookupTokenUsingModuleInjector(lView, token, flags, notFoundValue) {
3275
- if (flags & InjectFlags.Optional && notFoundValue === undefined) {
3275
+ if ((flags & InjectFlags.Optional) && notFoundValue === undefined) {
3276
3276
  // This must be set or the NullInjector will throw for optional deps
3277
3277
  notFoundValue = null;
3278
3278
  }
@@ -5787,10 +5787,6 @@ function _sanitizeUrl(url) {
5787
5787
  }
5788
5788
  return 'unsafe:' + url;
5789
5789
  }
5790
- function sanitizeSrcset(srcset) {
5791
- srcset = String(srcset);
5792
- return srcset.split(',').map((srcset) => _sanitizeUrl(srcset.trim())).join(', ');
5793
- }
5794
5790
 
5795
5791
  /**
5796
5792
  * @license
@@ -5837,12 +5833,10 @@ const INLINE_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, tagSet('a,abbr,a
5837
5833
  const VALID_ELEMENTS = merge(VOID_ELEMENTS, BLOCK_ELEMENTS, INLINE_ELEMENTS, OPTIONAL_END_TAG_ELEMENTS);
5838
5834
  // Attributes that have href and hence need to be sanitized
5839
5835
  const URI_ATTRS = tagSet('background,cite,href,itemtype,longdesc,poster,src,xlink:href');
5840
- // Attributes that have special href set hence need to be sanitized
5841
- const SRCSET_ATTRS = tagSet('srcset');
5842
5836
  const HTML_ATTRS = tagSet('abbr,accesskey,align,alt,autoplay,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,' +
5843
5837
  'compact,controls,coords,datetime,default,dir,download,face,headers,height,hidden,hreflang,hspace,' +
5844
5838
  'ismap,itemscope,itemprop,kind,label,lang,language,loop,media,muted,nohref,nowrap,open,preload,rel,rev,role,rows,rowspan,rules,' +
5845
- 'scope,scrolling,shape,size,sizes,span,srclang,start,summary,tabindex,target,title,translate,type,usemap,' +
5839
+ 'scope,scrolling,shape,size,sizes,span,srclang,srcset,start,summary,tabindex,target,title,translate,type,usemap,' +
5846
5840
  'valign,value,vspace,width');
5847
5841
  // Accessibility attributes as per WAI-ARIA 1.1 (W3C Working Draft 14 December 2018)
5848
5842
  const ARIA_ATTRS = tagSet('aria-activedescendant,aria-atomic,aria-autocomplete,aria-busy,aria-checked,aria-colcount,aria-colindex,' +
@@ -5858,7 +5852,7 @@ const ARIA_ATTRS = tagSet('aria-activedescendant,aria-atomic,aria-autocomplete,a
5858
5852
  // NB: Sanitization does not allow <form> elements or other active elements (<button> etc). Those
5859
5853
  // can be sanitized, but they increase security surface area without a legitimate use case, so they
5860
5854
  // are left out here.
5861
- const VALID_ATTRS = merge(URI_ATTRS, SRCSET_ATTRS, HTML_ATTRS, ARIA_ATTRS);
5855
+ const VALID_ATTRS = merge(URI_ATTRS, HTML_ATTRS, ARIA_ATTRS);
5862
5856
  // Elements whose content should not be traversed/preserved, if the elements themselves are invalid.
5863
5857
  //
5864
5858
  // Typically, `<invalid>Some content</invalid>` would traverse (and in this case preserve)
@@ -5941,8 +5935,6 @@ class SanitizingHtmlSerializer {
5941
5935
  // TODO(martinprobst): Special case image URIs for data:image/...
5942
5936
  if (URI_ATTRS[lower])
5943
5937
  value = _sanitizeUrl(value);
5944
- if (SRCSET_ATTRS[lower])
5945
- value = sanitizeSrcset(value);
5946
5938
  this.buf.push(' ', attrName, '="', encodeEntities(value), '"');
5947
5939
  }
5948
5940
  this.buf.push('>');
@@ -7243,7 +7235,7 @@ class Version {
7243
7235
  /**
7244
7236
  * @publicApi
7245
7237
  */
7246
- const VERSION = new Version('15.0.0-next.0');
7238
+ const VERSION = new Version('15.0.0-next.2');
7247
7239
 
7248
7240
  /**
7249
7241
  * @license
@@ -7547,7 +7539,7 @@ function getTemplateLocationDetails(lView) {
7547
7539
  * that the `CommonModule` should also be included.
7548
7540
  */
7549
7541
  const KNOWN_CONTROL_FLOW_DIRECTIVES = new Map([
7550
- ['ngIf', 'NgIf'], ['ngFor', 'NgForOf'], ['ngSwitchCase', 'NgSwitchCase'],
7542
+ ['ngIf', 'NgIf'], ['ngFor', 'NgFor'], ['ngSwitchCase', 'NgSwitchCase'],
7551
7543
  ['ngSwitchDefault', 'NgSwitchDefault']
7552
7544
  ]);
7553
7545
  /**
@@ -8351,16 +8343,16 @@ function getRootView(componentOrLView) {
8351
8343
  return lView;
8352
8344
  }
8353
8345
  /**
8354
- * Returns the `RootContext` instance that is associated with
8355
- * the application where the target is situated. It does this by walking the parent views until it
8356
- * gets to the root view, then getting the context off of that.
8346
+ * Returns the context information associated with the application where the target is situated. It
8347
+ * does this by walking the parent views until it gets to the root view, then getting the context
8348
+ * off of that.
8357
8349
  *
8358
8350
  * @param viewOrComponent the `LView` or component to get the root context for.
8359
8351
  */
8360
8352
  function getRootContext(viewOrComponent) {
8361
8353
  const rootView = getRootView(viewOrComponent);
8362
8354
  ngDevMode &&
8363
- assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');
8355
+ assertDefined(rootView[CONTEXT], 'Root view has no context. Perhaps it is disconnected?');
8364
8356
  return rootView[CONTEXT];
8365
8357
  }
8366
8358
  /**
@@ -12065,28 +12057,6 @@ function refreshView(tView, lView, templateFn, context) {
12065
12057
  leaveView();
12066
12058
  }
12067
12059
  }
12068
- function renderComponentOrTemplate(tView, lView, templateFn, context) {
12069
- const rendererFactory = lView[RENDERER_FACTORY];
12070
- // Check no changes mode is a dev only mode used to verify that bindings have not changed
12071
- // since they were assigned. We do not want to invoke renderer factory functions in that mode
12072
- // to avoid any possible side-effects.
12073
- const checkNoChangesMode = !!ngDevMode && isInCheckNoChangesMode();
12074
- const creationModeIsActive = isCreationMode(lView);
12075
- try {
12076
- if (!checkNoChangesMode && !creationModeIsActive && rendererFactory.begin) {
12077
- rendererFactory.begin();
12078
- }
12079
- if (creationModeIsActive) {
12080
- renderView(tView, lView, context);
12081
- }
12082
- refreshView(tView, lView, templateFn, context);
12083
- }
12084
- finally {
12085
- if (!checkNoChangesMode && !creationModeIsActive && rendererFactory.end) {
12086
- rendererFactory.end();
12087
- }
12088
- }
12089
- }
12090
12060
  function executeTemplate(tView, lView, templateFn, rf, context) {
12091
12061
  const prevSelectedIndex = getSelectedIndex();
12092
12062
  const isUpdatePhase = rf & 2 /* RenderFlags.Update */;
@@ -12157,7 +12127,7 @@ function saveResolvedLocalsInData(viewData, tNode, localRefExtractor = getNative
12157
12127
  * @param def ComponentDef
12158
12128
  * @returns TView
12159
12129
  */
12160
- function getOrCreateTComponentView(def) {
12130
+ function getOrCreateComponentTView(def) {
12161
12131
  const tView = def.tView;
12162
12132
  // Create a TView if there isn't one, or recreate it if the first create pass didn't
12163
12133
  // complete successfully since we can't know for sure whether it's in a usable shape.
@@ -12868,7 +12838,7 @@ function configureViewWithDirective(tView, tNode, lView, directiveIndex, def) {
12868
12838
  }
12869
12839
  function addComponentLogic(lView, hostTNode, def) {
12870
12840
  const native = getNativeByTNode(hostTNode, lView);
12871
- const tView = getOrCreateTComponentView(def);
12841
+ const tView = getOrCreateComponentTView(def);
12872
12842
  // Only component views should be added to the view tree directly. Embedded views are
12873
12843
  // accessed through their containers because they may be removed / re-added later.
12874
12844
  const rendererFactory = lView[RENDERER_FACTORY];
@@ -13195,63 +13165,32 @@ function markViewDirty(lView) {
13195
13165
  }
13196
13166
  return null;
13197
13167
  }
13198
- function tickRootContext(rootContext) {
13199
- for (let i = 0; i < rootContext.components.length; i++) {
13200
- const rootComponent = rootContext.components[i];
13201
- const lView = readPatchedLView(rootComponent);
13202
- // We might not have an `LView` if the component was destroyed.
13203
- if (lView !== null) {
13204
- const tView = lView[TVIEW];
13205
- renderComponentOrTemplate(tView, lView, tView.template, rootComponent);
13206
- }
13207
- }
13208
- }
13209
- function detectChangesInternal(tView, lView, context) {
13168
+ function detectChangesInternal(tView, lView, context, notifyErrorHandler = true) {
13210
13169
  const rendererFactory = lView[RENDERER_FACTORY];
13211
- if (rendererFactory.begin)
13170
+ // Check no changes mode is a dev only mode used to verify that bindings have not changed
13171
+ // since they were assigned. We do not want to invoke renderer factory functions in that mode
13172
+ // to avoid any possible side-effects.
13173
+ const checkNoChangesMode = !!ngDevMode && isInCheckNoChangesMode();
13174
+ if (!checkNoChangesMode && rendererFactory.begin)
13212
13175
  rendererFactory.begin();
13213
13176
  try {
13214
13177
  refreshView(tView, lView, tView.template, context);
13215
13178
  }
13216
13179
  catch (error) {
13217
- handleError(lView, error);
13180
+ if (notifyErrorHandler) {
13181
+ handleError(lView, error);
13182
+ }
13218
13183
  throw error;
13219
13184
  }
13220
13185
  finally {
13221
- if (rendererFactory.end)
13186
+ if (!checkNoChangesMode && rendererFactory.end)
13222
13187
  rendererFactory.end();
13223
13188
  }
13224
13189
  }
13225
- /**
13226
- * Synchronously perform change detection on a root view and its components.
13227
- *
13228
- * @param lView The view which the change detection should be performed on.
13229
- */
13230
- function detectChangesInRootView(lView) {
13231
- tickRootContext(lView[CONTEXT]);
13232
- }
13233
- function checkNoChangesInternal(tView, view, context) {
13234
- setIsInCheckNoChangesMode(true);
13235
- try {
13236
- detectChangesInternal(tView, view, context);
13237
- }
13238
- finally {
13239
- setIsInCheckNoChangesMode(false);
13240
- }
13241
- }
13242
- /**
13243
- * Checks the change detector on a root view and its components, and throws if any changes are
13244
- * detected.
13245
- *
13246
- * This is used in development mode to verify that running change detection doesn't
13247
- * introduce other changes.
13248
- *
13249
- * @param lView The view which the change detection should be checked on.
13250
- */
13251
- function checkNoChangesInRootView(lView) {
13190
+ function checkNoChangesInternal(tView, lView, context, notifyErrorHandler = true) {
13252
13191
  setIsInCheckNoChangesMode(true);
13253
13192
  try {
13254
- detectChangesInRootView(lView);
13193
+ detectChangesInternal(tView, lView, context, notifyErrorHandler);
13255
13194
  }
13256
13195
  finally {
13257
13196
  setIsInCheckNoChangesMode(false);
@@ -13744,11 +13683,17 @@ class RootViewRef extends ViewRef$1 {
13744
13683
  this._view = _view;
13745
13684
  }
13746
13685
  detectChanges() {
13747
- detectChangesInRootView(this._view);
13686
+ const lView = this._view;
13687
+ const tView = lView[TVIEW];
13688
+ const context = lView[CONTEXT];
13689
+ detectChangesInternal(tView, lView, context, false);
13748
13690
  }
13749
13691
  checkNoChanges() {
13750
13692
  if (ngDevMode) {
13751
- checkNoChangesInRootView(this._view);
13693
+ const lView = this._view;
13694
+ const tView = lView[TVIEW];
13695
+ const context = lView[CONTEXT];
13696
+ checkNoChangesInternal(tView, lView, context, false);
13752
13697
  }
13753
13698
  }
13754
13699
  get context() {
@@ -13815,7 +13760,7 @@ class ChainedInjector {
13815
13760
  }
13816
13761
  }
13817
13762
  /**
13818
- * Render3 implementation of {@link viewEngine_ComponentFactory}.
13763
+ * ComponentFactory interface implementation.
13819
13764
  */
13820
13765
  class ComponentFactory extends ComponentFactory$1 {
13821
13766
  /**
@@ -13865,10 +13810,9 @@ class ComponentFactory extends ComponentFactory$1 {
13865
13810
  createElementNode(rendererFactory.createRenderer(null, this.componentDef), elementName, getNamespace(elementName));
13866
13811
  const rootFlags = this.componentDef.onPush ? 32 /* LViewFlags.Dirty */ | 256 /* LViewFlags.IsRoot */ :
13867
13812
  16 /* LViewFlags.CheckAlways */ | 256 /* LViewFlags.IsRoot */;
13868
- const rootContext = createRootContext();
13869
13813
  // Create the root view. Uses empty TView and ContentTemplate.
13870
13814
  const rootTView = createTView(0 /* TViewType.Root */, null, null, 1, 0, null, null, null, null, null);
13871
- const rootLView = createLView(null, rootTView, rootContext, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
13815
+ const rootLView = createLView(null, rootTView, null, rootFlags, null, null, rendererFactory, hostRenderer, sanitizer, rootViewInjector, null);
13872
13816
  // rootView is the parent when bootstrapping
13873
13817
  // TODO(misko): it looks like we are entering view here but we don't really need to as
13874
13818
  // `renderView` does that. However as the code is written it is needed because
@@ -13912,7 +13856,8 @@ class ComponentFactory extends ComponentFactory$1 {
13912
13856
  // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
13913
13857
  // executed here?
13914
13858
  // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
13915
- component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
13859
+ component =
13860
+ createRootComponent(componentView, this.componentDef, rootLView, [LifecycleHooksFeature]);
13916
13861
  renderView(rootTView, rootLView, null);
13917
13862
  }
13918
13863
  finally {
@@ -14018,7 +13963,7 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14018
13963
  }
14019
13964
  }
14020
13965
  const viewRenderer = rendererFactory.createRenderer(rNode, def);
14021
- const componentView = createLView(rootView, getOrCreateTComponentView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
13966
+ const componentView = createLView(rootView, getOrCreateComponentTView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14022
13967
  if (tView.firstCreatePass) {
14023
13968
  diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
14024
13969
  markAsComponentHost(tView, tNode);
@@ -14032,12 +13977,13 @@ function createRootComponentView(rNode, def, rootView, rendererFactory, hostRend
14032
13977
  * Creates a root component and sets it up with features and host bindings.Shared by
14033
13978
  * renderComponent() and ViewContainerRef.createComponent().
14034
13979
  */
14035
- function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {
13980
+ function createRootComponent(componentView, componentDef, rootLView, hostFeatures) {
14036
13981
  const tView = rootLView[TVIEW];
14037
13982
  // Create directive instance with factory() and store at next index in viewData
14038
13983
  const component = instantiateRootComponent(tView, rootLView, componentDef);
14039
- rootContext.components.push(component);
14040
- componentView[CONTEXT] = component;
13984
+ // Root view only contains an instance of this component,
13985
+ // so we use a reference to that component instance as a context.
13986
+ componentView[CONTEXT] = rootLView[CONTEXT] = component;
14041
13987
  if (hostFeatures !== null) {
14042
13988
  for (const feature of hostFeatures) {
14043
13989
  feature(component, componentDef);
@@ -14061,9 +14007,6 @@ function createRootComponent(componentView, componentDef, rootLView, rootContext
14061
14007
  }
14062
14008
  return component;
14063
14009
  }
14064
- function createRootContext() {
14065
- return { components: [] };
14066
- }
14067
14010
  /**
14068
14011
  * Used to enable lifecycle hooks on the root component.
14069
14012
  *
@@ -20956,9 +20899,6 @@ function walkIcuTree(tView, tIcu, lView, sharedUpdateOpCodes, create, remove, up
20956
20899
  if (URI_ATTRS[lowerAttrName]) {
20957
20900
  generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, _sanitizeUrl);
20958
20901
  }
20959
- else if (SRCSET_ATTRS[lowerAttrName]) {
20960
- generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, sanitizeSrcset);
20961
- }
20962
20902
  else {
20963
20903
  generateBindingUpdateOpCodes(update, attr.value, newIndex, attr.name, 0, null);
20964
20904
  }
@@ -21927,7 +21867,7 @@ function getOwningComponent(elementOrDir) {
21927
21867
  */
21928
21868
  function getRootComponents(elementOrDir) {
21929
21869
  const lView = readPatchedLView(elementOrDir);
21930
- return lView !== null ? [...getRootContext(lView).components] : [];
21870
+ return lView !== null ? [getRootContext(lView)] : [];
21931
21871
  }
21932
21872
  /**
21933
21873
  * Retrieves an `Injector` associated with an element, component or directive instance.