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
@@ -305,9 +305,9 @@
305
305
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
306
306
  */
307
307
  // Increment whenever the LWC template compiler changes
308
- const LWC_VERSION = "2.21.0";
308
+ const LWC_VERSION = "2.23.0";
309
309
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
310
- /** version: 2.21.0 */
310
+ /** version: 2.23.0 */
311
311
 
312
312
  /*
313
313
  * Copyright (c) 2018, salesforce.com, inc.
@@ -461,7 +461,7 @@
461
461
  setFeatureFlag(name, value);
462
462
  }
463
463
  }
464
- /** version: 2.21.0 */
464
+ /** version: 2.23.0 */
465
465
 
466
466
  /*
467
467
  * Copyright (c) 2018, salesforce.com, inc.
@@ -693,18 +693,21 @@
693
693
  ArrayPush$1.call(this.listeners, reactiveObservers);
694
694
  }
695
695
  }
696
-
697
- /*
698
- * Copyright (c) 2018, salesforce.com, inc.
699
- * All rights reserved.
700
- * SPDX-License-Identifier: MIT
701
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
702
- */
703
696
  function componentValueMutated(vm, key) {
704
- valueMutated(vm.component, key);
697
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
698
+ {
699
+ valueMutated(vm.component, key);
700
+ }
705
701
  }
706
702
  function componentValueObserved(vm, key) {
707
- valueObserved(vm.component, key);
703
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
704
+ {
705
+ valueObserved(vm.component, key);
706
+ }
707
+ }
708
+ function createReactiveObserver(callback) {
709
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
710
+ return new ReactiveObserver(callback) ;
708
711
  }
709
712
 
710
713
  /*
@@ -1263,6 +1266,14 @@
1263
1266
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1264
1267
  }
1265
1268
 
1269
+ function updateComponentValue(vm, key, newValue) {
1270
+ const { cmpFields } = vm;
1271
+ if (newValue !== cmpFields[key]) {
1272
+ cmpFields[key] = newValue;
1273
+ componentValueMutated(vm, key);
1274
+ }
1275
+ }
1276
+
1266
1277
  /**
1267
1278
  * Copyright (C) 2017 salesforce.com, inc.
1268
1279
  */
@@ -1826,7 +1837,24 @@
1826
1837
  * change or being removed.
1827
1838
  */
1828
1839
  function unwrap(value) {
1829
- return reactiveMembrane.unwrapProxy(value);
1840
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1841
+ return reactiveMembrane.unwrapProxy(value) ;
1842
+ }
1843
+ function getReadOnlyProxy(value) {
1844
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1845
+ // them from their parents. This applies to both the client and server.
1846
+ return reactiveMembrane.getReadOnlyProxy(value);
1847
+ }
1848
+ function getReactiveProxy(value) {
1849
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1850
+ return reactiveMembrane.getProxy(value) ;
1851
+ }
1852
+ // Making the component instance a live value when using Locker to support expandos.
1853
+ function markLockerLiveObject(obj) {
1854
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1855
+ {
1856
+ obj[lockerLivePropertyKey] = undefined;
1857
+ }
1830
1858
  }
1831
1859
 
