lwc 2.5.7 → 2.5.8

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 +490 -68
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +490 -67
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +306 -60
  5. package/dist/engine-dom/iife/es5/engine-dom.js +566 -129
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +363 -113
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +490 -67
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +306 -60
  11. package/dist/engine-dom/umd/es5/engine-dom.js +566 -129
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +363 -113
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +361 -11
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +361 -11
  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
@@ -10,8 +10,6 @@
10
10
 
11
11
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
12
12
 
13
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
14
-
15
13
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
16
14
 
17
15
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -40,23 +38,25 @@
40
38
 
41
39
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
42
40
 
43
- 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"); } }
44
42
 
45
- 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); } }
46
44
 
47
- 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; }
48
46
 
49
- 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."); }
50
50
 
51
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; }
52
52
 
53
53
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
54
54
 
55
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
55
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
56
56
 
57
- 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); } }
57
+ 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); }
58
58
 
59
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
59
+ 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; }
60
60
 
61
61
  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); }
62
62
 
@@ -123,6 +123,7 @@
123
123
  setPrototypeOf = Object.setPrototypeOf;
124
124
  var isArray$1 = Array.isArray;
125
125
  var _Array$prototype = Array.prototype,
126
+ ArrayFilter = _Array$prototype.filter,
126
127
  ArrayIndexOf = _Array$prototype.indexOf,
127
128
  ArrayJoin = _Array$prototype.join,
128
129
  ArrayMap$1 = _Array$prototype.map,
@@ -350,7 +351,7 @@
350
351
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
351
352
  return attributeName;
352
353
  }
353
- /** version: 2.5.7 */
354
+ /** version: 2.5.8 */
354
355
 
355
356
  /*
356
357
  * Copyright (c) 2018, salesforce.com, inc.
@@ -530,7 +531,7 @@
530
531
  setFeatureFlag(name, value);
531
532
  }
532
533
  }
533
- /** version: 2.5.7 */
534
+ /** version: 2.5.8 */
534
535
 
535
536
  /* proxy-compat-disable */
536
537
 
@@ -582,6 +583,42 @@
582
583
  }
583
584
 
584
585
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
586
+ } // Borrowed from Vue template compiler.
587
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
588
+
589
+
590
+ var DECLARATION_DELIMITER = /;(?![^(]*\))/g;
591
+ var PROPERTY_DELIMITER = /:(.+)/;
592
+
593
+ function parseStyleText(cssText) {
594
+ var styleMap = {};
595
+ var declarations = cssText.split(DECLARATION_DELIMITER);
596
+
597
+ var _iterator = _createForOfIteratorHelper(declarations),
598
+ _step;
599
+
600
+ try {
601
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
602
+ var declaration = _step.value;
603
+
604
+ if (declaration) {
605
+ var _declaration$split = declaration.split(PROPERTY_DELIMITER),
606
+ _declaration$split2 = _slicedToArray(_declaration$split, 2),
607
+ prop = _declaration$split2[0],
608
+ value = _declaration$split2[1];
609
+
610
+ if (prop !== undefined && value !== undefined) {
611
+ styleMap[prop.trim()] = value.trim();
612
+ }
613
+ }
614
+ }
615
+ } catch (err) {
616
+ _iterator.e(err);
617
+ } finally {
618
+ _iterator.f();
619
+ }
620
+
621
+ return styleMap;
585
622
  }
586
623
  /*
587
624
  * Copyright (c) 2019, salesforce.com, inc.
@@ -770,8 +807,8 @@
770
807
  */
771
808
 
772
809
 
