lwc 2.31.6 → 2.31.8

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.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +163 -121
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +163 -121
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +117 -12
  5. package/dist/engine-dom/iife/es5/engine-dom.js +290 -182
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +219 -84
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +163 -121
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +117 -12
  11. package/dist/engine-dom/umd/es5/engine-dom.js +290 -182
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +219 -84
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +124 -73
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +124 -73
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +7 -7
@@ -341,9 +341,9 @@ function htmlAttributeToProperty(attrName) {
341
341
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
342
342
  */
343
343
  // Increment whenever the LWC template compiler changes
344
- const LWC_VERSION = "2.31.6";
344
+ const LWC_VERSION = "2.31.8";
345
345
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
346
- /** version: 2.31.6 */
346
+ /** version: 2.31.8 */
347
347
 
348
348
  /**
349
349
  * Copyright (C) 2018 salesforce.com, inc.
@@ -425,7 +425,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
425
425
  patch$1(propName);
426
426
  }
427
427
  }
428
- /** version: 2.31.6 */
428
+ /** version: 2.31.8 */
429
429
 
430
430
  /**
431
431
  * Copyright (C) 2018 salesforce.com, inc.
@@ -505,7 +505,7 @@ function setFeatureFlagForTest(name, value) {
505
505
  setFeatureFlag(name, value);
506
506
  }
507
507
  }
508
- /** version: 2.31.6 */
508
+ /** version: 2.31.8 */
509
509
 
510
510
  /*
511
511
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2996,6 +2996,93 @@ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOw
2996
2996
  freeze(BaseBridgeElement);
2997
2997
  seal(BaseBridgeElement.prototype);
2998
2998
 
2999
+ /*
3000
+ * Copyright (c) 2023, salesforce.com, inc.
3001
+ * All rights reserved.
3002
+ * SPDX-License-Identifier: MIT
3003
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3004
+ */
3005
+ const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
3006
+ // In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
3007
+ class LegacyWeakMultiMap {
3008
+ constructor() {
3009
+ this._map = new WeakMap();
3010
+ }
3011
+ _getValues(key) {
3012
+ let values = this._map.get(key);
3013
+ if (isUndefined$1(values)) {
3014
+ values = new Set();
3015
+ this._map.set(key, values);
3016
+ }
3017
+ return values;
3018
+ }
3019
+ get(key) {
3020
+ return this._getValues(key);
3021
+ }
3022
+ add(key, vm) {
3023
+ const set = this._getValues(key);
3024
+ set.add(vm);
3025
+ }
3026
+ delete(key) {
3027
+ this._map.delete(key);
3028
+ }
3029
+ }
3030
+ // This implementation relies on the WeakRef/FinalizationRegistry proposal.
3031
+ // For some background, see: https://github.com/tc39/proposal-weakrefs
3032
+ class ModernWeakMultiMap {
3033
+ constructor() {
3034
+ this._map = new WeakMap();
3035
+ this._registry = new FinalizationRegistry((weakRefs) => {
3036
+ // This should be considered an optional cleanup method to remove GC'ed values from their respective arrays.
3037
+ // JS VMs are not obligated to call FinalizationRegistry callbacks.
3038
+ // Work backwards, removing stale VMs
3039
+ for (let i = weakRefs.length - 1; i >= 0; i--) {
3040
+ const vm = weakRefs[i].deref();
3041
+ if (isUndefined$1(vm)) {
3042
+ ArraySplice.call(weakRefs, i, 1); // remove
3043
+ }
3044
+ }
3045
+ });
3046
+ }
3047
+ _getWeakRefs(key) {
3048
+ let weakRefs = this._map.get(key);
3049
+ if (isUndefined$1(weakRefs)) {
3050
+ weakRefs = [];
3051
+ this._map.set(key, weakRefs);
3052
+ }
3053
+ return weakRefs;
3054
+ }
3055
+ get(key) {
3056
+ const weakRefs = this._getWeakRefs(key);
3057
+ const result = new Set();
3058
+ for (const weakRef of weakRefs) {
3059
+ const vm = weakRef.deref();
3060
+ if (!isUndefined$1(vm)) {
3061
+ result.add(vm);
3062
+ }
3063
+ }
3064
+ return result;
3065
+ }
3066
+ add(key, value) {
3067
+ const weakRefs = this._getWeakRefs(key);
3068
+ // We could check for duplicate values here, but it doesn't seem worth it.
3069
+ // We transform the output into a Set anyway
3070
+ ArrayPush$1.call(weakRefs, new WeakRef(value));
3071
+ // It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
3072
+ // effectively creates a strong reference between the first argument (the "target") and the held value. When
3073
+ // the target is GC'ed, the callback is called, and then the held value is GC'ed.
3074
+ // Putting the key here would mean the key is not GC'ed until the value is GC'ed, which defeats the purpose
3075
+ // of the WeakMap. Whereas putting the weakRefs array here is fine, because it doesn't have a strong reference
3076
+ // to anything. See also this example:
3077
+ // https://gist.github.com/nolanlawson/79a3d36e8e6cc25c5048bb17c1795aea
3078
+ this._registry.register(value, weakRefs);
3079
+ }
3080
+ delete(key) {
3081
+ this._map.delete(key);
3082
+ }
3083
+ }
3084
+ const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
3085
+
2999
3086
  /*
3000
3087
  * Copyright (c) 2020, salesforce.com, inc.
3001
3088
  * All rights reserved.
@@ -3005,67 +3092,62 @@ seal(BaseBridgeElement.prototype);
3005
3092
  const swappedTemplateMap = new WeakMap();
3006
3093
  const swappedComponentMap = new WeakMap();
3007
3094
  const swappedStyleMap = new WeakMap();
3008
- const activeTemplates = new WeakMap();
3009
- const activeComponents = new WeakMap();
3010
- const activeStyles = new WeakMap();
3095
+ // The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
3096
+ // so we don't want to create strong references to them.
3097
+ // The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
3098
+ // never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
3099
+ const activeTemplates = new WeakMultiMap();
3100
+ const activeComponents = new WeakMultiMap();
3101
+ const activeStyles = new WeakMultiMap();
3011
3102
  function rehydrateHotTemplate(tpl) {
3012
3103
  const list = activeTemplates.get(tpl);
3013
- if (!isUndefined$1(list)) {
3014
- list.forEach((vm) => {
3015
- if (isFalse(vm.isDirty)) {
3016
- // forcing the vm to rehydrate in the micro-task:
3017
- markComponentAsDirty(vm);
3018
- scheduleRehydration(vm);
3019
- }
3020
- });
3021
- // resetting the Set to release the memory of those vm references
3022
- // since they are not longer related to this template, instead
3023
- // they will get re-associated once these instances are rehydrated.
3024
- list.clear();
3104
+ for (const vm of list) {
3105
+ if (isFalse(vm.isDirty)) {
3106
+ // forcing the vm to rehydrate in the micro-task:
3107
+ markComponentAsDirty(vm);
3108
+ scheduleRehydration(vm);
3109
+ }
3025
3110
  }
3111
+ // Resetting the Set since these VMs are no longer related to this template, instead
3112
+ // they will get re-associated once these instances are rehydrated.
3113
+ activeTemplates.delete(tpl);
3026
3114
  return true;
3027
3115
  }
3028
3116
  function rehydrateHotStyle(style) {
3029
3117
  const list = activeStyles.get(style);
3030
- if (!isUndefined$1(list)) {
3031
- list.forEach((vm) => {
3032
- // if a style definition is swapped, we must reset
3033
- // vm's template content in the next micro-task:
3034
- forceRehydration(vm);
3035
- });
3036
- // resetting the Set to release the memory of those vm references
3037
- // since they are not longer related to this style, instead
3038
- // they will get re-associated once these instances are rehydrated.
3039
- list.clear();
3040
- }
3118
+ for (const vm of list) {
3119
+ // if a style definition is swapped, we must reset
3120
+ // vm's template content in the next micro-task:
3121
+ forceRehydration(vm);
3122
+ }
3123
+ // Resetting the Set since these VMs are no longer related to this style, instead
3124
+ // they will get re-associated once these instances are rehydrated.
3125
+ activeStyles.delete(style);
3041
3126
  return true;
3042
3127
  }
3043
3128
  function rehydrateHotComponent(Ctor) {
3044
3129
  const list = activeComponents.get(Ctor);
3045
3130
  let canRefreshAllInstances = true;
3046
- if (!isUndefined$1(list)) {
3047
- list.forEach((vm) => {
3048
- const { owner } = vm;
3049
- if (!isNull(owner)) {
3050
- // if a component class definition is swapped, we must reset
3051
- // owner's template content in the next micro-task:
3052
- forceRehydration(owner);
3053
- }
3054
- else {
3055
- // the hot swapping for components only work for instances of components
3056
- // created from a template, root elements can't be swapped because we
3057
- // don't have a way to force the creation of the element with the same state
3058
- // of the current element.
3059
- // Instead, we can report the problem to the caller so it can take action,
3060
- // for example: reload the entire page.
3061
- canRefreshAllInstances = false;
3062
- }
3063
- });
3064
- // resetting the Set to release the memory of those vm references
3065
- // since they are not longer related to this constructor, instead
3066
- // they will get re-associated once these instances are rehydrated.
3067
- list.clear();
3068
- }
3131
+ for (const vm of list) {
3132
+ const { owner } = vm;
3133
+ if (!isNull(owner)) {
3134
+ // if a component class definition is swapped, we must reset
3135
+ // owner's template content in the next micro-task:
3136
+ forceRehydration(owner);
3137
+ }
3138
+ else {
3139
+ // the hot swapping for components only work for instances of components
3140
+ // created from a template, root elements can't be swapped because we
3141
+ // don't have a way to force the creation of the element with the same state
3142
+ // of the current element.
3143
+ // Instead, we can report the problem to the caller so it can take action,
3144
+ // for example: reload the entire page.
3145
+ canRefreshAllInstances = false;
3146
+ }
3147
+ }
3148
+ // resetting the Set since these VMs are no longer related to this constructor, instead
3149
+ // they will get re-associated once these instances are rehydrated.
3150
+ activeComponents.delete(Ctor);
3069
3151
  return canRefreshAllInstances;
3070
3152
  }
3071
3153
  function getTemplateOrSwappedTemplate(tpl) {
@@ -3111,75 +3193,27 @@ function setActiveVM(vm) {
3111
3193
  }
3112
3194
  // tracking active component
3113
3195
  const Ctor = vm.def.ctor;
3114
- let componentVMs = activeComponents.get(Ctor);
3115
- if (isUndefined$1(componentVMs)) {
3116
- componentVMs = new Set();
3117
- activeComponents.set(Ctor, componentVMs);
3118
- }
3119
3196
  // this will allow us to keep track of the hot components
3120
- componentVMs.add(vm);
3197
+ activeComponents.add(Ctor, vm);
3121
3198
  // tracking active template
3122
3199
  const tpl = vm.cmpTemplate;
3123
3200
  if (tpl) {
3124
- let templateVMs = activeTemplates.get(tpl);
3125
- if (isUndefined$1(templateVMs)) {
3126
- templateVMs = new Set();
3127
- activeTemplates.set(tpl, templateVMs);
3128
- }
3129
3201
  // this will allow us to keep track of the templates that are
3130
3202
  // being used by a hot component
3131
- templateVMs.add(vm);
3203
+ activeTemplates.add(tpl, vm);
3132
3204
  // tracking active styles associated to template
3133
3205
  const stylesheets = tpl.stylesheets;
3134
3206
  if (!isUndefined$1(stylesheets)) {
3135
- flattenStylesheets(stylesheets).forEach((stylesheet) => {
3207
+ for (const stylesheet of flattenStylesheets(stylesheets)) {
3136
3208
  // this is necessary because we don't hold the list of styles
3137
3209
  // in the vm, we only hold the selected (already swapped template)
3138
3210
  // but the styles attached to the template might not be the actual
3139
3211
  // active ones, but the swapped versions of those.
3140
- stylesheet = getStyleOrSwappedStyle(stylesheet);
3141
- let stylesheetVMs = activeStyles.get(stylesheet);
3142
- if (isUndefined$1(stylesheetVMs)) {
3143
- stylesheetVMs = new Set();
3144
- activeStyles.set(stylesheet, stylesheetVMs);
3145
- }
3212
+ const swappedStylesheet = getStyleOrSwappedStyle(stylesheet);
3146
3213
  // this will allow us to keep track of the stylesheet that are
3147
3214
  // being used by a hot component
3148
- stylesheetVMs.add(vm);
3149
- });
3150
- }
3151
- }
3152
- }
3153
- function removeActiveVM(vm) {
3154
- if (process.env.NODE_ENV === 'production') {
3155
- // this method should never leak to prod
3156
- throw new ReferenceError();
3157
- }
3158
- // tracking inactive component
3159
- const Ctor = vm.def.ctor;
3160
- let list = activeComponents.get(Ctor);
3161
- if (!isUndefined$1(list)) {
3162
- // deleting the vm from the set to avoid leaking memory
3163
- list.delete(vm);
3164
- }
3165
- // removing inactive template
3166
- const tpl = vm.cmpTemplate;
3167
- if (tpl) {
3168
- list = activeTemplates.get(tpl);
3169
- if (!isUndefined$1(list)) {
3170
- // deleting the vm from the set to avoid leaking memory
3171
- list.delete(vm);
3172
- }
3173
- // removing active styles associated to template
3174
- const styles = tpl.stylesheets;
3175
- if (!isUndefined$1(styles)) {
3176
- flattenStylesheets(styles).forEach((style) => {
3177
- list = activeStyles.get(style);
3178
- if (!isUndefined$1(list)) {
3179
- // deleting the vm from the set to avoid leaking memory
3180
- list.delete(vm);
3181
- }
3182
- });
3215
+ activeStyles.add(swappedStylesheet, vm);
3216
+ }
3183
3217
  }
3184
3218
  }
3185
3219
  }
@@ -5684,9 +5718,6 @@ function resetComponentStateWhenRemoved(vm) {
5684
5718
  runChildNodesDisconnectedCallback(vm);
5685
5719
  runLightChildNodesDisconnectedCallback(vm);
5686
5720
  }
5687
- if (process.env.NODE_ENV !== 'production') {
5688
- removeActiveVM(vm);
5689
- }
5690
5721
  }
5691
5722
  // this method is triggered by the diffing algo only when a vnode from the
5692
5723
  // old vnode.children is removed from the DOM.
@@ -6061,22 +6092,33 @@ function recursivelyDisconnectChildren(vnodes) {
6061
6092
  // into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
6062
6093
  // children VNodes might not be representing the current state of the DOM.
6063
6094
  function resetComponentRoot(vm) {
6095
+ recursivelyRemoveChildren(vm.children, vm);
6096
+ vm.children = EmptyArray;
6097
+ runChildNodesDisconnectedCallback(vm);
6098
+ vm.velements = EmptyArray;
6099
+ }
6100
+ // Helper function to remove all children of the root node.
6101
+ // If the set of children includes VFragment nodes, we need to remove the children of those nodes too.
6102
+ // Since VFragments can contain other VFragments, we need to traverse the entire of tree of VFragments.
6103
+ // If the set contains no VFragment nodes, no traversal is needed.
6104
+ function recursivelyRemoveChildren(vnodes, vm) {
6064
6105
  const {
6065
- children,
6066
6106
  renderRoot,
6067
6107
  renderer: {
6068
6108
  remove
6069
6109
  }
6070
6110
  } = vm;
6071
- for (let i = 0, len = children.length; i < len; i++) {
6072
- const child = children[i];
6073
- if (!isNull(child) && !isUndefined$1(child.elm)) {
6074
- remove(child.elm, renderRoot);
6111
+ for (let i = 0, len = vnodes.length; i < len; i += 1) {
6112
+ const vnode = vnodes[i];
6113
+ if (!isNull(vnode)) {
6114
+ // VFragments are special; their .elm property does not point to the root element since they have no single root.
6115
+ if (isVFragment(vnode)) {
6116
+ recursivelyRemoveChildren(vnode.children, vm);
6117
+ } else if (!isUndefined$1(vnode.elm)) {
6118
+ remove(vnode.elm, renderRoot);
6119
+ }
6075
6120
  }
6076
6121
  }
6077
- vm.children = EmptyArray;
6078
- runChildNodesDisconnectedCallback(vm);
6079
- vm.velements = EmptyArray;
6080
6122
  }
6081
6123
  function scheduleRehydration(vm) {
6082
6124
  if (isTrue(vm.isScheduled)) {
@@ -7024,7 +7066,7 @@ function getComponentConstructor(elm) {
7024
7066
  }
7025
7067
  return ctor;
7026
7068
  }
7027
- /* version: 2.31.6 */
7069
+ /* version: 2.31.8 */
7028
7070
 
7029
7071
  /*
7030
7072
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7997,7 +8039,7 @@ function rendererFactory(baseRenderer) {
7997
8039
  function isNull(obj) {
7998
8040
  return obj === null;
7999
8041
  }
8000
- /** version: 2.31.6 */
8042
+ /** version: 2.31.8 */
8001
8043
 
8002
8044
  /*
8003
8045
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8558,6 +8600,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
8558
8600
  });
8559
8601
  freeze(LightningElement);
8560
8602
  seal(LightningElement.prototype);
8561
- /* version: 2.31.6 */
8603
+ /* version: 2.31.8 */
8562
8604
 
8563
8605
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };