lwc 2.5.4 → 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 (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +567 -99
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +568 -98
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +383 -90
  5. package/dist/engine-dom/iife/es5/engine-dom.js +634 -150
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +430 -133
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +568 -98
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +383 -90
  11. package/dist/engine-dom/umd/es5/engine-dom.js +634 -150
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +430 -133
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +457 -49
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +457 -50
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +9 -39
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +9 -39
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +9 -39
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +9 -39
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +9 -39
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +9 -39
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +9 -39
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +9 -39
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +9 -39
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +8 -8
@@ -7,8 +7,6 @@ var LWC = (function (exports) {
7
7
 
8
8
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
9
9
 
10
- 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; } } }; }
11
-
12
10
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
13
11
 
14
12
  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."); }
@@ -37,23 +35,25 @@ var LWC = (function (exports) {
37
35
 
38
36
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
39
37
 
40
- 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"); } }
41
39
 
42
- 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); } }
43
41
 
44
- 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; }
45
43
 
46
- 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."); }
47
47
 
48
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; }
49
49
 
50
50
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
51
51
 
52
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
52
+ 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; } } }; }
53
53
 
54
- 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); } }
54
+ 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); }
55
55
 
56
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
56
+ 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; }
57
57
 
58
58
  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); }
59
59
 
@@ -120,6 +120,7 @@ var LWC = (function (exports) {
120
120
  setPrototypeOf = Object.setPrototypeOf;
121
121
  var isArray$1 = Array.isArray;
122
122
  var _Array$prototype = Array.prototype,
123
+ ArrayFilter = _Array$prototype.filter,
123
124
  ArrayIndexOf = _Array$prototype.indexOf,
124
125
  ArrayJoin = _Array$prototype.join,
125
126
  ArrayMap$1 = _Array$prototype.map,
@@ -347,7 +348,7 @@ var LWC = (function (exports) {
347
348
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
348
349
  return attributeName;
349
350
  }
350
- /** version: 2.5.4 */
351
+ /** version: 2.5.8 */
351
352
 
352
353
  /*
353
354
  * Copyright (c) 2018, salesforce.com, inc.
@@ -527,7 +528,7 @@ var LWC = (function (exports) {
527
528
  setFeatureFlag(name, value);
528
529
  }
529
530
  }
530
- /** version: 2.5.4 */
531
+ /** version: 2.5.8 */
531
532
 
532
533
  /* proxy-compat-disable */
533
534
 
@@ -579,6 +580,42 @@ var LWC = (function (exports) {
579
580
  }
580
581
 
581
582
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
583
+ } // Borrowed from Vue template compiler.
584
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
585
+
586
+
587
+ var DECLARATION_DELIMITER = /;(?![^(]*\))/g;
588
+ var PROPERTY_DELIMITER = /:(.+)/;
589
+
590
+ function parseStyleText(cssText) {
591
+ var styleMap = {};
592
+ var declarations = cssText.split(DECLARATION_DELIMITER);
593
+
594
+ var _iterator = _createForOfIteratorHelper(declarations),
595
+ _step;
596
+
597
+ try {
598
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
599
+ var declaration = _step.value;
600
+
601
+ if (declaration) {
602
+ var _declaration$split = declaration.split(PROPERTY_DELIMITER),
603
+ _declaration$split2 = _slicedToArray(_declaration$split, 2),
604
+ prop = _declaration$split2[0],
605
+ value = _declaration$split2[1];
606
+
607
+ if (prop !== undefined && value !== undefined) {
608
+ styleMap[prop.trim()] = value.trim();
609
+ }
610
+ }
611
+ }
612
+ } catch (err) {
613
+ _iterator.e(err);
614
+ } finally {
615
+ _iterator.f();
616
+ }
617
+
618
+ return styleMap;
582
619
  }
583
620
  /*
584
621
  * Copyright (c) 2019, salesforce.com, inc.
@@ -767,8 +804,8 @@ var LWC = (function (exports) {
767
804
  */
768
805
 
769
806
 
770
- function logError(message, vm) {
771
- var msg = "[LWC error]: ".concat(message);
807
+ function log(method, message, vm) {
808
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
772
809
 
773
810
  if (!isUndefined$1(vm)) {
774
811
  msg = "".concat(msg, "\n").concat(getComponentStack(vm));
@@ -776,7 +813,7 @@ var LWC = (function (exports) {
776
813
 
777
814
  if (process.env.NODE_ENV === 'test') {
778
815
  /* eslint-disable-next-line no-console */
779
- console.error(msg);
816
+ console[method](msg);
780
817
  return;
781
818
  }
782
819
 
@@ -784,9 +821,17 @@ var LWC = (function (exports) {
784
821
  throw new Error(msg);
785
822
  } catch (e) {
786
823
  /* eslint-disable-next-line no-console */
787
- console.error(e);
824
+ console[method](e);
788
825
  }
789
826
  }
827
+
828
+ function logError(message, vm) {
829
+ log('error', message, vm);
830
+ }
831
+
832
+ function logWarn(message, vm) {
833
+ log('warn', message, vm);
834
+ }
790
835
  /*
791
836
  * Copyright (c) 2018, salesforce.com, inc.
792
837
  * All rights reserved.
@@ -3015,7 +3060,9 @@ var LWC = (function (exports) {
3015
3060
  }
3016
3061
 
3017
3062
  return renderer[rendererMethod](elm);
3018
- }
3063
+ },
3064
+ configurable: true,
3065
+ enumerable: true
3019
3066
  };
3020
3067
  };
3021
3068
 
@@ -3038,7 +3085,10 @@ var LWC = (function (exports) {
3038
3085
  }
3039
3086
 
3040
3087
  return renderer[queryMethod](elm, arg);
3041
- }
3088
+ },
3089
+ configurable: true,
3090
+ enumerable: true,
3091
+ writable: true
3042
3092
  };
3043
3093
  };
3044
3094
 
@@ -3639,15 +3689,14 @@ var LWC = (function (exports) {
3639
3689
  return tpl;
3640
3690
  }
3641
3691
  /**
3642
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
3643
- * Service and other similar libraries to sanitize vulnerable attributes.
3644
- * This API is subject to change or being removed.
3692
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3693
+ * libraries to sanitize vulnerable attributes.
3645
3694
  */
3646
3695
 
3647
3696
 
3648
3697
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3649
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
3650
- // when ran off-core this function becomes a noop and returns the user authored value.
3698
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3699
+ // ran off-core this function becomes a noop and returns the user authored value.
3651
3700
  return attrValue;
3652
3701
  }
3653
3702
  /*
@@ -3932,12 +3981,12 @@ var LWC = (function (exports) {
3932
3981
  function flattenStylesheets(stylesheets) {
3933
3982
  var list = [];
3934
3983
 
3935
- var _iterator = _createForOfIteratorHelper(stylesheets),
3936
- _step;
3984
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
3985
+ _step2;
3937
3986
 
3938
3987
  try {
3939
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3940
- var stylesheet = _step.value;
3988
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3989
+ var stylesheet = _step2.value;
3941
3990
 
3942
3991
  if (!Array.isArray(stylesheet)) {
3943
3992
  list.push(stylesheet);
@@ -3946,9 +3995,9 @@ var LWC = (function (exports) {
3946
3995
  }
3947
3996
  }
3948
3997
  } catch (err) {
3949
- _iterator.e(err);
3998
+ _iterator2.e(err);
3950
3999
  } finally {
3951
- _iterator.f();
4000
+ _iterator2.f();
3952
4001
  }
3953
4002
 
3954
4003
  return list;
@@ -4212,7 +4261,7 @@ var LWC = (function (exports) {
4212
4261
  if (!isUndefined$1(ctorShadowSupportMode)) {
4213
4262
  assert.invariant(ctorShadowSupportMode === "any"
4214
4263
  /* Any */
4215
- || ctorShadowSupportMode === "default"
4264
+ || ctorShadowSupportMode === "reset"
4216
4265
  /* Default */
4217
4266
  , "Invalid value for static property shadowSupportMode: '".concat(ctorShadowSupportMode, "'"));
4218
4267
  }
@@ -4370,7 +4419,7 @@ var LWC = (function (exports) {
4370
4419
  renderMode: 1
4371
4420
  /* Shadow */
4372
4421
  ,
4373
- shadowSupportMode: "default"
4422
+ shadowSupportMode: "reset"
4374
4423
  /* Default */
4375
4424
  ,
4376
4425
  wire: EmptyObject,
@@ -4507,6 +4556,17 @@ var LWC = (function (exports) {
4507
4556
  modComputedStyle.create(vnode);
4508
4557
  }
4509
4558
 
4559
+ function hydrateElmHook(vnode) {
4560
+ modEvents.create(vnode); // Attrs are already on the element.
4561
+ // modAttrs.create(vnode);
4562
+
4563
+ modProps.create(vnode); // Already set.
4564
+ // modStaticClassName.create(vnode);
4565
+ // modStaticStyle.create(vnode);
4566
+ // modComputedClassName.create(vnode);
4567
+ // modComputedStyle.create(vnode);
4568
+ }
4569
+
4510
4570
  function fallbackElmHook(elm, vnode) {
4511
4571
  var owner = vnode.owner;
4512
4572
  setScopeTokenClassIfNecessary(elm, owner);
@@ -4656,6 +4716,174 @@ var LWC = (function (exports) {
4656
4716
  }
4657
4717
  }
4658
4718
 
4719
+ function isElementNode(node) {
4720
+ // eslint-disable-next-line lwc-internal/no-global-node
4721
+ return node.nodeType === Node.ELEMENT_NODE;
4722
+ }
4723
+
4724
+ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4725
+ var _vnode$data$attrs = vnode.data.attrs,
4726
+ attrs = _vnode$data$attrs === void 0 ? {} : _vnode$data$attrs,
4727
+ renderer = vnode.owner.renderer;
4728
+ var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4729
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4730
+
4731
+ for (var _i14 = 0, _Object$entries = Object.entries(attrs); _i14 < _Object$entries.length; _i14++) {
4732
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i14], 2),
4733
+ attrName = _Object$entries$_i[0],
4734
+ attrValue = _Object$entries$_i[1];
4735
+
4736
+ var elmAttrValue = renderer.getAttribute(elm, attrName);
4737
+
4738
+ if (attrValue !== elmAttrValue) {
4739
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
4740
+ nodesAreCompatible = false;
4741
+ }
4742
+ }
4743
+
4744
+ return nodesAreCompatible;
4745
+ }
4746
+
4747
+ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4748
+ var _vnode$data = vnode.data,
4749
+ className = _vnode$data.className,
4750
+ classMap = _vnode$data.classMap,
4751
+ renderer = vnode.owner.renderer;
4752
+ var nodesAreCompatible = true;
4753
+ var vnodeClassName;
4754
+
4755
+ if (!isUndefined$1(className) && className !== elm.className) {
4756
+ // className is used when class is bound to an expr.
4757
+ nodesAreCompatible = false;
4758
+ vnodeClassName = className;
4759
+ } else if (!isUndefined$1(classMap)) {
4760
+ // classMap is used when class is set to static value.
4761
+ var classList = renderer.getClassList(elm);
4762
+ var computedClassName = ''; // all classes from the vnode should be in the element.classList
4763
+
4764
+ for (var name in classMap) {
4765
+ computedClassName += ' ' + name;
4766
+
4767
+ if (!classList.contains(name)) {
4768
+ nodesAreCompatible = false;
4769
+ }
4770
+ }
4771
+
4772
+ vnodeClassName = computedClassName.trim();
4773
+
4774
+ if (classList.length > keys(classMap).length) {
4775
+ nodesAreCompatible = false;
4776
+ }
4777
+ }
4778
+
4779
+ if (!nodesAreCompatible) {
4780
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(elm.className, "\""), vnode.owner);
4781
+ }
4782
+
4783
+ return nodesAreCompatible;
4784
+ }
4785
+
4786
+ function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4787
+ var _vnode$data2 = vnode.data,
4788
+ style = _vnode$data2.style,
4789
+ styleDecls = _vnode$data2.styleDecls,
4790
+ renderer = vnode.owner.renderer;
4791
+ var elmStyle = renderer.getAttribute(elm, 'style') || '';
4792
+ var vnodeStyle;
4793
+ var nodesAreCompatible = true;
4794
+
4795
+ if (!isUndefined$1(style) && style !== elmStyle) {
4796
+ nodesAreCompatible = false;
4797
+ vnodeStyle = style;
4798
+ } else if (!isUndefined$1(styleDecls)) {
4799
+ var parsedVnodeStyle = parseStyleText(elmStyle);
4800
+ var expectedStyle = []; // styleMap is used when style is set to static value.
4801
+
4802
+ for (var _i15 = 0, n = styleDecls.length; _i15 < n; _i15++) {
4803
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i15], 3),
4804
+ prop = _styleDecls$_i2[0],
4805
+ value = _styleDecls$_i2[1],
4806
+ important = _styleDecls$_i2[2];
4807
+
4808
+ expectedStyle.push("".concat(prop, ": ").concat(value + (important ? ' important!' : '')));
4809
+ var parsedPropValue = parsedVnodeStyle[prop];
4810
+
4811
+ if (isUndefined$1(parsedPropValue)) {
4812
+ nodesAreCompatible = false;
4813
+ } else if (!parsedPropValue.startsWith(value)) {
4814
+ nodesAreCompatible = false;
4815
+ } else if (important && !parsedPropValue.endsWith('!important')) {
4816
+ nodesAreCompatible = false;
4817
+ }
4818
+ }
4819
+
4820
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
4821
+ nodesAreCompatible = false;
4822
+ }
4823
+
4824
+ vnodeStyle = ArrayJoin.call(expectedStyle, ';');
4825
+ }
4826
+
4827
+ if (!nodesAreCompatible) {
4828
+ // style is used when class is bound to an expr.
4829
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
4830
+ }
4831
+
4832
+ return nodesAreCompatible;
4833
+ }
4834
+
4835
+ function throwHydrationError() {
4836
+ assert.fail('Server rendered elements do not match client side generated elements');
4837
+ }
4838
+
4839
+ function hydrateChildrenHook(elmChildren, children, vm) {
4840
+ var _a, _b;
4841
+
4842
+ if (process.env.NODE_ENV !== 'production') {
4843
+ var filteredVNodes = ArrayFilter.call(children, function (vnode) {
4844
+ return !!vnode;
4845
+ });
4846
+
4847
+ if (elmChildren.length !== filteredVNodes.length) {
4848
+ logError("Hydration mismatch: incorrect number of rendered nodes, expected ".concat(filteredVNodes.length, " but found ").concat(elmChildren.length, "."), vm);
4849
+ throwHydrationError();
4850
+ }
4851
+ }
4852
+
4853
+ var elmCurrentChildIdx = 0;
4854
+
4855
+ for (var j = 0, n = children.length; j < n; j++) {
4856
+ var ch = children[j];
4857
+
4858
+ if (ch != null) {
4859
+ var childNode = elmChildren[elmCurrentChildIdx];
4860
+
4861
+ if (process.env.NODE_ENV !== 'production') {
4862
+ // VComments and VTexts validation is handled in their hooks
4863
+ if (isElementNode(childNode)) {
4864
+ if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
4865
+ 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);
4866
+ throwHydrationError();
4867
+ } // Note: props are not yet set
4868
+
4869
+
4870
+ var hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
4871
+ var hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
4872
+ var hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
4873
+ var isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4874
+
4875
+ if (!isVNodeAndElementCompatible) {
4876
+ throwHydrationError();
4877
+ }
4878
+ }
4879
+ }
4880
+
4881
+ ch.hook.hydrate(ch, childNode);
4882
+ elmCurrentChildIdx++;
4883
+ }
4884
+ }
4885
+ }
4886
+
4659
4887
  function updateCustomElmHook(oldVnode, vnode) {
4660
4888
  // Attrs need to be applied to element before props
4661
4889
  // IE11 will wipe out value on radio inputs if value
@@ -4763,7 +4991,26 @@ var LWC = (function (exports) {
4763
4991
  update: updateNodeHook,
4764
4992
  insert: insertNodeHook,
4765
4993
  move: insertNodeHook,
4766
- remove: removeNodeHook
4994
+ remove: removeNodeHook,
4995
+ hydrate: function hydrate(vNode, node) {
4996
+ var _a;
4997
+
4998
+ if (process.env.NODE_ENV !== 'production') {
4999
+ // eslint-disable-next-line lwc-internal/no-global-node
5000
+ if (node.nodeType !== Node.TEXT_NODE) {
5001
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5002
+ assert.fail('Hydration mismatch: incorrect node type received.');
5003
+ }
5004
+
5005
+ if (node.nodeValue !== vNode.text) {
5006
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
5007
+ }
5008
+ } // always set the text value to the one from the vnode.
5009
+
5010
+
5011
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5012
+ vNode.elm = node;
5013
+ }
4767
5014
  };
4768
5015
  var CommentHook = {
4769
5016
  create: function create(vnode) {
@@ -4777,7 +5024,26 @@ var LWC = (function (exports) {
4777
5024
  update: updateNodeHook,
4778
5025
  insert: insertNodeHook,
4779
5026
  move: insertNodeHook,
4780
- remove: removeNodeHook
5027
+ remove: removeNodeHook,
5028
+ hydrate: function hydrate(vNode, node) {
5029
+ var _a;
5030
+
5031
+ if (process.env.NODE_ENV !== 'production') {
5032
+ // eslint-disable-next-line lwc-internal/no-global-node
5033
+ if (node.nodeType !== Node.COMMENT_NODE) {
5034
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5035
+ assert.fail('Hydration mismatch: incorrect node type received.');
5036
+ }
5037
+
5038
+ if (node.nodeValue !== vNode.text) {
5039
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
5040
+ }
5041
+ } // always set the text value to the one from the vnode.
5042
+
5043
+
5044
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5045
+ vNode.elm = node;
5046
+ }
4781
5047
  }; // insert is called after update, which is used somewhere else (via a module)
4782
5048
  // to mark the vm as inserted, that means we cannot use update as the main channel
4783
5049
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -4811,6 +5077,34 @@ var LWC = (function (exports) {
4811
5077
  remove: function remove(vnode, parentNode) {
4812
5078
  removeNodeHook(vnode, parentNode);
4813
5079
  removeElmHook(vnode);
5080
+ },
5081
+ hydrate: function hydrate(vnode, node) {
5082
+ var elm = node;
5083
+ vnode.elm = elm;
5084
+ var context = vnode.data.context;
5085
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5086
+ /* manual */
5087
+ );
5088
+
5089
+ if (isDomManual) {
5090
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5091
+ // remove the innerHTML from props so it reuses the existing dom elements.
5092
+ var props = vnode.data.props;
5093
+
5094
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5095
+ if (elm.innerHTML === props.innerHTML) {
5096
+ delete props.innerHTML;
5097
+ } else {
5098
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5099
+ }
5100
+ }
5101
+ }
5102
+
5103
+ hydrateElmHook(vnode);
5104
+
5105
+ if (!isDomManual) {
5106
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
5107
+ }
4814
5108
  }
4815
5109
  };
4816
5110
  var CustomElementHook = {
@@ -4898,6 +5192,42 @@ var LWC = (function (exports) {
4898
5192
  // will take care of disconnecting any child VM attached to its shadow as well.
4899
5193
  removeVM(vm);
4900
5194
  }
5195
+ },
5196
+ hydrate: function hydrate(vnode, elm) {
5197
+ // the element is created, but the vm is not
5198
+ var sel = vnode.sel,
5199
+ mode = vnode.mode,
5200
+ ctor = vnode.ctor,
5201
+ owner = vnode.owner;
5202
+ var def = getComponentInternalDef(ctor);
5203
+ createVM(elm, def, {
5204
+ mode: mode,
5205
+ owner: owner,
5206
+ tagName: sel,
5207
+ renderer: owner.renderer
5208
+ });
5209
+ vnode.elm = elm;
5210
+ var vm = getAssociatedVM(elm);
5211
+ allocateChildrenHook(vnode, vm);
5212
+ hydrateElmHook(vnode); // Insert hook section:
5213
+
5214
+ if (process.env.NODE_ENV !== 'production') {
5215
+ assert.isTrue(vm.state === 0
5216
+ /* created */
5217
+ , "".concat(vm, " cannot be recycled."));
5218
+ }
5219
+
5220
+ runConnectedCallback(vm);
5221
+
5222
+ if (vm.renderMode !== 0
5223
+ /* Light */
5224
+ ) {
5225
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5226
+ // Note: for Light DOM, this is handled while hydrating the VM
5227
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
5228
+ }
5229
+
5230
+ hydrateVM(vm);
4901
5231
  }
4902
5232
  };
4903
5233
 
@@ -5098,7 +5428,7 @@ var LWC = (function (exports) {
5098
5428
  next = iterator.next();
5099
5429
  last = next.done; // template factory logic based on the previous collected value
5100
5430
 
5101
- var vnode = factory(value, j, j === 0, last);
5431
+ var vnode = factory(value, j, j === 0, last === true);
5102
5432
 
5103
5433
  if (isArray$1(vnode)) {
5104
5434
  ArrayPush$1.apply(list, vnode);
@@ -5361,24 +5691,48 @@ var LWC = (function (exports) {
5361
5691
  markAsDynamicChildren(vnodes);
5362
5692
  return vnodes;
5363
5693
  }
5694
+ /**
5695
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5696
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5697
+ * lwc:inner-html directive.
5698
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5699
+ */
5364
5700
 
5365
- var api = /*#__PURE__*/Object.freeze({
5366
- __proto__: null,
5367
- h: h,
5368
- ti: ti,
5701
+
5702
+ var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
5703
+ // locker-service patches this function during runtime to sanitize HTML content.
5704
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5705
+ };
5706
+ /**
5707
+ * Sets the sanitizeHtmlContentHook.
5708
+ */
5709
+
5710
+
5711
+ function setSanitizeHtmlContentHook(newHookImpl) {
5712
+ sanitizeHtmlContentHook = newHookImpl;
5713
+ } // [s]anitize [h]tml [c]ontent
5714
+
5715
+
5716
+ function shc(content) {
5717
+ return sanitizeHtmlContentHook(content);
5718
+ }
5719
+
5720
+ var api = freeze({
5369
5721
  s: s,
5722
+ h: h,
5370
5723
  c: c,
5371
5724
  i: i,
5372
5725
  f: f,
5373
5726
  t: t,
5374
- co: co,
5375
5727
  d: d,
5376
5728
  b: b,
5377
5729
  k: k,
5730
+ co: co,
5731
+ dc: dc,
5732
+ ti: ti,
5378
5733
  gid: gid,
5379
5734
  fid: fid,
5380
- dc: dc,
5381
- sc: sc
5735
+ shc: shc
5382
5736
  });
5383
5737
  /*
5384
5738
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5392,12 +5746,12 @@ var LWC = (function (exports) {
5392
5746
  }
5393
5747
 
5394
5748
  function createInlineStyleVNode(content) {
5395
- return h('style', {
5749
+ return api.h('style', {
5396
5750
  key: 'style',
5397
5751
  attrs: {
5398
5752
  type: 'text/css'
5399
5753
  }
5400
- }, [t(content)]);
5754
+ }, [api.t(content)]);
5401
5755
  }
5402
5756
 
5403
5757
  function updateStylesheetToken(vm, template) {
@@ -5458,8 +5812,8 @@ var LWC = (function (exports) {
5458
5812
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5459
5813
  var content = [];
5460
5814
 
5461
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
5462
- var stylesheet = stylesheets[_i14];
5815
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5816
+ var stylesheet = stylesheets[_i16];
5463
5817
 
5464
5818
  if (isArray$1(stylesheet)) {
5465
5819
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -5535,10 +5889,13 @@ var LWC = (function (exports) {
5535
5889
  && shadowMode === 1
5536
5890
  /* Synthetic */
5537
5891
  ) {
5538
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
5539
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
5892
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5893
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
5540
5894
  }
5541
- } else if (renderer.ssr) {
5895
+ } else if (renderer.ssr || renderer.isHydrating) {
5896
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5897
+ // This works in the client, because the stylesheets are created, and cached in the VM
5898
+ // the first time the VM renders.
5542
5899
  // native shadow or light DOM, SSR
5543
5900
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5544
5901
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -5547,12 +5904,12 @@ var LWC = (function (exports) {
5547
5904
  var root = getNearestNativeShadowComponent(vm);
5548
5905
  var isGlobal = isNull(root);
5549
5906
 
5550
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5907
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
5551
5908
  if (isGlobal) {
5552
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
5909
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
5553
5910
  } else {
5554
5911
  // local level
5555
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
5912
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
5556
5913
  }
5557
5914
  }
5558
5915
  }
@@ -5829,8 +6186,8 @@ var LWC = (function (exports) {
5829
6186
  var stylesheets = template.stylesheets;
5830
6187
 
5831
6188
  if (!isUndefined$1(stylesheets)) {
5832
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5833
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
6189
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6190
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
5834
6191
  return true;
5835
6192
  }
5836
6193
  }
@@ -6060,8 +6417,8 @@ var LWC = (function (exports) {
6060
6417
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6061
6418
  }
6062
6419
 
6063
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
6064
- var hookName = hooks[_i18];
6420
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6421
+ var hookName = hooks[_i20];
6065
6422
 
6066
6423
  if (hookName in service) {
6067
6424
  var l = Services[hookName];
@@ -6084,8 +6441,8 @@ var LWC = (function (exports) {
6084
6441
  def = vm.def,
6085
6442
  context = vm.context;
6086
6443
 
6087
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
6088
- cbs[_i19].call(undefined, component, {}, def, context);
6444
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
6445
+ cbs[_i21].call(undefined, component, {}, def, context);
6089
6446
  }
6090
6447
  }
6091
6448
  /*
@@ -6138,6 +6495,12 @@ var LWC = (function (exports) {
6138
6495
  , vm);
6139
6496
  }
6140
6497
 
6498
+ function hydrateRootElement(elm) {
6499
+ var vm = getAssociatedVM(elm);
6500
+ runConnectedCallback(vm);
6501
+ hydrateVM(vm);
6502
+ }
6503
+
6141
6504
  function disconnectRootElement(elm) {
6142
6505
  var vm = getAssociatedVM(elm);
6143
6506
  resetComponentStateWhenRemoved(vm);
@@ -6145,6 +6508,10 @@ var LWC = (function (exports) {
6145
6508
 
6146
6509
  function appendVM(vm) {
6147
6510
  rehydrate(vm);
6511
+ }
6512
+
6513
+ function hydrateVM(vm) {
6514
+ hydrate(vm);
6148
6515
  } // just in case the component comes back, with this we guarantee re-rendering it
6149
6516
  // while preventing any attempt to rehydration until after reinsertion.
6150
6517
 
@@ -6368,6 +6735,22 @@ var LWC = (function (exports) {
6368
6735
  }
6369
6736
  }
6370
6737
 
6738
+ function hydrate(vm) {
6739
+ if (isTrue(vm.isDirty)) {
6740
+ // manually diffing/patching here.
6741
+ // This routine is:
6742
+ // patchShadowRoot(vm, children);
6743
+ // -> addVnodes.
6744
+ var children = renderComponent(vm);
6745
+ vm.children = children;
6746
+ var vmChildren = vm.renderMode === 0
6747
+ /* Light */
6748
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
6749
+ hydrateChildrenHook(vmChildren, children, vm);
6750
+ runRenderedCallback(vm);
6751
+ }
6752
+ }
6753
+
6371
6754
  function patchShadowRoot(vm, newCh) {
6372
6755
  var oldCh = vm.children; // caching the new children collection
6373
6756
 
@@ -6448,19 +6831,19 @@ var LWC = (function (exports) {
6448
6831
  });
6449
6832
  rehydrateQueue = []; // reset to a new queue
6450
6833
 
6451
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
6452
- var vm = vms[_i20];
6834
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
6835
+ var vm = vms[_i22];
6453
6836
 
6454
6837
  try {
6455
6838
  rehydrate(vm);
6456
6839
  } catch (error) {
6457
- if (_i20 + 1 < _len7) {
6840
+ if (_i22 + 1 < _len7) {
6458
6841
  // pieces of the queue are still pending to be rehydrated, those should have priority
6459
6842
  if (rehydrateQueue.length === 0) {
6460
6843
  addCallbackToNextTick(flushRehydrationQueue);
6461
6844
  }
6462
6845
 
6463
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
6846
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
6464
6847
  } // we need to end the measure before throwing.
6465
6848
 
6466
6849
 
@@ -6564,8 +6947,8 @@ var LWC = (function (exports) {
6564
6947
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
6565
6948
  // inserted in reserved order.
6566
6949
 
6567
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
6568
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
6950
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
6951
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
6569
6952
  // * when there is an error during the construction phase, and an error
6570
6953
  // boundary picks it, there is a possibility that the VCustomElement
6571
6954
  // is not properly initialized, and therefore is should be ignored.
@@ -6599,8 +6982,8 @@ var LWC = (function (exports) {
6599
6982
 
6600
6983
 
6601
6984
  function recursivelyDisconnectChildren(vnodes) {
6602
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
6603
- var vnode = vnodes[_i22];
6985
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
6986
+ var vnode = vnodes[_i24];
6604
6987
 
6605
6988
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
6606
6989
  // vnode is a VElement with children
@@ -6624,8 +7007,8 @@ var LWC = (function (exports) {
6624
7007
  renderer = vm.renderer;
6625
7008
  var rootNode = getRenderRoot(vm);
6626
7009
 
6627
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
6628
- var child = children[_i23];
7010
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
7011
+ var child = children[_i25];
6629
7012
 
6630
7013
  if (!isNull(child) && !isUndefined$1(child.elm)) {
6631
7014
  renderer.remove(child.elm, rootNode);
@@ -6670,8 +7053,8 @@ var LWC = (function (exports) {
6670
7053
  var oldSlots = vm.cmpSlots;
6671
7054
  var cmpSlots = vm.cmpSlots = create(null);
6672
7055
 
6673
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
6674
- var vnode = children[_i24];
7056
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
7057
+ var vnode = children[_i26];
6675
7058
 
6676
7059
  if (isNull(vnode)) {
6677
7060
  continue;
@@ -6701,8 +7084,8 @@ var LWC = (function (exports) {
6701
7084
  return;
6702
7085
  }
6703
7086
 
6704
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
6705
- var key = oldKeys[_i25];
7087
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
7088
+ var key = oldKeys[_i27];
6706
7089
 
6707
7090
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
6708
7091
  markComponentAsDirty(vm);
@@ -7065,8 +7448,8 @@ var LWC = (function (exports) {
7065
7448
  function connectWireAdapters(vm) {
7066
7449
  var wiredConnecting = vm.context.wiredConnecting;
7067
7450
 
7068
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
7069
- wiredConnecting[_i26]();
7451
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
7452
+ wiredConnecting[_i28]();
7070
7453
  }
7071
7454
  }
7072
7455
 
@@ -7074,8 +7457,8 @@ var LWC = (function (exports) {
7074
7457
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7075
7458
  runWithBoundaryProtection(vm, vm, noop, function () {
7076
7459
  // job
7077
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
7078
- wiredDisconnecting[_i27]();
7460
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
7461
+ wiredDisconnecting[_i29]();
7079
7462
  }
7080
7463
  }, noop);
7081
7464
  }
@@ -7150,7 +7533,22 @@ var LWC = (function (exports) {
7150
7533
 
7151
7534
  return reactiveMembrane.getReadOnlyProxy(obj);
7152
7535
  }
7153
- /* version: 2.5.4 */
7536
+ /*
7537
+ * Copyright (c) 2018, salesforce.com, inc.
7538
+ * All rights reserved.
7539
+ * SPDX-License-Identifier: MIT
7540
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7541
+ */
7542
+
7543
+
7544
+ var hooksAreSet = false;
7545
+
7546
+ function setHooks(hooks) {
7547
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7548
+ hooksAreSet = true;
7549
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7550
+ }
7551
+ /* version: 2.5.8 */
7154
7552
 
7155
7553
  /*
7156
7554
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7165,15 +7563,18 @@ var LWC = (function (exports) {
7165
7563
  if (process.env.NODE_ENV === 'development') {
7166
7564
  // @ts-ignore
7167
7565
  window.__lwcResetGlobalStylesheets = function () {
7168
- for (var _i28 = 0, _Object$keys = Object.keys(globalStylesheets); _i28 < _Object$keys.length; _i28++) {
7169
- var key = _Object$keys[_i28];
7566
+ for (var _i30 = 0, _Object$keys = Object.keys(globalStylesheets); _i30 < _Object$keys.length; _i30++) {
7567
+ var key = _Object$keys[_i30];
7170
7568
  delete globalStylesheets[key];
7171
7569
  }
7172
7570
  };
7173
7571
  }
7174
7572
 
7175
- var globalStylesheetsParentElement = document.head || document.body || document;
7176
- var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync);
7573
+ var globalStylesheetsParentElement = document.head || document.body || document; // This check for constructable stylesheets is similar to Fast's:
7574
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
7575
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7576
+
7577
+ var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7177
7578
  var styleElements = create(null);
7178
7579
  var styleSheets = create(null);
7179
7580
  var nodesToStyleSheets = new WeakMap();
@@ -7302,8 +7703,19 @@ var LWC = (function (exports) {
7302
7703
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7303
7704
  }
7304
7705
 
7706
+ var isHydrating = false;
7707
+
7708
+ function setIsHydrating(v) {
7709
+ isHydrating = v;
7710
+ }
7711
+
7305
7712
  var renderer = {
7306
7713
  ssr: false,
7714
+
7715
+ get isHydrating() {
7716
+ return isHydrating;
7717
+ },
7718
+
7307
7719
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7308
7720
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7309
7721
  createElement: function createElement(tagName, namespace) {
@@ -7325,6 +7737,10 @@ var LWC = (function (exports) {
7325
7737
  return node.nextSibling;
7326
7738
  },
7327
7739
  attachShadow: function attachShadow(element, options) {
7740
+ if (isHydrating) {
7741
+ return element.shadowRoot;
7742
+ }
7743
+
7328
7744
  return element.attachShadow(options);
7329
7745
  },
7330
7746
  setText: function setText(node, content) {
@@ -7435,75 +7851,6 @@ var LWC = (function (exports) {
7435
7851
  getCustomElement: getCustomElement,
7436
7852
  HTMLElement: HTMLElementConstructor
7437
7853
  };
7438
- /*
7439
- * Copyright (c) 2018, salesforce.com, inc.
7440
- * All rights reserved.
7441
- * SPDX-License-Identifier: MIT
7442
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7443
- */
7444
-
7445
- /**
7446
- * This function builds a Web Component class from a LWC constructor so it can be
7447
- * registered as a new element via customElements.define() at any given time.
7448
- *
7449
- * @deprecated since version 1.3.11
7450
- *
7451
- * @example
7452
- * ```
7453
- * import { buildCustomElementConstructor } from 'lwc';
7454
- * import Foo from 'ns/foo';
7455
- * const WC = buildCustomElementConstructor(Foo);
7456
- * customElements.define('x-foo', WC);
7457
- * const elm = document.createElement('x-foo');
7458
- * ```
7459
- */
7460
-
7461
- function deprecatedBuildCustomElementConstructor(Ctor) {
7462
- if (process.env.NODE_ENV !== 'production') {
7463
- /* eslint-disable-next-line no-console */
7464
- 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."));
7465
- }
7466
-
7467
- return Ctor.CustomElementConstructor;
7468
- }
7469
-
7470
- function buildCustomElementConstructor(Ctor) {
7471
- var def = getComponentInternalDef(Ctor);
7472
- return /*#__PURE__*/function (_def$bridge) {
7473
- _inherits(_class, _def$bridge);
7474
-
7475
- var _super8 = _createSuper(_class);
7476
-
7477
- function _class() {
7478
- var _this6;
7479
-
7480
- _classCallCheck(this, _class);
7481
-
7482
- _this6 = _super8.call(this);
7483
- createVM(_assertThisInitialized(_this6), def, {
7484
- mode: 'open',
7485
- owner: null,
7486
- tagName: _this6.tagName,
7487
- renderer: renderer
7488
- });
7489
- return _this6;
7490
- }
7491
-
7492
- _createClass(_class, [{
7493
- key: "connectedCallback",
7494
- value: function connectedCallback() {
7495
- connectRootElement(this);
7496
- }
7497
- }, {
7498
- key: "disconnectedCallback",
7499
- value: function disconnectedCallback() {
7500
- disconnectRootElement(this);
7501
- }
7502
- }]);
7503
-
7504
- return _class;
7505
- }(def.bridge);
7506
- }
7507
7854
  /*
7508
7855
  * Copyright (c) 2018, salesforce.com, inc.
7509
7856
  * All rights reserved.
@@ -7513,7 +7860,6 @@ var LWC = (function (exports) {
7513
7860
  // TODO [#2472]: Remove this workaround when appropriate.
7514
7861
  // eslint-disable-next-line lwc-internal/no-global-node
7515
7862
 
7516
-
7517
7863
  var _Node$1 = Node;
7518
7864
  var ConnectingSlot = new WeakMap();
7519
7865
  var DisconnectingSlot = new WeakMap();
@@ -7623,6 +7969,142 @@ var LWC = (function (exports) {
7623
7969
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7624
7970
  */
7625
7971
 
7972
+
7973
+ function hydrateComponent(element, Ctor) {
7974
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7975
+
7976
+ if (!isFunction$1(Ctor)) {
7977
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
7978
+ }
7979
+
7980
+ if (!isObject(props) || isNull(props)) {
7981
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
7982
+ }
7983
+
7984
+ var def = getComponentInternalDef(Ctor);
7985
+
7986
+ try {
7987
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7988
+ // and uses the same algo to create the stylesheets as in SSR.
7989
+ setIsHydrating(true);
7990
+ createVM(element, def, {
7991
+ mode: 'open',
7992
+ owner: null,
7993
+ renderer: renderer,
7994
+ tagName: element.tagName.toLowerCase()
7995
+ });
7996
+
7997
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
7998
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
7999
+ key = _Object$entries2$_i[0],
8000
+ value = _Object$entries2$_i[1];
8001
+
8002
+ element[key] = value;
8003
+ }
8004
+
8005
+ hydrateRootElement(element); // set it back since now we finished hydration.
8006
+
8007
+ setIsHydrating(false);
8008
+ } catch (e) {
8009
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8010
+ // the client generated DOM.
8011
+
8012
+ /* eslint-disable-next-line no-console */
8013
+ console.error('Recovering from error while hydrating: ', e);
8014
+ setIsHydrating(false);
8015
+ var newElem = createElement(element.tagName, {
8016
+ is: Ctor,
8017
+ mode: 'open'
8018
+ });
8019
+
8020
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
8021
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
8022
+ _key3 = _Object$entries3$_i[0],
8023
+ _value2 = _Object$entries3$_i[1];
8024
+
8025
+ newElem[_key3] = _value2;
8026
+ }
8027
+
8028
+ element.parentNode.replaceChild(newElem, element);
8029
+ }
8030
+ }
8031
+ /*
8032
+ * Copyright (c) 2018, salesforce.com, inc.
8033
+ * All rights reserved.
8034
+ * SPDX-License-Identifier: MIT
8035
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8036
+ */
8037
+
8038
+ /**
8039
+ * This function builds a Web Component class from a LWC constructor so it can be
8040
+ * registered as a new element via customElements.define() at any given time.
8041
+ *
8042
+ * @deprecated since version 1.3.11
8043
+ *
8044
+ * @example
8045
+ * ```
8046
+ * import { buildCustomElementConstructor } from 'lwc';
8047
+ * import Foo from 'ns/foo';
8048
+ * const WC = buildCustomElementConstructor(Foo);
8049
+ * customElements.define('x-foo', WC);
8050
+ * const elm = document.createElement('x-foo');
8051
+ * ```
8052
+ */
8053
+
8054
+
8055
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8056
+ if (process.env.NODE_ENV !== 'production') {
8057
+ /* eslint-disable-next-line no-console */
8058
+ 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."));
8059
+ }
8060
+
8061
+ return Ctor.CustomElementConstructor;
8062
+ }
8063
+
8064
+ function buildCustomElementConstructor(Ctor) {
8065
+ var def = getComponentInternalDef(Ctor);
8066
+ return /*#__PURE__*/function (_def$bridge) {
8067
+ _inherits(_class, _def$bridge);
8068
+
8069
+ var _super8 = _createSuper(_class);
8070
+
8071
+ function _class() {
8072
+ var _this6;
8073
+
8074
+ _classCallCheck(this, _class);
8075
+
8076
+ _this6 = _super8.call(this);
8077
+ createVM(_assertThisInitialized(_this6), def, {
8078
+ mode: 'open',
8079
+ owner: null,
8080
+ tagName: _this6.tagName,
8081
+ renderer: renderer
8082
+ });
8083
+ return _this6;
8084
+ }
8085
+
8086
+ _createClass(_class, [{
8087
+ key: "connectedCallback",
8088
+ value: function connectedCallback() {
8089
+ connectRootElement(this);
8090
+ }
8091
+ }, {
8092
+ key: "disconnectedCallback",
8093
+ value: function disconnectedCallback() {
8094
+ disconnectRootElement(this);
8095
+ }
8096
+ }]);
8097
+
8098
+ return _class;
8099
+ }(def.bridge);
8100
+ }
8101
+ /*
8102
+ * Copyright (c) 2018, salesforce.com, inc.
8103
+ * All rights reserved.
8104
+ * SPDX-License-Identifier: MIT
8105
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8106
+ */
8107
+
7626
8108
  /**
7627
8109
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7628
8110
  * This API is subject to change or being removed.
@@ -7721,7 +8203,7 @@ var LWC = (function (exports) {
7721
8203
  });
7722
8204
  freeze(LightningElement);
7723
8205
  seal(LightningElement.prototype);
7724
- /* version: 2.5.4 */
8206
+ /* version: 2.5.8 */
7725
8207
 
7726
8208
  exports.LightningElement = LightningElement;
7727
8209
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7731,6 +8213,7 @@ var LWC = (function (exports) {
7731
8213
  exports.createElement = createElement;
7732
8214
  exports.getComponentConstructor = getComponentConstructor;
7733
8215
  exports.getComponentDef = getComponentDef;
8216
+ exports.hydrateComponent = hydrateComponent;
7734
8217
  exports.isComponentConstructor = isComponentConstructor;
7735
8218
  exports.isNodeFromTemplate = isNodeFromTemplate;
7736
8219
  exports.readonly = readonly;
@@ -7741,6 +8224,7 @@ var LWC = (function (exports) {
7741
8224
  exports.sanitizeAttribute = sanitizeAttribute;
7742
8225
  exports.setFeatureFlag = setFeatureFlag;
7743
8226
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
8227
+ exports.setHooks = setHooks;
7744
8228
  exports.swapComponent = swapComponent;
7745
8229
  exports.swapStyle = swapStyle;
7746
8230
  exports.swapTemplate = swapTemplate;