1832
1860
  /*
@@ -1878,10 +1906,7 @@
1878
1906
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1879
1907
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1880
1908
  }
1881
- if (newValue !== vm.cmpProps[propName]) {
1882
- vm.cmpProps[propName] = newValue;
1883
- componentValueMutated(vm, propName);
1884
- }
1909
+ updateComponentValue(vm, propName, newValue);
1885
1910
  return set.call(vm.elm, newValue);
1886
1911
  },
1887
1912
  };
@@ -1916,8 +1941,7 @@
1916
1941
  vm.setHook = setHook;
1917
1942
  vm.getHook = getHook;
1918
1943
  }
1919
- // Making the component instance a live value when using Locker to support expandos.
1920
- this[lockerLivePropertyKey] = undefined;
1944
+ markLockerLiveObject(this);
1921
1945
  // Linking elm, shadow root and component with the VM.
1922
1946
  associateVM(component, vm);
1923
1947
  associateVM(elm, vm);
@@ -2177,15 +2201,51 @@
2177
2201
  },
2178
2202
  set(newValue) {
2179
2203
  const vm = getAssociatedVM(this);
2180
- if (newValue !== vm.cmpFields[key]) {
2181
- vm.cmpFields[key] = newValue;
2182
- componentValueMutated(vm, key);
2183
- }
2204
+ updateComponentValue(vm, key, newValue);
2184
2205
  },
2185
2206
  enumerable: true,
2186
2207
  configurable: true,
2187
2208
  };
2188
2209
  }
2210
+ class AccessorReactiveObserver extends ReactiveObserver {
2211
+ constructor(vm, set) {
2212
+ super(() => {
2213
+ if (isFalse(this.debouncing)) {
2214
+ this.debouncing = true;
2215
+ addCallbackToNextTick(() => {
2216
+ if (isTrue(this.debouncing)) {
2217
+ const { value } = this;
2218
+ const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
2219
+ set.call(component, value);
2220
+ // de-bouncing after the call to the original setter to prevent
2221
+ // infinity loop if the setter itself is mutating things that
2222
+ // were accessed during the previous invocation.
2223
+ this.debouncing = false;
2224
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2225
+ // immediate rehydration due to a setter driven mutation, otherwise
2226
+ // the component will get rendered on the second tick, which it is not
2227
+ // desirable.
2228
+ rerenderVM(vm);
2229
+ }
2230
+ }
2231
+ });
2232
+ }
2233
+ });
2234
+ this.debouncing = false;
2235
+ }
2236
+ reset(value) {
2237
+ super.reset();
2238
+ this.debouncing = false;
2239
+ if (arguments.length > 0) {
2240
+ this.value = value;
2241
+ }
2242
+ }
2243
+ }
2244
+ function createAccessorReactiveObserver(vm, set) {
2245
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
2246
+ return new AccessorReactiveObserver(vm, set)
2247
+ ;
2248
+ }
2189
2249
 
2190
2250
  /*
2191
2251
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2234,50 +2294,6 @@
2234
2294
  configurable: true
2235
2295
  };
2236
2296
  }
2237
- class AccessorReactiveObserver extends ReactiveObserver {
2238
- constructor(vm, set) {
2239
- super(() => {
2240
- if (isFalse(this.debouncing)) {
2241
- this.debouncing = true;
2242
- addCallbackToNextTick(() => {
2243
- if (isTrue(this.debouncing)) {
2244
- const {
2245
- value
2246
- } = this;
2247
- const {
2248
- isDirty: dirtyStateBeforeSetterCall,
2249
- component,
2250
- idx
2251
- } = vm;
2252
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
2253
- // infinity loop if the setter itself is mutating things that
2254
- // were accessed during the previous invocation.
2255
-
2256
- this.debouncing = false;
2257
-
2258
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2259
- // immediate rehydration due to a setter driven mutation, otherwise
2260
- // the component will get rendered on the second tick, which it is not
2261
- // desirable.
2262
- rerenderVM(vm);
2263
- }
2264
- }
2265
- });
2266
- }
2267
- });
2268
- this.debouncing = false;
2269
- }
2270
-
2271
- reset(value) {
2272
- super.reset();
2273
- this.debouncing = false;
2274
-
2275
- if (arguments.length > 0) {
2276
- this.value = value;
2277
- }
2278
- }
2279
-
2280
- }
2281
2297
  function createPublicAccessorDescriptor(key, descriptor) {
2282
2298
  const {
2283
2299
  get,
@@ -2318,7 +2334,7 @@
2318
2334
  let ro = vm.oar[key];
2319
2335
 
2320
2336
  if (isUndefined$1(ro)) {
2321
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
2337
+ ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
2322
2338
  } // every time we invoke this setter from outside (through this wrapper setter)
2323
2339
  // we should reset the value and then debounce just in case there is a pending
2324
2340
  // invocation the next tick that is not longer relevant since the value is changing
@@ -2350,7 +2366,7 @@
2350
2366
  */
