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
@@ -38,23 +38,23 @@
38
38
 
39
39
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
40
40
 
41
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
41
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
42
42
 
43
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
44
44
 
45
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
46
46
 
47
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
47
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
48
+
49
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
48
50
 
49
51
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
50
52
 
51
53
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
52
54
 
53
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
54
-
55
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
55
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
56
56
 
57
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
57
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
58
58
 
59
59
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
60
60
 
@@ -344,7 +344,7 @@
344
344
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
345
345
  return attributeName;
346
346
  }
347
- /** version: 2.5.7 */
347
+ /** version: 2.5.8 */
348
348
 
349
349
  /*
350
350
  * Copyright (c) 2018, salesforce.com, inc.
@@ -516,7 +516,7 @@
516
516
 
517
517
  function setFeatureFlagForTest(name, value) {
518
518
  }
519
- /** version: 2.5.7 */
519
+ /** version: 2.5.8 */
520
520
 
521
521
  /* proxy-compat-disable */
522
522
 
@@ -558,7 +558,7 @@
558
558
  }
559
559
 
560
560
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
561
- }
561
+ } // Borrowed from Vue template compiler.
562
562
  /*
563
563
  * Copyright (c) 2019, salesforce.com, inc.
564
564
  * All rights reserved.
@@ -713,6 +713,20 @@
713
713
  return "<".concat(StringToLowerCase.call(vm.tagName), ">");
714
714
  } // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
715
715
 
716
+
717
+ function getComponentStack(vm) {
718
+ var stack = [];
719
+ var prefix = '';
720
+
721
+ while (!isNull(vm.owner)) {
722
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
723
+ vm = vm.owner;
724
+ prefix += '\t';
725
+ }
726
+
727
+ return ArrayJoin.call(stack, '\n');
728
+ }
729
+
716
730
  function getErrorComponentStack(vm) {
717
731
  var wcStack = [];
718
732
  var currentVm = vm;
@@ -732,6 +746,32 @@
732
746
  */
733
747
 
734
748
 
749
+ function log(method, message, vm) {
750
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
751
+
752
+ if (!isUndefined$1(vm)) {
753
+ msg = "".concat(msg, "\n").concat(getComponentStack(vm));
754
+ }
755
+
756
+ try {
757
+ throw new Error(msg);
758
+ } catch (e) {
759
+ /* eslint-disable-next-line no-console */
760
+ console[method](e);
761
+ }
762
+ }
763
+
764
+ function logWarn(message, vm) {
765
+ log('warn', message, vm);
766
+ }
767
+ /*
768
+ * Copyright (c) 2018, salesforce.com, inc.
769
+ * All rights reserved.
770
+ * SPDX-License-Identifier: MIT
771
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
772
+ */
773
+
774
+
735
775
  function handleEvent(event, vnode) {
736
776
  var type = event.type;
737
777
  var on = vnode.data.on;
@@ -3382,6 +3422,17 @@
3382
3422
  modComputedStyle.create(vnode);
3383
3423
  }
3384
3424
 
3425
+ function hydrateElmHook(vnode) {
3426
+ modEvents.create(vnode); // Attrs are already on the element.
3427
+ // modAttrs.create(vnode);
3428
+
3429
+ modProps.create(vnode); // Already set.
3430
+ // modStaticClassName.create(vnode);
3431
+ // modStaticStyle.create(vnode);
3432
+ // modComputedClassName.create(vnode);
3433
+ // modComputedStyle.create(vnode);
3434
+ }
3435
+
3385
3436
  function fallbackElmHook(elm, vnode) {
3386
3437
  var owner = vnode.owner;
3387
3438
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3513,6 +3564,22 @@
3513
3564
  }
3514
3565
  }
3515
3566
 