773
- function logError(message, vm) {
774
- var msg = "[LWC error]: ".concat(message);
810
+ function log(method, message, vm) {
811
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
775
812
 
776
813
  if (!isUndefined$1(vm)) {
777
814
  msg = "".concat(msg, "\n").concat(getComponentStack(vm));
@@ -779,7 +816,7 @@
779
816
 
780
817
  if (process.env.NODE_ENV === 'test') {
781
818
  /* eslint-disable-next-line no-console */
782
- console.error(msg);
819
+ console[method](msg);
783
820
  return;
784
821
  }
785
822
 
@@ -787,9 +824,17 @@
787
824
  throw new Error(msg);
788
825
  } catch (e) {
789
826
  /* eslint-disable-next-line no-console */
790
- console.error(e);
827
+ console[method](e);
791
828
  }
792
829
  }
830
+
831
+ function logError(message, vm) {
832
+ log('error', message, vm);
833
+ }
834
+
835
+ function logWarn(message, vm) {
836
+ log('warn', message, vm);
837
+ }
793
838
  /*
794
839
  * Copyright (c) 2018, salesforce.com, inc.
795
840
  * All rights reserved.
@@ -3939,12 +3984,12 @@
3939
3984
  function flattenStylesheets(stylesheets) {
3940
3985
  var list = [];
3941
3986
 
3942
- var _iterator = _createForOfIteratorHelper(stylesheets),
3943
- _step;
3987
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
3988
+ _step2;
3944
3989
 
3945
3990
  try {
3946
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3947
- var stylesheet = _step.value;
3991
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3992
+ var stylesheet = _step2.value;
3948
3993
 
3949
3994
  if (!Array.isArray(stylesheet)) {
3950
3995
  list.push(stylesheet);
@@ -3953,9 +3998,9 @@
3953
3998
  }
3954
3999
  }
3955
4000
  } catch (err) {
3956
- _iterator.e(err);
4001
+ _iterator2.e(err);
3957
4002
  } finally {
3958
- _iterator.f();
4003
+ _iterator2.f();
3959
4004
  }
3960
4005
 
3961
4006
  return list;
@@ -4514,6 +4559,17 @@
4514
4559
  modComputedStyle.create(vnode);
4515
4560
  }
4516
4561
 
4562
+ function hydrateElmHook(vnode) {
4563
+ modEvents.create(vnode); // Attrs are already on the element.
4564
+ // modAttrs.create(vnode);
4565
+
4566
+ modProps.create(vnode); // Already set.
4567
+ // modStaticClassName.create(vnode);
4568
+ // modStaticStyle.create(vnode);
4569
+ // modComputedClassName.create(vnode);
4570
+ // modComputedStyle.create(vnode);
4571
+ }
4572
+
4517
4573
  function fallbackElmHook(elm, vnode) {
4518
4574
  var owner = vnode.owner;
4519
4575
  setScopeTokenClassIfNecessary(elm, owner);
@@ -4663,6 +4719,174 @@
4663
4719
  }
4664
4720
  }
4665
4721
 
4722
+ function isElementNode(node) {
4723
+ // eslint-disable-next-line lwc-internal/no-global-node
4724
+ return node.nodeType === Node.ELEMENT_NODE;
4725
+ }
4726
+
4727
+ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4728
+ var _vnode$data$attrs = vnode.data.attrs,
4729
+ attrs = _vnode$data$attrs === void 0 ? {} : _vnode$data$attrs,
4730
+ renderer = vnode.owner.renderer;
4731
+ var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4732
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4733
+
4734
+ for (var _i14 = 0, _Object$entries = Object.entries(attrs); _i14 < _Object$entries.length; _i14++) {
4735
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i14], 2),
4736
+ attrName = _Object$entries$_i[0],
4737
+ attrValue = _Object$entries$_i[1];
4738
+
4739
+ var elmAttrValue = renderer.getAttribute(elm, attrName);
4740
+
4741
+ if (attrValue !== elmAttrValue) {
4742
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
4743
+ nodesAreCompatible = false;
4744
+ }
4745
+ }
4746
+
4747
+ return nodesAreCompatible;
4748
+ }
4749
+
4750
+ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4751
+ var _vnode$data = vnode.data,
4752
+ className = _vnode$data.className,
4753
+ classMap = _vnode$data.classMap,
4754
+ renderer = vnode.owner.renderer;
4755
+ var nodesAreCompatible = true;
4756
+ var vnodeClassName;
4757
+
4758
+ if (!isUndefined$1(className) && className !== elm.className) {
4759
+ // className is used when class is bound to an expr.
4760
+ nodesAreCompatible = false;
4761
+ vnodeClassName = className;
4762
+ } else if (!isUndefined$1(classMap)) {
4763
+ // classMap is used when class is set to static value.
4764
+ var classList = renderer.getClassList(elm);
4765
+ var computedClassName = ''; // all classes from the vnode should be in the element.classList
4766
+
4767
+ for (var name in classMap) {
4768
+ computedClassName += ' ' + name;
4769
+
4770
+ if (!classList.contains(name)) {
4771
+ nodesAreCompatible = false;
4772
+ }
4773
+ }
4774
+
4775
+ vnodeClassName = computedClassName.trim();
4776
+
4777
+ if (classList.length > keys(classMap).length) {
4778
+ nodesAreCompatible = false;
4779
+ }
4780
+ }
4781
+
4782
+ if (!nodesAreCompatible) {
4783
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(elm.className, "\""), vnode.owner);
4784
+ }
4785
+
4786
+ return nodesAreCompatible;
4787
+ }
4788
+
4789
+ function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4790
+ var _vnode$data2 = vnode.data,
4791
+ style = _vnode$data2.style,
4792
+ styleDecls = _vnode$data2.styleDecls,
4793
+ renderer = vnode.owner.renderer;
4794
+ var elmStyle = renderer.getAttribute(elm, 'style') || '';
4795
+ var vnodeStyle;
4796
+ var nodesAreCompatible = true;
4797
+
4798
+ if (!isUndefined$1(style) && style !== elmStyle) {
4799
+ nodesAreCompatible = false;
4800
+ vnodeStyle = style;
4801
+ } else if (!isUndefined$1(styleDecls)) {
4802
+ var parsedVnodeStyle = parseStyleText(elmStyle);
4803
+ var expectedStyle = []; // styleMap is used when style is set to static value.
4804
+
4805
+ for (var _i15 = 0, n = styleDecls.length; _i15 < n; _i15++) {
4806
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i15], 3),
4807
+ prop = _styleDecls$_i2[0],
4808
+ value = _styleDecls$_i2[1],
4809
+ important = _styleDecls$_i2[2];
4810
+
4811
+ expectedStyle.push("".concat(prop, ": ").concat(value + (important ? ' important!' : '')));
4812
+ var parsedPropValue = parsedVnodeStyle[prop];
4813
+
4814
+ if (isUndefined$1(parsedPropValue)) {
4815
+ nodesAreCompatible = false;
4816
+ } else if (!parsedPropValue.startsWith(value)) {
4817
+ nodesAreCompatible = false;
4818
+ } else if (important && !parsedPropValue.endsWith('!important')) {
4819
+ nodesAreCompatible = false;
4820
+ }
4821
+ }
4822
+
4823
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
4824
+ nodesAreCompatible = false;
4825
+ }
4826
+
4827
+ vnodeStyle = ArrayJoin.call(expectedStyle, ';');
4828
+ }
4829
+
4830
+ if (!nodesAreCompatible) {
4831
+ // style is used when class is bound to an expr.
4832
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
4833
+ }
4834
+
4835
+ return nodesAreCompatible;
4836
+ }
4837
+
4838
+ function throwHydrationError() {
4839
+ assert.fail('Server rendered elements do not match client side generated elements');
4840
+ }
4841
+
4842
+ function hydrateChildrenHook(elmChildren, children, vm) {
4843
+ var _a, _b;
4844
+
4845
+ if (process.env.NODE_ENV !== 'production') {
4846
+ var filteredVNodes = ArrayFilter.call(children, function (vnode) {
4847
+ return !!vnode;
4848
+ });
4849
+
4850
+ if (elmChildren.length !== filteredVNodes.length) {
4851
+ logError("Hydration mismatch: incorrect number of rendered nodes, expected ".concat(filteredVNodes.length, " but found ").concat(elmChildren.length, "."), vm);
4852
+ throwHydrationError();
4853
+ }
4854
+ }
4855
+
4856
+ var elmCurrentChildIdx = 0;
4857
+
4858
+ for (var j = 0, n = children.length; j < n; j++) {
4859
+ var ch = children[j];
4860
+
4861
+ if (ch != null) {
4862
+ var childNode = elmChildren[elmCurrentChildIdx];
4863
+
4864
+ if (process.env.NODE_ENV !== 'production') {
4865
+ // VComments and VTexts validation is handled in their hooks
4866
+ if (isElementNode(childNode)) {
4867
+ if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
4868
+ logError("Hydration mismatch: expecting element with tag \"".concat((_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase(), "\" but found \"").concat(childNode.tagName.toLowerCase(), "\"."), vm);
4869
+ throwHydrationError();
4870
+ } // Note: props are not yet set
4871
+
4872
+
4873
+ var hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
4874
+ var hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
4875
+ var hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
4876
+ var isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4877
+
4878
+ if (!isVNodeAndElementCompatible) {
4879
+ throwHydrationError();
4880
+ }
4881
+ }
4882
+ }
4883
+
4884
+ ch.hook.hydrate(ch, childNode);
4885
+ elmCurrentChildIdx++;
4886
+ }
4887
+ }
4888
+ }
4889
+
4666
4890
  function updateCustomElmHook(oldVnode, vnode) {
4667
4891
  // Attrs need to be applied to element before props
4668
4892
  // IE11 will wipe out value on radio inputs if value
@@ -4770,7 +4994,26 @@
4770
4994
  update: updateNodeHook,
4771
4995
  insert: insertNodeHook,
4772
4996
  move: insertNodeHook,
4773
- remove: removeNodeHook
4997
+ remove: removeNodeHook,
4998
+ hydrate: function hydrate(vNode, node) {
4999
+ var _a;
5000
+
5001
+ if (process.env.NODE_ENV !== 'production') {
5002
+ // eslint-disable-next-line lwc-internal/no-global-node
5003
+ if (node.nodeType !== Node.TEXT_NODE) {
5004
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5005
+ assert.fail('Hydration mismatch: incorrect node type received.');
5006
+ }
5007
+
5008
+ if (node.nodeValue !== vNode.text) {
5009
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
5010
+ }
5011
+ } // always set the text value to the one from the vnode.
5012
+
5013
+
5014
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5015
+ vNode.elm = node;
5016
+ }
4774
5017
  };
4775
5018
  var CommentHook = {
4776
5019
  create: function create(vnode) {
@@ -4784,7 +5027,26 @@
4784
5027
  update: updateNodeHook,
4785
5028
  insert: insertNodeHook,
4786
5029
  move: insertNodeHook,
4787
- remove: removeNodeHook
5030
+ remove: removeNodeHook,
5031
+ hydrate: function hydrate(vNode, node) {
5032
+ var _a;
5033
+
5034
+ if (process.env.NODE_ENV !== 'production') {
5035
+ // eslint-disable-next-line lwc-internal/no-global-node
5036
+ if (node.nodeType !== Node.COMMENT_NODE) {
5037
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5038
+ assert.fail('Hydration mismatch: incorrect node type received.');
5039
+ }
5040
+
5041
+ if (node.nodeValue !== vNode.text) {
5042
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
5043
+ }
5044
+ } // always set the text value to the one from the vnode.
5045
+
5046
+
5047
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5048
+ vNode.elm = node;
5049
+ }
4788
5050
  }; // insert is called after update, which is used somewhere else (via a module)
4789
5051
  // to mark the vm as inserted, that means we cannot use update as the main channel
4790
5052
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -4818,6 +5080,34 @@
4818
5080
  remove: function remove(vnode, parentNode) {
4819
5081
  removeNodeHook(vnode, parentNode);
4820
5082
  removeElmHook(vnode);
5083
+ },
5084
+ hydrate: function hydrate(vnode, node) {
5085
+ var elm = node;
5086
+ vnode.elm = elm;
5087
+ var context = vnode.data.context;
5088
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5089
+ /* manual */
5090
+ );
5091
+
5092
+ if (isDomManual) {
5093
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5094
+ // remove the innerHTML from props so it reuses the existing dom elements.
5095
+ var props = vnode.data.props;
5096
+
5097
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5098
+ if (elm.innerHTML === props.innerHTML) {
5099
+ delete props.innerHTML;
5100
+ } else {
5101
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5102
+ }
5103
+ }
5104
+ }
5105
+
5106
+ hydrateElmHook(vnode);
5107
+
5108
+ if (!isDomManual) {
5109
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
5110
+ }
4821
5111
  }
