lwc 2.5.6 → 2.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +605 -181
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +605 -181
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +406 -169
  5. package/dist/engine-dom/iife/es5/engine-dom.js +684 -242
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +466 -221
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +605 -181
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +406 -169
  11. package/dist/engine-dom/umd/es5/engine-dom.js +684 -242
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +466 -221
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +484 -133
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +485 -133
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +8 -8
@@ -75,7 +75,7 @@
75
75
  find: ArrayFind,
76
76
  indexOf: ArrayIndexOf,
77
77
  join: ArrayJoin,
78
- map: ArrayMap$1,
78
+ map: ArrayMap,
79
79
  push: ArrayPush$1,
80
80
  reduce: ArrayReduce,
81
81
  reverse: ArrayReverse,
@@ -138,7 +138,7 @@
138
138
  // Array.prototype.toString directly will cause an error Iterate through
139
139
  // all the items and handle individually.
140
140
  if (isArray$1(obj)) {
141
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
141
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
142
142
  }
143
143
 
144
144
  return obj.toString();
@@ -301,7 +301,7 @@
301
301
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
302
302
  return attributeName;
303
303
  }
304
- /** version: 2.5.6 */
304
+ /** version: 2.5.10 */
305
305
 
306
306
  /*
307
307
  * Copyright (c) 2018, salesforce.com, inc.
@@ -473,7 +473,7 @@
473
473
 
474
474
  function setFeatureFlagForTest(name, value) {
475
475
  }
476
- /** version: 2.5.6 */
476
+ /** version: 2.5.10 */
477
477
 
478
478
  /* proxy-compat-disable */
479
479
 
@@ -515,7 +515,7 @@
515
515
  }
516
516
 
517
517
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
518
- }
518
+ } // Borrowed from Vue template compiler.
519
519
  /*
520
520
  * Copyright (c) 2019, salesforce.com, inc.
521
521
  * All rights reserved.
@@ -663,6 +663,20 @@
663
663
  return `<${StringToLowerCase.call(vm.tagName)}>`;
664
664
  } // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
665
665
 
666
+
667
+ function getComponentStack(vm) {
668
+ const stack = [];
669
+ let prefix = '';
670
+
671
+ while (!isNull(vm.owner)) {
672
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
673
+ vm = vm.owner;
674
+ prefix += '\t';
675
+ }
676
+
677
+ return ArrayJoin.call(stack, '\n');
678
+ }
679
+
666
680
  function getErrorComponentStack(vm) {
667
681
  const wcStack = [];
668
682
  let currentVm = vm;
@@ -682,6 +696,32 @@
682
696
  */
683
697
 
684
698
 
699
+ function log(method, message, vm) {
700
+ let msg = `[LWC ${method}]: ${message}`;
701
+
702
+ if (!isUndefined$1(vm)) {
703
+ msg = `${msg}\n${getComponentStack(vm)}`;
704
+ }
705
+
706
+ try {
707
+ throw new Error(msg);
708
+ } catch (e) {
709
+ /* eslint-disable-next-line no-console */
710
+ console[method](e);
711
+ }
712
+ }
713
+
714
+ function logWarn(message, vm) {
715
+ log('warn', message, vm);
716
+ }
717
+ /*
718
+ * Copyright (c) 2018, salesforce.com, inc.
719
+ * All rights reserved.
720
+ * SPDX-License-Identifier: MIT
721
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
722
+ */
723
+
724
+
685
725
  function handleEvent(event, vnode) {
686
726
  const {
687
727
  type
@@ -1459,7 +1499,6 @@
1459
1499
  getPrototypeOf,
1460
1500
  create: ObjectCreate,
1461
1501
  defineProperty: ObjectDefineProperty,
1462
- defineProperties: ObjectDefineProperties,
1463
1502
  isExtensible,
1464
1503
  getOwnPropertyDescriptor,
1465
1504
  getOwnPropertyNames,
@@ -1469,8 +1508,7 @@
1469
1508
  } = Object;
1470
1509
  const {
1471
1510
  push: ArrayPush,
1472
- concat: ArrayConcat,
1473
- map: ArrayMap
1511
+ concat: ArrayConcat
1474
1512
  } = Array.prototype;
1475
1513
 
1476
1514
  function isUndefined(obj) {
@@ -1524,7 +1562,9 @@
1524
1562
  // but it will always be compatible with the previous descriptor
1525
1563
  // to preserve the object invariants, which makes these lines safe.
1526
1564
 
1527
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1565
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1566
+
1567
+ /* istanbul ignore else */
1528
1568
 
1529
1569
  if (!isUndefined(originalDescriptor)) {
1530
1570
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1552,11 +1592,17 @@
1552
1592
 
1553
1593
  preventExtensions(shadowTarget);
1554
1594
  } // Shared Traps
1595
+ // TODO: apply() is never called
1596
+
1597
+ /* istanbul ignore next */
1555
1598
 
1556
1599
 
1557
1600
  apply(shadowTarget, thisArg, argArray) {
1558
1601
  /* No op */
1559
- }
1602
+ } // TODO: construct() is never called
1603
+
1604
+ /* istanbul ignore next */
1605
+
1560
1606
 
1561
1607
  construct(shadowTarget, argArray, newTarget) {
1562
1608
  /* No op */
@@ -1669,8 +1715,8 @@
1669
1715
 
1670
1716
  }
1671
1717
 
1672
- const getterMap = new WeakMap();
1673
- const setterMap = new WeakMap();
1718
+ const getterMap$1 = new WeakMap();
1719
+ const setterMap$1 = new WeakMap();
1674
1720
  const reverseGetterMap = new WeakMap();
1675
1721
  const reverseSetterMap = new WeakMap();
1676
1722
 
@@ -1680,7 +1726,7 @@
1680
1726
  }
