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
@@ -38,23 +38,23 @@
38
38
 
39
39
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
40
40
 
41
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
41
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
42
42
 
43
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
44
44
 
45
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
46
46
 
47
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
47
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
48
+
49
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
48
50
 
49
51
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
50
52
 
51
53
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
52
54
 
53
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
54
-
55
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
55
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
56
56
 
57
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
57
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
58
58
 
59
59
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
60
60
 
@@ -123,7 +123,7 @@
123
123
  var _Array$prototype = Array.prototype,
124
124
  ArrayIndexOf = _Array$prototype.indexOf,
125
125
  ArrayJoin = _Array$prototype.join,
126
- ArrayMap$1 = _Array$prototype.map,
126
+ ArrayMap = _Array$prototype.map,
127
127
  ArrayPush$1 = _Array$prototype.push,
128
128
  ArraySlice = _Array$prototype.slice,
129
129
  ArraySplice = _Array$prototype.splice,
@@ -180,7 +180,7 @@
180
180
  // Array.prototype.toString directly will cause an error Iterate through
181
181
  // all the items and handle individually.
182
182
  if (isArray$1(obj)) {
183
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
183
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
184
184
  }
185
185
 
186
186
  return obj.toString();
@@ -344,7 +344,7 @@
344
344
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
345
345
  return attributeName;
346
346
  }
347
- /** version: 2.5.6 */
347
+ /** version: 2.5.10 */
348
348
 
349
349
  /*
350
350
  * Copyright (c) 2018, salesforce.com, inc.
@@ -516,7 +516,7 @@
516
516
 
517
517
  function setFeatureFlagForTest(name, value) {
518
518
  }
519
- /** version: 2.5.6 */
519
+ /** version: 2.5.10 */
520
520
 
521
521
  /* proxy-compat-disable */
522
522
 
@@ -558,7 +558,7 @@
558
558
  }
559
559
 
560
560
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
561
- }
561
+ } // Borrowed from Vue template compiler.
562
562
  /*
563
563
  * Copyright (c) 2019, salesforce.com, inc.
564
564
  * All rights reserved.
@@ -713,6 +713,20 @@
713
713
  return "<".concat(StringToLowerCase.call(vm.tagName), ">");
714
714
  } // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
715
715
 
716
+
717
+ function getComponentStack(vm) {
718
+ var stack = [];
719
+ var prefix = '';
720
+
721
+ while (!isNull(vm.owner)) {
722
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
723
+ vm = vm.owner;
724
+ prefix += '\t';
725
+ }
726
+
727
+ return ArrayJoin.call(stack, '\n');
728
+ }
729
+
716
730
  function getErrorComponentStack(vm) {
717
731
  var wcStack = [];
718
732
  var currentVm = vm;
@@ -732,6 +746,32 @@
732
746
  */
733
747
 
734
748
 
749
+ function log(method, message, vm) {
750
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
751
+
752
+ if (!isUndefined$1(vm)) {
753
+ msg = "".concat(msg, "\n").concat(getComponentStack(vm));
754
+ }
755
+
756
+ try {
757
+ throw new Error(msg);
758
+ } catch (e) {
759
+ /* eslint-disable-next-line no-console */
760
+ console[method](e);
761
+ }
762
+ }
763
+
764
+ function logWarn(message, vm) {
765
+ log('warn', message, vm);
766
+ }
767
+ /*
768
+ * Copyright (c) 2018, salesforce.com, inc.
769
+ * All rights reserved.
770
+ * SPDX-License-Identifier: MIT
771
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
772
+ */
773
+
774
+
735
775
  function handleEvent(event, vnode) {
736
776
  var type = event.type;
737
777
  var on = vnode.data.on;
@@ -1524,7 +1564,10 @@
1524
1564
  // but it will always be compatible with the previous descriptor
1525
1565
  // to preserve the object invariants, which makes these lines safe.
1526
1566
 
1527
- var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key);
1567
+ var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1568
+
1569
+ /* istanbul ignore else */
1570
+
1528
1571
 
1529
1572
  if (!isUndefined(originalDescriptor)) {
1530
1573
  var wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1549,12 +1592,18 @@
1549
1592
 
1550
1593
  _preventExtensions(shadowTarget);
1551
1594
  } // Shared Traps
1595
+ // TODO: apply() is never called
1596
+
1597
+ /* istanbul ignore next */
1552
1598
 