4822
5112
  };
4823
5113
  var CustomElementHook = {
@@ -4905,6 +5195,42 @@
4905
5195
  // will take care of disconnecting any child VM attached to its shadow as well.
4906
5196
  removeVM(vm);
4907
5197
  }
5198
+ },
5199
+ hydrate: function hydrate(vnode, elm) {
5200
+ // the element is created, but the vm is not
5201
+ var sel = vnode.sel,
5202
+ mode = vnode.mode,
5203
+ ctor = vnode.ctor,
5204
+ owner = vnode.owner;
5205
+ var def = getComponentInternalDef(ctor);
5206
+ createVM(elm, def, {
5207
+ mode: mode,
5208
+ owner: owner,
5209
+ tagName: sel,
5210
+ renderer: owner.renderer
5211
+ });
5212
+ vnode.elm = elm;
5213
+ var vm = getAssociatedVM(elm);
5214
+ allocateChildrenHook(vnode, vm);
5215
+ hydrateElmHook(vnode); // Insert hook section:
5216
+
5217
+ if (process.env.NODE_ENV !== 'production') {
5218
+ assert.isTrue(vm.state === 0
5219
+ /* created */
5220
+ , "".concat(vm, " cannot be recycled."));
5221
+ }
5222
+
5223
+ runConnectedCallback(vm);
5224
+
5225
+ if (vm.renderMode !== 0
5226
+ /* Light */
5227
+ ) {
5228
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5229
+ // Note: for Light DOM, this is handled while hydrating the VM
5230
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
5231
+ }
5232
+
5233
+ hydrateVM(vm);
4908
5234
  }