3567
+ function hydrateChildrenHook(elmChildren, children, vm) {
3568
+
3569
+ var elmCurrentChildIdx = 0;
3570
+
3571
+ for (var j = 0, n = children.length; j < n; j++) {
3572
+ var ch = children[j];
3573
+
3574
+ if (ch != null) {
3575
+ var childNode = elmChildren[elmCurrentChildIdx];
3576
+
3577
+ ch.hook.hydrate(ch, childNode);
3578
+ elmCurrentChildIdx++;
3579
+ }
3580
+ }
3581
+ }
3582
+
3516
3583
  function updateCustomElmHook(oldVnode, vnode) {
3517
3584
  // Attrs need to be applied to element before props
3518
3585
  // IE11 will wipe out value on radio inputs if value
@@ -3620,7 +3687,14 @@
3620
3687
  update: updateNodeHook,
3621
3688
  insert: insertNodeHook,
3622
3689
  move: insertNodeHook,
3623
- remove: removeNodeHook
3690
+ remove: removeNodeHook,
3691
+ hydrate: function hydrate(vNode, node) {
3692
+ var _a;
3693
+
3694
+
3695
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3696
+ vNode.elm = node;
3697
+ }
3624
3698
  };
3625
3699
  var CommentHook = {
3626
3700
  create: function create(vnode) {
@@ -3634,7 +3708,14 @@
3634
3708
  update: updateNodeHook,
3635
3709
  insert: insertNodeHook,
3636
3710
  move: insertNodeHook,
3637
- remove: removeNodeHook
3711
+ remove: removeNodeHook,
3712
+ hydrate: function hydrate(vNode, node) {
3713
+ var _a;
3714
+
3715
+
3716
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3717
+ vNode.elm = node;
3718
+ }
3638
3719
  }; // insert is called after update, which is used somewhere else (via a module)
3639
3720
  // to mark the vm as inserted, that means we cannot use update as the main channel
3640
3721
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3668,6 +3749,34 @@
3668
3749
  remove: function remove(vnode, parentNode) {
3669
3750
  removeNodeHook(vnode, parentNode);
3670
3751
  removeElmHook(vnode);
3752
+ },
3753
+ hydrate: function hydrate(vnode, node) {
3754
+ var elm = node;
3755
+ vnode.elm = elm;
3756
+ var context = vnode.data.context;
3757
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3758
+ /* manual */
3759
+ );
3760
+
3761
+ if (isDomManual) {
3762
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3763
+ // remove the innerHTML from props so it reuses the existing dom elements.
3764
+ var props = vnode.data.props;
3765
+
3766
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3767
+ if (elm.innerHTML === props.innerHTML) {
3768
+ delete props.innerHTML;
3769
+ } else {
3770
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
3771
+ }
3772
+ }
3773
+ }
3774
+
3775
+ hydrateElmHook(vnode);
3776
+
3777
+ if (!isDomManual) {
3778
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3779
+ }
3671
3780
  }
3672
3781
  };
3673
3782
  var CustomElementHook = {
@@ -3747,6 +3856,36 @@
3747
3856
  // will take care of disconnecting any child VM attached to its shadow as well.
3748
3857
  removeVM(vm);
3749
3858
  }
3859
+ },
3860
+ hydrate: function hydrate(vnode, elm) {
3861
+ // the element is created, but the vm is not
3862
+ var sel = vnode.sel,
3863
+ mode = vnode.mode,
3864
+ ctor = vnode.ctor,
3865
+ owner = vnode.owner;
3866
+ var def = getComponentInternalDef(ctor);
3867
+ createVM(elm, def, {
3868
+ mode: mode,
3869
+ owner: owner,
3870
+ tagName: sel,
3871
+ renderer: owner.renderer
3872
+ });
3873
+ vnode.elm = elm;
3874
+ var vm = getAssociatedVM(elm);
3875
+ allocateChildrenHook(vnode, vm);
3876
+ hydrateElmHook(vnode); // Insert hook section:
3877
+
3878
+ runConnectedCallback(vm);
3879
+
3880
+ if (vm.renderMode !== 0
3881
+ /* Light */
3882
+ ) {
3883
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
3884
+ // Note: for Light DOM, this is handled while hydrating the VM
3885
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
3886
+ }
3887
+
3888
+ hydrateVM(vm);
3750
3889
  }
3751
3890
  };
3752
3891
 
@@ -4209,8 +4348,8 @@
4209
4348
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4210
4349
  var content = [];
4211
4350
 
4212
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
4213
- var stylesheet = stylesheets[_i14];
4351
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4352
+ var stylesheet = stylesheets[_i16];
4214
4353
 
