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
@@ -291,7 +291,7 @@ var LWC = (function (exports) {
291
291
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
292
292
  return attributeName;
293
293
  }
294
- /** version: 2.21.0 */
294
+ /** version: 2.23.0 */
295
295
 
296
296
  /*
297
297
  * Copyright (c) 2018, salesforce.com, inc.
@@ -592,18 +592,21 @@ var LWC = (function (exports) {
592
592
  ArrayPush$1.call(this.listeners, reactiveObservers);
593
593
  }
594
594
  }
595
-
596
- /*
597
- * Copyright (c) 2018, salesforce.com, inc.
598
- * All rights reserved.
599
- * SPDX-License-Identifier: MIT
600
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
601
- */
602
595
  function componentValueMutated(vm, key) {
603
- valueMutated(vm.component, key);
596
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
597
+ {
598
+ valueMutated(vm.component, key);
599
+ }
604
600
  }
605
601
  function componentValueObserved(vm, key) {
606
- valueObserved(vm.component, key);
602
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
603
+ {
604
+ valueObserved(vm.component, key);
605
+ }
606
+ }
607
+ function createReactiveObserver(callback) {
608
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
609
+ return new ReactiveObserver(callback) ;
607
610
  }
608
611
 
609
612
  /*
@@ -856,6 +859,14 @@ var LWC = (function (exports) {
856
859
  }
857
860
  });
858
861
 
862
+ function updateComponentValue(vm, key, newValue) {
863
+ const { cmpFields } = vm;
864
+ if (newValue !== cmpFields[key]) {
865
+ cmpFields[key] = newValue;
866
+ componentValueMutated(vm, key);
867
+ }
868
+ }
869
+
859
870
  /**
860
871
  * Copyright (C) 2017 salesforce.com, inc.
861
872
  */
@@ -1286,7 +1297,24 @@ var LWC = (function (exports) {
1286
1297
  * change or being removed.
1287
1298
  */
1288
1299
  function unwrap(value) {
1289
- return reactiveMembrane.unwrapProxy(value);
1300
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1301
+ return reactiveMembrane.unwrapProxy(value) ;
1302
+ }
1303
+ function getReadOnlyProxy(value) {
1304
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1305
+ // them from their parents. This applies to both the client and server.
1306
+ return reactiveMembrane.getReadOnlyProxy(value);
1307
+ }
1308
+ function getReactiveProxy(value) {
1309
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1310
+ return reactiveMembrane.getProxy(value) ;
1311
+ }
1312
+ // Making the component instance a live value when using Locker to support expandos.
1313
+ function markLockerLiveObject(obj) {
1314
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1315
+ {
1316
+ obj[lockerLivePropertyKey] = undefined;
1317
+ }
1290
1318
  }
1291
1319
 
1292
1320
  /*
@@ -1322,10 +1350,7 @@ var LWC = (function (exports) {
1322
1350
  },
1323
1351
  set(newValue) {
1324
1352
  const vm = getAssociatedVM(this);
1325
- if (newValue !== vm.cmpProps[propName]) {
1326
- vm.cmpProps[propName] = newValue;
1327
- componentValueMutated(vm, propName);
1328
- }
1353
+ updateComponentValue(vm, propName, newValue);
1329
1354
  return set.call(vm.elm, newValue);
1330
1355
  },
1331
1356
  };
@@ -1356,8 +1381,7 @@ var LWC = (function (exports) {
1356
1381
  vm.setHook = setHook;
1357
1382
  vm.getHook = getHook;
1358
1383
  }
1359
- // Making the component instance a live value when using Locker to support expandos.
1360
- this[lockerLivePropertyKey] = undefined;
1384
+ markLockerLiveObject(this);
1361
1385
  // Linking elm, shadow root and component with the VM.
1362
1386
  associateVM(component, vm);
1363
1387
  associateVM(elm, vm);
@@ -1555,15 +1579,51 @@ var LWC = (function (exports) {
1555
1579
  },
1556
1580
  set(newValue) {
1557
1581
  const vm = getAssociatedVM(this);
1558
- if (newValue !== vm.cmpFields[key]) {
1559
- vm.cmpFields[key] = newValue;
1560
- componentValueMutated(vm, key);
1561
- }
1582
+ updateComponentValue(vm, key, newValue);
1562
1583
  },
1563
1584
  enumerable: true,
1564
1585
  configurable: true,
1565
1586
  };
1566
1587
  }
1588
+ class AccessorReactiveObserver extends ReactiveObserver {
1589
+ constructor(vm, set) {
1590
+ super(() => {
1591
+ if (isFalse(this.debouncing)) {
1592
+ this.debouncing = true;
1593
+ addCallbackToNextTick(() => {
1594
+ if (isTrue(this.debouncing)) {
1595
+ const { value } = this;
1596
+ const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
1597
+ set.call(component, value);
1598
+ // de-bouncing after the call to the original setter to prevent
1599
+ // infinity loop if the setter itself is mutating things that
1600
+ // were accessed during the previous invocation.
1601
+ this.debouncing = false;
1602
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
1603
+ // immediate rehydration due to a setter driven mutation, otherwise
1604
+ // the component will get rendered on the second tick, which it is not
1605
+ // desirable.
1606
+ rerenderVM(vm);
1607
+ }
1608
+ }
1609
+ });
1610
+ }
1611
+ });
1612
+ this.debouncing = false;
1613
+ }
1614
+ reset(value) {
1615
+ super.reset();
1616
+ this.debouncing = false;
1617
+ if (arguments.length > 0) {
1618
+ this.value = value;
1619
+ }
1620
+ }
1621
+ }
1622
+ function createAccessorReactiveObserver(vm, set) {
1623
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1624
+ return new AccessorReactiveObserver(vm, set)
1625
+ ;
1626
+ }
1567
1627
 
1568
1628
  /*
1569
1629
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1600,50 +1660,6 @@ var LWC = (function (exports) {
1600
1660
  configurable: true
1601
1661
  };
1602
1662
  }
1603
- class AccessorReactiveObserver extends ReactiveObserver {
1604
- constructor(vm, set) {
1605
- super(() => {
1606
- if (isFalse(this.debouncing)) {
1607
- this.debouncing = true;
1608
- addCallbackToNextTick(() => {
1609
- if (isTrue(this.debouncing)) {
1610
- const {
1611
- value
1612
- } = this;
1613
- const {
1614
- isDirty: dirtyStateBeforeSetterCall,
1615
- component,
1616
- idx
1617
- } = vm;
1618
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
1619
- // infinity loop if the setter itself is mutating things that
1620
- // were accessed during the previous invocation.
1621
-
1622
- this.debouncing = false;
1623
-
1624
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
1625
- // immediate rehydration due to a setter driven mutation, otherwise
1626
- // the component will get rendered on the second tick, which it is not
1627
- // desirable.
1628
- rerenderVM(vm);
1629
- }
1630
- }
1631
- });
1632
- }
1633
- });
1634
- this.debouncing = false;
1635
- }
1636
-
1637
- reset(value) {
1638
- super.reset();
1639
- this.debouncing = false;
1640
-
1641
- if (arguments.length > 0) {
1642
- this.value = value;
1643
- }
1644
- }
1645
-
1646
- }
1647
1663
  function createPublicAccessorDescriptor(key, descriptor) {
1648
1664
  const {
1649
1665
  get,
@@ -1671,7 +1687,7 @@ var LWC = (function (exports) {
1671
1687
  let ro = vm.oar[key];
1672
1688
 
1673
1689
  if (isUndefined$1(ro)) {
1674
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
1690
+ ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
1675
1691
  } // every time we invoke this setter from outside (through this wrapper setter)
1676
1692
  // we should reset the value and then debounce just in case there is a pending
1677
1693
  // invocation the next tick that is not longer relevant since the value is changing
@@ -1701,7 +1717,7 @@ var LWC = (function (exports) {
1701
1717
  */
1702
1718
  function track(target) {
1703
1719
  if (arguments.length === 1) {
1704
- return reactiveMembrane.getProxy(target);
1720
+ return getReactiveProxy(target);
1705
1721
  }
1706
1722
  throw new Error();
1707
1723
  }
@@ -1714,11 +1730,8 @@ var LWC = (function (exports) {
1714
1730
  },
1715
1731
  set(newValue) {
1716
1732
  const vm = getAssociatedVM(this);
1717
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
1718
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
1719
- vm.cmpFields[key] = reactiveOrAnyValue;
1720
- componentValueMutated(vm, key);
1721
- }
1733
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
1734
+ updateComponentValue(vm, key, reactiveOrAnyValue);
1722
1735
  },
1723
1736
  enumerable: true,
1724
1737
  configurable: true,
@@ -1754,10 +1767,7 @@ var LWC = (function (exports) {
1754
1767
  * letting the author to do the wrong thing, but it will keep our
1755
1768
  * system to be backward compatible.
1756
1769
  */
1757
- if (value !== vm.cmpFields[key]) {
1758
- vm.cmpFields[key] = value;
1759
- componentValueMutated(vm, key);
1760
- }
1770
+ updateComponentValue(vm, key, value);
1761
1771
  },
1762
1772
  enumerable: true,
1763
1773
  configurable: true,
@@ -1967,7 +1977,7 @@ var LWC = (function (exports) {
1967
1977
  fn = cachedSetterByKey[key] = function (newValue) {
1968
1978
  const vm = getAssociatedVM(this);
1969
1979
  const { setHook } = vm;
1970
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
1980
+ newValue = getReadOnlyProxy(newValue);
1971
1981
  setHook(vm.component, key, newValue);
1972
1982
  };
1973
1983
  }
@@ -2426,13 +2436,13 @@ var LWC = (function (exports) {
2426
2436
  return owner;
2427
2437
  }
2428
2438
  function createStylesheet(vm, stylesheets) {
2429
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
2439
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
2430
2440
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
2431
2441
  for (let i = 0; i < stylesheets.length; i++) {
2432
2442
  insertStylesheet(stylesheets[i]);
2433
2443
  }
2434
2444
  }
2435
- else if (ssr || vm.hydrated) {
2445
+ else if (vm.hydrated) {
2436
2446
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
2437
2447
  // This works in the client, because the stylesheets are created, and cached in the VM
2438
2448
  // the first time the VM renders.
@@ -2729,7 +2739,7 @@ var LWC = (function (exports) {
2729
2739
  updateStaticChildren(c1, c2, parent, renderer);
2730
2740
  }
2731
2741
  }
2732
- function patch(n1, n2, renderer) {
2742
+ function patch(n1, n2, parent, renderer) {
2733
2743
  var _a, _b;
2734
2744
  if (n1 === n2) {
2735
2745
  return;
@@ -2750,7 +2760,7 @@ var LWC = (function (exports) {
2750
2760
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
2751
2761
  break;
2752
2762
  case 3 /* VNodeType.CustomElement */:
2753
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2763
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
2754
2764
  break;
2755
2765
  }
2756
2766
  }
@@ -2811,10 +2821,10 @@ var LWC = (function (exports) {
2811
2821
  const { sel, owner, data: { svg }, } = vnode;
2812
2822
  const { createElement } = renderer;
2813
2823
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
2814
- const elm = createElement(sel, namespace);
2824
+ const elm = (vnode.elm = createElement(sel, namespace));
2815
2825
  linkNodeToShadow(elm, owner, renderer);
2816
- fallbackElmHook(elm, vnode, renderer);
2817
- vnode.elm = elm;
2826
+ applyStyleScoping(elm, owner, renderer);
2827
+ applyDomManual(elm, vnode);
2818
2828
  patchElementPropsAndAttrs$1(null, vnode, renderer);
2819
2829
  insertNode(elm, parent, anchor, renderer);
2820
2830
  mountVNodes(vnode.children, elm, renderer, null);
@@ -2852,9 +2862,10 @@ var LWC = (function (exports) {
2852
2862
  // the custom element from the registry is expecting an upgrade callback
2853
2863
  vm = createViewModelHook(elm, vnode, renderer);
2854
2864
  });
2855
- linkNodeToShadow(elm, owner, renderer);
2856
2865
  vnode.elm = elm;
2857
2866
  vnode.vm = vm;
2867
+ linkNodeToShadow(elm, owner, renderer);
2868
+ applyStyleScoping(elm, owner, renderer);
2858
2869
  if (vm) {
2859
2870
  allocateChildren(vnode, vm);
2860
2871
  }
@@ -2871,22 +2882,32 @@ var LWC = (function (exports) {
2871
2882
  appendVM(vm);
2872
2883
  }
2873
2884
  }
2874
- function patchCustomElement(n1, n2, renderer) {
2875
- const elm = (n2.elm = n1.elm);
2876
- const vm = (n2.vm = n1.vm);
2877
- patchElementPropsAndAttrs$1(n1, n2, renderer);
2878
- if (!isUndefined$1(vm)) {
2879
- // in fallback mode, the allocation will always set children to
2880
- // empty and delegate the real allocation to the slot elements
2881
- allocateChildren(n2, vm);
2885
+ function patchCustomElement(n1, n2, parent, renderer) {
2886
+ if (n1.ctor !== n2.ctor) {
2887
+ // If the constructor, unmount the current component and mount a new one using the new
2888
+ // constructor.
2889
+ const anchor = renderer.nextSibling(n1.elm);
2890
+ unmount(n1, parent, renderer, true);
2891
+ mountCustomElement(n2, parent, anchor, renderer);
2882
2892
  }
2883
- // in fallback mode, the children will be always empty, so, nothing
2884
- // will happen, but in native, it does allocate the light dom
2885
- patchChildren(n1.children, n2.children, elm, renderer);
2886
- if (!isUndefined$1(vm)) {
2887
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
2888
- // this is important to preserve the top to bottom synchronous rendering phase.
2889
- rerenderVM(vm);
2893
+ else {
2894
+ // Otherwise patch the existing component with new props/attrs/etc.
2895
+ const elm = (n2.elm = n1.elm);
2896
+ const vm = (n2.vm = n1.vm);
2897
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
2898
+ if (!isUndefined$1(vm)) {
2899
+ // in fallback mode, the allocation will always set children to
2900
+ // empty and delegate the real allocation to the slot elements
2901
+ allocateChildren(n2, vm);
2902
+ }
2903
+ // in fallback mode, the children will be always empty, so, nothing
2904
+ // will happen, but in native, it does allocate the light dom
2905
+ patchChildren(n1.children, n2.children, elm, renderer);
2906
+ if (!isUndefined$1(vm)) {
2907
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
2908
+ // this is important to preserve the top to bottom synchronous rendering phase.
2909
+ rerenderVM(vm);
2910
+ }
2890
2911
  }
2891
2912
  }
2892
2913
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -2935,22 +2956,6 @@ var LWC = (function (exports) {
2935
2956
  function isVNode(vnode) {
2936
2957
  return vnode != null;
2937
2958
  }
2938
- function observeElementChildNodes(elm) {
2939
- elm.$domManual$ = true;
2940
- }
2941
- function setElementShadowToken(elm, token) {
2942
- elm.$shadowToken$ = token;
2943
- }
2944
- // Set the scope token class for *.scoped.css styles
2945
- function setScopeTokenClassIfNecessary(elm, owner, renderer) {
2946
- const token = getScopeTokenClass(owner);
2947
- if (!isNull(token)) {
2948
- const { getClassList } = renderer;
2949
- // TODO [#2762]: this dot notation with add is probably problematic
2950
- // probably we should have a renderer api for just the add operation
2951
- getClassList(elm).add(token);
2952
- }
2953
- }
2954
2959
  function linkNodeToShadow(elm, owner, renderer) {
2955
2960
  const { renderRoot, renderMode, shadowMode } = owner;
2956
2961
  const { isSyntheticShadowDefined } = renderer;
@@ -2985,23 +2990,26 @@ var LWC = (function (exports) {
2985
2990
  patchAttributes(oldVnode, vnode, renderer);
2986
2991
  patchProps(oldVnode, vnode, renderer);
2987
2992
  }
2988
- function fallbackElmHook(elm, vnode, renderer) {
2989
- const { owner } = vnode;
2990
- setScopeTokenClassIfNecessary(elm, owner, renderer);
2991
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
2992
- const { data: { context }, } = vnode;
2993
- const { stylesheetToken } = owner.context;
2994
- if (!isUndefined$1(context) &&
2995
- !isUndefined$1(context.lwc) &&
2996
- context.lwc.dom === "manual" /* LwcDomMode.Manual */) {
2997
- // this element will now accept any manual content inserted into it
2998
- observeElementChildNodes(elm);
2999
- }
3000
- if (!isUndefined$1(stylesheetToken)) {
3001
- // when running in synthetic shadow mode, we need to set the shadowToken value
3002
- // into each element from the template, so they can be styled accordingly.
3003
- setElementShadowToken(elm, stylesheetToken);
3004
- }
2993
+ function applyStyleScoping(elm, owner, renderer) {
2994
+ // Set the class name for `*.scoped.css` style scoping.
2995
+ const scopeToken = getScopeTokenClass(owner);
2996
+ if (!isNull(scopeToken)) {
2997
+ const { getClassList } = renderer;
2998
+ // TODO [#2762]: this dot notation with add is probably problematic
2999
+ // probably we should have a renderer api for just the add operation
3000
+ getClassList(elm).add(scopeToken);
3001
+ }
3002
+ // Set property element for synthetic shadow DOM style scoping.
3003
+ const { stylesheetToken: syntheticToken } = owner.context;
3004
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
3005
+ elm.$shadowToken$ = syntheticToken;
3006
+ }
3007
+ }
3008
+ function applyDomManual(elm, vnode) {
3009
+ var _a;
3010
+ const { owner, data: { context }, } = vnode;
3011
+ 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 */) {
3012
+ elm.$domManual$ = true;
3005
3013
  }
3006
3014
  }
3007
3015
  function allocateChildren(vnode, vm) {
@@ -3036,15 +3044,6 @@ var LWC = (function (exports) {
3036
3044
  return vm;
3037
3045
  }
3038
3046
  const { sel, mode, ctor, owner } = vnode;
3039
- setScopeTokenClassIfNecessary(elm, owner, renderer);
3040
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
3041
- const { stylesheetToken } = owner.context;
3042
- // when running in synthetic shadow mode, we need to set the shadowToken value
3043
- // into each element from the template, so they can be styled accordingly.
3044
- if (!isUndefined$1(stylesheetToken)) {
3045
- setElementShadowToken(elm, stylesheetToken);
3046
- }
3047
- }
3048
3047
  vm = createVM(elm, ctor, renderer, {
3049
3048
  mode,
3050
3049
  owner,
@@ -3146,25 +3145,25 @@ var LWC = (function (exports) {
3146
3145
  newEndVnode = newCh[--newEndIdx];
3147
3146
  }
3148
3147
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
3149
- patch(oldStartVnode, newStartVnode, renderer);
3148
+ patch(oldStartVnode, newStartVnode, parent, renderer);
3150
3149
  oldStartVnode = oldCh[++oldStartIdx];
3151
3150
  newStartVnode = newCh[++newStartIdx];
3152
3151
  }
3153
3152
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
3154
- patch(oldEndVnode, newEndVnode, renderer);
3153
+ patch(oldEndVnode, newEndVnode, parent, renderer);
3155
3154
  oldEndVnode = oldCh[--oldEndIdx];
3156
3155
  newEndVnode = newCh[--newEndIdx];
3157
3156
  }
3158
3157
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
3159
3158
  // Vnode moved right
3160
- patch(oldStartVnode, newEndVnode, renderer);
3159
+ patch(oldStartVnode, newEndVnode, parent, renderer);
3161
3160
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3162
3161
  oldStartVnode = oldCh[++oldStartIdx];
3163
3162
  newEndVnode = newCh[--newEndIdx];
3164
3163
  }
3165
3164
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
3166
3165
  // Vnode moved left
3167
- patch(oldEndVnode, newStartVnode, renderer);
3166
+ patch(oldEndVnode, newStartVnode, parent, renderer);
3168
3167
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3169
3168
  oldEndVnode = oldCh[--oldEndIdx];
3170
3169
  newStartVnode = newCh[++newStartIdx];
@@ -3187,7 +3186,7 @@ var LWC = (function (exports) {
3187
3186
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3188
3187
  }
3189
3188
  else {
3190
- patch(elmToMove, newStartVnode, renderer);
3189
+ patch(elmToMove, newStartVnode, parent, renderer);
3191
3190
  // Delete the old child, but copy the array since it is read-only.
3192
3191
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3193
3192
  // so we only care about the `oldCh` object inside this function.
@@ -3247,7 +3246,7 @@ var LWC = (function (exports) {
3247
3246
  if (isVNode(n1)) {
3248
3247
  if (isVNode(n2)) {
3249
3248
  // both vnodes are equivalent, and we just need to patch them
3250
- patch(n1, n2, renderer);
3249
+ patch(n1, n2, parent, renderer);
3251
3250
  anchor = n2.elm;
3252
3251
  }
3253
3252
  else {
@@ -3476,13 +3475,6 @@ var LWC = (function (exports) {
3476
3475
  }
3477
3476
  return url;
3478
3477
  }
3479
- /**
3480
- * Map to store an index value assigned to any dynamic component reference ingested
3481
- * by dc() api. This allows us to generate a unique unique per template per dynamic
3482
- * component reference to avoid diffing algo mismatches.
3483
- */
3484
- const DynamicImportedComponentMap = new Map();
3485
- let dynamicImportedComponentCounter = 0;
3486
3478
  /**
3487
3479
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
3488
3480
  */
@@ -3494,18 +3486,7 @@ var LWC = (function (exports) {
3494
3486
  if (!isComponentConstructor(Ctor)) {
3495
3487
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
3496
3488
  }
3497
- let idx = DynamicImportedComponentMap.get(Ctor);
3498
- if (isUndefined$1(idx)) {
3499
- idx = dynamicImportedComponentCounter++;
3500
- DynamicImportedComponentMap.set(Ctor, idx);
3501
- }
3502
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
3503
- // to identify different constructors as vnodes with different keys to avoid reusing the
3504
- // element used for previous constructors.
3505
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
3506
- // hoisting optimization.
3507
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
3508
- return c(sel, Ctor, newData, children);
3489
+ return c(sel, Ctor, data, children);
3509
3490
  }
3510
3491
  /**
3511
3492
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -3861,7 +3842,7 @@ var LWC = (function (exports) {
3861
3842
  return signedTemplateMap.get(Ctor);
3862
3843
  }
3863
3844
  function getTemplateReactiveObserver(vm) {
3864
- return new ReactiveObserver(() => {
3845
+ return createReactiveObserver(() => {
3865
3846
  const { isDirty } = vm;
3866
3847
  if (isFalse(isDirty)) {
3867
3848
  markComponentAsDirty(vm);
@@ -4225,16 +4206,9 @@ var LWC = (function (exports) {
4225
4206
  const {
4226
4207
  def: {
4227
4208
  renderedCallback
4228
- },
4229
- renderer: {
4230
- ssr
4231
4209
  }
4232
4210
  } = vm;
4233
4211
 
4234
- if (isTrue(ssr)) {
4235
- return;
4236
- }
4237
-
4238
4212
  const {
4239
4213
  rendered
4240
4214
  } = Services;
@@ -4475,13 +4449,7 @@ var LWC = (function (exports) {
4475
4449
  vm.velements = EmptyArray;
4476
4450
  }
4477
4451
  function scheduleRehydration(vm) {
4478
- const {
4479
- renderer: {
4480
- ssr
4481
- }
4482
- } = vm;
4483
-
4484
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
4452
+ if (isTrue(vm.isScheduled)) {
4485
4453
  return;
4486
4454
  }
4487
4455
 
@@ -4571,15 +4539,8 @@ var LWC = (function (exports) {
4571
4539
  }
4572
4540
 
4573
4541
  function createFieldDataCallback(vm, name) {
4574
- const {
4575
- cmpFields
4576
- } = vm;
4577
4542
  return value => {
4578
- if (value !== vm.cmpFields[name]) {
4579
- // storing the value in the underlying storage
4580
- cmpFields[name] = value;
4581
- componentValueMutated(vm, name);
4582
- }
4543
+ updateComponentValue(vm, name, value);
4583
4544
  };
4584
4545
  }
4585
4546
 
@@ -4596,7 +4557,7 @@ var LWC = (function (exports) {
4596
4557
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
4597
4558
  let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
4598
4559
 
4599
- const ro = new ReactiveObserver(() => {
4560
+ const ro = createReactiveObserver(() => {
4600
4561
  if (hasPendingConfig === false) {
4601
4562
  hasPendingConfig = true; // collect new config in the micro-task
4602
4563
 
@@ -4882,7 +4843,7 @@ var LWC = (function (exports) {
4882
4843
  * being removed.
4883
4844
  */
4884
4845
  function readonly(obj) {
4885
- return reactiveMembrane.getReadOnlyProxy(obj);
4846
+ return getReadOnlyProxy(obj);
4886
4847
  }
4887
4848
 
4888
4849
  /*
@@ -5234,7 +5195,7 @@ var LWC = (function (exports) {
5234
5195
  }
5235
5196
  return ctor;
5236
5197
  }
5237
- /* version: 2.21.0 */
5198
+ /* version: 2.23.0 */
5238
5199
 
5239
5200
  /*
5240
5201
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5369,6 +5330,69 @@ var LWC = (function (exports) {
5369
5330
  }
5370
5331
  }
5371
5332
 
5333
+ /*
5334
+ * Copyright (c) 2018, salesforce.com, inc.
5335
+ * All rights reserved.
5336
+ * SPDX-License-Identifier: MIT
5337
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5338
+ */
5339
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
5340
+ let createFragment;
5341
+ if (SUPPORTS_TEMPLATE) {
5342
+ // Parse the fragment HTML string into DOM
5343
+ createFragment = function (html) {
5344
+ const template = document.createElement('template');
5345
+ template.innerHTML = html;
5346
+ return template.content.firstChild;
5347
+ };
5348
+ }
5349
+ else {
5350
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
5351
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
5352
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
5353
+ // With other elements added from:
5354
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
5355
+ // Using the test:
5356
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
5357
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
5358
+ const topLevelWrappingMap = {
5359
+ caption: ['table'],
5360
+ col: ['colgroup', 'table'],
5361
+ colgroup: ['table'],
5362
+ option: ['select'],
5363
+ tbody: ['table'],
5364
+ td: ['tr', 'tbody', 'table'],
5365
+ th: ['tr', 'tbody', 'table'],
5366
+ thead: ['table'],
5367
+ tfoot: ['table'],
5368
+ tr: ['tbody', 'table'],
5369
+ };
5370
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
5371
+ const getTagName = function (text) {
5372
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
5373
+ };
5374
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
5375
+ createFragment = function (html) {
5376
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
5377
+ if (!isUndefined$1(wrapperTags)) {
5378
+ for (const wrapperTag of wrapperTags) {
5379
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
5380
+ }
5381
+ }
5382
+ // For IE11, the document title must not be undefined, but it can be an empty string
5383
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
5384
+ const doc = document.implementation.createHTMLDocument('');
5385
+ doc.body.innerHTML = html;
5386
+ let content = doc.body;
5387
+ if (!isUndefined$1(wrapperTags)) {
5388
+ for (let i = 0; i < wrapperTags.length; i++) {
5389
+ content = content.firstChild;
5390
+ }
5391
+ }
5392
+ return content.firstChild;
5393
+ };
5394
+ }
5395
+
5372
5396
  /*
5373
5397
  * Copyright (c) 2018, salesforce.com, inc.
5374
5398
  * All rights reserved.
@@ -5434,22 +5458,11 @@ var LWC = (function (exports) {
5434
5458
  };
5435
5459
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5436
5460
  }
5437
- let hydrating = false;
5438
- function setIsHydrating(value) {
5439
- hydrating = value;
5440
- }
5441
- const ssr = false;
5442
- function isHydrating() {
5443
- return hydrating;
5444
- }
5445
5461
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
5446
5462
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
5447
5463
  function cloneNode(node, deep) {
5448
5464
  return node.cloneNode(deep);
5449
5465
  }
5450
- function createFragment(html) {
5451
- return document.createRange().createContextualFragment(html).firstChild;
5452
- }
5453
5466
  function createElement$1(tagName, namespace) {
5454
5467
  return isUndefined$1(namespace)
5455
5468
  ? document.createElement(tagName)
@@ -5471,15 +5484,11 @@ var LWC = (function (exports) {
5471
5484
  return node.nextSibling;
5472
5485
  }
5473
5486
  function attachShadow(element, options) {
5474
- // `hydrating` will be true in two cases:
5487
+ // `shadowRoot` will be non-null in two cases:
5475
5488
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
5476
5489
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
5477
- // root component with customeElement.define('c-app', Ctor)
5478
- //
5479
- // The second case can be treated as a failed hydration with nominal impact
5480
- // to performance. However, because <c-app> won't have a <template shadowroot>
5481
- // declarative child, `element.shadowRoot` is `null`.
5482
- if (hydrating && element.shadowRoot) {
5490
+ // root component with customElement.define('c-app', Ctor)
5491
+ if (!isNull(element.shadowRoot)) {
5483
5492
  return element.shadowRoot;
5484
5493
  }
5485
5494
  return element.attachShadow(options);
@@ -5569,11 +5578,9 @@ var LWC = (function (exports) {
5569
5578
  }
5570
5579
  const HTMLElementExported = HTMLElementConstructor;
5571
5580
  const renderer = {
5572
- ssr,
5573
5581
  isNativeShadowDefined,
5574
5582
  isSyntheticShadowDefined,
5575
5583
  HTMLElementExported,
5576
- isHydrating,
5577
5584
  insert,
5578
5585
  remove,
5579
5586
  cloneNode,
@@ -5659,13 +5666,8 @@ var LWC = (function (exports) {
5659
5666
  return;
5660
5667
  }
5661
5668
  try {
5662
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
5663
- // and uses the same algo to create the stylesheets as in SSR.
5664
- setIsHydrating(true);
5665
5669
  const vm = createVMWithProps(element, Ctor, props);
5666
5670
  hydrateRoot(vm);
5667
- // set it back since now we finished hydration.
5668
- setIsHydrating(false);
5669
5671
  }
5670
5672
  catch (e) {
5671
5673
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -5676,13 +5678,8 @@ var LWC = (function (exports) {
5676
5678
  resetShadowRootAndLightDom(element, Ctor);
5677
5679
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
5678
5680
  createVMWithProps(element, Ctor, props);
5679
- setIsHydrating(false);
5680
5681
  connectRootElement(element);
5681
5682
  }
5682
- finally {
5683
- // in case there's an error during recovery
5684
- setIsHydrating(false);
5685
- }
5686
5683
  }
5687
5684
 
5688
5685
  /*
@@ -5899,7 +5896,7 @@ var LWC = (function (exports) {
5899
5896
  });
5900
5897
  freeze(LightningElement);
5901
5898
  seal(LightningElement.prototype);
5902
- /* version: 2.21.0 */
5899
+ /* version: 2.23.0 */
5903
5900
 
5904
5901
  exports.LightningElement = LightningElement;
5905
5902
  exports.__unstable__ProfilerControl = profilerControl;