4909
5235
  };
4910
5236
 
@@ -5489,8 +5815,8 @@
5489
5815
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5490
5816
  var content = [];
5491
5817
 
5492
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
5493
- var stylesheet = stylesheets[_i14];
5818
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5819
+ var stylesheet = stylesheets[_i16];
5494
5820
 
5495
5821
  if (isArray$1(stylesheet)) {
5496
5822
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -5566,10 +5892,13 @@
5566
5892
  && shadowMode === 1
5567
5893
  /* Synthetic */
5568
5894
  ) {
5569
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
5570
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
5895
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5896
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
5571
5897
  }
5572
- } else if (renderer.ssr) {
5898
+ } else if (renderer.ssr || renderer.isHydrating) {
5899
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5900
+ // This works in the client, because the stylesheets are created, and cached in the VM
5901
+ // the first time the VM renders.
5573
5902
  // native shadow or light DOM, SSR
5574
5903
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5575
5904
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -5578,12 +5907,12 @@
5578
5907
  var root = getNearestNativeShadowComponent(vm);
5579
5908
  var isGlobal = isNull(root);
5580
5909
 
5581
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5910
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
5582
5911
  if (isGlobal) {
5583
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
5912
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
5584
5913
  } else {
5585
5914
  // local level
5586
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
5915
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
5587
5916
  }
5588
5917
  }