4215
4354
  if (isArray$1(stylesheet)) {
4216
4355
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4280,10 +4419,13 @@
4280
4419
  && shadowMode === 1
4281
4420
  /* Synthetic */
4282
4421
  ) {
4283
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
4284
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
4422
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4423
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
4285
4424
  }
4286
- } else if (renderer.ssr) {
4425
+ } else if (renderer.ssr || renderer.isHydrating) {
4426
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4427
+ // This works in the client, because the stylesheets are created, and cached in the VM
4428
+ // the first time the VM renders.
4287
4429
  // native shadow or light DOM, SSR
4288
4430
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4289
4431
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4292,12 +4434,12 @@
4292
4434
  var root = getNearestNativeShadowComponent(vm);
4293
4435
  var isGlobal = isNull(root);
4294
4436
 
4295
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4437
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4296
4438
  if (isGlobal) {
4297
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
4439
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
4298
4440
  } else {
4299
4441
  // local level
4300
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
4442
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
4301
4443
  }
4302
4444
  }
4303
4445
  }
@@ -4482,8 +4624,8 @@
4482
4624
  var stylesheets = template.stylesheets;
4483
4625
 
4484
4626
  if (!isUndefined$1(stylesheets)) {
4485
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4486
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
4627
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4628
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4487
4629
  return true;
4488
4630
  }
4489
4631
  }
@@ -4684,8 +4826,8 @@
4684
4826
 
4685
4827
  function register(service) {
4686
4828
 
4687
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
4688
- var hookName = hooks[_i18];
4829
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4830
+ var hookName = hooks[_i20];
4689
4831
 
4690
4832
  if (hookName in service) {
4691
4833
  var l = Services[hookName];
@@ -4705,8 +4847,8 @@
4705
4847
  def = vm.def,
4706
4848
  context = vm.context;
4707
4849
 
4708
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
4709
- cbs[_i19].call(undefined, component, {}, def, context);
4850
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
4851
+ cbs[_i21].call(undefined, component, {}, def, context);
4710
4852
  }
4711
4853
  }
4712
4854
  /*
@@ -4759,6 +4901,12 @@
4759
4901
  , vm);
4760
4902
  }
4761
4903
 
4904
+ function hydrateRootElement(elm) {
4905
+ var vm = getAssociatedVM(elm);
4906
+ runConnectedCallback(vm);
4907
+ hydrateVM(vm);
4908
+ }
4909
+
4762
4910
  function disconnectRootElement(elm) {
4763
4911
  var vm = getAssociatedVM(elm);
4764
4912
  resetComponentStateWhenRemoved(vm);
@@ -4766,6 +4914,10 @@
4766
4914
 
4767
4915
  function appendVM(vm) {
4768
4916
  rehydrate(vm);
4917
+ }
4918
+
4919
+ function hydrateVM(vm) {
4920
+ hydrate(vm);
4769
4921
  } // just in case the component comes back, with this we guarantee re-rendering it
4770
4922
  // while preventing any attempt to rehydration until after reinsertion.
4771
4923
 
@@ -4950,6 +5102,22 @@
4950
5102
  }
4951
5103
  }
4952
5104
 
5105
+ function hydrate(vm) {
5106
+ if (isTrue(vm.isDirty)) {
5107
+ // manually diffing/patching here.
5108
+ // This routine is:
5109
+ // patchShadowRoot(vm, children);
5110
+ // -> addVnodes.
5111
+ var children = renderComponent(vm);
5112
+ vm.children = children;
5113
+ var vmChildren = vm.renderMode === 0
5114
+ /* Light */
5115
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5116
+ hydrateChildrenHook(vmChildren, children);
5117
+ runRenderedCallback(vm);
5118
+ }
5119
+ }
5120
+
4953
5121
  function patchShadowRoot(vm, newCh) {
4954
5122
  var oldCh = vm.children; // caching the new children collection
4955
5123
 
@@ -5026,19 +5194,19 @@
5026
5194
  });
5027
5195
  rehydrateQueue = []; // reset to a new queue
5028
5196
 
5029
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
5030
- var vm = vms[_i20];
5197
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5198
+ var vm = vms[_i22];
5031
5199
 