1681
1727
 
1682
1728
  wrapGetter(originalGet) {
1683
- const wrappedGetter = getterMap.get(originalGet);
1729
+ const wrappedGetter = getterMap$1.get(originalGet);
1684
1730
 
1685
1731
  if (!isUndefined(wrappedGetter)) {
1686
1732
  return wrappedGetter;
@@ -1693,13 +1739,13 @@
1693
1739
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1694
1740
  };
1695
1741
 
1696
- getterMap.set(originalGet, get);
1742
+ getterMap$1.set(originalGet, get);
1697
1743
  reverseGetterMap.set(get, originalGet);
1698
1744
  return get;
1699
1745
  }
1700
1746
 
1701
1747
  wrapSetter(originalSet) {
1702
- const wrappedSetter = setterMap.get(originalSet);
1748
+ const wrappedSetter = setterMap$1.get(originalSet);
1703
1749
 
1704
1750
  if (!isUndefined(wrappedSetter)) {
1705
1751
  return wrappedSetter;
@@ -1710,7 +1756,7 @@
1710
1756
  originalSet.call(unwrap$1(this), unwrap$1(v));
1711
1757
  };
1712
1758
 
1713
- setterMap.set(originalSet, set);
1759
+ setterMap$1.set(originalSet, set);
1714
1760
  reverseSetterMap.set(set, originalSet);
1715
1761
  return set;
1716
1762
  }
@@ -1751,7 +1797,7 @@
1751
1797
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1752
1798
  };
1753
1799
 
1754
- getterMap.set(get, redGet);
1800
+ getterMap$1.set(get, redGet);
1755
1801
  reverseGetterMap.set(redGet, get);
1756
1802
  return get;
1757
1803
  }
@@ -1770,7 +1816,7 @@
1770
1816
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1771
1817
  };
1772
1818
 
1773
- setterMap.set(set, redSet);
1819
+ setterMap$1.set(set, redSet);
1774
1820
  reverseSetterMap.set(redSet, set);
1775
1821
  return set;
1776
1822
  }
@@ -1821,6 +1867,11 @@
1821
1867
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1822
1868
  // the preventExtension call, in which case we should not attempt to lock down
1823
1869
  // the shadow target.
1870
+ // TODO: It should not actually be possible to reach this `if` statement.
1871
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1872
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1873
+
1874
+ /* istanbul ignore if */
1824
1875
 
1825
1876
  if (isExtensible(originalTarget)) {
1826
1877
  return false;
@@ -1862,8 +1913,8 @@
1862
1913
 
1863
1914
  }
1864
1915
 
1865
- const getterMap$1 = new WeakMap();
1866
- const setterMap$1 = new WeakMap();
1916
+ const getterMap = new WeakMap();
1917
+ const setterMap = new WeakMap();
1867
1918
 