5589
5918
  }
@@ -5860,8 +6189,8 @@
5860
6189
  var stylesheets = template.stylesheets;
5861
6190
 
5862
6191
  if (!isUndefined$1(stylesheets)) {
5863
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5864
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
6192
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6193
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
5865
6194
  return true;
5866
6195
  }
5867
6196
  }
@@ -6091,8 +6420,8 @@
6091
6420
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6092
6421
  }
6093
6422
 
6094
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
6095
- var hookName = hooks[_i18];
6423
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6424
+ var hookName = hooks[_i20];
6096
6425
 
6097
6426
  if (hookName in service) {
6098
6427
  var l = Services[hookName];
@@ -6115,8 +6444,8 @@
6115
6444
  def = vm.def,
6116
6445
  context = vm.context;
6117
6446
 
6118
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
6119
- cbs[_i19].call(undefined, component, {}, def, context);
6447
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
6448
+ cbs[_i21].call(undefined, component, {}, def, context);
6120
6449
  }
6121
6450
  }
6122
6451
  /*
@@ -6169,6 +6498,12 @@
6169
6498
  , vm);
6170
6499
  }
6171
6500
 
6501
+ function hydrateRootElement(elm) {
6502
+ var vm = getAssociatedVM(elm);
6503
+ runConnectedCallback(vm);
6504
+ hydrateVM(vm);
6505
+ }
6506
+
6172
6507
  function disconnectRootElement(elm) {
6173
6508
  var vm = getAssociatedVM(elm);
6174
6509
  resetComponentStateWhenRemoved(vm);
@@ -6176,6 +6511,10 @@
6176
6511
 
6177
6512
  function appendVM(vm) {
6178
6513
  rehydrate(vm);
6514
+ }
6515
+
6516
+ function hydrateVM(vm) {
6517
+ hydrate(vm);
6179
6518
  } // just in case the component comes back, with this we guarantee re-rendering it
6180
6519
  // while preventing any attempt to rehydration until after reinsertion.
6181
6520
 
@@ -6399,6 +6738,22 @@
6399
6738
  }
6400
6739
  }
6401
6740
 
6741
+ function hydrate(vm) {
6742
+ if (isTrue(vm.isDirty)) {
6743
+ // manually diffing/patching here.
6744
+ // This routine is:
6745
+ // patchShadowRoot(vm, children);
6746
+ // -> addVnodes.
6747
+ var children = renderComponent(vm);
6748
+ vm.children = children;
6749
+ var vmChildren = vm.renderMode === 0
6750
+ /* Light */
6751
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
6752
+ hydrateChildrenHook(vmChildren, children, vm);
6753
+ runRenderedCallback(vm);
6754
+ }
6755
+ }
6756
+
6402
6757
  function patchShadowRoot(vm, newCh) {
6403
6758
  var oldCh = vm.children; // caching the new children collection
6404
6759
 
@@ -6479,19 +6834,19 @@
6479
6834
  });
6480
6835
  rehydrateQueue = []; // reset to a new queue
6481
6836
 
6482
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
6483
- var vm = vms[_i20];
6837
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
6838
+ var vm = vms[_i22];
6484
6839
 