5032
5200
  try {
5033
5201
  rehydrate(vm);
5034
5202
  } catch (error) {
5035
- if (_i20 + 1 < _len7) {
5203
+ if (_i22 + 1 < _len7) {
5036
5204
  // pieces of the queue are still pending to be rehydrated, those should have priority
5037
5205
  if (rehydrateQueue.length === 0) {
5038
5206
  addCallbackToNextTick(flushRehydrationQueue);
5039
5207
  }
5040
5208
 
5041
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
5209
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5042
5210
  } // we need to end the measure before throwing.
5043
5211
 
5044
5212
 
@@ -5137,8 +5305,8 @@
5137
5305
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5138
5306
  // inserted in reserved order.
5139
5307
 
5140
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
5141
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
5308
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
5309
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
5142
5310
  // * when there is an error during the construction phase, and an error
5143
5311
  // boundary picks it, there is a possibility that the VCustomElement
5144
5312
  // is not properly initialized, and therefore is should be ignored.
@@ -5172,8 +5340,8 @@
5172
5340
 
5173
5341
 
5174
5342
  function recursivelyDisconnectChildren(vnodes) {
5175
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
5176
- var vnode = vnodes[_i22];
5343
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5344
+ var vnode = vnodes[_i24];
5177
5345
 
5178
5346
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5179
5347
  // vnode is a VElement with children
@@ -5197,8 +5365,8 @@
5197
5365
  renderer = vm.renderer;
5198
5366
  var rootNode = getRenderRoot(vm);
5199
5367
 
5200
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
5201
- var child = children[_i23];
5368
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5369
+ var child = children[_i25];
5202
5370
 
5203
5371
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5204
5372
  renderer.remove(child.elm, rootNode);
@@ -5243,8 +5411,8 @@
5243
5411
  var oldSlots = vm.cmpSlots;
5244
5412
  var cmpSlots = vm.cmpSlots = create(null);
5245
5413
 
5246
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
5247
- var vnode = children[_i24];
5414
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5415
+ var vnode = children[_i26];
5248
5416
 
5249
5417
  if (isNull(vnode)) {
5250
5418
  continue;
@@ -5274,8 +5442,8 @@
5274
5442
  return;
5275
5443
  }
5276
5444
 
5277
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
5278
- var key = oldKeys[_i25];
5445
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5446
+ var key = oldKeys[_i27];
5279
5447
 
5280
5448
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5281
5449
  markComponentAsDirty(vm);
@@ -5614,8 +5782,8 @@
5614
5782
  function connectWireAdapters(vm) {
5615
5783
  var wiredConnecting = vm.context.wiredConnecting;
5616
5784
 
5617
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
5618
- wiredConnecting[_i26]();
5785
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5786
+ wiredConnecting[_i28]();
5619
5787
  }
5620
5788
  }
5621
5789
 
@@ -5623,8 +5791,8 @@
5623
5791
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5624
5792
  runWithBoundaryProtection(vm, vm, noop, function () {
5625
5793
  // job
5626
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
5627
- wiredDisconnecting[_i27]();
5794
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5795
+ wiredDisconnecting[_i29]();
5628
5796
  }
5629
5797
  }, noop);
5630
5798
  }
@@ -5708,7 +5876,7 @@
5708
5876
  hooksAreSet = true;
5709
5877
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5710
5878
  }
5711
- /* version: 2.5.7 */
5879
+ /* version: 2.5.8 */
5712
5880
 
