lwc 2.5.5-canary1 → 2.5.9

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 (41) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +672 -214
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +673 -215
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +473 -202
  5. package/dist/engine-dom/iife/es5/engine-dom.js +741 -265
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +522 -243
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +674 -216
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +474 -203
  11. package/dist/engine-dom/umd/es5/engine-dom.js +742 -266
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +523 -244
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +551 -166
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +552 -166
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +9 -39
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +10 -40
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +10 -40
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +10 -40
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +10 -40
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +11 -41
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +11 -41
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +11 -41
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +11 -41
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +3 -3
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +3 -3
  33. package/dist/wire-service/iife/es5/wire-service.js +3 -3
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +3 -3
  36. package/dist/wire-service/umd/es2017/wire-service.js +4 -4
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +4 -4
  38. package/dist/wire-service/umd/es5/wire-service.js +4 -4
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +4 -4
  41. package/package.json +8 -8
@@ -35,23 +35,23 @@ var LWC = (function (exports) {
35
35
 
36
36
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
37
37
 
38
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
38
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
39
39
 
40
- 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."); }
40
+ 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); } }
41
41
 
42
- 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); }
42
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
43
43
 
44
- 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; }
44
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
45
+
46
+ 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."); }
45
47
 
46
48
  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; }
47
49
 
48
50
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
49
51
 
50
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
51
-
52
- 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); } }
52
+ 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); }
53
53
 
54
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
54
+ 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; }
55
55
 
56
56
  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); }
57
57
 