6485
6840
  try {
6486
6841
  rehydrate(vm);
6487
6842
  } catch (error) {
6488
- if (_i20 + 1 < _len7) {
6843
+ if (_i22 + 1 < _len7) {
6489
6844
  // pieces of the queue are still pending to be rehydrated, those should have priority
6490
6845
  if (rehydrateQueue.length === 0) {
6491
6846
  addCallbackToNextTick(flushRehydrationQueue);
6492
6847
  }
6493
6848
 
6494
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
6849
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
6495
6850
  } // we need to end the measure before throwing.
6496
6851
 
6497
6852
 
@@ -6595,8 +6950,8 @@
6595
6950
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
6596
6951
  // inserted in reserved order.
6597
6952
 
6598
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
6599
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
6953
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
6954
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
6600
6955
  // * when there is an error during the construction phase, and an error
6601
6956
  // boundary picks it, there is a possibility that the VCustomElement
6602
6957
  // is not properly initialized, and therefore is should be ignored.
@@ -6630,8 +6985,8 @@
6630
6985
 
6631
6986
 
6632
6987
  function recursivelyDisconnectChildren(vnodes) {
6633
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
6634
- var vnode = vnodes[_i22];
6988
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
6989
+ var vnode = vnodes[_i24];
6635
6990
 
6636
6991
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
6637
6992
  // vnode is a VElement with children
@@ -6655,8 +7010,8 @@
6655
7010
  renderer = vm.renderer;
6656
7011
  var rootNode = getRenderRoot(vm);
6657
7012
 
6658
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
6659
- var child = children[_i23];
7013
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
7014
+ var child = children[_i25];
6660
7015
 
6661
7016
  if (!isNull(child) && !isUndefined$1(child.elm)) {
6662
7017
  renderer.remove(child.elm, rootNode);
@@ -6701,8 +7056,8 @@
6701
7056
  var oldSlots = vm.cmpSlots;
6702
7057
  var cmpSlots = vm.cmpSlots = create(null);
6703
7058
 
6704
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
6705
- var vnode = children[_i24];
7059
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
7060
+ var vnode = children[_i26];
6706
7061
 
6707
7062
  if (isNull(vnode)) {
6708
7063
  continue;
@@ -6732,8 +7087,8 @@
6732
7087
  return;
6733
7088
  }
6734
7089
 
6735
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
6736
- var key = oldKeys[_i25];
7090
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
7091
+ var key = oldKeys[_i27];
6737
7092
 
6738
7093
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
6739
7094
  markComponentAsDirty(vm);
@@ -7096,8 +7451,8 @@
7096
7451
  function connectWireAdapters(vm) {
7097
7452
  var wiredConnecting = vm.context.wiredConnecting;
7098
7453
 
7099
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
7100
- wiredConnecting[_i26]();
7454
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
7455
+ wiredConnecting[_i28]();
7101
7456
  }
7102
7457
  }
7103
7458
 
@@ -7105,8 +7460,8 @@
7105
7460
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7106
7461
  runWithBoundaryProtection(vm, vm, noop, function () {
7107
7462
  // job
7108
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
7109
- wiredDisconnecting[_i27]();
7463
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
7464
+ wiredDisconnecting[_i29]();
7110
7465
  }
7111
7466
  }, noop);
7112
7467
  }
@@ -7196,7 +7551,7 @@
7196
7551
  hooksAreSet = true;
7197
7552
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7198
7553
  }
7199
- /* version: 2.5.7 */
7554
+ /* version: 2.5.8 */
7200
7555
 
