@angular/core 14.2.1 → 14.2.3

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