5713
5881
  /*
5714
5882
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5853,8 +6021,19 @@
5853
6021
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5854
6022
  }
5855
6023
 
6024
+ var isHydrating = false;
6025
+
6026
+ function setIsHydrating(v) {
6027
+ isHydrating = v;
6028
+ }
6029
+
5856
6030
  var renderer = {
5857
6031
  ssr: false,
6032
+
6033
+ get isHydrating() {
6034
+ return isHydrating;
6035
+ },
6036
+
5858
6037
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5859
6038
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5860
6039
  createElement: function createElement(tagName, namespace) {
@@ -5876,6 +6055,10 @@
5876
6055
  return node.nextSibling;
5877
6056
  },
5878
6057
  attachShadow: function attachShadow(element, options) {
6058
+ if (isHydrating) {
6059
+ return element.shadowRoot;
6060
+ }
6061
+
5879
6062
  return element.attachShadow(options);
5880
6063
  },
5881
6064
  setText: function setText(node, content) {
@@ -5980,71 +6163,6 @@
5980
6163
  getCustomElement: getCustomElement,
5981
6164
  HTMLElement: HTMLElementConstructor
5982
6165
  };
5983
- /*
5984
- * Copyright (c) 2018, salesforce.com, inc.
5985
- * All rights reserved.
5986
- * SPDX-License-Identifier: MIT
5987
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5988
- */
5989
-
5990
- /**
5991
- * This function builds a Web Component class from a LWC constructor so it can be
5992
- * registered as a new element via customElements.define() at any given time.
5993
- *
5994
- * @deprecated since version 1.3.11
5995
- *
5996
- * @example
5997
- * ```
5998
- * import { buildCustomElementConstructor } from 'lwc';
5999
- * import Foo from 'ns/foo';
6000
- * const WC = buildCustomElementConstructor(Foo);
6001
- * customElements.define('x-foo', WC);
6002
- * const elm = document.createElement('x-foo');
6003
- * ```
6004
- */
6005
-
6006
- function deprecatedBuildCustomElementConstructor(Ctor) {
6007
-
6008
- return Ctor.CustomElementConstructor;
6009
- }
6010
-
6011
- function buildCustomElementConstructor(Ctor) {
6012
- var def = getComponentInternalDef(Ctor);
6013
- return /*#__PURE__*/function (_def$bridge) {
6014
- _inherits(_class, _def$bridge);
6015
-
6016
- var _super8 = _createSuper(_class);
6017
-
6018
- function _class() {
6019
- var _this6;
6020
-
6021
- _classCallCheck(this, _class);
6022
-
6023
- _this6 = _super8.call(this);
6024
- createVM(_assertThisInitialized(_this6), def, {
6025
- mode: 'open',
6026
- owner: null,
6027
- tagName: _this6.tagName,
6028
- renderer: renderer
6029
- });
6030
- return _this6;
6031
- }
6032
-
6033
- _createClass(_class, [{
6034
- key: "connectedCallback",
6035
- value: function connectedCallback() {
6036
- connectRootElement(this);
6037
- }
6038
- }, {
6039
- key: "disconnectedCallback",
6040
- value: function disconnectedCallback() {
6041
- disconnectRootElement(this);
6042
- }
6043
- }]);
6044
-
6045
- return _class;
6046
- }(def.bridge);
6047
- }
6048
6166
  /*
6049
6167
  * Copyright (c) 2018, salesforce.com, inc.
6050
6168
  * All rights reserved.
@@ -6054,7 +6172,6 @@
6054
6172
  // TODO [#2472]: Remove this workaround when appropriate.
6055
6173
  // eslint-disable-next-line lwc-internal/no-global-node
6056
6174
 
6057
-
6058
6175
  var _Node$1 = Node;
6059
6176
  var ConnectingSlot = new WeakMap();
6060
6177
  var DisconnectingSlot = new WeakMap();
@@ -6161,6 +6278,138 @@
6161
6278
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6162
6279
  */
6163
6280
 