1868
1919
  class ReadOnlyHandler extends BaseProxyHandler {
1869
1920
  wrapValue(value) {
@@ -1871,7 +1922,7 @@
1871
1922
  }
1872
1923
 
1873
1924
  wrapGetter(originalGet) {
1874
- const wrappedGetter = getterMap$1.get(originalGet);
1925
+ const wrappedGetter = getterMap.get(originalGet);
1875
1926
 
1876
1927
  if (!isUndefined(wrappedGetter)) {
1877
1928
  return wrappedGetter;
@@ -1884,12 +1935,12 @@
1884
1935
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1885
1936
  };
1886
1937
 
1887
- getterMap$1.set(originalGet, get);
1938
+ getterMap.set(originalGet, get);
1888
1939
  return get;
1889
1940
  }
1890
1941
 
1891
1942
  wrapSetter(originalSet) {
1892
- const wrappedSetter = setterMap$1.get(originalSet);
1943
+ const wrappedSetter = setterMap.get(originalSet);
1893
1944
 
1894
1945
  if (!isUndefined(wrappedSetter)) {
1895
1946
  return wrappedSetter;
@@ -1898,16 +1949,20 @@
1898
1949
  const set = function (v) {
1899
1950
  };
1900
1951
 
1901
- setterMap$1.set(originalSet, set);
1952
+ setterMap.set(originalSet, set);
1902
1953
  return set;
1903
1954
  }
1904
1955
 
1905
1956
  set(shadowTarget, key, value) {
1957
+ /* istanbul ignore next */
1958
+
1906
1959
 
1907
1960
  return false;
1908
1961
  }
1909
1962
 
1910
1963
  deleteProperty(shadowTarget, key) {
1964
+ /* istanbul ignore next */
1965
+
1911
1966
 
1912
1967
  return false;
1913
1968
  }
@@ -1916,11 +1971,15 @@
1916
1971
  }
1917
1972
 
1918
1973
  preventExtensions(shadowTarget) {
1974
+ /* istanbul ignore next */
1975
+
1919
1976
 
1920
1977
  return false;
1921
1978
  }
1922
1979
 
1923
1980
  defineProperty(shadowTarget, key, descriptor) {
1981
+ /* istanbul ignore next */
1982
+
1924
1983
 
1925
1984
  return false;
1926
1985
  }
@@ -1968,7 +2027,8 @@
1968
2027
  this.valueMutated = defaultValueMutated;
1969
2028
  this.valueObserved = defaultValueObserved;
1970
2029
  this.valueIsObservable = defaultValueIsObservable;
1971
- this.objectGraph = new WeakMap();
2030
+ this.readOnlyObjectGraph = new WeakMap();
2031
+ this.reactiveObjectGraph = new WeakMap();
1972
2032
 
1973
2033
  if (!isUndefined(options)) {
1974
2034
  const {
@@ -1991,10 +2051,13 @@
1991
2051
  const distorted = this.valueDistortion(unwrappedValue);
1992
2052
 
1993
2053
  if (this.valueIsObservable(distorted)) {
1994
- const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
1995
- // we return the readonly.
2054
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2055
+ // when trying to extract the writable version of a readonly
2056
+ // we return the readonly.
2057
+ return value;
2058
+ }
1996
2059
 
1997
- return o.readOnly === value ? value : o.reactive;
2060
+ return this.getReactiveHandler(unwrappedValue, distorted);
1998
2061
  }
1999
2062
 
2000
2063
  return distorted;
@@ -2005,7 +2068,7 @@
2005
2068
  const distorted = this.valueDistortion(value);
2006
2069
 
2007
2070
  if (this.valueIsObservable(distorted)) {
2008
- return this.getReactiveState(value, distorted).readOnly;
2071
+ return this.getReadOnlyHandler(value, distorted);
2009
2072
  }
2010
2073
 
2011
2074
  return distorted;
@@ -2015,47 +2078,36 @@
2015
2078
  return unwrap$1(p);
2016
2079
  }
2017
2080
 
2018
- getReactiveState(value, distortedValue) {
2019
- const {
2020
- objectGraph
2021
- } = this;
2022
- let reactiveState = objectGraph.get(distortedValue);
2081
+ getReactiveHandler(value, distortedValue) {
2082
+ let proxy = this.reactiveObjectGraph.get(distortedValue);
2023
2083
 
2024
- if (reactiveState) {
2025
- return reactiveState;
2084
+ if (isUndefined(proxy)) {
2085
+ // caching the proxy after the first time it is accessed
2086
+ const handler = new ReactiveProxyHandler(this, distortedValue);
2087
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2088
+ registerProxy(proxy, value);
2089
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2026
2090
  }
2027
2091
 
2028
- const membrane = this;
2029
- reactiveState = {
2030
- get reactive() {
2031
- const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2032
-
2033
- const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2034
- registerProxy(proxy, value);
2035
- ObjectDefineProperty(this, 'reactive', {
2036
- value: proxy
2037
- });
2038
- return proxy;
2039
- },
2092
+ return proxy;
2093
+ }
2040
2094
 
2041
- get readOnly() {
2042
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2095
+ getReadOnlyHandler(value, distortedValue) {
2096
+ let proxy = this.readOnlyObjectGraph.get(distortedValue);
2043
2097
 
2044
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2045
- registerProxy(proxy, value);
2046
- ObjectDefineProperty(this, 'readOnly', {
2047
- value: proxy
2048
- });
2049
- return proxy;
2050
- }
2098
+ if (isUndefined(proxy)) {
2099
+ // caching the proxy after the first time it is accessed
2100
+ const handler = new ReadOnlyHandler(this, distortedValue);
2101
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2102
+ registerProxy(proxy, value);
2103
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2104
+ }
2051
2105
 
2052
- };
2053
- objectGraph.set(distortedValue, reactiveState);
2054
- return reactiveState;
2106
+ return proxy;
2055
2107
  }
2056
2108
 
2057
2109
  }
2058
- /** version: 1.0.0 */
2110
+ /** version: 1.1.5 */
2059
2111
 
2060
2112
  /*
2061
2113
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2434,8 +2486,10 @@
2434
2486
  } = vm;
2435
2487
 
2436
2488
  return renderer[rendererMethod](elm);
2437
- }
2489
+ },
2438
2490
 
2491
+ configurable: true,
2492
+ enumerable: true
2439
2493
  };
2440
2494
  }
2441
2495
 
@@ -2451,8 +2505,11 @@
2451
2505
  } = vm;
2452
2506
 
2453
2507
  return renderer[queryMethod](elm, arg);
2454
- }
2508
+ },
2455
2509
 
2510
+ configurable: true,
2511
+ enumerable: true,
2512
+ writable: true
2456
2513
  };
2457
2514
  }
2458
2515
 
@@ -3303,7 +3360,7 @@
3303
3360
  renderMode: 1
3304
3361
  /* Shadow */
3305
3362
  ,
3306
- shadowSupportMode: "default"
3363
+ shadowSupportMode: "reset"
3307
3364
  /* Default */
3308
3365
  ,
3309
3366
  wire: EmptyObject,
@@ -3429,6 +3486,17 @@
3429
3486
  modComputedStyle.create(vnode);
3430
3487
  }
3431
3488
 
3489
+ function hydrateElmHook(vnode) {
3490
+ modEvents.create(vnode); // Attrs are already on the element.
3491
+ // modAttrs.create(vnode);
3492
+
3493
+ modProps.create(vnode); // Already set.
3494
+ // modStaticClassName.create(vnode);
3495
+ // modStaticStyle.create(vnode);
3496
+ // modComputedClassName.create(vnode);
3497
+ // modComputedStyle.create(vnode);
3498
+ }
3499
+
3432
3500
  function fallbackElmHook(elm, vnode) {
3433
3501
  const {
3434
3502
  owner
@@ -3578,6 +3646,22 @@
3578
3646
  }
3579
3647
  }
3580
3648
 
3649
+ function hydrateChildrenHook(elmChildren, children, vm) {
3650
+
3651
+ let elmCurrentChildIdx = 0;
3652
+
3653
+ for (let j = 0, n = children.length; j < n; j++) {
3654
+ const ch = children[j];
3655
+
3656
+ if (ch != null) {
3657
+ const childNode = elmChildren[elmCurrentChildIdx];
3658
+
3659
+ ch.hook.hydrate(ch, childNode);
3660
+ elmCurrentChildIdx++;
3661
+ }
3662
+ }
3663
+ }
3664
+
3581
3665
  function updateCustomElmHook(oldVnode, vnode) {
3582
3666
  // Attrs need to be applied to element before props
3583
3667
  // IE11 will wipe out value on radio inputs if value
@@ -3661,38 +3745,6 @@
3661
3745
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3662
3746
  */
3663
3747
 
3664
- /**
3665
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3666
- * libraries to sanitize HTML content. This hook process the content passed via the template to
3667
- * lwc:inner-html directive.
3668
- * It is meant to be overridden with setSanitizeHtmlContentHook
3669
- */
3670
-
3671
-
3672
- let sanitizeHtmlContentHook = () => {
3673
- // locker-service patches this function during runtime to sanitize HTML content.
3674
- throw new Error('sanitizeHtmlContent hook must be implemented.');
3675
- };
3676
- /**
3677
- * Sets the sanitizeHtmlContentHook.
3678
- *
3679
- * @param newHookImpl
3680
- * @returns oldHookImplementation.
3681
- */
3682
-
3683
-
3684
- function setSanitizeHtmlContentHook(newHookImpl) {
3685
- const currentHook = sanitizeHtmlContentHook;
3686
- sanitizeHtmlContentHook = newHookImpl;
3687
- return currentHook;
3688
- }
3689
- /*
3690
- * Copyright (c) 2018, salesforce.com, inc.
3691
- * All rights reserved.
3692
- * SPDX-License-Identifier: MIT
3693
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3694
- */
3695
-
3696
3748
 
3697
3749
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
3698
3750
  const SymbolIterator = Symbol.iterator;
@@ -3711,7 +3763,14 @@
3711
3763
  update: updateNodeHook,
3712
3764
  insert: insertNodeHook,
3713
3765
  move: insertNodeHook,
3714
- remove: removeNodeHook
3766
+ remove: removeNodeHook,
3767
+ hydrate: (vNode, node) => {
3768
+ var _a;
3769
+
3770
+
3771
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3772
+ vNode.elm = node;
3773
+ }
3715
3774
  };
3716
3775
  const CommentHook = {
3717
3776
  create: vnode => {
@@ -3729,7 +3788,14 @@
3729
3788
  update: updateNodeHook,
3730
3789
  insert: insertNodeHook,
3731
3790
  move: insertNodeHook,
3732
- remove: removeNodeHook
3791
+ remove: removeNodeHook,
3792
+ hydrate: (vNode, node) => {
3793
+ var _a;
3794
+
3795
+
3796
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3797
+ vNode.elm = node;
3798
+ }
3733
3799
  }; // insert is called after update, which is used somewhere else (via a module)
3734
3800
  // to mark the vm as inserted, that means we cannot use update as the main channel
3735
3801
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3769,6 +3835,38 @@
3769
3835
  remove: (vnode, parentNode) => {
3770
3836
  removeNodeHook(vnode, parentNode);
3771
3837
  removeElmHook(vnode);
3838
+ },
3839
+ hydrate: (vnode, node) => {
3840
+ const elm = node;
3841
+ vnode.elm = elm;
3842
+ const {
3843
+ context
3844
+ } = vnode.data;
3845
+ const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3846
+ /* manual */
3847
+ );
3848
+
3849
+ if (isDomManual) {
3850
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3851
+ // remove the innerHTML from props so it reuses the existing dom elements.
3852
+ const {
3853
+ props
3854
+ } = vnode.data;
3855
+
3856
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3857
+ if (elm.innerHTML === props.innerHTML) {
3858
+ delete props.innerHTML;
3859
+ } else {
3860
+ logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
3861
+ }
3862
+ }
3863
+ }
3864
+
3865
+ hydrateElmHook(vnode);
3866
+
3867
+ if (!isDomManual) {
3868
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3869
+ }
3772
3870
  }
