lwc 2.21.0 → 2.23.0

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 (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +234 -236
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +234 -236
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +221 -224
  5. package/dist/engine-dom/iife/es5/engine-dom.js +282 -265
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +257 -237
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +234 -236
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +221 -224
  11. package/dist/engine-dom/umd/es5/engine-dom.js +282 -265
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +257 -237
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +138 -445
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +138 -445
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +13 -10
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +13 -10
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +13 -10
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +15 -14
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +15 -14
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +13 -10
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +13 -10
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +15 -14
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +15 -14
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -299,9 +299,9 @@ function htmlPropertyToAttribute(propName) {
299
299
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
300
300
  */
301
301
  // Increment whenever the LWC template compiler changes
302
- const LWC_VERSION = "2.21.0";
302
+ const LWC_VERSION = "2.23.0";
303
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
304
- /** version: 2.21.0 */
304
+ /** version: 2.23.0 */
305
305
 
306
306
  /*
307
307
  * Copyright (c) 2018, salesforce.com, inc.
@@ -455,7 +455,7 @@ function setFeatureFlagForTest(name, value) {
455
455
  setFeatureFlag(name, value);
456
456
  }
457
457
  }
458
- /** version: 2.21.0 */
458
+ /** version: 2.23.0 */
459
459
 
460
460
  /*
461
461
  * Copyright (c) 2018, salesforce.com, inc.
@@ -687,18 +687,21 @@ class ReactiveObserver {
687
687
  ArrayPush$1.call(this.listeners, reactiveObservers);
688
688
  }
689
689
  }
690
-
691
- /*
692
- * Copyright (c) 2018, salesforce.com, inc.
693
- * All rights reserved.
694
- * SPDX-License-Identifier: MIT
695
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
696
- */
697
690
  function componentValueMutated(vm, key) {
698
- valueMutated(vm.component, key);
691
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
692
+ {
693
+ valueMutated(vm.component, key);
694
+ }
699
695
  }
700
696
  function componentValueObserved(vm, key) {
701
- valueObserved(vm.component, key);
697
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
698
+ {
699
+ valueObserved(vm.component, key);
700
+ }
701
+ }
702
+ function createReactiveObserver(callback) {
703
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
704
+ return new ReactiveObserver(callback) ;
702
705
  }
703
706
 
704
707
  /*
@@ -1257,6 +1260,14 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
1257
1260
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1258
1261
  }
1259
1262
 
1263
+ function updateComponentValue(vm, key, newValue) {
1264
+ const { cmpFields } = vm;
1265
+ if (newValue !== cmpFields[key]) {
1266
+ cmpFields[key] = newValue;
1267
+ componentValueMutated(vm, key);
1268
+ }
1269
+ }
1270
+
1260
1271
  /**
1261
1272
  * Copyright (C) 2017 salesforce.com, inc.
1262
1273
  */
@@ -1820,7 +1831,24 @@ const reactiveMembrane = new ObservableMembrane({
1820
1831
  * change or being removed.
1821
1832
  */
1822
1833
  function unwrap(value) {
1823
- return reactiveMembrane.unwrapProxy(value);
1834
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1835
+ return reactiveMembrane.unwrapProxy(value) ;
1836
+ }
1837
+ function getReadOnlyProxy(value) {
1838
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1839
+ // them from their parents. This applies to both the client and server.
1840
+ return reactiveMembrane.getReadOnlyProxy(value);
1841
+ }
1842
+ function getReactiveProxy(value) {
1843
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1844
+ return reactiveMembrane.getProxy(value) ;
1845
+ }
1846
+ // Making the component instance a live value when using Locker to support expandos.
1847
+ function markLockerLiveObject(obj) {
1848
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1849
+ {
1850
+ obj[lockerLivePropertyKey] = undefined;
1851
+ }
1824
1852
  }
1825
1853
 
1826
1854
  /*
@@ -1872,10 +1900,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1872
1900
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1873
1901
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1874
1902
  }
1875
- if (newValue !== vm.cmpProps[propName]) {
1876
- vm.cmpProps[propName] = newValue;
1877
- componentValueMutated(vm, propName);
1878
- }
1903
+ updateComponentValue(vm, propName, newValue);
1879
1904
  return set.call(vm.elm, newValue);
1880
1905
  },
1881
1906
  };
@@ -1910,8 +1935,7 @@ const LightningElement = function () {
1910
1935
  vm.setHook = setHook;
1911
1936
  vm.getHook = getHook;
1912
1937
  }
1913
- // Making the component instance a live value when using Locker to support expandos.
1914
- this[lockerLivePropertyKey] = undefined;
1938
+ markLockerLiveObject(this);
1915
1939
  // Linking elm, shadow root and component with the VM.
1916
1940
  associateVM(component, vm);
1917
1941
  associateVM(elm, vm);
@@ -2171,15 +2195,51 @@ function createObservedFieldPropertyDescriptor(key) {
2171
2195
  },
2172
2196
  set(newValue) {
2173
2197
  const vm = getAssociatedVM(this);
2174
- if (newValue !== vm.cmpFields[key]) {
2175
- vm.cmpFields[key] = newValue;
2176
- componentValueMutated(vm, key);
2177
- }
2198
+ updateComponentValue(vm, key, newValue);
2178
2199
  },
2179
2200
  enumerable: true,
2180
2201
  configurable: true,
2181
2202
  };
2182
2203
  }
2204
+ class AccessorReactiveObserver extends ReactiveObserver {
2205
+ constructor(vm, set) {
2206
+ super(() => {
2207
+ if (isFalse(this.debouncing)) {
2208
+ this.debouncing = true;
2209
+ addCallbackToNextTick(() => {
2210
+ if (isTrue(this.debouncing)) {
2211
+ const { value } = this;
2212
+ const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
2213
+ set.call(component, value);
2214
+ // de-bouncing after the call to the original setter to prevent
2215
+ // infinity loop if the setter itself is mutating things that
2216
+ // were accessed during the previous invocation.
2217
+ this.debouncing = false;
2218
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2219
+ // immediate rehydration due to a setter driven mutation, otherwise
2220
+ // the component will get rendered on the second tick, which it is not
2221
+ // desirable.
2222
+ rerenderVM(vm);
2223
+ }
2224
+ }
2225
+ });
2226
+ }
2227
+ });
2228
+ this.debouncing = false;
2229
+ }
2230
+ reset(value) {
2231
+ super.reset();
2232
+ this.debouncing = false;
2233
+ if (arguments.length > 0) {
2234
+ this.value = value;
2235
+ }
2236
+ }
2237
+ }
2238
+ function createAccessorReactiveObserver(vm, set) {
2239
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
2240
+ return new AccessorReactiveObserver(vm, set)
2241
+ ;
2242
+ }
2183
2243
 
2184
2244
  /*
2185
2245
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2228,50 +2288,6 @@ function createPublicPropertyDescriptor(key) {
2228
2288
  configurable: true
2229
2289
  };
2230
2290
  }
2231
- class AccessorReactiveObserver extends ReactiveObserver {
2232
- constructor(vm, set) {
2233
- super(() => {
2234
- if (isFalse(this.debouncing)) {
2235
- this.debouncing = true;
2236
- addCallbackToNextTick(() => {
2237
- if (isTrue(this.debouncing)) {
2238
- const {
2239
- value
2240
- } = this;
2241
- const {
2242
- isDirty: dirtyStateBeforeSetterCall,
2243
- component,
2244
- idx
2245
- } = vm;
2246
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
2247
- // infinity loop if the setter itself is mutating things that
2248
- // were accessed during the previous invocation.
2249
-
2250
- this.debouncing = false;
2251
-
2252
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2253
- // immediate rehydration due to a setter driven mutation, otherwise
2254
- // the component will get rendered on the second tick, which it is not
2255
- // desirable.
2256
- rerenderVM(vm);
2257
- }
2258
- }
2259
- });
2260
- }
2261
- });
2262
- this.debouncing = false;
2263
- }
2264
-
2265
- reset(value) {
2266
- super.reset();
2267
- this.debouncing = false;
2268
-
2269
- if (arguments.length > 0) {
2270
- this.value = value;
2271
- }
2272
- }
2273
-
2274
- }
2275
2291
  function createPublicAccessorDescriptor(key, descriptor) {
2276
2292
  const {
2277
2293
  get,
@@ -2312,7 +2328,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
2312
2328
  let ro = vm.oar[key];
2313
2329
 
2314
2330
  if (isUndefined$1(ro)) {
2315
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
2331
+ ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
2316
2332
  } // every time we invoke this setter from outside (through this wrapper setter)
2317
2333
  // we should reset the value and then debounce just in case there is a pending
2318
2334
  // invocation the next tick that is not longer relevant since the value is changing
@@ -2344,7 +2360,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
2344
2360
  */
2345
2361
  function track(target) {
2346
2362
  if (arguments.length === 1) {
2347
- return reactiveMembrane.getProxy(target);
2363
+ return getReactiveProxy(target);
2348
2364
  }
2349
2365
  if (process.env.NODE_ENV !== 'production') {
2350
2366
  assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
@@ -2365,11 +2381,8 @@ function internalTrackDecorator(key) {
2365
2381
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2366
2382
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2367
2383
  }
2368
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2369
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2370
- vm.cmpFields[key] = reactiveOrAnyValue;
2371
- componentValueMutated(vm, key);
2372
- }
2384
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2385
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2373
2386
  },
2374
2387
  enumerable: true,
2375
2388
  configurable: true,
@@ -2408,10 +2421,7 @@ function internalWireFieldDecorator(key) {
2408
2421
  * letting the author to do the wrong thing, but it will keep our
2409
2422
  * system to be backward compatible.
2410
2423
  */
2411
- if (value !== vm.cmpFields[key]) {
2412
- vm.cmpFields[key] = value;
2413
- componentValueMutated(vm, key);
2414
- }
2424
+ updateComponentValue(vm, key, value);
2415
2425
  },
2416
2426
  enumerable: true,
2417
2427
  configurable: true,
@@ -2757,7 +2767,7 @@ function createSetter(key) {
2757
2767
  fn = cachedSetterByKey[key] = function (newValue) {
2758
2768
  const vm = getAssociatedVM(this);
2759
2769
  const { setHook } = vm;
2760
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2770
+ newValue = getReadOnlyProxy(newValue);
2761
2771
  setHook(vm.component, key, newValue);
2762
2772
  };
2763
2773
  }
@@ -3500,13 +3510,13 @@ function getNearestNativeShadowComponent(vm) {
3500
3510
  return owner;
3501
3511
  }
3502
3512
  function createStylesheet(vm, stylesheets) {
3503
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3513
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3504
3514
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3505
3515
  for (let i = 0; i < stylesheets.length; i++) {
3506
3516
  insertStylesheet(stylesheets[i]);
3507
3517
  }
3508
3518
  }
3509
- else if (ssr || vm.hydrated) {
3519
+ else if (vm.hydrated) {
3510
3520
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3511
3521
  // This works in the client, because the stylesheets are created, and cached in the VM
3512
3522
  // the first time the VM renders.
@@ -3807,7 +3817,7 @@ function patchChildren(c1, c2, parent, renderer) {
3807
3817
  updateStaticChildren(c1, c2, parent, renderer);
3808
3818
  }
3809
3819
  }
3810
- function patch(n1, n2, renderer) {
3820
+ function patch(n1, n2, parent, renderer) {
3811
3821
  var _a, _b;
3812
3822
  if (n1 === n2) {
3813
3823
  return;
@@ -3836,7 +3846,7 @@ function patch(n1, n2, renderer) {
3836
3846
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3837
3847
  break;
3838
3848
  case 3 /* VNodeType.CustomElement */:
3839
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3849
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3840
3850
  break;
3841
3851
  }
3842
3852
  }
@@ -3897,10 +3907,11 @@ function mountElement(vnode, parent, anchor, renderer) {
3897
3907
  const { sel, owner, data: { svg }, } = vnode;
3898
3908
  const { createElement } = renderer;
3899
3909
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3900
- const elm = createElement(sel, namespace);
3910
+ const elm = (vnode.elm = createElement(sel, namespace));
3901
3911
  linkNodeToShadow(elm, owner, renderer);
3902
- fallbackElmHook(elm, vnode, renderer);
3903
- vnode.elm = elm;
3912
+ applyStyleScoping(elm, owner, renderer);
3913
+ applyDomManual(elm, vnode);
3914
+ applyElementRestrictions(elm, vnode);
3904
3915
  patchElementPropsAndAttrs$1(null, vnode, renderer);
3905
3916
  insertNode(elm, parent, anchor, renderer);
3906
3917
  mountVNodes(vnode.children, elm, renderer, null);
@@ -3915,6 +3926,7 @@ function mountStatic(vnode, parent, anchor, renderer) {
3915
3926
  const { cloneNode, isSyntheticShadowDefined } = renderer;
3916
3927
  const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3917
3928
  linkNodeToShadow(elm, owner, renderer);
3929
+ applyElementRestrictions(elm, vnode);
3918
3930
  // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3919
3931
  const { renderMode, shadowMode } = owner;
3920
3932
  if (isSyntheticShadowDefined) {
@@ -3922,10 +3934,6 @@ function mountStatic(vnode, parent, anchor, renderer) {
3922
3934
  elm[KEY__SHADOW_STATIC] = true;
3923
3935
  }
3924
3936
  }
3925
- if (process.env.NODE_ENV !== 'production') {
3926
- const isLight = renderMode === 0 /* RenderMode.Light */;
3927
- patchElementWithRestrictions(elm, { isPortal: false, isLight });
3928
- }
3929
3937
  insertNode(elm, parent, anchor, renderer);
3930
3938
  }
3931
3939
  function mountCustomElement(vnode, parent, anchor, renderer) {
@@ -3942,9 +3950,10 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3942
3950
  // the custom element from the registry is expecting an upgrade callback
3943
3951
  vm = createViewModelHook(elm, vnode, renderer);
3944
3952
  });
3945
- linkNodeToShadow(elm, owner, renderer);
3946
3953
  vnode.elm = elm;
3947
3954
  vnode.vm = vm;
3955
+ linkNodeToShadow(elm, owner, renderer);
3956
+ applyStyleScoping(elm, owner, renderer);
3948
3957
  if (vm) {
3949
3958
  allocateChildren(vnode, vm);
3950
3959
  }
@@ -3964,22 +3973,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3964
3973
  appendVM(vm);
3965
3974
  }
3966
3975
  }
3967
- function patchCustomElement(n1, n2, renderer) {
3968
- const elm = (n2.elm = n1.elm);
3969
- const vm = (n2.vm = n1.vm);
3970
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3971
- if (!isUndefined$1(vm)) {
3972
- // in fallback mode, the allocation will always set children to
3973
- // empty and delegate the real allocation to the slot elements
3974
- allocateChildren(n2, vm);
3976
+ function patchCustomElement(n1, n2, parent, renderer) {
3977
+ if (n1.ctor !== n2.ctor) {
3978
+ // If the constructor, unmount the current component and mount a new one using the new
3979
+ // constructor.
3980
+ const anchor = renderer.nextSibling(n1.elm);
3981
+ unmount(n1, parent, renderer, true);
3982
+ mountCustomElement(n2, parent, anchor, renderer);
3975
3983
  }
3976
- // in fallback mode, the children will be always empty, so, nothing
3977
- // will happen, but in native, it does allocate the light dom
3978
- patchChildren(n1.children, n2.children, elm, renderer);
3979
- if (!isUndefined$1(vm)) {
3980
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3981
- // this is important to preserve the top to bottom synchronous rendering phase.
3982
- rerenderVM(vm);
3984
+ else {
3985
+ // Otherwise patch the existing component with new props/attrs/etc.
3986
+ const elm = (n2.elm = n1.elm);
3987
+ const vm = (n2.vm = n1.vm);
3988
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3989
+ if (!isUndefined$1(vm)) {
3990
+ // in fallback mode, the allocation will always set children to
3991
+ // empty and delegate the real allocation to the slot elements
3992
+ allocateChildren(n2, vm);
3993
+ }
3994
+ // in fallback mode, the children will be always empty, so, nothing
3995
+ // will happen, but in native, it does allocate the light dom
3996
+ patchChildren(n1.children, n2.children, elm, renderer);
3997
+ if (!isUndefined$1(vm)) {
3998
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3999
+ // this is important to preserve the top to bottom synchronous rendering phase.
4000
+ rerenderVM(vm);
4001
+ }
3983
4002
  }
3984
4003
  }
3985
4004
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4028,22 +4047,6 @@ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, en
4028
4047
  function isVNode(vnode) {
4029
4048
  return vnode != null;
4030
4049
  }
4031
- function observeElementChildNodes(elm) {
4032
- elm.$domManual$ = true;
4033
- }
4034
- function setElementShadowToken(elm, token) {
4035
- elm.$shadowToken$ = token;
4036
- }
4037
- // Set the scope token class for *.scoped.css styles
4038
- function setScopeTokenClassIfNecessary(elm, owner, renderer) {
4039
- const token = getScopeTokenClass(owner);
4040
- if (!isNull(token)) {
4041
- const { getClassList } = renderer;
4042
- // TODO [#2762]: this dot notation with add is probably problematic
4043
- // probably we should have a renderer api for just the add operation
4044
- getClassList(elm).add(token);
4045
- }
4046
- }
4047
4050
  function linkNodeToShadow(elm, owner, renderer) {
4048
4051
  const { renderRoot, renderMode, shadowMode } = owner;
4049
4052
  const { isSyntheticShadowDefined } = renderer;
@@ -4096,31 +4099,37 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
4096
4099
  patchAttributes(oldVnode, vnode, renderer);
4097
4100
  patchProps(oldVnode, vnode, renderer);
4098
4101
  }
4099
- function fallbackElmHook(elm, vnode, renderer) {
4100
- const { owner } = vnode;
4101
- setScopeTokenClassIfNecessary(elm, owner, renderer);
4102
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
4103
- const { data: { context }, } = vnode;
4104
- const { stylesheetToken } = owner.context;
4105
- if (!isUndefined$1(context) &&
4106
- !isUndefined$1(context.lwc) &&
4107
- context.lwc.dom === "manual" /* LwcDomMode.Manual */) {
4108
- // this element will now accept any manual content inserted into it
4109
- observeElementChildNodes(elm);
4110
- }
4111
- if (!isUndefined$1(stylesheetToken)) {
4112
- // when running in synthetic shadow mode, we need to set the shadowToken value
4113
- // into each element from the template, so they can be styled accordingly.
4114
- setElementShadowToken(elm, stylesheetToken);
4115
- }
4102
+ function applyStyleScoping(elm, owner, renderer) {
4103
+ // Set the class name for `*.scoped.css` style scoping.
4104
+ const scopeToken = getScopeTokenClass(owner);
4105
+ if (!isNull(scopeToken)) {
4106
+ const { getClassList } = renderer;
4107
+ // TODO [#2762]: this dot notation with add is probably problematic
4108
+ // probably we should have a renderer api for just the add operation
4109
+ getClassList(elm).add(scopeToken);
4110
+ }
4111
+ // Set property element for synthetic shadow DOM style scoping.
4112
+ const { stylesheetToken: syntheticToken } = owner.context;
4113
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
4114
+ elm.$shadowToken$ = syntheticToken;
4115
+ }
4116
+ }
4117
+ function applyDomManual(elm, vnode) {
4118
+ var _a;
4119
+ const { owner, data: { context }, } = vnode;
4120
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
4121
+ elm.$domManual$ = true;
4116
4122
  }
4123
+ }
4124
+ function applyElementRestrictions(elm, vnode) {
4125
+ var _a, _b;
4117
4126
  if (process.env.NODE_ENV !== 'production') {
4118
- const { data: { context }, } = vnode;
4119
- const isPortal = !isUndefined$1(context) &&
4120
- !isUndefined$1(context.lwc) &&
4121
- context.lwc.dom === "manual" /* LwcDomMode.Manual */;
4122
- const isLight = owner.renderMode === 0 /* RenderMode.Light */;
4123
- patchElementWithRestrictions(elm, { isPortal, isLight });
4127
+ const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
4128
+ const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4129
+ patchElementWithRestrictions(elm, {
4130
+ isPortal,
4131
+ isLight,
4132
+ });
4124
4133
  }
4125
4134
  }
4126
4135
  function allocateChildren(vnode, vm) {
@@ -4155,15 +4164,6 @@ function createViewModelHook(elm, vnode, renderer) {
4155
4164
  return vm;
4156
4165
  }
4157
4166
  const { sel, mode, ctor, owner } = vnode;
4158
- setScopeTokenClassIfNecessary(elm, owner, renderer);
4159
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
4160
- const { stylesheetToken } = owner.context;
4161
- // when running in synthetic shadow mode, we need to set the shadowToken value
4162
- // into each element from the template, so they can be styled accordingly.
4163
- if (!isUndefined$1(stylesheetToken)) {
4164
- setElementShadowToken(elm, stylesheetToken);
4165
- }
4166
- }
4167
4167
  vm = createVM(elm, ctor, renderer, {
4168
4168
  mode,
4169
4169
  owner,
@@ -4268,25 +4268,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4268
4268
  newEndVnode = newCh[--newEndIdx];
4269
4269
  }
4270
4270
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4271
- patch(oldStartVnode, newStartVnode, renderer);
4271
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4272
4272
  oldStartVnode = oldCh[++oldStartIdx];
4273
4273
  newStartVnode = newCh[++newStartIdx];
4274
4274
  }
4275
4275
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4276
- patch(oldEndVnode, newEndVnode, renderer);
4276
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4277
4277
  oldEndVnode = oldCh[--oldEndIdx];
4278
4278
  newEndVnode = newCh[--newEndIdx];
4279
4279
  }
4280
4280
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4281
4281
  // Vnode moved right
4282
- patch(oldStartVnode, newEndVnode, renderer);
4282
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4283
4283
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4284
4284
  oldStartVnode = oldCh[++oldStartIdx];
4285
4285
  newEndVnode = newCh[--newEndIdx];
4286
4286
  }
4287
4287
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4288
4288
  // Vnode moved left
4289
- patch(oldEndVnode, newStartVnode, renderer);
4289
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4290
4290
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4291
4291
  oldEndVnode = oldCh[--oldEndIdx];
4292
4292
  newStartVnode = newCh[++newStartIdx];
@@ -4309,7 +4309,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4309
4309
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4310
4310
  }
4311
4311
  else {
4312
- patch(elmToMove, newStartVnode, renderer);
4312
+ patch(elmToMove, newStartVnode, parent, renderer);
4313
4313
  // Delete the old child, but copy the array since it is read-only.
4314
4314
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4315
4315
  // so we only care about the `oldCh` object inside this function.
@@ -4369,7 +4369,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
4369
4369
  if (isVNode(n1)) {
4370
4370
  if (isVNode(n2)) {
4371
4371
  // both vnodes are equivalent, and we just need to patch them
4372
- patch(n1, n2, renderer);
4372
+ patch(n1, n2, parent, renderer);
4373
4373
  anchor = n2.elm;
4374
4374
  }
4375
4375
  else {
@@ -4703,13 +4703,6 @@ function fid(url) {
4703
4703
  }
4704
4704
  return url;
4705
4705
  }
4706
- /**
4707
- * Map to store an index value assigned to any dynamic component reference ingested
4708
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4709
- * component reference to avoid diffing algo mismatches.
4710
- */
4711
- const DynamicImportedComponentMap = new Map();
4712
- let dynamicImportedComponentCounter = 0;
4713
4706
  /**
4714
4707
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4715
4708
  */
@@ -4726,18 +4719,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
4726
4719
  if (!isComponentConstructor(Ctor)) {
4727
4720
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4728
4721
  }
4729
- let idx = DynamicImportedComponentMap.get(Ctor);
4730
- if (isUndefined$1(idx)) {
4731
- idx = dynamicImportedComponentCounter++;
4732
- DynamicImportedComponentMap.set(Ctor, idx);
4733
- }
4734
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4735
- // to identify different constructors as vnodes with different keys to avoid reusing the
4736
- // element used for previous constructors.
4737
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4738
- // hoisting optimization.
4739
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4740
- return c(sel, Ctor, newData, children);
4722
+ return c(sel, Ctor, data, children);
4741
4723
  }
4742
4724
  /**
4743
4725
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5213,7 +5195,7 @@ function getComponentRegisteredTemplate(Ctor) {
5213
5195
  return signedTemplateMap.get(Ctor);
5214
5196
  }
5215
5197
  function getTemplateReactiveObserver(vm) {
5216
- return new ReactiveObserver(() => {
5198
+ return createReactiveObserver(() => {
5217
5199
  const { isDirty } = vm;
5218
5200
  if (isFalse(isDirty)) {
5219
5201
  markComponentAsDirty(vm);
@@ -5631,16 +5613,9 @@ function runRenderedCallback(vm) {
5631
5613
  const {
5632
5614
  def: {
5633
5615
  renderedCallback
5634
- },
5635
- renderer: {
5636
- ssr
5637
5616
  }
5638
5617
  } = vm;
5639
5618
 
5640
- if (isTrue(ssr)) {
5641
- return;
5642
- }
5643
-
5644
5619
  const {
5645
5620
  rendered
5646
5621
  } = Services;
@@ -5890,13 +5865,7 @@ function resetComponentRoot(vm) {
5890
5865
  vm.velements = EmptyArray;
5891
5866
  }
5892
5867
  function scheduleRehydration(vm) {
5893
- const {
5894
- renderer: {
5895
- ssr
5896
- }
5897
- } = vm;
5898
-
5899
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5868
+ if (isTrue(vm.isScheduled)) {
5900
5869
  return;
5901
5870
  }
5902
5871
 
@@ -6003,15 +5972,8 @@ class WireContextRegistrationEvent extends CustomEvent {
6003
5972
  }
6004
5973
 
6005
5974
  function createFieldDataCallback(vm, name) {
6006
- const {
6007
- cmpFields
6008
- } = vm;
6009
5975
  return value => {
6010
- if (value !== vm.cmpFields[name]) {
6011
- // storing the value in the underlying storage
6012
- cmpFields[name] = value;
6013
- componentValueMutated(vm, name);
6014
- }
5976
+ updateComponentValue(vm, name, value);
6015
5977
  };
6016
5978
  }
6017
5979
 
@@ -6028,7 +5990,7 @@ function createMethodDataCallback(vm, method) {
6028
5990
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
6029
5991
  let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
6030
5992
 
6031
- const ro = new ReactiveObserver(() => {
5993
+ const ro = createReactiveObserver(() => {
6032
5994
  if (hasPendingConfig === false) {
6033
5995
  hasPendingConfig = true; // collect new config in the micro-task
6034
5996
 
@@ -6324,7 +6286,7 @@ function readonly(obj) {
6324
6286
  assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
6325
6287
  }
6326
6288
  }
6327
- return reactiveMembrane.getReadOnlyProxy(obj);
6289
+ return getReadOnlyProxy(obj);
6328
6290
  }
6329
6291
 
6330
6292
  /*
@@ -6835,7 +6797,7 @@ function getComponentConstructor(elm) {
6835
6797
  }
6836
6798
  return ctor;
6837
6799
  }
6838
- /* version: 2.21.0 */
6800
+ /* version: 2.23.0 */
6839
6801
 
6840
6802
  /*
6841
6803
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6979,6 +6941,69 @@ function insertStylesheet(content, target) {
6979
6941
  }
6980
6942
  }
6981
6943
 
6944
+ /*
6945
+ * Copyright (c) 2018, salesforce.com, inc.
6946
+ * All rights reserved.
6947
+ * SPDX-License-Identifier: MIT
6948
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6949
+ */
6950
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
6951
+ let createFragment;
6952
+ if (SUPPORTS_TEMPLATE) {
6953
+ // Parse the fragment HTML string into DOM
6954
+ createFragment = function (html) {
6955
+ const template = document.createElement('template');
6956
+ template.innerHTML = html;
6957
+ return template.content.firstChild;
6958
+ };
6959
+ }
6960
+ else {
6961
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
6962
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
6963
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
6964
+ // With other elements added from:
6965
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
6966
+ // Using the test:
6967
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
6968
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
6969
+ const topLevelWrappingMap = {
6970
+ caption: ['table'],
6971
+ col: ['colgroup', 'table'],
6972
+ colgroup: ['table'],
6973
+ option: ['select'],
6974
+ tbody: ['table'],
6975
+ td: ['tr', 'tbody', 'table'],
6976
+ th: ['tr', 'tbody', 'table'],
6977
+ thead: ['table'],
6978
+ tfoot: ['table'],
6979
+ tr: ['tbody', 'table'],
6980
+ };
6981
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
6982
+ const getTagName = function (text) {
6983
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
6984
+ };
6985
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
6986
+ createFragment = function (html) {
6987
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
6988
+ if (!isUndefined$1(wrapperTags)) {
6989
+ for (const wrapperTag of wrapperTags) {
6990
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
6991
+ }
6992
+ }
6993
+ // For IE11, the document title must not be undefined, but it can be an empty string
6994
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
6995
+ const doc = document.implementation.createHTMLDocument('');
6996
+ doc.body.innerHTML = html;
6997
+ let content = doc.body;
6998
+ if (!isUndefined$1(wrapperTags)) {
6999
+ for (let i = 0; i < wrapperTags.length; i++) {
7000
+ content = content.firstChild;
7001
+ }
7002
+ }
7003
+ return content.firstChild;
7004
+ };
7005
+ }
7006
+
6982
7007
  /*
6983
7008
  * Copyright (c) 2018, salesforce.com, inc.
6984
7009
  * All rights reserved.
@@ -7044,22 +7069,11 @@ else {
7044
7069
  };
7045
7070
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7046
7071
  }
7047
- let hydrating = false;
7048
- function setIsHydrating(value) {
7049
- hydrating = value;
7050
- }
7051
- const ssr = false;
7052
- function isHydrating() {
7053
- return hydrating;
7054
- }
7055
7072
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
7056
7073
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7057
7074
  function cloneNode(node, deep) {
7058
7075
  return node.cloneNode(deep);
7059
7076
  }
7060
- function createFragment(html) {
7061
- return document.createRange().createContextualFragment(html).firstChild;
7062
- }
7063
7077
  function createElement$1(tagName, namespace) {
7064
7078
  return isUndefined$1(namespace)
7065
7079
  ? document.createElement(tagName)
@@ -7081,15 +7095,11 @@ function nextSibling(node) {
7081
7095
  return node.nextSibling;
7082
7096
  }
7083
7097
  function attachShadow(element, options) {
7084
- // `hydrating` will be true in two cases:
7098
+ // `shadowRoot` will be non-null in two cases:
7085
7099
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7086
7100
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
7087
- // root component with customeElement.define('c-app', Ctor)
7088
- //
7089
- // The second case can be treated as a failed hydration with nominal impact
7090
- // to performance. However, because <c-app> won't have a <template shadowroot>
7091
- // declarative child, `element.shadowRoot` is `null`.
7092
- if (hydrating && element.shadowRoot) {
7101
+ // root component with customElement.define('c-app', Ctor)
7102
+ if (!isNull(element.shadowRoot)) {
7093
7103
  return element.shadowRoot;
7094
7104
  }
7095
7105
  return element.attachShadow(options);
@@ -7185,11 +7195,9 @@ function assertInstanceOfHTMLElement(elm, msg) {
7185
7195
  }
7186
7196
  const HTMLElementExported = HTMLElementConstructor;
7187
7197
  const renderer = {
7188
- ssr,
7189
7198
  isNativeShadowDefined,
7190
7199
  isSyntheticShadowDefined,
7191
7200
  HTMLElementExported,
7192
- isHydrating,
7193
7201
  insert,
7194
7202
  remove,
7195
7203
  cloneNode,
@@ -7275,13 +7283,8 @@ function hydrateComponent(element, Ctor, props = {}) {
7275
7283
  return;
7276
7284
  }
7277
7285
  try {
7278
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7279
- // and uses the same algo to create the stylesheets as in SSR.
7280
- setIsHydrating(true);
7281
7286
  const vm = createVMWithProps(element, Ctor, props);
7282
7287
  hydrateRoot(vm);
7283
- // set it back since now we finished hydration.
7284
- setIsHydrating(false);
7285
7288
  }
7286
7289
  catch (e) {
7287
7290
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -7292,13 +7295,8 @@ function hydrateComponent(element, Ctor, props = {}) {
7292
7295
  resetShadowRootAndLightDom(element, Ctor);
7293
7296
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
7294
7297
  createVMWithProps(element, Ctor, props);
7295
- setIsHydrating(false);
7296
7298
  connectRootElement(element);
7297
7299
  }
7298
- finally {
7299
- // in case there's an error during recovery
7300
- setIsHydrating(false);
7301
- }
7302
7300
  }
7303
7301
 
7304
7302
  /*
@@ -7523,6 +7521,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7523
7521
  });
7524
7522
  freeze(LightningElement);
7525
7523
  seal(LightningElement.prototype);
7526
- /* version: 2.21.0 */
7524
+ /* version: 2.23.0 */
7527
7525
 
7528
7526
  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, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };