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