2351
2367
  function track(target) {
2352
2368
  if (arguments.length === 1) {
2353
- return reactiveMembrane.getProxy(target);
2369
+ return getReactiveProxy(target);
2354
2370
  }
2355
2371
  if (process.env.NODE_ENV !== 'production') {
2356
2372
  assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
@@ -2371,11 +2387,8 @@
2371
2387
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2372
2388
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2373
2389
  }
2374
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2375
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2376
- vm.cmpFields[key] = reactiveOrAnyValue;
2377
- componentValueMutated(vm, key);
2378
- }
2390
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2391
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2379
2392
  },
2380
2393
  enumerable: true,
2381
2394
  configurable: true,
@@ -2414,10 +2427,7 @@
2414
2427
  * letting the author to do the wrong thing, but it will keep our
2415
2428
  * system to be backward compatible.
2416
2429
  */
2417
- if (value !== vm.cmpFields[key]) {
2418
- vm.cmpFields[key] = value;
2419
- componentValueMutated(vm, key);
2420
- }
2430
+ updateComponentValue(vm, key, value);
2421
2431
  },
2422
2432
  enumerable: true,
2423
2433
  configurable: true,
@@ -2763,7 +2773,7 @@
2763
2773
  fn = cachedSetterByKey[key] = function (newValue) {
2764
2774
  const vm = getAssociatedVM(this);
2765
2775
  const { setHook } = vm;
2766
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2776
+ newValue = getReadOnlyProxy(newValue);
2767
2777
  setHook(vm.component, key, newValue);
2768
2778
  };
2769
2779
  }
@@ -3506,13 +3516,13 @@
3506
3516
  return owner;
3507
3517
  }
3508
3518
  function createStylesheet(vm, stylesheets) {
3509
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3519
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3510
3520
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3511
3521
  for (let i = 0; i < stylesheets.length; i++) {
3512
3522
  insertStylesheet(stylesheets[i]);
3513
3523
  }
3514
3524
  }
3515
- else if (ssr || vm.hydrated) {
3525
+ else if (vm.hydrated) {
3516
3526
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3517
3527
  // This works in the client, because the stylesheets are created, and cached in the VM
3518
3528
  // the first time the VM renders.
@@ -3813,7 +3823,7 @@
3813
3823
  updateStaticChildren(c1, c2, parent, renderer);
3814
3824
  }
3815
3825
  }
3816
- function patch(n1, n2, renderer) {
3826
+ function patch(n1, n2, parent, renderer) {
3817
3827
  var _a, _b;
3818
3828
  if (n1 === n2) {
3819
3829
  return;
@@ -3842,7 +3852,7 @@
3842
3852
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3843
3853
  break;
3844
3854
  case 3 /* VNodeType.CustomElement */:
3845
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3855
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3846
3856
  break;
3847
3857
  }
3848
3858
  }
@@ -3903,10 +3913,11 @@
3903
3913
  const { sel, owner, data: { svg }, } = vnode;
3904
3914
  const { createElement } = renderer;
3905
3915
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3906
- const elm = createElement(sel, namespace);
3916
+ const elm = (vnode.elm = createElement(sel, namespace));
3907
3917
  linkNodeToShadow(elm, owner, renderer);
3908
- fallbackElmHook(elm, vnode, renderer);
3909
- vnode.elm = elm;
3918
+ applyStyleScoping(elm, owner, renderer);
3919
+ applyDomManual(elm, vnode);
3920
+ applyElementRestrictions(elm, vnode);
3910
3921
  patchElementPropsAndAttrs$1(null, vnode, renderer);
3911
3922
  insertNode(elm, parent, anchor, renderer);
3912
3923
  mountVNodes(vnode.children, elm, renderer, null);
@@ -3921,6 +3932,7 @@
3921
3932
  const { cloneNode, isSyntheticShadowDefined } = renderer;
3922
3933
  const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3923
3934
  linkNodeToShadow(elm, owner, renderer);
3935
+ applyElementRestrictions(elm, vnode);
3924
3936
  // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3925
3937
  const { renderMode, shadowMode } = owner;
3926
3938
  if (isSyntheticShadowDefined) {
@@ -3928,10 +3940,6 @@
3928
3940
  elm[KEY__SHADOW_STATIC] = true;
3929
3941
  }
3930
3942
  }