3773
3871
  };
3774
3872
  const CustomElementHook = {
@@ -3852,6 +3950,38 @@
3852
3950
  // will take care of disconnecting any child VM attached to its shadow as well.
3853
3951
  removeVM(vm);
3854
3952
  }
3953
+ },
3954
+ hydrate: (vnode, elm) => {
3955
+ // the element is created, but the vm is not
3956
+ const {
3957
+ sel,
3958
+ mode,
3959
+ ctor,
3960
+ owner
3961
+ } = vnode;
3962
+ const def = getComponentInternalDef(ctor);
3963
+ createVM(elm, def, {
3964
+ mode,
3965
+ owner,
3966
+ tagName: sel,
3967
+ renderer: owner.renderer
3968
+ });
3969
+ vnode.elm = elm;
3970
+ const vm = getAssociatedVM(elm);
3971
+ allocateChildrenHook(vnode, vm);
3972
+ hydrateElmHook(vnode); // Insert hook section:
3973
+
3974
+ runConnectedCallback(vm);
3975
+
3976
+ if (vm.renderMode !== 0
3977
+ /* Light */
3978
+ ) {
3979
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
3980
+ // Note: for Light DOM, this is handled while hydrating the VM
3981
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
3982
+ }
3983
+
3984
+ hydrateVM(vm);
3855
3985
  }