1553
1599
  }, {
1554
1600
  key: "apply",
1555
1601
  value: function apply(shadowTarget, thisArg, argArray) {
1556
1602
  /* No op */
1557
- }
1603
+ } // TODO: construct() is never called
1604
+
1605
+ /* istanbul ignore next */
1606
+
1558
1607
  }, {
1559
1608
  key: "construct",
1560
1609
  value: function construct(shadowTarget, argArray, newTarget) {
@@ -1659,8 +1708,8 @@
1659
1708
  return BaseProxyHandler;
1660
1709
  }();
1661
1710
 
1662
- var getterMap = new WeakMap();
1663
- var setterMap = new WeakMap();
1711
+ var getterMap$1 = new WeakMap();
1712
+ var setterMap$1 = new WeakMap();
1664
1713
  var reverseGetterMap = new WeakMap();
1665
1714
  var reverseSetterMap = new WeakMap();
1666
1715
 
@@ -1683,7 +1732,7 @@
1683
1732
  }, {
1684
1733
  key: "wrapGetter",
1685
1734
  value: function wrapGetter(originalGet) {
1686
- var wrappedGetter = getterMap.get(originalGet);
1735
+ var wrappedGetter = getterMap$1.get(originalGet);
1687
1736
 
1688
1737
  if (!isUndefined(wrappedGetter)) {
1689
1738
  return wrappedGetter;
@@ -1696,14 +1745,14 @@
1696
1745
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1697
1746
  };
1698
1747
 
1699
- getterMap.set(originalGet, get);
1748
+ getterMap$1.set(originalGet, get);
1700
1749
  reverseGetterMap.set(get, originalGet);
1701
1750
  return get;
1702
1751
  }
1703
1752
  }, {
1704
1753
  key: "wrapSetter",
1705
1754
  value: function wrapSetter(originalSet) {
1706
- var wrappedSetter = setterMap.get(originalSet);
1755
+ var wrappedSetter = setterMap$1.get(originalSet);
1707
1756
 
1708
1757
  if (!isUndefined(wrappedSetter)) {
1709
1758
  return wrappedSetter;
@@ -1714,7 +1763,7 @@
1714
1763
  originalSet.call(unwrap$1(this), unwrap$1(v));
1715
1764
  };
1716
1765
 
1717
- setterMap.set(originalSet, set);
1766
+ setterMap$1.set(originalSet, set);
1718
1767
  reverseSetterMap.set(set, originalSet);
1719
1768
  return set;
1720
1769
  }
@@ -1755,7 +1804,7 @@
1755
1804
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1756
1805
  };
1757
1806
 
1758
- getterMap.set(get, redGet);
1807
+ getterMap$1.set(get, redGet);
1759
1808
  reverseGetterMap.set(redGet, get);
1760
1809
  return get;
1761
1810
  }
@@ -1775,7 +1824,7 @@
1775
1824
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1776
1825
  };
1777
1826
 
1778
- setterMap.set(set, redSet);
1827
+ setterMap$1.set(set, redSet);
1779
1828
  reverseSetterMap.set(redSet, set);
1780
1829
  return set;
1781
1830
  }
@@ -1821,6 +1870,11 @@
1821
1870
  _preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1822
1871
  // the preventExtension call, in which case we should not attempt to lock down
1823
1872
  // the shadow target.
1873
+ // TODO: It should not actually be possible to reach this `if` statement.
1874
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1875
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1876
+
1877
+ /* istanbul ignore if */
1824
1878
 
1825
1879
 
1826
1880
  if (_isExtensible(originalTarget)) {
@@ -1863,8 +1917,8 @@
1863
1917
  return ReactiveProxyHandler;
1864
1918
  }(BaseProxyHandler);
1865
1919
 
1866
- var getterMap$1 = new WeakMap();
1867
- var setterMap$1 = new WeakMap();
1920
+ var getterMap = new WeakMap();
1921
+ var setterMap = new WeakMap();
1868
1922
 