3931
- if (process.env.NODE_ENV !== 'production') {
3932
- const isLight = renderMode === 0 /* RenderMode.Light */;
3933
- patchElementWithRestrictions(elm, { isPortal: false, isLight });
3934
- }
3935
3943
  insertNode(elm, parent, anchor, renderer);
3936
3944
  }
3937
3945
  function mountCustomElement(vnode, parent, anchor, renderer) {
@@ -3948,9 +3956,10 @@
3948
3956
  // the custom element from the registry is expecting an upgrade callback
3949
3957
  vm = createViewModelHook(elm, vnode, renderer);
3950
3958
  });
3951
- linkNodeToShadow(elm, owner, renderer);
3952
3959
  vnode.elm = elm;
3953
3960
  vnode.vm = vm;
3961
+ linkNodeToShadow(elm, owner, renderer);
3962
+ applyStyleScoping(elm, owner, renderer);
3954
3963
  if (vm) {
3955
3964
  allocateChildren(vnode, vm);
3956
3965
  }
@@ -3970,22 +3979,32 @@
3970
3979
  appendVM(vm);
3971
3980
  }
3972
3981
  }
3973
- function patchCustomElement(n1, n2, renderer) {
3974
- const elm = (n2.elm = n1.elm);
3975
- const vm = (n2.vm = n1.vm);
3976
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3977
- if (!isUndefined$1(vm)) {
3978
- // in fallback mode, the allocation will always set children to
3979
- // empty and delegate the real allocation to the slot elements
3980
- allocateChildren(n2, vm);
3982
+ function patchCustomElement(n1, n2, parent, renderer) {
3983
+ if (n1.ctor !== n2.ctor) {
3984
+ // If the constructor, unmount the current component and mount a new one using the new
3985
+ // constructor.
3986
+ const anchor = renderer.nextSibling(n1.elm);
3987
+ unmount(n1, parent, renderer, true);
3988
+ mountCustomElement(n2, parent, anchor, renderer);
3981
3989
  }
3982
- // in fallback mode, the children will be always empty, so, nothing
3983
- // will happen, but in native, it does allocate the light dom
3984
- patchChildren(n1.children, n2.children, elm, renderer);
3985
- if (!isUndefined$1(vm)) {
3986
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3987
- // this is important to preserve the top to bottom synchronous rendering phase.
3988
- rerenderVM(vm);
3990
+ else {
3991
+ // Otherwise patch the existing component with new props/attrs/etc.
3992
+ const elm = (n2.elm = n1.elm);
3993
+ const vm = (n2.vm = n1.vm);
3994
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3995
+ if (!isUndefined$1(vm)) {
3996
+ // in fallback mode, the allocation will always set children to
3997
+ // empty and delegate the real allocation to the slot elements
3998
+ allocateChildren(n2, vm);
3999
+ }
4000
+ // in fallback mode, the children will be always empty, so, nothing
4001
+ // will happen, but in native, it does allocate the light dom
4002
+ patchChildren(n1.children, n2.children, elm, renderer);
4003
+ if (!isUndefined$1(vm)) {
4004
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4005
+ // this is important to preserve the top to bottom synchronous rendering phase.
4006
+ rerenderVM(vm);
4007
+ }
3989
4008
  }
3990
4009
  }
3991
4010
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4034,22 +4053,6 @@
4034
4053
  function isVNode(vnode) {
4035
4054
  return vnode != null;
4036
4055
  }
4037
- function observeElementChildNodes(elm) {
4038
- elm.$domManual$ = true;
4039
- }
4040
- function setElementShadowToken(elm, token) {
4041
- elm.$shadowToken$ = token;
4042
- }
4043
- // Set the scope token class for *.scoped.css styles
4044
- function setScopeTokenClassIfNecessary(elm, owner, renderer) {
4045
- const token = getScopeTokenClass(owner);
4046
- if (!isNull(token)) {
4047
- const { getClassList } = renderer;
4048
- // TODO [#2762]: this dot notation with add is probably problematic
4049
- // probably we should have a renderer api for just the add operation
4050
- getClassList(elm).add(token);
4051
- }
4052
- }
4053
4056
  function linkNodeToShadow(elm, owner, renderer) {
4054
4057
  const { renderRoot, renderMode, shadowMode } = owner;
4055
4058
  const { isSyntheticShadowDefined } = renderer;
@@ -4102,31 +4105,37 @@
4102
4105
  patchAttributes(oldVnode, vnode, renderer);
4103
4106
  patchProps(oldVnode, vnode, renderer);
4104
4107
  }
4105
- function fallbackElmHook(elm, vnode, renderer) {
4106
- const { owner } = vnode;
4107
- setScopeTokenClassIfNecessary(elm, owner, renderer);
4108
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
4109
- const { data: { context }, } = vnode;
4110
- const { stylesheetToken } = owner.context;
4111
- if (!isUndefined$1(context) &&
4112
- !isUndefined$1(context.lwc) &&
4113
- context.lwc.dom === "manual" /* LwcDomMode.Manual */) {
4114
- // this element will now accept any manual content inserted into it
4115
- observeElementChildNodes(elm);
4116
- }
4117
- if (!isUndefined$1(stylesheetToken)) {
4118
- // when running in synthetic shadow mode, we need to set the shadowToken value
4119
- // into each element from the template, so they can be styled accordingly.
4120
- setElementShadowToken(elm, stylesheetToken);
4121
- }
4108
+ function applyStyleScoping(elm, owner, renderer) {
4109
+ // Set the class name for `*.scoped.css` style scoping.
4110
+ const scopeToken = getScopeTokenClass(owner);
4111
+ if (!isNull(scopeToken)) {
4112
+ const { getClassList } = renderer;
4113
+ // TODO [#2762]: this dot notation with add is probably problematic
4114
+ // probably we should have a renderer api for just the add operation
4115
+ getClassList(elm).add(scopeToken);
4116
+ }
4117
+ // Set property element for synthetic shadow DOM style scoping.
4118
+ const { stylesheetToken: syntheticToken } = owner.context;
4119
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
4120
+ elm.$shadowToken$ = syntheticToken;
4121
+ }
4122
+ }
4123
+ function applyDomManual(elm, vnode) {
4124
+ var _a;
4125
+ const { owner, data: { context }, } = vnode;
4126
+ 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 */) {
4127
+ elm.$domManual$ = true;
4122
4128
  }
4129
+ }
4130
+ function applyElementRestrictions(elm, vnode) {
4131
+ var _a, _b;
4123
4132
  if (process.env.NODE_ENV !== 'production') {
4124
- const { data: { context }, } = vnode;
4125
- const isPortal = !isUndefined$1(context) &&
4126
- !isUndefined$1(context.lwc) &&
4127
- context.lwc.dom === "manual" /* LwcDomMode.Manual */;
4128
- const isLight = owner.renderMode === 0 /* RenderMode.Light */;
4129
- patchElementWithRestrictions(elm, { isPortal, isLight });
4133
+ 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 */;
4134
+ const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4135
+ patchElementWithRestrictions(elm, {
4136
+ isPortal,
4137
+ isLight,
4138
+ });
4130
4139
  }
4131
4140
  }
4132
4141
  function allocateChildren(vnode, vm) {
@@ -4161,15 +4170,6 @@
4161
4170
  return vm;
4162
4171
  }
4163
4172
  const { sel, mode, ctor, owner } = vnode;
4164
- setScopeTokenClassIfNecessary(elm, owner, renderer);
4165
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
4166
- const { stylesheetToken } = owner.context;
4167
- // when running in synthetic shadow mode, we need to set the shadowToken value
4168
- // into each element from the template, so they can be styled accordingly.
4169
- if (!isUndefined$1(stylesheetToken)) {
4170
- setElementShadowToken(elm, stylesheetToken);
4171
- }
4172
- }
4173
4173
  vm = createVM(elm, ctor, renderer, {
4174
4174
  mode,
4175
4175
  owner,
@@ -4274,25 +4274,25 @@
4274
4274
  newEndVnode = newCh[--newEndIdx];
4275
4275
  }
4276
4276
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4277
- patch(oldStartVnode, newStartVnode, renderer);
4277
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4278
4278
  oldStartVnode = oldCh[++oldStartIdx];
4279
4279
  newStartVnode = newCh[++newStartIdx];
4280
4280
  }
4281
4281
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4282
- patch(oldEndVnode, newEndVnode, renderer);
4282
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4283
4283
  oldEndVnode = oldCh[--oldEndIdx];
4284
4284
  newEndVnode = newCh[--newEndIdx];
4285
4285
  }