3856
3986
  };
3857
3987
 
@@ -4061,7 +4191,7 @@
4061
4191
 
4062
4192
 
4063
4193
  function d(value) {
4064
- return value == null ? '' : value;
4194
+ return value == null ? '' : String(value);
4065
4195
  } // [b]ind function
4066
4196
 
4067
4197
 
@@ -4202,6 +4332,26 @@
4202
4332
 
4203
4333
  markAsDynamicChildren(vnodes);
4204
4334
  return vnodes;
4335
+ }
4336
+ /**
4337
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4338
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4339
+ * lwc:inner-html directive.
4340
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
4341
+ */
4342
+
4343
+
4344
+ let sanitizeHtmlContentHook = () => {
4345
+ // locker-service patches this function during runtime to sanitize HTML content.
4346
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4347
+ };
4348
+ /**
4349
+ * Sets the sanitizeHtmlContentHook.
4350
+ */
4351
+
4352
+
4353
+ function setSanitizeHtmlContentHook(newHookImpl) {
4354
+ sanitizeHtmlContentHook = newHookImpl;
4205
4355
  } // [s]anitize [h]tml [c]ontent
4206
4356
 
4207
4357
 
@@ -4390,7 +4540,10 @@
4390
4540
  for (let i = 0; i < stylesheets.length; i++) {
4391
4541
  renderer.insertGlobalStylesheet(stylesheets[i]);
4392
4542
  }