6281
+
6282
+ function hydrateComponent(element, Ctor) {
6283
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6284
+
6285
+ if (!isFunction$1(Ctor)) {
6286
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6287
+ }
6288
+
6289
+ if (!isObject(props) || isNull(props)) {
6290
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6291
+ }
6292
+
6293
+ var def = getComponentInternalDef(Ctor);
6294
+
6295
+ try {
6296
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6297
+ // and uses the same algo to create the stylesheets as in SSR.
6298
+ setIsHydrating(true);
6299
+ createVM(element, def, {
6300
+ mode: 'open',
6301
+ owner: null,
6302
+ renderer: renderer,
6303
+ tagName: element.tagName.toLowerCase()
6304
+ });
6305
+
6306
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6307
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6308
+ key = _Object$entries2$_i[0],
6309
+ value = _Object$entries2$_i[1];
6310
+
6311
+ element[key] = value;
6312
+ }
6313
+
6314
+ hydrateRootElement(element); // set it back since now we finished hydration.
6315
+
6316
+ setIsHydrating(false);
6317
+ } catch (e) {
6318
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6319
+ // the client generated DOM.
6320
+
6321
+ /* eslint-disable-next-line no-console */
6322
+ console.error('Recovering from error while hydrating: ', e);
6323
+ setIsHydrating(false);
6324
+ var newElem = createElement(element.tagName, {
6325
+ is: Ctor,
6326
+ mode: 'open'
6327
+ });
6328
+
6329
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6330
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6331
+ _key3 = _Object$entries3$_i[0],
6332
+ _value2 = _Object$entries3$_i[1];
6333
+
6334
+ newElem[_key3] = _value2;
6335
+ }
6336
+
6337
+ element.parentNode.replaceChild(newElem, element);
6338
+ }
6339
+ }
6340
+ /*
6341
+ * Copyright (c) 2018, salesforce.com, inc.
6342
+ * All rights reserved.
6343
+ * SPDX-License-Identifier: MIT
6344
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6345
+ */
6346
+
6347
+ /**
6348
+ * This function builds a Web Component class from a LWC constructor so it can be
6349
+ * registered as a new element via customElements.define() at any given time.
6350
+ *
6351
+ * @deprecated since version 1.3.11
6352
+ *
6353
+ * @example
6354
+ * ```
6355
+ * import { buildCustomElementConstructor } from 'lwc';
6356
+ * import Foo from 'ns/foo';
6357
+ * const WC = buildCustomElementConstructor(Foo);
6358
+ * customElements.define('x-foo', WC);
6359
+ * const elm = document.createElement('x-foo');
6360
+ * ```
6361
+ */
6362
+
6363
+
6364
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6365
+
6366
+ return Ctor.CustomElementConstructor;
6367
+ }
6368
+
6369
+ function buildCustomElementConstructor(Ctor) {
6370
+ var def = getComponentInternalDef(Ctor);
6371
+ return /*#__PURE__*/function (_def$bridge) {
6372
+ _inherits(_class, _def$bridge);
6373
+
6374
+ var _super8 = _createSuper(_class);
6375
+
6376
+ function _class() {
6377
+ var _this6;
6378
+
6379
+ _classCallCheck(this, _class);
6380
+
6381
+ _this6 = _super8.call(this);
6382
+ createVM(_assertThisInitialized(_this6), def, {
6383
+ mode: 'open',
6384
+ owner: null,
6385
+ tagName: _this6.tagName,
6386
+ renderer: renderer
6387
+ });
6388
+ return _this6;
6389
+ }
6390
+
6391
+ _createClass(_class, [{
6392
+ key: "connectedCallback",
6393
+ value: function connectedCallback() {
6394
+ connectRootElement(this);
6395
+ }
6396
+ }, {
6397
+ key: "disconnectedCallback",
6398
+ value: function disconnectedCallback() {
6399
+ disconnectRootElement(this);
6400
+ }
6401
+ }]);
6402
+
6403
+ return _class;
6404
+ }(def.bridge);
6405
+ }
6406
+ /*
6407
+ * Copyright (c) 2018, salesforce.com, inc.
6408
+ * All rights reserved.
6409
+ * SPDX-License-Identifier: MIT
6410
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6411
+ */
6412
+
6164
6413
  /**
6165
6414
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6166
6415
  * This API is subject to change or being removed.
@@ -6259,7 +6508,7 @@
6259
6508
  });
6260
6509
  freeze(LightningElement);
6261
6510
  seal(LightningElement.prototype);
6262
- /* version: 2.5.7 */
6511
+ /* version: 2.5.8 */
6263
6512
 
6264
6513
  exports.LightningElement = LightningElement;
6265
6514
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6269,6 +6518,7 @@
6269
6518
  exports.createElement = createElement;
6270
6519
  exports.getComponentConstructor = getComponentConstructor;
6271
6520
  exports.getComponentDef = getComponentDef;
6521
+ exports.hydrateComponent = hydrateComponent;
6272
6522
  exports.isComponentConstructor = isComponentConstructor;
6273
6523
  exports.isNodeFromTemplate = isNodeFromTemplate;
6274
6524
  exports.readonly = readonly;