1869
1923
  var ReadOnlyHandler = /*#__PURE__*/function (_BaseProxyHandler2) {
1870
1924
  _inherits(ReadOnlyHandler, _BaseProxyHandler2);
@@ -1885,7 +1939,7 @@
1885
1939
  }, {
1886
1940
  key: "wrapGetter",
1887
1941
  value: function wrapGetter(originalGet) {
1888
- var wrappedGetter = getterMap$1.get(originalGet);
1942
+ var wrappedGetter = getterMap.get(originalGet);
1889
1943
 
1890
1944
  if (!isUndefined(wrappedGetter)) {
1891
1945
  return wrappedGetter;
@@ -1898,13 +1952,13 @@
1898
1952
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1899
1953
  };
1900
1954
 
1901
- getterMap$1.set(originalGet, get);
1955
+ getterMap.set(originalGet, get);
1902
1956
  return get;
1903
1957
  }
1904
1958
  }, {
1905
1959
  key: "wrapSetter",
1906
1960
  value: function wrapSetter(originalSet) {
1907
- var wrappedSetter = setterMap$1.get(originalSet);
1961
+ var wrappedSetter = setterMap.get(originalSet);
1908
1962
 
1909
1963
  if (!isUndefined(wrappedSetter)) {
1910
1964
  return wrappedSetter;
@@ -1913,18 +1967,22 @@
1913
1967
  var set = function set(v) {
1914
1968
  };
1915
1969
 
1916
- setterMap$1.set(originalSet, set);
1970
+ setterMap.set(originalSet, set);
1917
1971
  return set;
1918
1972
  }
1919
1973
  }, {
1920
1974
  key: "set",
1921
1975
  value: function set(shadowTarget, key, value) {
1976
+ /* istanbul ignore next */
1977
+
1922
1978
 
1923
1979
  return false;
1924
1980
  }
1925
1981
  }, {
1926
1982
  key: "deleteProperty",
1927
1983
  value: function deleteProperty(shadowTarget, key) {
1984
+ /* istanbul ignore next */
1985
+
1928
1986
 
1929
1987
  return false;
1930
1988
  }
@@ -1935,12 +1993,16 @@
1935
1993
  }, {
1936
1994
  key: "preventExtensions",
1937
1995
  value: function preventExtensions(shadowTarget) {
1996
+ /* istanbul ignore next */
1997
+
1938
1998
 
1939
1999
  return false;
1940
2000
  }
1941
2001
  }, {
1942
2002
  key: "defineProperty",
1943
2003
  value: function defineProperty(shadowTarget, key, descriptor) {
2004
+ /* istanbul ignore next */
2005
+
1944
2006
 
1945
2007
  return false;
1946
2008
  }
@@ -1995,7 +2057,8 @@
1995
2057
  this.valueMutated = defaultValueMutated;
1996
2058
  this.valueObserved = defaultValueObserved;
1997
2059
  this.valueIsObservable = defaultValueIsObservable;
1998
- this.objectGraph = new WeakMap();
2060
+ this.readOnlyObjectGraph = new WeakMap();
2061
+ this.reactiveObjectGraph = new WeakMap();
1999
2062
 
2000
2063
  if (!isUndefined(options)) {
2001
2064
  var _valueDistortion = options.valueDistortion,
@@ -2018,10 +2081,13 @@
2018
2081
  var distorted = this.valueDistortion(unwrappedValue);
2019
2082
 
2020
2083
  if (this.valueIsObservable(distorted)) {
2021
- var o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2022
- // we return the readonly.
2084
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2085
+ // when trying to extract the writable version of a readonly
2086
+ // we return the readonly.
2087
+ return value;
2088
+ }
2023
2089
 
2024
- return o.readOnly === value ? value : o.reactive;
2090
+ return this.getReactiveHandler(unwrappedValue, distorted);
2025
2091
  }
2026
2092
 
2027
2093
  return distorted;
@@ -2033,7 +2099,7 @@
2033
2099
  var distorted = this.valueDistortion(value);
2034
2100
 
2035
2101
  if (this.valueIsObservable(distorted)) {
2036
- return this.getReactiveState(value, distorted).readOnly;
2102
+ return this.getReadOnlyHandler(value, distorted);
2037
2103
  }
2038
2104
 
2039
2105
  return distorted;
@@ -2044,48 +2110,40 @@
2044
2110
  return unwrap$1(p);
2045
2111
  }
2046
2112
  }, {
2047
- key: "getReactiveState",
2048
- value: function getReactiveState(value, distortedValue) {
2049
- var objectGraph = this.objectGraph;
2050
- var reactiveState = objectGraph.get(distortedValue);
2051
-
2052
- if (reactiveState) {
2053
- return reactiveState;
2113
+ key: "getReactiveHandler",
2114
+ value: function getReactiveHandler(value, distortedValue) {
2115
+ var proxy = this.reactiveObjectGraph.get(distortedValue);
2116
+
2117
+ if (isUndefined(proxy)) {
2118
+ // caching the proxy after the first time it is accessed
2119
+ var handler = new ReactiveProxyHandler(this, distortedValue);
2120
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2121
+ registerProxy(proxy, value);
2122
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2054
2123
  }
2055
2124
 
2056
- var membrane = this;
2057
- reactiveState = {
2058
- get reactive() {
2059
- var reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2060
-
2061
- var proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2062
- registerProxy(proxy, value);
2063
- ObjectDefineProperty(this, 'reactive', {
2064
- value: proxy
2065
- });
2066
- return proxy;
2067
- },
2068
-
2069
- get readOnly() {
2070
- var readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2071
-
2072
- var proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2073
- registerProxy(proxy, value);
2074
- ObjectDefineProperty(this, 'readOnly', {
2075
- value: proxy
2076
- });
2077
- return proxy;
2078
- }
2125
+ return proxy;
2126
+ }
2127
+ }, {
2128
+ key: "getReadOnlyHandler",
2129
+ value: function getReadOnlyHandler(value, distortedValue) {
2130
+ var proxy = this.readOnlyObjectGraph.get(distortedValue);
2131
+
2132
+ if (isUndefined(proxy)) {
2133
+ // caching the proxy after the first time it is accessed
2134
+ var handler = new ReadOnlyHandler(this, distortedValue);
2135
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2136
+ registerProxy(proxy, value);
2137
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2138
+ }
2079
2139
 
2080
- };
2081
- objectGraph.set(distortedValue, reactiveState);
2082
- return reactiveState;
2140
+ return proxy;
2083
2141
  }
2084
2142
  }]);
2085
2143
 
2086
2144
  return ReactiveMembrane;
2087
2145
  }();
2088
- /** version: 1.0.0 */
2146
+ /** version: 1.1.5 */
2089
2147
 
2090
2148
  /*
2091
2149
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2394,7 +2452,9 @@
2394
2452
  renderer = vm.renderer;
2395
2453
 
2396
2454
  return renderer[rendererMethod](elm);
2397
- }
2455
+ },
2456
+ configurable: true,
2457
+ enumerable: true
2398
2458
  };
2399
2459
  };
2400
2460
 
@@ -2413,7 +2473,10 @@
2413
2473
  renderer = vm.renderer;
2414
2474
 
2415
2475
  return renderer[queryMethod](elm, arg);
2416
- }
2476
+ },
2477
+ configurable: true,
2478
+ enumerable: true,
2479
+ writable: true
2417
2480
  };
2418
2481
  };
2419
2482
 
@@ -3263,7 +3326,7 @@
3263
3326
  renderMode: 1
3264
3327
  /* Shadow */