7201
7556
  /*
7202
7557
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7211,8 +7566,8 @@
7211
7566
  if (process.env.NODE_ENV === 'development') {
7212
7567
  // @ts-ignore
7213
7568
  window.__lwcResetGlobalStylesheets = function () {
7214
- for (var _i28 = 0, _Object$keys = Object.keys(globalStylesheets); _i28 < _Object$keys.length; _i28++) {
7215
- var key = _Object$keys[_i28];
7569
+ for (var _i30 = 0, _Object$keys = Object.keys(globalStylesheets); _i30 < _Object$keys.length; _i30++) {
7570
+ var key = _Object$keys[_i30];
7216
7571
  delete globalStylesheets[key];
7217
7572
  }
7218
7573
  };
@@ -7351,8 +7706,19 @@
7351
7706
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7352
7707
  }
7353
7708
 
7709
+ var isHydrating = false;
7710
+
7711
+ function setIsHydrating(v) {
7712
+ isHydrating = v;
7713
+ }
7714
+
7354
7715
  var renderer = {
7355
7716
  ssr: false,
7717
+
7718
+ get isHydrating() {
7719
+ return isHydrating;
7720
+ },
7721
+
7356
7722
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7357
7723
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7358
7724
  createElement: function createElement(tagName, namespace) {
@@ -7374,6 +7740,10 @@
7374
7740
  return node.nextSibling;
7375
7741
  },
7376
7742
  attachShadow: function attachShadow(element, options) {
7743
+ if (isHydrating) {
7744
+ return element.shadowRoot;
7745
+ }
7746
+
7377
7747
  return element.attachShadow(options);
7378
7748
  },
7379
7749
  setText: function setText(node, content) {
@@ -7484,75 +7854,6 @@
7484
7854
  getCustomElement: getCustomElement,
7485
7855
  HTMLElement: HTMLElementConstructor
7486
7856
  };
7487
- /*
7488
- * Copyright (c) 2018, salesforce.com, inc.
7489
- * All rights reserved.
7490
- * SPDX-License-Identifier: MIT
7491
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7492
- */
7493
-
7494
- /**
7495
- * This function builds a Web Component class from a LWC constructor so it can be
7496
- * registered as a new element via customElements.define() at any given time.
7497
- *
7498
- * @deprecated since version 1.3.11
7499
- *
7500
- * @example
7501
- * ```
7502
- * import { buildCustomElementConstructor } from 'lwc';
7503
- * import Foo from 'ns/foo';
7504
- * const WC = buildCustomElementConstructor(Foo);
7505
- * customElements.define('x-foo', WC);
7506
- * const elm = document.createElement('x-foo');
7507
- * ```
7508
- */
7509
-
7510
- function deprecatedBuildCustomElementConstructor(Ctor) {
7511
- if (process.env.NODE_ENV !== 'production') {
7512
- /* eslint-disable-next-line no-console */
7513
- console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + "Use \"".concat(Ctor.name, ".CustomElementConstructor\" static property of the component constructor to access the corresponding custom element constructor instead."));
7514
- }
7515
-
7516
- return Ctor.CustomElementConstructor;
7517
- }
7518
-
7519
- function buildCustomElementConstructor(Ctor) {
7520
- var def = getComponentInternalDef(Ctor);
7521
- return /*#__PURE__*/function (_def$bridge) {
7522
- _inherits(_class, _def$bridge);
7523
-
7524
- var _super8 = _createSuper(_class);
7525
-
7526
- function _class() {
7527
- var _this6;
7528
-
7529
- _classCallCheck(this, _class);
7530
-
7531
- _this6 = _super8.call(this);
7532
- createVM(_assertThisInitialized(_this6), def, {
7533
- mode: 'open',
7534
- owner: null,
7535
- tagName: _this6.tagName,
7536
- renderer: renderer
7537
- });
7538
- return _this6;
7539
- }
7540
-
7541
- _createClass(_class, [{
7542
- key: "connectedCallback",
7543
- value: function connectedCallback() {
7544
- connectRootElement(this);
7545
- }
7546
- }, {
7547
- key: "disconnectedCallback",
7548
- value: function disconnectedCallback() {
7549
- disconnectRootElement(this);
7550
- }
7551
- }]);
7552
-
7553
- return _class;
7554
- }(def.bridge);
7555
- }
7556
7857
  /*
7557
7858
  * Copyright (c) 2018, salesforce.com, inc.
7558
7859
  * All rights reserved.
@@ -7562,7 +7863,6 @@
7562
7863
  // TODO [#2472]: Remove this workaround when appropriate.
7563
7864
  // eslint-disable-next-line lwc-internal/no-global-node
7564
7865
 
7565
-
7566
7866
  var _Node$1 = Node;
7567
7867
  var ConnectingSlot = new WeakMap();
7568
7868
  var DisconnectingSlot = new WeakMap();
@@ -7672,6 +7972,142 @@
7672
7972
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7673
7973
  */
7674
7974
 