4393
- } else if (renderer.ssr) {
4543
+ } else if (renderer.ssr || renderer.isHydrating()) {
4544
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4545
+ // This works in the client, because the stylesheets are created, and cached in the VM
4546
+ // the first time the VM renders.
4394
4547
  // native shadow or light DOM, SSR
4395
4548
  const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4396
4549
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4889,6 +5042,12 @@
4889
5042
  , vm);
4890
5043
  }
4891
5044
 
5045
+ function hydrateRootElement(elm) {
5046
+ const vm = getAssociatedVM(elm);
5047
+ runConnectedCallback(vm);
5048
+ hydrateVM(vm);
5049
+ }
5050
+
4892
5051
  function disconnectRootElement(elm) {
4893
5052
  const vm = getAssociatedVM(elm);
4894
5053
  resetComponentStateWhenRemoved(vm);
@@ -4896,6 +5055,10 @@
4896
5055
 
4897
5056
  function appendVM(vm) {
4898
5057
  rehydrate(vm);
5058
+ }
5059
+
5060
+ function hydrateVM(vm) {
5061
+ hydrate(vm);
4899
5062
  } // just in case the component comes back, with this we guarantee re-rendering it
4900
5063
  // while preventing any attempt to rehydration until after reinsertion.
4901
5064
 
@@ -5090,6 +5253,22 @@
5090
5253
  }
5091
5254
  }
5092
5255
 