3265
3328
  ,
3266
- shadowSupportMode: "default"
3329
+ shadowSupportMode: "reset"
3267
3330
  /* Default */
3268
3331
  ,
3269
3332
  wire: EmptyObject,
@@ -3377,6 +3440,17 @@
3377
3440
  modComputedStyle.create(vnode);
3378
3441
  }
3379
3442
 
3443
+ function hydrateElmHook(vnode) {
3444
+ modEvents.create(vnode); // Attrs are already on the element.
3445
+ // modAttrs.create(vnode);
3446
+
3447
+ modProps.create(vnode); // Already set.
3448
+ // modStaticClassName.create(vnode);
3449
+ // modStaticStyle.create(vnode);
3450
+ // modComputedClassName.create(vnode);
3451
+ // modComputedStyle.create(vnode);
3452
+ }
3453
+
3380
3454
  function fallbackElmHook(elm, vnode) {
3381
3455
  var owner = vnode.owner;
3382
3456
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3508,6 +3582,22 @@
3508
3582
  }
3509
3583
  }
3510
3584
 
3585
+ function hydrateChildrenHook(elmChildren, children, vm) {
3586
+
3587
+ var elmCurrentChildIdx = 0;
3588
+
3589
+ for (var j = 0, n = children.length; j < n; j++) {
3590
+ var ch = children[j];
3591
+
3592
+ if (ch != null) {
3593
+ var childNode = elmChildren[elmCurrentChildIdx];
3594
+
3595
+ ch.hook.hydrate(ch, childNode);
3596
+ elmCurrentChildIdx++;
3597
+ }
3598
+ }
3599
+ }
3600
+
3511
3601
  function updateCustomElmHook(oldVnode, vnode) {
3512
3602
  // Attrs need to be applied to element before props
3513
3603
  // IE11 will wipe out value on radio inputs if value
@@ -3601,38 +3691,6 @@
3601
3691
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3602
3692
  */
3603
3693
 
3604
- /**
3605
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3606
- * libraries to sanitize HTML content. This hook process the content passed via the template to
3607
- * lwc:inner-html directive.
3608
- * It is meant to be overridden with setSanitizeHtmlContentHook
3609
- */
3610
-
3611
-
3612
- var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
3613
- // locker-service patches this function during runtime to sanitize HTML content.
3614
- throw new Error('sanitizeHtmlContent hook must be implemented.');
3615
- };
3616
- /**
3617
- * Sets the sanitizeHtmlContentHook.
3618
- *
3619
- * @param newHookImpl
3620
- * @returns oldHookImplementation.
3621
- */
3622
-
3623
-
3624
- function setSanitizeHtmlContentHook(newHookImpl) {
3625
- var currentHook = sanitizeHtmlContentHook;
3626
- sanitizeHtmlContentHook = newHookImpl;
3627
- return currentHook;
3628
- }
3629
- /*
3630
- * Copyright (c) 2018, salesforce.com, inc.
3631
- * All rights reserved.
3632
- * SPDX-License-Identifier: MIT
3633
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3634
- */
3635
-
3636
3694
 
3637
3695
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
3638
3696
  var SymbolIterator = Symbol.iterator;
@@ -3647,7 +3705,14 @@
3647
3705
  update: updateNodeHook,
3648
3706
  insert: insertNodeHook,
3649
3707
  move: insertNodeHook,
3650
- remove: removeNodeHook
3708
+ remove: removeNodeHook,
3709
+ hydrate: function hydrate(vNode, node) {
3710
+ var _a;
3711
+
3712
+
3713
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3714
+ vNode.elm = node;
3715
+ }
3651
3716
  };
3652
3717
  var CommentHook = {
3653
3718
  create: function create(vnode) {
@@ -3661,7 +3726,14 @@
3661
3726
  update: updateNodeHook,
3662
3727
  insert: insertNodeHook,
3663
3728
  move: insertNodeHook,
3664
- remove: removeNodeHook
3729
+ remove: removeNodeHook,
3730
+ hydrate: function hydrate(vNode, node) {
3731
+ var _a;
3732
+
3733
+
3734
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3735
+ vNode.elm = node;
3736
+ }
3665
3737
  }; // insert is called after update, which is used somewhere else (via a module)
3666
3738
  // to mark the vm as inserted, that means we cannot use update as the main channel
3667
3739
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3695,6 +3767,34 @@
3695
3767
  remove: function remove(vnode, parentNode) {
3696
3768
  removeNodeHook(vnode, parentNode);
3697
3769
  removeElmHook(vnode);
3770
+ },
3771
+ hydrate: function hydrate(vnode, node) {
3772
+ var elm = node;
3773
+ vnode.elm = elm;
3774
+ var context = vnode.data.context;
3775
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3776
+ /* manual */
3777
+ );
3778
+
3779
+ if (isDomManual) {
3780
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3781
+ // remove the innerHTML from props so it reuses the existing dom elements.
3782
+ var props = vnode.data.props;
3783
+
3784
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3785
+ if (elm.innerHTML === props.innerHTML) {
3786
+ delete props.innerHTML;
3787
+ } else {
3788
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
3789
+ }
3790
+ }
3791
+ }
3792
+
3793
+ hydrateElmHook(vnode);
3794
+
3795
+ if (!isDomManual) {
3796
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3797
+ }
3698
3798
  }