7975
+
7976
+ function hydrateComponent(element, Ctor) {
7977
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7978
+
7979
+ if (!isFunction$1(Ctor)) {
7980
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
7981
+ }
7982
+
7983
+ if (!isObject(props) || isNull(props)) {
7984
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
7985
+ }
7986
+
7987
+ var def = getComponentInternalDef(Ctor);
7988
+
7989
+ try {
7990
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7991
+ // and uses the same algo to create the stylesheets as in SSR.
7992
+ setIsHydrating(true);
7993
+ createVM(element, def, {
7994
+ mode: 'open',
7995
+ owner: null,
7996
+ renderer: renderer,
7997
+ tagName: element.tagName.toLowerCase()
7998
+ });
7999
+
8000
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
8001
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
8002
+ key = _Object$entries2$_i[0],
8003
+ value = _Object$entries2$_i[1];
8004
+
8005
+ element[key] = value;
8006
+ }
8007
+
8008
+ hydrateRootElement(element); // set it back since now we finished hydration.
8009
+
8010
+ setIsHydrating(false);
8011
+ } catch (e) {
8012
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8013
+ // the client generated DOM.
8014
+
8015
+ /* eslint-disable-next-line no-console */
8016
+ console.error('Recovering from error while hydrating: ', e);
8017
+ setIsHydrating(false);
8018
+ var newElem = createElement(element.tagName, {
8019
+ is: Ctor,
8020
+ mode: 'open'
8021
+ });
8022
+
8023
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
8024
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
8025
+ _key3 = _Object$entries3$_i[0],
8026
+ _value2 = _Object$entries3$_i[1];
8027
+
8028
+ newElem[_key3] = _value2;
8029
+ }
8030
+
8031
+ element.parentNode.replaceChild(newElem, element);
8032
+ }
8033
+ }
8034
+ /*
8035
+ * Copyright (c) 2018, salesforce.com, inc.
8036
+ * All rights reserved.
8037
+ * SPDX-License-Identifier: MIT
8038
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8039
+ */
8040
+
8041
+ /**
8042
+ * This function builds a Web Component class from a LWC constructor so it can be
8043
+ * registered as a new element via customElements.define() at any given time.
8044
+ *
8045
+ * @deprecated since version 1.3.11
8046
+ *
8047
+ * @example
8048
+ * ```
8049
+ * import { buildCustomElementConstructor } from 'lwc';
8050
+ * import Foo from 'ns/foo';
8051
+ * const WC = buildCustomElementConstructor(Foo);
8052
+ * customElements.define('x-foo', WC);
8053
+ * const elm = document.createElement('x-foo');
8054
+ * ```
8055
+ */
8056
+
8057
+
8058
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8059
+ if (process.env.NODE_ENV !== 'production') {
8060
+ /* eslint-disable-next-line no-console */
8061
+ console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + "Use \"".concat(Ctor.name, ".CustomElementConstructor\" static property of the component constructor to access the corresponding custom element constructor instead."));
8062
+ }
8063
+
8064
+ return Ctor.CustomElementConstructor;
8065
+ }
8066
+
8067
+ function buildCustomElementConstructor(Ctor) {
8068
+ var def = getComponentInternalDef(Ctor);
8069
+ return /*#__PURE__*/function (_def$bridge) {
8070
+ _inherits(_class, _def$bridge);
8071
+
8072
+ var _super8 = _createSuper(_class);
8073
+
8074
+ function _class() {
8075
+ var _this6;
8076
+
8077
+ _classCallCheck(this, _class);
8078
+
8079
+ _this6 = _super8.call(this);
8080
+ createVM(_assertThisInitialized(_this6), def, {
8081
+ mode: 'open',
8082
+ owner: null,
8083
+ tagName: _this6.tagName,
8084
+ renderer: renderer
8085
+ });
8086
+ return _this6;
8087
+ }
8088
+
8089
+ _createClass(_class, [{
8090
+ key: "connectedCallback",
8091
+ value: function connectedCallback() {
8092
+ connectRootElement(this);
8093
+ }
8094
+ }, {
8095
+ key: "disconnectedCallback",
8096
+ value: function disconnectedCallback() {
8097
+ disconnectRootElement(this);
8098
+ }
8099
+ }]);
8100
+
8101
+ return _class;
8102
+ }(def.bridge);
8103
+ }
8104
+ /*
8105
+ * Copyright (c) 2018, salesforce.com, inc.
8106
+ * All rights reserved.
8107
+ * SPDX-License-Identifier: MIT
8108
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8109
+ */
8110
+
7675
8111
  /**
7676
8112
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7677
8113
  * This API is subject to change or being removed.
@@ -7770,7 +8206,7 @@
7770
8206
  });
7771
8207
  freeze(LightningElement);
7772
8208
  seal(LightningElement.prototype);
7773
- /* version: 2.5.7 */
8209
+ /* version: 2.5.8 */
7774
8210
 
7775
8211
  exports.LightningElement = LightningElement;
7776
8212
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7780,6 +8216,7 @@
7780
8216
  exports.createElement = createElement;
7781
8217
  exports.getComponentConstructor = getComponentConstructor;
7782
8218
  exports.getComponentDef = getComponentDef;
8219
+ exports.hydrateComponent = hydrateComponent;
7783
8220
  exports.isComponentConstructor = isComponentConstructor;
7784
8221
  exports.isNodeFromTemplate = isNodeFromTemplate;
7785
8222
  exports.readonly = readonly;