5256
+ function hydrate(vm) {
5257
+ if (isTrue(vm.isDirty)) {
5258
+ // manually diffing/patching here.
5259
+ // This routine is:
5260
+ // patchShadowRoot(vm, children);
5261
+ // -> addVnodes.
5262
+ const children = renderComponent(vm);
5263
+ vm.children = children;
5264
+ const vmChildren = vm.renderMode === 0
5265
+ /* Light */
5266
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5267
+ hydrateChildrenHook(vmChildren, children);
5268
+ runRenderedCallback(vm);
5269
+ }
5270
+ }
5271
+
5093
5272
  function patchShadowRoot(vm, newCh) {
5094
5273
  const {
5095
5274
  children: oldCh
@@ -5879,25 +6058,12 @@
5879
6058
 
5880
6059
  let hooksAreSet = false;
5881
6060
 
5882
- function overrideHooks(hooks) {
5883
- const oldHooks = {};
5884
-
5885
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
5886
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5887
- }
5888
-
5889
- return oldHooks;
5890
- }
5891
-
5892
6061
  function setHooks(hooks) {
5893
6062
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5894
- overrideHooks(hooks);
5895
6063
  hooksAreSet = true;
6064
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5896
6065
  }
5897
-
5898
- function setHooksForTest(hooks) {
5899
- }
5900
- /* version: 2.5.6 */
6066
+ /* version: 2.5.10 */
5901
6067
 
5902
6068
  /*
5903
6069
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6032,8 +6198,19 @@
6032
6198
  HTMLElementConstructor.prototype = HTMLElement.prototype;
6033
6199
  }
6034
6200
 
6201
+ let isHydrating = false;
6202
+
6203
+ function setIsHydrating(v) {
6204
+ isHydrating = v;
6205
+ }
6206
+
6035
6207
  const renderer = {
6036
6208
  ssr: false,
6209
+
6210
+ isHydrating() {
6211
+ return isHydrating;
6212
+ },
6213
+
6037
6214
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
6038
6215
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
6039
6216
 
@@ -6062,6 +6239,10 @@
6062
6239
  },
6063
6240
 
6064
6241
  attachShadow(element, options) {
6242
+ if (isHydrating) {
6243
+ return element.shadowRoot;
6244
+ }
6245
+
6065
6246
  return element.attachShadow(options);
6066
6247
  },
6067
6248
 
@@ -6193,57 +6374,6 @@
6193
6374
  getCustomElement,
6194
6375
  HTMLElement: HTMLElementConstructor
6195
6376
  };
6196
- /*
6197
- * Copyright (c) 2018, salesforce.com, inc.
6198
- * All rights reserved.
6199
- * SPDX-License-Identifier: MIT
6200
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6201
- */
6202
-
6203
- /**
6204
- * This function builds a Web Component class from a LWC constructor so it can be
6205
- * registered as a new element via customElements.define() at any given time.
6206
- *
6207
- * @deprecated since version 1.3.11
6208
- *
6209
- * @example
6210
- * ```
6211
- * import { buildCustomElementConstructor } from 'lwc';
6212
- * import Foo from 'ns/foo';
6213
- * const WC = buildCustomElementConstructor(Foo);
6214
- * customElements.define('x-foo', WC);
6215
- * const elm = document.createElement('x-foo');
6216
- * ```
6217
- */
6218
-
6219
- function deprecatedBuildCustomElementConstructor(Ctor) {
6220
-
6221
- return Ctor.CustomElementConstructor;
6222
- }
6223
-
6224
- function buildCustomElementConstructor(Ctor) {
6225
- const def = getComponentInternalDef(Ctor);
6226
- return class extends def.bridge {
6227
- constructor() {
6228
- super();
6229
- createVM(this, def, {
6230
- mode: 'open',
6231
- owner: null,
6232
- tagName: this.tagName,
6233
- renderer
6234
- });
6235
- }
6236
-
6237
- connectedCallback() {
6238
- connectRootElement(this);
6239
- }
6240
-
6241
- disconnectedCallback() {
6242
- disconnectRootElement(this);
6243
- }
6244
-
6245
- };
6246
- }
6247
6377
  /*
6248
6378
  * Copyright (c) 2018, salesforce.com, inc.
6249
6379
  * All rights reserved.
@@ -6253,7 +6383,6 @@
6253
6383
  // TODO [#2472]: Remove this workaround when appropriate.
6254
6384
  // eslint-disable-next-line lwc-internal/no-global-node
6255
6385
 
6256
-
6257
6386
  const _Node$1 = Node;
6258
6387
  const ConnectingSlot = new WeakMap();
6259
6388
  const DisconnectingSlot = new WeakMap();
@@ -6361,6 +6490,114 @@
6361
6490
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6362
6491
  */
6363
6492
 
6493
+
6494
+ function hydrateComponent(element, Ctor, props = {}) {
6495
+ if (!isFunction$1(Ctor)) {
6496
+ throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
6497
+ }
6498
+
6499
+ if (!isObject(props) || isNull(props)) {
6500
+ throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
6501
+ }
6502
+
6503
+ const def = getComponentInternalDef(Ctor);
6504
+
6505
+ try {
6506
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6507
+ // and uses the same algo to create the stylesheets as in SSR.
6508
+ setIsHydrating(true);
6509
+ createVM(element, def, {
6510
+ mode: 'open',
6511
+ owner: null,
6512
+ renderer,
6513
+ tagName: element.tagName.toLowerCase()
6514
+ });
6515
+
6516
+ for (const [key, value] of Object.entries(props)) {
6517
+ element[key] = value;
6518
+ }
6519
+
6520
+ hydrateRootElement(element); // set it back since now we finished hydration.
6521
+
6522
+ setIsHydrating(false);
6523
+ } catch (e) {
6524
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6525
+ // the client generated DOM.
6526
+
6527
+ /* eslint-disable-next-line no-console */
6528
+ console.error('Recovering from error while hydrating: ', e);
6529
+ setIsHydrating(false);
6530
+ const newElem = createElement(element.tagName, {
6531
+ is: Ctor,
6532
+ mode: 'open'
6533
+ });
6534
+
6535
+ for (const [key, value] of Object.entries(props)) {
6536
+ newElem[key] = value;
6537
+ }
6538
+
6539
+ element.parentNode.replaceChild(newElem, element);
6540
+ }
6541
+ }
6542
+ /*
6543
+ * Copyright (c) 2018, salesforce.com, inc.
6544
+ * All rights reserved.
6545
+ * SPDX-License-Identifier: MIT
6546
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6547
+ */
6548
+
6549
+ /**
6550
+ * This function builds a Web Component class from a LWC constructor so it can be
6551
+ * registered as a new element via customElements.define() at any given time.
6552
+ *
6553
+ * @deprecated since version 1.3.11
6554
+ *
6555
+ * @example
6556
+ * ```
6557
+ * import { buildCustomElementConstructor } from 'lwc';
6558
+ * import Foo from 'ns/foo';
6559
+ * const WC = buildCustomElementConstructor(Foo);
6560
+ * customElements.define('x-foo', WC);
6561
+ * const elm = document.createElement('x-foo');
6562
+ * ```
6563
+ */
6564
+
6565
+
6566
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6567
+
6568
+ return Ctor.CustomElementConstructor;
6569
+ }
6570
+
6571
+ function buildCustomElementConstructor(Ctor) {
6572
+ const def = getComponentInternalDef(Ctor);
6573
+ return class extends def.bridge {
6574
+ constructor() {
6575
+ super();
6576
+ createVM(this, def, {
6577
+ mode: 'open',
6578
+ owner: null,
6579
+ tagName: this.tagName,
6580
+ renderer
6581
+ });
6582
+ }
6583
+
6584
+ connectedCallback() {
6585
+ connectRootElement(this);
6586
+ }
6587
+
6588
+ disconnectedCallback() {
6589
+ disconnectRootElement(this);
6590
+ }
6591
+
6592
+ };
6593
+ }
6594
+ /*
6595
+ * Copyright (c) 2018, salesforce.com, inc.
6596
+ * All rights reserved.
6597
+ * SPDX-License-Identifier: MIT
6598
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6599
+ */
6600
+
6364
6601
  /**
6365
6602
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6366
6603
  * This API is subject to change or being removed.
@@ -6460,7 +6697,7 @@
6460
6697
  });
6461
6698
  freeze(LightningElement);
6462
6699
  seal(LightningElement.prototype);
6463
- /* version: 2.5.6 */
6700
+ /* version: 2.5.10 */
6464
6701
 
6465
6702
  exports.LightningElement = LightningElement;
6466
6703
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6470,6 +6707,7 @@
6470
6707
  exports.createElement = createElement;
6471
6708
  exports.getComponentConstructor = getComponentConstructor;
6472
6709
  exports.getComponentDef = getComponentDef;
6710
+ exports.hydrateComponent = hydrateComponent;
6473
6711
  exports.isComponentConstructor = isComponentConstructor;
6474
6712
  exports.isNodeFromTemplate = isNodeFromTemplate;
6475
6713
  exports.readonly = readonly;
@@ -6481,7 +6719,6 @@
6481
6719
  exports.setFeatureFlag = setFeatureFlag;
6482
6720
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6483
6721
  exports.setHooks = setHooks;
6484
- exports.setHooksForTest = setHooksForTest;
6485
6722
  exports.swapComponent = swapComponent;
6486
6723
  exports.swapStyle = swapStyle;
6487
6724
  exports.swapTemplate = swapTemplate;