@@ -120,7 +120,7 @@ var LWC = (function (exports) {
120
120
  var _Array$prototype = Array.prototype,
121
121
  ArrayIndexOf = _Array$prototype.indexOf,
122
122
  ArrayJoin = _Array$prototype.join,
123
- ArrayMap$1 = _Array$prototype.map,
123
+ ArrayMap = _Array$prototype.map,
124
124
  ArrayPush$1 = _Array$prototype.push,
125
125
  ArraySlice = _Array$prototype.slice,
126
126
  ArraySplice = _Array$prototype.splice,
@@ -177,7 +177,7 @@ var LWC = (function (exports) {
177
177
  // Array.prototype.toString directly will cause an error Iterate through
178
178
  // all the items and handle individually.
179
179
  if (isArray$1(obj)) {
180
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
180
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
181
181
  }
182
182
 
183
183
  return obj.toString();
@@ -341,7 +341,7 @@ var LWC = (function (exports) {
341
341
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
342
342
  return attributeName;
343
343
  }
344
- /** version: 2.5.5-canary1 */
344
+ /** version: 2.5.9 */
345
345
 
346
346
  /*
347
347
  * Copyright (c) 2018, salesforce.com, inc.
@@ -513,7 +513,7 @@ var LWC = (function (exports) {
513
513
 
514
514
  function setFeatureFlagForTest(name, value) {
515
515
  }
516
- /** version: 2.5.5-canary1 */
516
+ /** version: 2.5.9 */
517
517
 
518
518
  /* proxy-compat-disable */
519
519
 
@@ -555,7 +555,7 @@ var LWC = (function (exports) {
555
555
  }
556
556
 
557
557
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
558
- }
558
+ } // Borrowed from Vue template compiler.
559
559
  /*
560
560
  * Copyright (c) 2019, salesforce.com, inc.
561
561
  * All rights reserved.
@@ -710,6 +710,20 @@ var LWC = (function (exports) {
710
710
  return "<".concat(StringToLowerCase.call(vm.tagName), ">");
711
711
  } // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
712
712
 
713
+
714
+ function getComponentStack(vm) {
715
+ var stack = [];
716
+ var prefix = '';
717
+
718
+ while (!isNull(vm.owner)) {
719
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
720
+ vm = vm.owner;
721
+ prefix += '\t';
722
+ }
723
+
724
+ return ArrayJoin.call(stack, '\n');
725
+ }
726
+
713
727
  function getErrorComponentStack(vm) {
714
728
  var wcStack = [];
715
729
  var currentVm = vm;
@@ -729,6 +743,32 @@ var LWC = (function (exports) {
729
743
  */
730
744
 
731
745
 
746
+ function log(method, message, vm) {
747
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
748
+
749
+ if (!isUndefined$1(vm)) {
750
+ msg = "".concat(msg, "\n").concat(getComponentStack(vm));
751
+ }
752
+
753
+ try {
754
+ throw new Error(msg);
755
+ } catch (e) {
756
+ /* eslint-disable-next-line no-console */
757
+ console[method](e);
758
+ }
759
+ }
760
+
761
+ function logWarn(message, vm) {
762
+ log('warn', message, vm);
763
+ }
764
+ /*
765
+ * Copyright (c) 2018, salesforce.com, inc.
766
+ * All rights reserved.
767
+ * SPDX-License-Identifier: MIT
768
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
769
+ */
770
+
771
+
732
772
  function handleEvent(event, vnode) {
733
773
  var type = event.type;
734
774
  var on = vnode.data.on;
@@ -1521,7 +1561,10 @@ var LWC = (function (exports) {
1521
1561
  // but it will always be compatible with the previous descriptor
1522
1562
  // to preserve the object invariants, which makes these lines safe.
1523
1563
 
1524
- var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key);
1564
+ var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1565
+
1566
+ /* istanbul ignore else */
1567
+
1525
1568
 
1526
1569
  if (!isUndefined(originalDescriptor)) {
1527
1570
  var wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1546,12 +1589,18 @@ var LWC = (function (exports) {
1546
1589
 
1547
1590
  _preventExtensions(shadowTarget);
1548
1591
  } // Shared Traps
1592
+ // TODO: apply() is never called
1593
+
1594
+ /* istanbul ignore next */
1549
1595
 
1550
1596
  }, {
1551
1597
  key: "apply",
1552
1598
  value: function apply(shadowTarget, thisArg, argArray) {
1553
1599
  /* No op */
1554
- }
1600
+ } // TODO: construct() is never called
1601
+
1602
+ /* istanbul ignore next */
1603
+
1555
1604
  }, {
1556
1605
  key: "construct",
1557
1606
  value: function construct(shadowTarget, argArray, newTarget) {
@@ -1656,8 +1705,8 @@ var LWC = (function (exports) {
1656
1705
  return BaseProxyHandler;
1657
1706
  }();
1658
1707
 
1659
- var getterMap = new WeakMap();
1660
- var setterMap = new WeakMap();
1708
+ var getterMap$1 = new WeakMap();
1709
+ var setterMap$1 = new WeakMap();
1661
1710
  var reverseGetterMap = new WeakMap();
1662
1711
  var reverseSetterMap = new WeakMap();
1663
1712
 
@@ -1680,7 +1729,7 @@ var LWC = (function (exports) {
1680
1729
  }, {
1681
1730
  key: "wrapGetter",
1682
1731
  value: function wrapGetter(originalGet) {
1683
- var wrappedGetter = getterMap.get(originalGet);
1732
+ var wrappedGetter = getterMap$1.get(originalGet);
1684
1733
 
1685
1734
  if (!isUndefined(wrappedGetter)) {
1686
1735
  return wrappedGetter;
@@ -1693,14 +1742,14 @@ var LWC = (function (exports) {
1693
1742
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1694
1743
  };
1695
1744
 
1696
- getterMap.set(originalGet, get);
1745
+ getterMap$1.set(originalGet, get);
1697
1746
  reverseGetterMap.set(get, originalGet);
1698
1747
  return get;
1699
1748
  }
1700
1749
  }, {
1701
1750
  key: "wrapSetter",
1702
1751
  value: function wrapSetter(originalSet) {
1703
- var wrappedSetter = setterMap.get(originalSet);
1752
+ var wrappedSetter = setterMap$1.get(originalSet);
1704
1753
 
1705
1754
  if (!isUndefined(wrappedSetter)) {
1706
1755
  return wrappedSetter;
@@ -1711,7 +1760,7 @@ var LWC = (function (exports) {
1711
1760
  originalSet.call(unwrap$1(this), unwrap$1(v));
1712
1761
  };
1713
1762
 
1714
- setterMap.set(originalSet, set);
1763
+ setterMap$1.set(originalSet, set);
1715
1764
  reverseSetterMap.set(set, originalSet);
1716
1765
  return set;
1717
1766
  }
@@ -1752,7 +1801,7 @@ var LWC = (function (exports) {
1752
1801
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1753
1802
  };
1754
1803
 
1755
- getterMap.set(get, redGet);
1804
+ getterMap$1.set(get, redGet);
1756
1805
  reverseGetterMap.set(redGet, get);
1757
1806
  return get;
1758
1807
  }
@@ -1772,7 +1821,7 @@ var LWC = (function (exports) {
1772
1821
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1773
1822
  };
1774
1823
 
1775
- setterMap.set(set, redSet);
1824
+ setterMap$1.set(set, redSet);
1776
1825
  reverseSetterMap.set(redSet, set);
1777
1826
  return set;
1778
1827
  }
@@ -1818,6 +1867,11 @@ var LWC = (function (exports) {
1818
1867
  _preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1819
1868
  // the preventExtension call, in which case we should not attempt to lock down
1820
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 */
1821
1875
 
1822
1876
 
1823
1877
  if (_isExtensible(originalTarget)) {
@@ -1860,8 +1914,8 @@ var LWC = (function (exports) {
1860
1914
  return ReactiveProxyHandler;
1861
1915
  }(BaseProxyHandler);
1862
1916
 
1863
- var getterMap$1 = new WeakMap();
1864
- var setterMap$1 = new WeakMap();
1917
+ var getterMap = new WeakMap();
1918
+ var setterMap = new WeakMap();
1865
1919
 
1866
1920
  var ReadOnlyHandler = /*#__PURE__*/function (_BaseProxyHandler2) {
1867
1921
  _inherits(ReadOnlyHandler, _BaseProxyHandler2);
@@ -1882,7 +1936,7 @@ var LWC = (function (exports) {
1882
1936
  }, {
1883
1937
  key: "wrapGetter",
1884
1938
  value: function wrapGetter(originalGet) {
1885
- var wrappedGetter = getterMap$1.get(originalGet);
1939
+ var wrappedGetter = getterMap.get(originalGet);
1886
1940
 
1887
1941
  if (!isUndefined(wrappedGetter)) {
1888
1942
  return wrappedGetter;
@@ -1895,13 +1949,13 @@ var LWC = (function (exports) {
1895
1949
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1896
1950
  };
1897
1951
 
1898
- getterMap$1.set(originalGet, get);
1952
+ getterMap.set(originalGet, get);
1899
1953
  return get;
1900
1954
  }
1901
1955
  }, {
1902
1956
  key: "wrapSetter",
1903
1957
  value: function wrapSetter(originalSet) {
1904
- var wrappedSetter = setterMap$1.get(originalSet);
1958
+ var wrappedSetter = setterMap.get(originalSet);
1905
1959
 
1906
1960
  if (!isUndefined(wrappedSetter)) {
1907
1961
  return wrappedSetter;
@@ -1910,18 +1964,22 @@ var LWC = (function (exports) {
1910
1964
  var set = function set(v) {
1911
1965
  };
1912
1966
 
1913
- setterMap$1.set(originalSet, set);
1967
+ setterMap.set(originalSet, set);
1914
1968
  return set;
1915
1969
  }
1916
1970
  }, {
1917
1971
  key: "set",
1918
1972
  value: function set(shadowTarget, key, value) {
1973
+ /* istanbul ignore next */
1974
+
1919
1975
 
1920
1976
  return false;
1921
1977
  }
1922
1978
  }, {
1923
1979
  key: "deleteProperty",
1924
1980
  value: function deleteProperty(shadowTarget, key) {
1981
+ /* istanbul ignore next */
1982
+
1925
1983
 
1926
1984
  return false;
1927
1985
  }
@@ -1932,12 +1990,16 @@ var LWC = (function (exports) {
1932
1990
  }, {
1933
1991
  key: "preventExtensions",
1934
1992
  value: function preventExtensions(shadowTarget) {
1993
+ /* istanbul ignore next */
1994
+
1935
1995
 
1936
1996
  return false;
1937
1997
  }
1938
1998
  }, {
1939
1999
  key: "defineProperty",
1940
2000
  value: function defineProperty(shadowTarget, key, descriptor) {
2001
+ /* istanbul ignore next */
2002
+
1941
2003
 
1942
2004
  return false;
1943
2005
  }
@@ -1992,7 +2054,8 @@ var LWC = (function (exports) {
1992
2054
  this.valueMutated = defaultValueMutated;
1993
2055
  this.valueObserved = defaultValueObserved;
1994
2056
  this.valueIsObservable = defaultValueIsObservable;
1995
- this.objectGraph = new WeakMap();
2057
+ this.readOnlyObjectGraph = new WeakMap();
2058
+ this.reactiveObjectGraph = new WeakMap();
1996
2059
 
1997
2060
  if (!isUndefined(options)) {
1998
2061
  var _valueDistortion = options.valueDistortion,
@@ -2015,10 +2078,13 @@ var LWC = (function (exports) {
2015
2078
  var distorted = this.valueDistortion(unwrappedValue);
2016
2079
 
2017
2080
  if (this.valueIsObservable(distorted)) {
2018
- var o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2019
- // we return the readonly.
2081
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2082
+ // when trying to extract the writable version of a readonly
2083
+ // we return the readonly.
2084
+ return value;
2085
+ }
2020
2086
 
2021
- return o.readOnly === value ? value : o.reactive;
2087
+ return this.getReactiveHandler(unwrappedValue, distorted);
2022
2088
  }
2023
2089
 
2024
2090
  return distorted;
@@ -2030,7 +2096,7 @@ var LWC = (function (exports) {
2030
2096
  var distorted = this.valueDistortion(value);
2031
2097
 
2032
2098
  if (this.valueIsObservable(distorted)) {
2033
- return this.getReactiveState(value, distorted).readOnly;
2099
+ return this.getReadOnlyHandler(value, distorted);
2034
2100
  }
2035
2101
 
2036
2102
  return distorted;
@@ -2041,48 +2107,40 @@ var LWC = (function (exports) {
2041
2107
  return unwrap$1(p);
2042
2108
  }
2043
2109
  }, {
2044
- key: "getReactiveState",
2045
- value: function getReactiveState(value, distortedValue) {
2046
- var objectGraph = this.objectGraph;
2047
- var reactiveState = objectGraph.get(distortedValue);
2048
-
2049
- if (reactiveState) {
2050
- return reactiveState;
2110
+ key: "getReactiveHandler",
2111
+ value: function getReactiveHandler(value, distortedValue) {
2112
+ var proxy = this.reactiveObjectGraph.get(distortedValue);
2113
+
2114
+ if (isUndefined(proxy)) {
2115
+ // caching the proxy after the first time it is accessed
2116
+ var handler = new ReactiveProxyHandler(this, distortedValue);
2117
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2118
+ registerProxy(proxy, value);
2119
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2051
2120
  }
2052
2121
 
2053
- var membrane = this;
2054
- reactiveState = {
2055
- get reactive() {
2056
- var reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2057
-
2058
- var proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2059
- registerProxy(proxy, value);
2060
- ObjectDefineProperty(this, 'reactive', {
2061
- value: proxy
2062
- });
2063
- return proxy;
2064
- },
2065
-
2066
- get readOnly() {
2067
- var readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2068
-
2069
- var proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2070
- registerProxy(proxy, value);
2071
- ObjectDefineProperty(this, 'readOnly', {
2072
- value: proxy
2073
- });
2074
- return proxy;
2075
- }
2122
+ return proxy;
2123
+ }
2124
+ }, {
2125
+ key: "getReadOnlyHandler",
2126
+ value: function getReadOnlyHandler(value, distortedValue) {
2127
+ var proxy = this.readOnlyObjectGraph.get(distortedValue);
2128
+
2129
+ if (isUndefined(proxy)) {
2130
+ // caching the proxy after the first time it is accessed
2131
+ var handler = new ReadOnlyHandler(this, distortedValue);
2132
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2133
+ registerProxy(proxy, value);
2134
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2135
+ }
2076
2136
 
2077
- };
2078
- objectGraph.set(distortedValue, reactiveState);
2079
- return reactiveState;
2137
+ return proxy;
2080
2138
  }
2081
2139
  }]);
2082
2140
 
2083
2141
  return ReactiveMembrane;
2084
2142
  }();
2085
- /** version: 1.0.0 */
2143
+ /** version: 1.1.5 */
2086
2144
 
2087
2145
  /*
2088
2146
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2391,7 +2449,9 @@ var LWC = (function (exports) {
2391
2449
  renderer = vm.renderer;
2392
2450
 
2393
2451
  return renderer[rendererMethod](elm);
2394
- }
2452
+ },
2453
+ configurable: true,
2454
+ enumerable: true
2395
2455
  };
2396
2456
  };
2397
2457
 
@@ -2410,7 +2470,10 @@ var LWC = (function (exports) {
2410
2470
  renderer = vm.renderer;
2411
2471
 
2412
2472
  return renderer[queryMethod](elm, arg);
2413
- }
2473
+ },
2474
+ configurable: true,
2475
+ enumerable: true,
2476
+ writable: true
2414
2477
  };
2415
2478
  };
2416
2479
 
@@ -3260,7 +3323,7 @@ var LWC = (function (exports) {
3260
3323
  renderMode: 1
3261
3324
  /* Shadow */
3262
3325
  ,
3263
- shadowSupportMode: "default"
3326
+ shadowSupportMode: "reset"
3264
3327
  /* Default */
3265
3328
  ,
3266
3329
  wire: EmptyObject,
@@ -3374,6 +3437,17 @@ var LWC = (function (exports) {
3374
3437
  modComputedStyle.create(vnode);
3375
3438
  }
3376
3439
 
3440
+ function hydrateElmHook(vnode) {
3441
+ modEvents.create(vnode); // Attrs are already on the element.
3442
+ // modAttrs.create(vnode);
3443
+
3444
+ modProps.create(vnode); // Already set.
3445
+ // modStaticClassName.create(vnode);
3446
+ // modStaticStyle.create(vnode);
3447
+ // modComputedClassName.create(vnode);
3448
+ // modComputedStyle.create(vnode);
3449
+ }
3450
+
3377
3451
  function fallbackElmHook(elm, vnode) {
3378
3452
  var owner = vnode.owner;
3379
3453
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3505,6 +3579,22 @@ var LWC = (function (exports) {
3505
3579
  }
3506
3580
  }
3507
3581
 
3582
+ function hydrateChildrenHook(elmChildren, children, vm) {
3583
+
3584
+ var elmCurrentChildIdx = 0;
3585
+
3586
+ for (var j = 0, n = children.length; j < n; j++) {
3587
+ var ch = children[j];
3588
+
3589
+ if (ch != null) {
3590
+ var childNode = elmChildren[elmCurrentChildIdx];
3591
+
3592
+ ch.hook.hydrate(ch, childNode);
3593
+ elmCurrentChildIdx++;
3594
+ }
3595
+ }
3596
+ }
3597
+
3508
3598
  function updateCustomElmHook(oldVnode, vnode) {
3509
3599
  // Attrs need to be applied to element before props
3510
3600
  // IE11 will wipe out value on radio inputs if value
@@ -3598,38 +3688,6 @@ var LWC = (function (exports) {
3598
3688
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3599
3689
  */
3600
3690
 
3601
- /**
3602
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3603
- * libraries to sanitize HTML content. This hook process the content passed via the template to
3604
- * lwc:inner-html directive.
3605
- * It is meant to be overridden with setSanitizeHtmlContentHook
3606
- */
3607
-
3608
-
3609
- var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
3610
- // locker-service patches this function during runtime to sanitize HTML content.
3611
- throw new Error('sanitizeHtmlContent hook must be implemented.');
3612
- };
3613
- /**
3614
- * Sets the sanitizeHtmlContentHook.
3615
- *
3616
- * @param newHookImpl
3617
- * @returns oldHookImplementation.
3618
- */
3619
-
3620
-
3621
- function setSanitizeHtmlContentHook(newHookImpl) {
3622
- var currentHook = sanitizeHtmlContentHook;
3623
- sanitizeHtmlContentHook = newHookImpl;
3624
- return currentHook;
3625
- }
3626
- /*
3627
- * Copyright (c) 2018, salesforce.com, inc.
3628
- * All rights reserved.
3629
- * SPDX-License-Identifier: MIT
3630
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3631
- */
3632
-
3633
3691
 
3634
3692
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
3635
3693
  var SymbolIterator = Symbol.iterator;
@@ -3644,7 +3702,14 @@ var LWC = (function (exports) {
3644
3702
  update: updateNodeHook,
3645
3703
  insert: insertNodeHook,
3646
3704
  move: insertNodeHook,
3647
- remove: removeNodeHook
3705
+ remove: removeNodeHook,
3706
+ hydrate: function hydrate(vNode, node) {
3707
+ var _a;
3708
+
3709
+
3710
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3711
+ vNode.elm = node;
3712
+ }
3648
3713
  };
3649
3714
  var CommentHook = {
3650
3715
  create: function create(vnode) {
@@ -3658,7 +3723,14 @@ var LWC = (function (exports) {
3658
3723
  update: updateNodeHook,
3659
3724
  insert: insertNodeHook,
3660
3725
  move: insertNodeHook,
3661
- remove: removeNodeHook
3726
+ remove: removeNodeHook,
3727
+ hydrate: function hydrate(vNode, node) {
3728
+ var _a;
3729
+
3730
+
3731
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3732
+ vNode.elm = node;
3733
+ }
3662
3734
  }; // insert is called after update, which is used somewhere else (via a module)
3663
3735
  // to mark the vm as inserted, that means we cannot use update as the main channel
3664
3736
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3692,6 +3764,34 @@ var LWC = (function (exports) {
3692
3764
  remove: function remove(vnode, parentNode) {
3693
3765
  removeNodeHook(vnode, parentNode);
3694
3766
  removeElmHook(vnode);
3767
+ },
3768
+ hydrate: function hydrate(vnode, node) {
3769
+ var elm = node;
3770
+ vnode.elm = elm;
3771
+ var context = vnode.data.context;
3772
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3773
+ /* manual */
3774
+ );
3775
+
3776
+ if (isDomManual) {
3777
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3778
+ // remove the innerHTML from props so it reuses the existing dom elements.
3779
+ var props = vnode.data.props;
3780
+
3781
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3782
+ if (elm.innerHTML === props.innerHTML) {
3783
+ delete props.innerHTML;
3784
+ } else {
3785
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
3786
+ }
3787
+ }
3788
+ }
3789
+
3790
+ hydrateElmHook(vnode);
3791
+
3792
+ if (!isDomManual) {
3793
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3794
+ }
3695
3795
  }
3696
3796
  };
3697
3797
  var CustomElementHook = {
@@ -3771,6 +3871,36 @@ var LWC = (function (exports) {
3771
3871
  // will take care of disconnecting any child VM attached to its shadow as well.
3772
3872
  removeVM(vm);
3773
3873
  }
3874
+ },
3875
+ hydrate: function hydrate(vnode, elm) {
3876
+ // the element is created, but the vm is not
3877
+ var sel = vnode.sel,
3878
+ mode = vnode.mode,
3879
+ ctor = vnode.ctor,
3880
+ owner = vnode.owner;
3881
+ var def = getComponentInternalDef(ctor);
3882
+ createVM(elm, def, {
3883
+ mode: mode,
3884
+ owner: owner,
3885
+ tagName: sel,
3886
+ renderer: owner.renderer
3887
+ });
3888
+ vnode.elm = elm;
3889
+ var vm = getAssociatedVM(elm);
3890
+ allocateChildrenHook(vnode, vm);
3891
+ hydrateElmHook(vnode); // Insert hook section:
3892
+
3893
+ runConnectedCallback(vm);
3894
+
3895
+ if (vm.renderMode !== 0
3896
+ /* Light */
3897
+ ) {
3898
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
3899
+ // Note: for Light DOM, this is handled while hydrating the VM
3900
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
3901
+ }
3902
+
3903
+ hydrateVM(vm);
3774
3904
  }
3775
3905
  };
3776
3906
 
@@ -3898,7 +4028,7 @@ var LWC = (function (exports) {
3898
4028
  next = iterator.next();
3899
4029
  last = next.done; // template factory logic based on the previous collected value
3900
4030
 
3901
- var vnode = factory(value, j, j === 0, last);
4031
+ var vnode = factory(value, j, j === 0, last === true);
3902
4032
 
3903
4033
  if (isArray$1(vnode)) {
3904
4034
  ArrayPush$1.apply(list, vnode);
@@ -3972,7 +4102,7 @@ var LWC = (function (exports) {
3972
4102
 
3973
4103
 
3974
4104
  function d(value) {
3975
- return value == null ? '' : value;
4105
+ return value == null ? '' : String(value);
3976
4106
  } // [b]ind function
3977
4107
 
3978
4108
 
@@ -4111,6 +4241,26 @@ var LWC = (function (exports) {
4111
4241
 
4112
4242
  markAsDynamicChildren(vnodes);
4113
4243
  return vnodes;
4244
+ }
4245
+ /**
4246
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4247
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4248
+ * lwc:inner-html directive.
4249
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
4250
+ */
4251
+
4252
+
4253
+ var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
4254
+ // locker-service patches this function during runtime to sanitize HTML content.
4255
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4256
+ };
4257
+ /**
4258
+ * Sets the sanitizeHtmlContentHook.
4259
+ */
4260
+
4261
+
4262
+ function setSanitizeHtmlContentHook(newHookImpl) {
4263
+ sanitizeHtmlContentHook = newHookImpl;
4114
4264
  } // [s]anitize [h]tml [c]ontent
4115
4265
 
4116
4266
 
@@ -4118,23 +4268,21 @@ var LWC = (function (exports) {
4118
4268
  return sanitizeHtmlContentHook(content);
4119
4269
  }
4120
4270
 
4121
- var api = /*#__PURE__*/Object.freeze({
4122
- __proto__: null,
4123
- h: h,
4124
- ti: ti,
4271
+ var api = freeze({
4125
4272
  s: s,
4273
+ h: h,
4126
4274
  c: c,
4127
4275
  i: i,
4128
4276
  f: f,
4129
4277
  t: t,
4130
- co: co,
4131
4278
  d: d,
4132
4279
  b: b,
4133
4280
  k: k,
4281
+ co: co,
4282
+ dc: dc,
4283
+ ti: ti,
4134
4284
  gid: gid,
4135
4285
  fid: fid,
4136
- dc: dc,
4137
- sc: sc,
4138
4286
  shc: shc
4139
4287
  });
4140
4288
  /*
@@ -4149,12 +4297,12 @@ var LWC = (function (exports) {
4149
4297
  }
4150
4298
 
4151
4299
  function createInlineStyleVNode(content) {
4152
- return h('style', {
4300
+ return api.h('style', {
4153
4301
  key: 'style',
4154
4302
  attrs: {
4155
4303
  type: 'text/css'
4156
4304
  }
4157
- }, [t(content)]);
4305
+ }, [api.t(content)]);
4158
4306
  }
4159
4307
 
4160
4308
  function updateStylesheetToken(vm, template) {
@@ -4214,29 +4362,53 @@ var LWC = (function (exports) {
4214
4362
 
4215
4363
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4216
4364
  var content = [];
4365
+ var root;
4217
4366
 
4218
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
4219
- var stylesheet = stylesheets[_i14];
4367
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4368
+ var stylesheet = stylesheets[_i16];
4220
4369
 
4221
4370
  if (isArray$1(stylesheet)) {
4222
4371
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
4223
4372
  } else {
4224
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
4225
4373
 
4374
+ var isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
4375
+
4376
+ var scopeToken = isScopedCss || vm.shadowMode === 1
4377
+ /* Synthetic */
4378
+ && vm.renderMode === 1
4379
+ /* Shadow */
4380
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
4381
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
4226
4382
 
4227
- var isScopedCss = stylesheet[KEY__SCOPED_CSS];
4228
4383
  var useActualHostSelector = vm.renderMode === 0
4229
4384
  /* Light */
4230
4385
  ? !isScopedCss : vm.shadowMode === 0
4231
4386
  /* Native */
4232
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
4387
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
4388
+ // we use an attribute selector on the host to simulate :dir().
4233
4389
 
4234
- var scopeToken = isScopedCss || vm.shadowMode === 1
4235
- /* Synthetic */
4236
- && vm.renderMode === 1
4390
+ var useNativeDirPseudoclass = void 0;
4391
+
4392
+ if (vm.renderMode === 1
4237
4393
  /* Shadow */
4238
- ? stylesheetToken : undefined;
4239
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
4394
+ ) {
4395
+ useNativeDirPseudoclass = vm.shadowMode === 0
4396
+ /* Native */
4397
+ ;
4398
+ } else {
4399
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
4400
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
4401
+ if (isUndefined$1(root)) {
4402
+ // Only calculate the root once as necessary
4403
+ root = getNearestShadowComponent(vm);
4404
+ }
4405
+
4406
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
4407
+ /* Native */
4408
+ ;
4409
+ }
4410
+
4411
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
4240
4412
  }
4241
4413
  }
4242
4414
 
@@ -4258,14 +4430,12 @@ var LWC = (function (exports) {
4258
4430
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
4259
4431
 
4260
4432
 
4261
- function getNearestNativeShadowComponent(vm) {
4433
+ function getNearestShadowComponent(vm) {
4262
4434
  var owner = vm;
4263
4435
 
4264
4436
  while (!isNull(owner)) {
4265
4437
  if (owner.renderMode === 1
4266
4438
  /* Shadow */
4267
- && owner.shadowMode === 0
4268
- /* Native */
4269
4439
  ) {
4270
4440
  return owner;
4271
4441
  }
@@ -4276,6 +4446,20 @@ var LWC = (function (exports) {
4276
4446
  return owner;
4277
4447
  }
4278
4448
 
4449
+ function getNearestNativeShadowComponent(vm) {
4450
+ var owner = getNearestShadowComponent(vm);
4451
+
4452
+ if (!isNull(owner) && owner.shadowMode === 1
4453
+ /* Synthetic */
4454
+ ) {
4455
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
4456
+ // synthetic, we know we won't find a native component if we go any further.
4457
+ return null;
4458
+ }
4459
+
4460
+ return owner;
4461
+ }
4462
+
4279
4463
  function createStylesheet(vm, stylesheets) {
4280
4464
  var renderer = vm.renderer,
4281
4465
  renderMode = vm.renderMode,
@@ -4286,10 +4470,13 @@ var LWC = (function (exports) {
4286
4470
  && shadowMode === 1
4287
4471
  /* Synthetic */
4288
4472
  ) {
4289
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
4290
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
4473
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4474
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
4291
4475
  }
4292
- } else if (renderer.ssr) {
4476
+ } else if (renderer.ssr || renderer.isHydrating()) {
4477
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4478
+ // This works in the client, because the stylesheets are created, and cached in the VM
4479
+ // the first time the VM renders.
4293
4480
  // native shadow or light DOM, SSR
4294
4481
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4295
4482
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4298,12 +4485,12 @@ var LWC = (function (exports) {
4298
4485
  var root = getNearestNativeShadowComponent(vm);
4299
4486
  var isGlobal = isNull(root);
4300
4487
 
4301
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4488
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4302
4489
  if (isGlobal) {
4303
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
4490
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
4304
4491
  } else {
4305
4492
  // local level
4306
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
4493
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
4307
4494
  }
4308
4495
  }
4309
4496
  }
@@ -4488,8 +4675,8 @@ var LWC = (function (exports) {
4488
4675
  var stylesheets = template.stylesheets;
4489
4676
 
4490
4677
  if (!isUndefined$1(stylesheets)) {
4491
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4492
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
4678
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4679
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4493
4680
  return true;
4494
4681
  }
4495
4682
  }
@@ -4690,8 +4877,8 @@ var LWC = (function (exports) {
4690
4877
 
4691
4878
  function register(service) {
4692
4879
 
4693
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
4694
- var hookName = hooks[_i18];
4880
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4881
+ var hookName = hooks[_i20];
4695
4882
 
4696
4883
  if (hookName in service) {
4697
4884
  var l = Services[hookName];
@@ -4711,8 +4898,8 @@ var LWC = (function (exports) {
4711
4898
  def = vm.def,
4712
4899
  context = vm.context;
4713
4900
 
4714
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
4715
- cbs[_i19].call(undefined, component, {}, def, context);
4901
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
4902
+ cbs[_i21].call(undefined, component, {}, def, context);
4716
4903
  }
4717
4904
  }
4718
4905
  /*
@@ -4765,6 +4952,12 @@ var LWC = (function (exports) {
4765
4952
  , vm);
4766
4953
  }
4767
4954
 
4955
+ function hydrateRootElement(elm) {
4956
+ var vm = getAssociatedVM(elm);
4957
+ runConnectedCallback(vm);
4958
+ hydrateVM(vm);
4959
+ }
4960
+
4768
4961
  function disconnectRootElement(elm) {
4769
4962
  var vm = getAssociatedVM(elm);
4770
4963
  resetComponentStateWhenRemoved(vm);
@@ -4772,6 +4965,10 @@ var LWC = (function (exports) {
4772
4965
 
4773
4966
  function appendVM(vm) {
4774
4967
  rehydrate(vm);
4968
+ }
4969
+
4970
+ function hydrateVM(vm) {
4971
+ hydrate(vm);
4775
4972
  } // just in case the component comes back, with this we guarantee re-rendering it
4776
4973
  // while preventing any attempt to rehydration until after reinsertion.
4777
4974
 
@@ -4956,6 +5153,22 @@ var LWC = (function (exports) {
4956
5153
  }
4957
5154
  }
4958
5155
 
5156
+ function hydrate(vm) {
5157
+ if (isTrue(vm.isDirty)) {
5158
+ // manually diffing/patching here.
5159
+ // This routine is:
5160
+ // patchShadowRoot(vm, children);
5161
+ // -> addVnodes.
5162
+ var children = renderComponent(vm);
5163
+ vm.children = children;
5164
+ var vmChildren = vm.renderMode === 0
5165
+ /* Light */
5166
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5167
+ hydrateChildrenHook(vmChildren, children);
5168
+ runRenderedCallback(vm);
5169
+ }
5170
+ }
5171
+
4959
5172
  function patchShadowRoot(vm, newCh) {
4960
5173
  var oldCh = vm.children; // caching the new children collection
4961
5174
 
@@ -5032,19 +5245,19 @@ var LWC = (function (exports) {
5032
5245
  });
5033
5246
  rehydrateQueue = []; // reset to a new queue
5034
5247
 
5035
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
5036
- var vm = vms[_i20];
5248
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5249
+ var vm = vms[_i22];
5037
5250
 
5038
5251
  try {
5039
5252
  rehydrate(vm);
5040
5253
  } catch (error) {
5041
- if (_i20 + 1 < _len7) {
5254
+ if (_i22 + 1 < _len7) {
5042
5255
  // pieces of the queue are still pending to be rehydrated, those should have priority
5043
5256
  if (rehydrateQueue.length === 0) {
5044
5257
  addCallbackToNextTick(flushRehydrationQueue);
5045
5258
  }
5046
5259
 
5047
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
5260
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5048
5261
  } // we need to end the measure before throwing.
5049
5262
 
5050
5263
 
@@ -5143,8 +5356,8 @@ var LWC = (function (exports) {
5143
5356
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5144
5357
  // inserted in reserved order.
5145
5358
 
5146
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
5147
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
5359
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
5360
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
5148
5361
  // * when there is an error during the construction phase, and an error
5149
5362
  // boundary picks it, there is a possibility that the VCustomElement
5150
5363
  // is not properly initialized, and therefore is should be ignored.
@@ -5178,8 +5391,8 @@ var LWC = (function (exports) {
5178
5391
 
5179
5392
 
5180
5393
  function recursivelyDisconnectChildren(vnodes) {
5181
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
5182
- var vnode = vnodes[_i22];
5394
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5395
+ var vnode = vnodes[_i24];
5183
5396
 
5184
5397
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5185
5398
  // vnode is a VElement with children
@@ -5203,8 +5416,8 @@ var LWC = (function (exports) {
5203
5416
  renderer = vm.renderer;
5204
5417
  var rootNode = getRenderRoot(vm);
5205
5418
 
5206
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
5207
- var child = children[_i23];
5419
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5420
+ var child = children[_i25];
5208
5421
 
5209
5422
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5210
5423
  renderer.remove(child.elm, rootNode);
@@ -5249,8 +5462,8 @@ var LWC = (function (exports) {
5249
5462
  var oldSlots = vm.cmpSlots;
5250
5463
  var cmpSlots = vm.cmpSlots = create(null);
5251
5464
 
5252
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
5253
- var vnode = children[_i24];
5465
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5466
+ var vnode = children[_i26];
5254
5467
 
5255
5468
  if (isNull(vnode)) {
5256
5469
  continue;
@@ -5280,8 +5493,8 @@ var LWC = (function (exports) {
5280
5493
  return;
5281
5494
  }
5282
5495
 
5283
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
5284
- var key = oldKeys[_i25];
5496
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5497
+ var key = oldKeys[_i27];
5285
5498
 
5286
5499
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5287
5500
  markComponentAsDirty(vm);
@@ -5620,8 +5833,8 @@ var LWC = (function (exports) {
5620
5833
  function connectWireAdapters(vm) {
5621
5834
  var wiredConnecting = vm.context.wiredConnecting;
5622
5835
 
5623
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
5624
- wiredConnecting[_i26]();
5836
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5837
+ wiredConnecting[_i28]();
5625
5838
  }
5626
5839
  }
5627
5840
 
@@ -5629,8 +5842,8 @@ var LWC = (function (exports) {
5629
5842
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5630
5843
  runWithBoundaryProtection(vm, vm, noop, function () {
5631
5844
  // job
5632
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
5633
- wiredDisconnecting[_i27]();
5845
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5846
+ wiredDisconnecting[_i29]();
5634
5847
  }
5635
5848
  }, noop);
5636
5849
  }
@@ -5709,25 +5922,12 @@ var LWC = (function (exports) {
5709
5922
 
5710
5923
  var hooksAreSet = false;
5711
5924
 
5712
- function overrideHooks(hooks) {
5713
- var oldHooks = {};
5714
-
5715
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
5716
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5717
- }
5718
-
5719
- return oldHooks;
5720
- }
5721
-
5722
5925
  function setHooks(hooks) {
5723
5926
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5724
- overrideHooks(hooks);
5725
5927
  hooksAreSet = true;
5928
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5726
5929
  }
5727
-
5728
- function setHooksForTest(hooks) {
5729
- }
5730
- /* version: 2.5.5-canary1 */
5930
+ /* version: 2.5.9 */
5731
5931
 
5732
5932
  /*
5733
5933
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5872,8 +6072,17 @@ var LWC = (function (exports) {
5872
6072
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5873
6073
  }
5874
6074
 
6075
+ var _isHydrating = false;
6076
+
6077
+ function setIsHydrating(v) {
6078
+ _isHydrating = v;
6079
+ }
6080
+
5875
6081
  var renderer = {
5876
6082
  ssr: false,
6083
+ isHydrating: function isHydrating() {
6084
+ return _isHydrating;
6085
+ },
5877
6086
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5878
6087
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5879
6088
  createElement: function createElement(tagName, namespace) {
@@ -5895,6 +6104,10 @@ var LWC = (function (exports) {
5895
6104
  return node.nextSibling;
5896
6105
  },
5897
6106
  attachShadow: function attachShadow(element, options) {
6107
+ if (_isHydrating) {
6108
+ return element.shadowRoot;
6109
+ }
6110
+
5898
6111
  return element.attachShadow(options);
5899
6112
  },
5900
6113
  setText: function setText(node, content) {
@@ -5999,71 +6212,6 @@ var LWC = (function (exports) {
5999
6212
  getCustomElement: getCustomElement,
6000
6213
  HTMLElement: HTMLElementConstructor
6001
6214
  };
6002
- /*
6003
- * Copyright (c) 2018, salesforce.com, inc.
6004
- * All rights reserved.
6005
- * SPDX-License-Identifier: MIT
6006
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6007
- */
6008
-
6009
- /**
6010
- * This function builds a Web Component class from a LWC constructor so it can be
6011
- * registered as a new element via customElements.define() at any given time.
6012
- *
6013
- * @deprecated since version 1.3.11
6014
- *
6015
- * @example
6016
- * ```
6017
- * import { buildCustomElementConstructor } from 'lwc';
6018
- * import Foo from 'ns/foo';
6019
- * const WC = buildCustomElementConstructor(Foo);
6020
- * customElements.define('x-foo', WC);
6021
- * const elm = document.createElement('x-foo');
6022
- * ```
6023
- */
6024
-
6025
- function deprecatedBuildCustomElementConstructor(Ctor) {
6026
-
6027
- return Ctor.CustomElementConstructor;
6028
- }
6029
-
6030
- function buildCustomElementConstructor(Ctor) {
6031
- var def = getComponentInternalDef(Ctor);
6032
- return /*#__PURE__*/function (_def$bridge) {
6033
- _inherits(_class, _def$bridge);
6034
-
6035
- var _super8 = _createSuper(_class);
6036
-
6037
- function _class() {
6038
- var _this6;
6039
-
6040
- _classCallCheck(this, _class);
6041
-
6042
- _this6 = _super8.call(this);
6043
- createVM(_assertThisInitialized(_this6), def, {
6044
- mode: 'open',
6045
- owner: null,
6046
- tagName: _this6.tagName,
6047
- renderer: renderer
6048
- });
6049
- return _this6;
6050
- }
6051
-
6052
- _createClass(_class, [{
6053
- key: "connectedCallback",
6054
- value: function connectedCallback() {
6055
- connectRootElement(this);
6056
- }
6057
- }, {
6058
- key: "disconnectedCallback",
6059
- value: function disconnectedCallback() {
6060
- disconnectRootElement(this);
6061
- }
6062
- }]);
6063
-
6064
- return _class;
6065
- }(def.bridge);
6066
- }
6067
6215
  /*
6068
6216
  * Copyright (c) 2018, salesforce.com, inc.
6069
6217
  * All rights reserved.
@@ -6073,7 +6221,6 @@ var LWC = (function (exports) {
6073
6221
  // TODO [#2472]: Remove this workaround when appropriate.
6074
6222
  // eslint-disable-next-line lwc-internal/no-global-node
6075
6223
 
6076
-
6077
6224
  var _Node$1 = Node;
6078
6225
  var ConnectingSlot = new WeakMap();
6079
6226
  var DisconnectingSlot = new WeakMap();
@@ -6180,6 +6327,138 @@ var LWC = (function (exports) {
6180
6327
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6181
6328
  */
6182
6329
 
6330
+
6331
+ function hydrateComponent(element, Ctor) {
6332
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6333
+
6334
+ if (!isFunction$1(Ctor)) {
6335
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6336
+ }
6337
+
6338
+ if (!isObject(props) || isNull(props)) {
6339
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6340
+ }
6341
+
6342
+ var def = getComponentInternalDef(Ctor);
6343
+
6344
+ try {
6345
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6346
+ // and uses the same algo to create the stylesheets as in SSR.
6347
+ setIsHydrating(true);
6348
+ createVM(element, def, {
6349
+ mode: 'open',
6350
+ owner: null,
6351
+ renderer: renderer,
6352
+ tagName: element.tagName.toLowerCase()
6353
+ });
6354
+
6355
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6356
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6357
+ key = _Object$entries2$_i[0],
6358
+ value = _Object$entries2$_i[1];
6359
+
6360
+ element[key] = value;
6361
+ }
6362
+
6363
+ hydrateRootElement(element); // set it back since now we finished hydration.
6364
+
6365
+ setIsHydrating(false);
6366
+ } catch (e) {
6367
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6368
+ // the client generated DOM.
6369
+
6370
+ /* eslint-disable-next-line no-console */
6371
+ console.error('Recovering from error while hydrating: ', e);
6372
+ setIsHydrating(false);
6373
+ var newElem = createElement(element.tagName, {
6374
+ is: Ctor,
6375
+ mode: 'open'
6376
+ });
6377
+
6378
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6379
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6380
+ _key3 = _Object$entries3$_i[0],
6381
+ _value2 = _Object$entries3$_i[1];
6382
+
6383
+ newElem[_key3] = _value2;
6384
+ }
6385
+
6386
+ element.parentNode.replaceChild(newElem, element);
6387
+ }
6388
+ }
6389
+ /*
6390
+ * Copyright (c) 2018, salesforce.com, inc.
6391
+ * All rights reserved.
6392
+ * SPDX-License-Identifier: MIT
6393
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6394
+ */
6395
+
6396
+ /**
6397
+ * This function builds a Web Component class from a LWC constructor so it can be
6398
+ * registered as a new element via customElements.define() at any given time.
6399
+ *
6400
+ * @deprecated since version 1.3.11
6401
+ *
6402
+ * @example
6403
+ * ```
6404
+ * import { buildCustomElementConstructor } from 'lwc';
6405
+ * import Foo from 'ns/foo';
6406
+ * const WC = buildCustomElementConstructor(Foo);
6407
+ * customElements.define('x-foo', WC);
6408
+ * const elm = document.createElement('x-foo');
6409
+ * ```
6410
+ */
6411
+
6412
+
6413
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6414
+
6415
+ return Ctor.CustomElementConstructor;
6416
+ }
6417
+
6418
+ function buildCustomElementConstructor(Ctor) {
6419
+ var def = getComponentInternalDef(Ctor);
6420
+ return /*#__PURE__*/function (_def$bridge) {
6421
+ _inherits(_class, _def$bridge);
6422
+
6423
+ var _super8 = _createSuper(_class);
6424
+
6425
+ function _class() {
6426
+ var _this6;
6427
+
6428
+ _classCallCheck(this, _class);
6429
+
6430
+ _this6 = _super8.call(this);
6431
+ createVM(_assertThisInitialized(_this6), def, {
6432
+ mode: 'open',
6433
+ owner: null,
6434
+ tagName: _this6.tagName,
6435
+ renderer: renderer
6436
+ });
6437
+ return _this6;
6438
+ }
6439
+
6440
+ _createClass(_class, [{
6441
+ key: "connectedCallback",
6442
+ value: function connectedCallback() {
6443
+ connectRootElement(this);
6444
+ }
6445
+ }, {
6446
+ key: "disconnectedCallback",
6447
+ value: function disconnectedCallback() {
6448
+ disconnectRootElement(this);
6449
+ }
6450
+ }]);
6451
+
6452
+ return _class;
6453
+ }(def.bridge);
6454
+ }
6455
+ /*
6456
+ * Copyright (c) 2018, salesforce.com, inc.
6457
+ * All rights reserved.
6458
+ * SPDX-License-Identifier: MIT
6459
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6460
+ */
6461
+
6183
6462
  /**
6184
6463
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6185
6464
  * This API is subject to change or being removed.
@@ -6278,7 +6557,7 @@ var LWC = (function (exports) {
6278
6557
  });
6279
6558
  freeze(LightningElement);
6280
6559
  seal(LightningElement.prototype);
6281
- /* version: 2.5.5-canary1 */
6560
+ /* version: 2.5.9 */
6282
6561
 
6283
6562
  exports.LightningElement = LightningElement;
6284
6563
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6288,6 +6567,7 @@ var LWC = (function (exports) {
6288
6567
  exports.createElement = createElement;
6289
6568
  exports.getComponentConstructor = getComponentConstructor;
6290
6569
  exports.getComponentDef = getComponentDef;
6570
+ exports.hydrateComponent = hydrateComponent;
6291
6571
  exports.isComponentConstructor = isComponentConstructor;
6292
6572
  exports.isNodeFromTemplate = isNodeFromTemplate;
6293
6573
  exports.readonly = readonly;
@@ -6299,7 +6579,6 @@ var LWC = (function (exports) {
6299
6579
  exports.setFeatureFlag = setFeatureFlag;
6300
6580
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6301
6581
  exports.setHooks = setHooks;
6302
- exports.setHooksForTest = setHooksForTest;
6303
6582
  exports.swapComponent = swapComponent;
6304
6583
  exports.swapStyle = swapStyle;
6305
6584
  exports.swapTemplate = swapTemplate;
@@ -6311,4 +6590,4 @@ var LWC = (function (exports) {
6311
6590
 
6312
6591
  return exports;
6313
6592
 
6314
- }({}));
6593
+ })({});