4286
4286
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4287
4287
  // Vnode moved right
4288
- patch(oldStartVnode, newEndVnode, renderer);
4288
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4289
4289
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4290
4290
  oldStartVnode = oldCh[++oldStartIdx];
4291
4291
  newEndVnode = newCh[--newEndIdx];
4292
4292
  }
4293
4293
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4294
4294
  // Vnode moved left
4295
- patch(oldEndVnode, newStartVnode, renderer);
4295
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4296
4296
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4297
4297
  oldEndVnode = oldCh[--oldEndIdx];
4298
4298
  newStartVnode = newCh[++newStartIdx];
@@ -4315,7 +4315,7 @@
4315
4315
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4316
4316
  }
4317
4317
  else {
4318
- patch(elmToMove, newStartVnode, renderer);
4318
+ patch(elmToMove, newStartVnode, parent, renderer);
4319
4319
  // Delete the old child, but copy the array since it is read-only.
4320
4320
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4321
4321
  // so we only care about the `oldCh` object inside this function.
@@ -4375,7 +4375,7 @@
4375
4375
  if (isVNode(n1)) {
4376
4376
  if (isVNode(n2)) {
4377
4377
  // both vnodes are equivalent, and we just need to patch them
4378
- patch(n1, n2, renderer);
4378
+ patch(n1, n2, parent, renderer);
4379
4379
  anchor = n2.elm;
4380
4380
  }
4381
4381
  else {
@@ -4709,13 +4709,6 @@
4709
4709
  }
4710
4710
  return url;
4711
4711
  }
4712
- /**
4713
- * Map to store an index value assigned to any dynamic component reference ingested
4714
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4715
- * component reference to avoid diffing algo mismatches.
4716
- */
4717
- const DynamicImportedComponentMap = new Map();
4718
- let dynamicImportedComponentCounter = 0;
4719
4712
  /**
4720
4713
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4721
4714
  */
@@ -4732,18 +4725,7 @@
4732
4725
  if (!isComponentConstructor(Ctor)) {
4733
4726
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4734
4727
  }
4735
- let idx = DynamicImportedComponentMap.get(Ctor);
4736
- if (isUndefined$1(idx)) {
4737
- idx = dynamicImportedComponentCounter++;
4738
- DynamicImportedComponentMap.set(Ctor, idx);
4739
- }
4740
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4741
- // to identify different constructors as vnodes with different keys to avoid reusing the
4742
- // element used for previous constructors.
4743
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4744
- // hoisting optimization.
4745
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4746
- return c(sel, Ctor, newData, children);
4728
+ return c(sel, Ctor, data, children);
4747
4729
  }