3699
3799
  };
3700
3800
  var CustomElementHook = {
@@ -3774,6 +3874,36 @@
3774
3874
  // will take care of disconnecting any child VM attached to its shadow as well.
3775
3875
  removeVM(vm);
3776
3876
  }
3877
+ },
3878
+ hydrate: function hydrate(vnode, elm) {
3879
+ // the element is created, but the vm is not
3880
+ var sel = vnode.sel,
3881
+ mode = vnode.mode,
3882
+ ctor = vnode.ctor,
3883
+ owner = vnode.owner;
3884
+ var def = getComponentInternalDef(ctor);
3885
+ createVM(elm, def, {
3886
+ mode: mode,
3887
+ owner: owner,
3888
+ tagName: sel,
3889
+ renderer: owner.renderer
3890
+ });
3891
+ vnode.elm = elm;
3892
+ var vm = getAssociatedVM(elm);
3893
+ allocateChildrenHook(vnode, vm);
3894
+ hydrateElmHook(vnode); // Insert hook section:
3895
+
3896
+ runConnectedCallback(vm);
3897
+
3898
+ if (vm.renderMode !== 0
3899
+ /* Light */
3900
+ ) {
3901
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
3902
+ // Note: for Light DOM, this is handled while hydrating the VM
3903
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
3904
+ }
3905
+
3906
+ hydrateVM(vm);
3777
3907
  }
3778
3908
  };
3779
3909
 
@@ -3975,7 +4105,7 @@
3975
4105
 
3976
4106
 
3977
4107
  function d(value) {
3978
- return value == null ? '' : value;
4108
+ return value == null ? '' : String(value);
3979
4109
  } // [b]ind function
3980
4110
 
3981
4111
 
@@ -4114,6 +4244,26 @@
4114
4244
 
4115
4245
  markAsDynamicChildren(vnodes);
4116
4246
  return vnodes;
4247
+ }
4248
+ /**
4249
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4250
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4251
+ * lwc:inner-html directive.
4252
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
4253
+ */
4254
+
4255
+
4256
+ var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
4257
+ // locker-service patches this function during runtime to sanitize HTML content.
4258
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4259
+ };
4260
+ /**
4261
+ * Sets the sanitizeHtmlContentHook.
4262
+ */
4263
+
4264
+
4265
+ function setSanitizeHtmlContentHook(newHookImpl) {
4266
+ sanitizeHtmlContentHook = newHookImpl;
4117
4267
  } // [s]anitize [h]tml [c]ontent
4118
4268
 
4119
4269
 
@@ -4216,8 +4366,8 @@
4216
4366
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4217
4367
  var content = [];
4218
4368
 
4219
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
4220
- var stylesheet = stylesheets[_i14];
4369
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4370
+ var stylesheet = stylesheets[_i16];
4221
4371
 
4222
4372
  if (isArray$1(stylesheet)) {
4223
4373
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4287,10 +4437,13 @@
4287
4437
  && shadowMode === 1
4288
4438
  /* Synthetic */
4289
4439
  ) {
4290
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
4291
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
4440
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4441
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
4292
4442
  }
4293
- } else if (renderer.ssr) {
4443
+ } else if (renderer.ssr || renderer.isHydrating()) {
4444
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4445
+ // This works in the client, because the stylesheets are created, and cached in the VM
4446
+ // the first time the VM renders.
4294
4447
  // native shadow or light DOM, SSR
4295
4448
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4296
4449
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4299,12 +4452,12 @@
4299
4452
  var root = getNearestNativeShadowComponent(vm);
4300
4453
  var isGlobal = isNull(root);
4301
4454
 
4302
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4455
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4303
4456
  if (isGlobal) {
4304
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
4457
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
4305
4458
  } else {
4306
4459
  // local level
4307
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
4460
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
4308
4461
  }
4309
4462
  }
4310
4463
  }
@@ -4489,8 +4642,8 @@
4489
4642
  var stylesheets = template.stylesheets;
4490
4643
 
4491
4644
  if (!isUndefined$1(stylesheets)) {
4492
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4493
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
4645
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4646
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4494
4647
  return true;
4495
4648
  }
4496
4649
  }
@@ -4691,8 +4844,8 @@
4691
4844
 
4692
4845
  function register(service) {
4693
4846
 
4694
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
4695
- var hookName = hooks[_i18];
4847
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4848
+ var hookName = hooks[_i20];
4696
4849
 
4697
4850
  if (hookName in service) {
4698
4851
  var l = Services[hookName];
@@ -4712,8 +4865,8 @@
4712
4865
  def = vm.def,
4713
4866
  context = vm.context;
4714
4867
 
4715
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
4716
- cbs[_i19].call(undefined, component, {}, def, context);
4868
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
4869
+ cbs[_i21].call(undefined, component, {}, def, context);
4717
4870
  }
4718
4871
  }
4719
4872
  /*
@@ -4766,6 +4919,12 @@
4766
4919
  , vm);
4767
4920
  }
4768
4921
 
4922
+ function hydrateRootElement(elm) {
4923
+ var vm = getAssociatedVM(elm);
4924
+ runConnectedCallback(vm);
4925
+ hydrateVM(vm);
4926
+ }
4927
+
4769
4928
  function disconnectRootElement(elm) {
4770
4929
  var vm = getAssociatedVM(elm);
4771
4930
  resetComponentStateWhenRemoved(vm);
@@ -4773,6 +4932,10 @@
4773
4932
 
4774
4933
  function appendVM(vm) {
4775
4934
  rehydrate(vm);
4935
+ }
4936
+
4937
+ function hydrateVM(vm) {
4938
+ hydrate(vm);
4776
4939
  } // just in case the component comes back, with this we guarantee re-rendering it
4777
4940
  // while preventing any attempt to rehydration until after reinsertion.
4778
4941
 
@@ -4957,6 +5120,22 @@
4957
5120
  }
4958
5121
  }
4959
5122
 
5123
+ function hydrate(vm) {
5124
+ if (isTrue(vm.isDirty)) {
5125
+ // manually diffing/patching here.
5126
+ // This routine is:
5127
+ // patchShadowRoot(vm, children);
5128
+ // -> addVnodes.
5129
+ var children = renderComponent(vm);
5130
+ vm.children = children;
5131
+ var vmChildren = vm.renderMode === 0
5132
+ /* Light */
5133
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5134
+ hydrateChildrenHook(vmChildren, children);
5135
+ runRenderedCallback(vm);
5136
+ }
5137
+ }
5138
+
4960
5139
  function patchShadowRoot(vm, newCh) {
4961
5140
  var oldCh = vm.children; // caching the new children collection
4962
5141
 
@@ -5033,19 +5212,19 @@
5033
5212
  });
5034
5213
  rehydrateQueue = []; // reset to a new queue
5035
5214
 
5036
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
5037
- var vm = vms[_i20];
5215
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5216
+ var vm = vms[_i22];
5038
5217
 
5039
5218
  try {
5040
5219
  rehydrate(vm);
5041
5220
  } catch (error) {
5042
- if (_i20 + 1 < _len7) {
5221
+ if (_i22 + 1 < _len7) {
5043
5222
  // pieces of the queue are still pending to be rehydrated, those should have priority
5044
5223
  if (rehydrateQueue.length === 0) {
5045
5224
  addCallbackToNextTick(flushRehydrationQueue);
5046
5225
  }
5047
5226
 
5048
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
5227
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5049
5228
  } // we need to end the measure before throwing.
5050
5229
 
5051
5230
 
@@ -5144,8 +5323,8 @@
5144
5323
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5145
5324
  // inserted in reserved order.
5146
5325
 
5147
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
5148
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
5326
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
5327
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
5149
5328
  // * when there is an error during the construction phase, and an error
5150
5329
  // boundary picks it, there is a possibility that the VCustomElement
5151
5330
  // is not properly initialized, and therefore is should be ignored.
@@ -5179,8 +5358,8 @@
5179
5358
 
5180
5359
 
5181
5360
  function recursivelyDisconnectChildren(vnodes) {
5182
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
5183
- var vnode = vnodes[_i22];
5361
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5362
+ var vnode = vnodes[_i24];
5184
5363
 
5185
5364
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5186
5365
  // vnode is a VElement with children
@@ -5204,8 +5383,8 @@
5204
5383
  renderer = vm.renderer;
5205
5384
  var rootNode = getRenderRoot(vm);
5206
5385
 
5207
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
5208
- var child = children[_i23];
5386
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5387
+ var child = children[_i25];
5209
5388
 
5210
5389
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5211
5390
  renderer.remove(child.elm, rootNode);
@@ -5250,8 +5429,8 @@
5250
5429
  var oldSlots = vm.cmpSlots;
5251
5430
  var cmpSlots = vm.cmpSlots = create(null);
5252
5431
 
5253
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
5254
- var vnode = children[_i24];
5432
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5433
+ var vnode = children[_i26];
5255
5434
 
5256
5435
  if (isNull(vnode)) {
5257
5436
  continue;
@@ -5281,8 +5460,8 @@
5281
5460
  return;
5282
5461
  }
5283
5462
 
5284
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
5285
- var key = oldKeys[_i25];
5463
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5464
+ var key = oldKeys[_i27];
5286
5465
 
5287
5466
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5288
5467
  markComponentAsDirty(vm);
@@ -5621,8 +5800,8 @@
5621
5800
  function connectWireAdapters(vm) {
5622
5801
  var wiredConnecting = vm.context.wiredConnecting;
5623
5802
 
5624
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
5625
- wiredConnecting[_i26]();
5803
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5804
+ wiredConnecting[_i28]();
5626
5805
  }
5627
5806
  }
5628
5807
 
@@ -5630,8 +5809,8 @@
5630
5809
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5631
5810
  runWithBoundaryProtection(vm, vm, noop, function () {
5632
5811
  // job
5633
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
5634
- wiredDisconnecting[_i27]();
5812
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5813
+ wiredDisconnecting[_i29]();
5635
5814
  }
5636
5815
  }, noop);
5637
5816
  }