4748
4730
  /**
4749
4731
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5219,7 +5201,7 @@
5219
5201
  return signedTemplateMap.get(Ctor);
5220
5202
  }
5221
5203
  function getTemplateReactiveObserver(vm) {
5222
- return new ReactiveObserver(() => {
5204
+ return createReactiveObserver(() => {
5223
5205
  const { isDirty } = vm;
5224
5206
  if (isFalse(isDirty)) {
5225
5207
  markComponentAsDirty(vm);
@@ -5637,16 +5619,9 @@
5637
5619
  const {
5638
5620
  def: {
5639
5621
  renderedCallback
5640
- },
5641
- renderer: {
5642
- ssr
5643
5622
  }
5644
5623
  } = vm;
5645
5624
 
5646
- if (isTrue(ssr)) {
5647
- return;
5648
- }
5649
-
5650
5625
  const {
5651
5626
  rendered
5652
5627
  } = Services;
@@ -5896,13 +5871,7 @@
5896
5871
  vm.velements = EmptyArray;
5897
5872
  }
5898
5873
  function scheduleRehydration(vm) {
5899
- const {
5900
- renderer: {
5901
- ssr
5902
- }
5903
- } = vm;
5904
-
5905
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5874
+ if (isTrue(vm.isScheduled)) {
5906
5875
  return;
5907
5876
  }
5908
5877
 
@@ -6009,15 +5978,8 @@
6009
5978
  }
6010
5979
 
6011
5980
  function createFieldDataCallback(vm, name) {
6012
- const {
6013
- cmpFields
6014
- } = vm;
6015
5981
  return value => {
6016
- if (value !== vm.cmpFields[name]) {
6017
- // storing the value in the underlying storage
6018
- cmpFields[name] = value;
6019
- componentValueMutated(vm, name);
6020
- }
5982
+ updateComponentValue(vm, name, value);
6021
5983
  };
6022
5984
  }
6023
5985
 
@@ -6034,7 +5996,7 @@
6034
5996
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
6035
5997
  let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
6036
5998
 
6037
- const ro = new ReactiveObserver(() => {
5999
+ const ro = createReactiveObserver(() => {
6038
6000
  if (hasPendingConfig === false) {
6039
6001
  hasPendingConfig = true; // collect new config in the micro-task
6040
6002
 
@@ -6330,7 +6292,7 @@
6330
6292
  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.');
6331
6293
  }
6332
6294
  }
6333
- return reactiveMembrane.getReadOnlyProxy(obj);
6295
+ return getReadOnlyProxy(obj);
6334
6296
  }
6335
6297
 
6336
6298
  /*
@@ -6841,7 +6803,7 @@
6841
6803
  }
6842
6804
  return ctor;
6843
6805
  }
6844
- /* version: 2.21.0 */
6806
+ /* version: 2.23.0 */
6845
6807
 