@@ -5710,25 +5889,12 @@
5710
5889
 
5711
5890
  var hooksAreSet = false;
5712
5891
 
5713
- function overrideHooks(hooks) {
5714
- var oldHooks = {};
5715
-
5716
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
5717
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5718
- }
5719
-
5720
- return oldHooks;
5721
- }
5722
-
5723
5892
  function setHooks(hooks) {
5724
5893
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5725
- overrideHooks(hooks);
5726
5894
  hooksAreSet = true;
5895
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5727
5896
  }
5728
-
5729
- function setHooksForTest(hooks) {
5730
- }
5731
- /* version: 2.5.6 */
5897
+ /* version: 2.5.10 */
5732
5898
 
5733
5899
  /*
5734
5900
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5873,8 +6039,17 @@
5873
6039
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5874
6040
  }
5875
6041
 
6042
+ var _isHydrating = false;
6043
+
6044
+ function setIsHydrating(v) {
6045
+ _isHydrating = v;
6046
+ }
6047
+
5876
6048
  var renderer = {
5877
6049
  ssr: false,
6050
+ isHydrating: function isHydrating() {
6051
+ return _isHydrating;
6052
+ },
5878
6053
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5879
6054
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5880
6055
  createElement: function createElement(tagName, namespace) {
@@ -5896,6 +6071,10 @@
5896
6071
  return node.nextSibling;
5897
6072
  },
5898
6073
  attachShadow: function attachShadow(element, options) {
6074
+ if (_isHydrating) {
6075
+ return element.shadowRoot;
6076
+ }
6077
+
5899
6078
  return element.attachShadow(options);
5900
6079
  },
5901
6080
  setText: function setText(node, content) {
@@ -6000,71 +6179,6 @@
6000
6179
  getCustomElement: getCustomElement,
6001
6180
  HTMLElement: HTMLElementConstructor
6002
6181
  };
6003
- /*
6004
- * Copyright (c) 2018, salesforce.com, inc.
6005
- * All rights reserved.
6006
- * SPDX-License-Identifier: MIT
6007
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6008
- */
6009
-
6010
- /**
6011
- * This function builds a Web Component class from a LWC constructor so it can be
6012
- * registered as a new element via customElements.define() at any given time.
6013
- *
6014
- * @deprecated since version 1.3.11
6015
- *
6016
- * @example
6017
- * ```
6018
- * import { buildCustomElementConstructor } from 'lwc';
6019
- * import Foo from 'ns/foo';
6020
- * const WC = buildCustomElementConstructor(Foo);
6021
- * customElements.define('x-foo', WC);
6022
- * const elm = document.createElement('x-foo');
6023
- * ```
6024
- */
6025
-
6026
- function deprecatedBuildCustomElementConstructor(Ctor) {
6027
-
6028
- return Ctor.CustomElementConstructor;
6029
- }
6030
-
6031
- function buildCustomElementConstructor(Ctor) {
6032
- var def = getComponentInternalDef(Ctor);
6033
- return /*#__PURE__*/function (_def$bridge) {
6034
- _inherits(_class, _def$bridge);
6035
-
6036
- var _super8 = _createSuper(_class);
6037
-
6038
- function _class() {
6039
- var _this6;
6040
-
6041
- _classCallCheck(this, _class);
6042
-
6043
- _this6 = _super8.call(this);
6044
- createVM(_assertThisInitialized(_this6), def, {
6045
- mode: 'open',
6046
- owner: null,
6047
- tagName: _this6.tagName,
6048
- renderer: renderer
6049
- });
6050
- return _this6;
6051
- }
6052
-
6053
- _createClass(_class, [{
6054
- key: "connectedCallback",
6055
- value: function connectedCallback() {
6056
- connectRootElement(this);
6057
- }
6058
- }, {
6059
- key: "disconnectedCallback",
6060
- value: function disconnectedCallback() {
6061
- disconnectRootElement(this);
6062
- }
6063
- }]);
6064
-
6065
- return _class;
6066
- }(def.bridge);
6067
- }
6068
6182
  /*
6069
6183
  * Copyright (c) 2018, salesforce.com, inc.
6070
6184
  * All rights reserved.
@@ -6074,7 +6188,6 @@
6074
6188
  // TODO [#2472]: Remove this workaround when appropriate.
6075
6189
  // eslint-disable-next-line lwc-internal/no-global-node
6076
6190
 
6077
-
6078
6191
  var _Node$1 = Node;
6079
6192
  var ConnectingSlot = new WeakMap();
6080
6193
  var DisconnectingSlot = new WeakMap();
@@ -6181,6 +6294,138 @@
6181
6294
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6182
6295
  */
6183
6296
 