6846
6808
  /*
6847
6809
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6985,6 +6947,69 @@
6985
6947
  }
6986
6948
  }
6987
6949
 
6950
+ /*
6951
+ * Copyright (c) 2018, salesforce.com, inc.
6952
+ * All rights reserved.
6953
+ * SPDX-License-Identifier: MIT
6954
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6955
+ */
6956
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
6957
+ let createFragment;
6958
+ if (SUPPORTS_TEMPLATE) {
6959
+ // Parse the fragment HTML string into DOM
6960
+ createFragment = function (html) {
6961
+ const template = document.createElement('template');
6962
+ template.innerHTML = html;
6963
+ return template.content.firstChild;
6964
+ };
6965
+ }
6966
+ else {
6967
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
6968
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
6969
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
6970
+ // With other elements added from:
6971
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
6972
+ // Using the test:
6973
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
6974
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
6975
+ const topLevelWrappingMap = {
6976
+ caption: ['table'],
6977
+ col: ['colgroup', 'table'],
6978
+ colgroup: ['table'],
6979
+ option: ['select'],
6980
+ tbody: ['table'],
6981
+ td: ['tr', 'tbody', 'table'],
6982
+ th: ['tr', 'tbody', 'table'],
6983
+ thead: ['table'],
6984
+ tfoot: ['table'],
6985
+ tr: ['tbody', 'table'],
6986
+ };
6987
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
6988
+ const getTagName = function (text) {
6989
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
6990
+ };
6991
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
6992
+ createFragment = function (html) {
6993
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
6994
+ if (!isUndefined$1(wrapperTags)) {
6995
+ for (const wrapperTag of wrapperTags) {
6996
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
6997
+ }
6998
+ }
6999
+ // For IE11, the document title must not be undefined, but it can be an empty string
7000
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
7001
+ const doc = document.implementation.createHTMLDocument('');
7002
+ doc.body.innerHTML = html;
7003
+ let content = doc.body;
7004
+ if (!isUndefined$1(wrapperTags)) {
7005
+ for (let i = 0; i < wrapperTags.length; i++) {
7006
+ content = content.firstChild;
7007
+ }
7008
+ }
7009
+ return content.firstChild;
7010
+ };
7011
+ }
7012
+
6988
7013
  /*
6989
7014
  * Copyright (c) 2018, salesforce.com, inc.
6990
7015
  * All rights reserved.
@@ -7050,22 +7075,11 @@
7050
7075
  };
7051
7076
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7052
7077
  }
7053
- let hydrating = false;
7054
- function setIsHydrating(value) {
7055
- hydrating = value;
7056
- }
7057
- const ssr = false;
7058
- function isHydrating() {
7059
- return hydrating;
7060
- }
7061
7078
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
7062
7079
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7063
7080
  function cloneNode(node, deep) {
7064
7081
  return node.cloneNode(deep);
7065
7082
  }
7066
- function createFragment(html) {
7067
- return document.createRange().createContextualFragment(html).firstChild;
7068
- }
7069
7083
  function createElement$1(tagName, namespace) {
7070
7084
  return isUndefined$1(namespace)
7071
7085
  ? document.createElement(tagName)
@@ -7087,15 +7101,11 @@
7087
7101
  return node.nextSibling;
7088
7102
  }
7089
7103
  function attachShadow(element, options) {
7090
- // `hydrating` will be true in two cases:
7104
+ // `shadowRoot` will be non-null in two cases:
7091
7105
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7092
7106
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
7093
- // root component with customeElement.define('c-app', Ctor)
7094
- //
7095
- // The second case can be treated as a failed hydration with nominal impact
7096
- // to performance. However, because <c-app> won't have a <template shadowroot>
7097
- // declarative child, `element.shadowRoot` is `null`.
7098
- if (hydrating && element.shadowRoot) {
7107
+ // root component with customElement.define('c-app', Ctor)
7108
+ if (!isNull(element.shadowRoot)) {
7099
7109
  return element.shadowRoot;
7100
7110
  }
7101
7111
  return element.attachShadow(options);
@@ -7191,11 +7201,9 @@
7191
7201
  }
7192
7202
  const HTMLElementExported = HTMLElementConstructor;
7193
7203
  const renderer = {
7194
- ssr,
7195
7204
  isNativeShadowDefined,
7196
7205
  isSyntheticShadowDefined,
7197
7206
  HTMLElementExported,
7198
- isHydrating,
7199
7207
  insert,
7200
7208
  remove,
7201
7209
  cloneNode,
@@ -7281,13 +7289,8 @@
7281
7289
  return;
7282
7290
  }
7283
7291
  try {
7284
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7285
- // and uses the same algo to create the stylesheets as in SSR.
7286
- setIsHydrating(true);
7287
7292
  const vm = createVMWithProps(element, Ctor, props);
7288
7293
  hydrateRoot(vm);
7289
- // set it back since now we finished hydration.
7290
- setIsHydrating(false);
7291
7294
  }
7292
7295
  catch (e) {
7293
7296
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -7298,13 +7301,8 @@
7298
7301
  resetShadowRootAndLightDom(element, Ctor);
7299
7302
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
7300
7303
  createVMWithProps(element, Ctor, props);
7301
- setIsHydrating(false);
7302
7304
  connectRootElement(element);
7303
7305
  }
7304
- finally {
7305
- // in case there's an error during recovery
7306
- setIsHydrating(false);
7307
- }
7308
7306
  }
7309
7307
 
7310
7308
  /*
@@ -7529,7 +7527,7 @@
7529
7527
  });
7530
7528
  freeze(LightningElement);
7531
7529
  seal(LightningElement.prototype);
7532
- /* version: 2.21.0 */
7530
+ /* version: 2.23.0 */
7533
7531
 
7534
7532
  exports.LightningElement = LightningElement;
7535
7533
  exports.__unstable__ProfilerControl = profilerControl;