6297
+
6298
+ function hydrateComponent(element, Ctor) {
6299
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6300
+
6301
+ if (!isFunction$1(Ctor)) {
6302
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6303
+ }
6304
+
6305
+ if (!isObject(props) || isNull(props)) {
6306
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6307
+ }
6308
+
6309
+ var def = getComponentInternalDef(Ctor);
6310
+
6311
+ try {
6312
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6313
+ // and uses the same algo to create the stylesheets as in SSR.
6314
+ setIsHydrating(true);
6315
+ createVM(element, def, {
6316
+ mode: 'open',
6317
+ owner: null,
6318
+ renderer: renderer,
6319
+ tagName: element.tagName.toLowerCase()
6320
+ });
6321
+
6322
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6323
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6324
+ key = _Object$entries2$_i[0],
6325
+ value = _Object$entries2$_i[1];
6326
+
6327
+ element[key] = value;
6328
+ }
6329
+
6330
+ hydrateRootElement(element); // set it back since now we finished hydration.
6331
+
6332
+ setIsHydrating(false);
6333
+ } catch (e) {
6334
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6335
+ // the client generated DOM.
6336
+
6337
+ /* eslint-disable-next-line no-console */
6338
+ console.error('Recovering from error while hydrating: ', e);
6339
+ setIsHydrating(false);
6340
+ var newElem = createElement(element.tagName, {
6341
+ is: Ctor,
6342
+ mode: 'open'
6343
+ });
6344
+
6345
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6346
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6347
+ _key3 = _Object$entries3$_i[0],
6348
+ _value2 = _Object$entries3$_i[1];
6349
+
6350
+ newElem[_key3] = _value2;
6351
+ }
6352
+
6353
+ element.parentNode.replaceChild(newElem, element);
6354
+ }
6355
+ }
6356
+ /*
6357
+ * Copyright (c) 2018, salesforce.com, inc.
6358
+ * All rights reserved.
6359
+ * SPDX-License-Identifier: MIT
6360
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6361
+ */
6362
+
6363
+ /**
6364
+ * This function builds a Web Component class from a LWC constructor so it can be
6365
+ * registered as a new element via customElements.define() at any given time.
6366
+ *
6367
+ * @deprecated since version 1.3.11
6368
+ *
6369
+ * @example
6370
+ * ```
6371
+ * import { buildCustomElementConstructor } from 'lwc';
6372
+ * import Foo from 'ns/foo';
6373
+ * const WC = buildCustomElementConstructor(Foo);
6374
+ * customElements.define('x-foo', WC);
6375
+ * const elm = document.createElement('x-foo');
6376
+ * ```
6377
+ */
6378
+
6379
+
6380
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6381
+
6382
+ return Ctor.CustomElementConstructor;
6383
+ }
6384
+
6385
+ function buildCustomElementConstructor(Ctor) {
6386
+ var def = getComponentInternalDef(Ctor);
6387
+ return /*#__PURE__*/function (_def$bridge) {
6388
+ _inherits(_class, _def$bridge);
6389
+
6390
+ var _super8 = _createSuper(_class);
6391
+
6392
+ function _class() {
6393
+ var _this6;
6394
+
6395
+ _classCallCheck(this, _class);
6396
+
6397
+ _this6 = _super8.call(this);
6398
+ createVM(_assertThisInitialized(_this6), def, {
6399
+ mode: 'open',
6400
+ owner: null,
6401
+ tagName: _this6.tagName,
6402
+ renderer: renderer
6403
+ });
6404
+ return _this6;
6405
+ }
6406
+
6407
+ _createClass(_class, [{
6408
+ key: "connectedCallback",
6409
+ value: function connectedCallback() {
6410
+ connectRootElement(this);
6411
+ }
6412
+ }, {
6413
+ key: "disconnectedCallback",
6414
+ value: function disconnectedCallback() {
6415
+ disconnectRootElement(this);
6416
+ }
6417
+ }]);
6418
+
6419
+ return _class;
6420
+ }(def.bridge);
6421
+ }
6422
+ /*
6423
+ * Copyright (c) 2018, salesforce.com, inc.
6424
+ * All rights reserved.
6425
+ * SPDX-License-Identifier: MIT
6426
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6427
+ */
6428
+
6184
6429
  /**
6185
6430
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6186
6431
  * This API is subject to change or being removed.
@@ -6279,7 +6524,7 @@
6279
6524
  });
6280
6525
  freeze(LightningElement);
6281
6526
  seal(LightningElement.prototype);
6282
- /* version: 2.5.6 */
6527
+ /* version: 2.5.10 */
6283
6528
 
6284
6529
  exports.LightningElement = LightningElement;
6285
6530
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6289,6 +6534,7 @@
6289
6534
  exports.createElement = createElement;
6290
6535
  exports.getComponentConstructor = getComponentConstructor;
6291
6536
  exports.getComponentDef = getComponentDef;
6537
+ exports.hydrateComponent = hydrateComponent;
6292
6538
  exports.isComponentConstructor = isComponentConstructor;
6293
6539
  exports.isNodeFromTemplate = isNodeFromTemplate;
6294
6540
  exports.readonly = readonly;
@@ -6300,7 +6546,6 @@
6300
6546
  exports.setFeatureFlag = setFeatureFlag;
6301
6547
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6302
6548
  exports.setHooks = setHooks;
6303
- exports.setHooksForTest = setHooksForTest;
6304
6549
  exports.swapComponent = swapComponent;
6305
6550
  exports.swapStyle = swapStyle;
6306
6551
  exports.swapTemplate = swapTemplate;