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
@@ -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.4 */
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.4 */
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.
@@ -3018,7 +3063,9 @@
3018
3063
  }
3019
3064
 
3020
3065
  return renderer[rendererMethod](elm);
3021
- }
3066
+ },
3067
+ configurable: true,
3068
+ enumerable: true
3022
3069
  };
3023
3070
  };
3024
3071
 
@@ -3041,7 +3088,10 @@
3041
3088
  }
3042
3089
 
3043
3090
  return renderer[queryMethod](elm, arg);
3044
- }
3091
+ },
3092
+ configurable: true,
3093
+ enumerable: true,
3094
+ writable: true
3045
3095
  };
3046
3096
  };
3047
3097
 
@@ -3642,15 +3692,14 @@
3642
3692
  return tpl;
3643
3693
  }
3644
3694
  /**
3645
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
3646
- * Service and other similar libraries to sanitize vulnerable attributes.
3647
- * This API is subject to change or being removed.
3695
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3696
+ * libraries to sanitize vulnerable attributes.
3648
3697
  */
3649
3698
 
3650
3699
 
3651
3700
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3652
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
3653
- // when ran off-core this function becomes a noop and returns the user authored value.
3701
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3702
+ // ran off-core this function becomes a noop and returns the user authored value.
3654
3703
  return attrValue;
3655
3704
  }
3656
3705
  /*
@@ -3935,12 +3984,12 @@
3935
3984
  function flattenStylesheets(stylesheets) {
3936
3985
  var list = [];
3937
3986
 
3938
- var _iterator = _createForOfIteratorHelper(stylesheets),
3939
- _step;
3987
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
3988
+ _step2;
3940
3989
 
3941
3990
  try {
3942
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3943
- var stylesheet = _step.value;
3991
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3992
+ var stylesheet = _step2.value;
3944
3993
 
3945
3994
  if (!Array.isArray(stylesheet)) {
3946
3995
  list.push(stylesheet);
@@ -3949,9 +3998,9 @@
3949
3998
  }
3950
3999
  }
3951
4000
  } catch (err) {
3952
- _iterator.e(err);
4001
+ _iterator2.e(err);
3953
4002
  } finally {
3954
- _iterator.f();
4003
+ _iterator2.f();
3955
4004
  }
3956
4005
 
3957
4006
  return list;
@@ -4215,7 +4264,7 @@
4215
4264
  if (!isUndefined$1(ctorShadowSupportMode)) {
4216
4265
  assert.invariant(ctorShadowSupportMode === "any"
4217
4266
  /* Any */
4218
- || ctorShadowSupportMode === "default"
4267
+ || ctorShadowSupportMode === "reset"
4219
4268
  /* Default */
4220
4269
  , "Invalid value for static property shadowSupportMode: '".concat(ctorShadowSupportMode, "'"));
4221
4270
  }
@@ -4373,7 +4422,7 @@
4373
4422
  renderMode: 1
4374
4423
  /* Shadow */
4375
4424
  ,
4376
- shadowSupportMode: "default"
4425
+ shadowSupportMode: "reset"
4377
4426
  /* Default */
4378
4427
  ,
4379
4428
  wire: EmptyObject,
@@ -4510,6 +4559,17 @@
4510
4559
  modComputedStyle.create(vnode);
4511
4560
  }
4512
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
+
4513
4573
  function fallbackElmHook(elm, vnode) {
4514
4574
  var owner = vnode.owner;
4515
4575
  setScopeTokenClassIfNecessary(elm, owner);
@@ -4659,6 +4719,174 @@
4659
4719
  }
4660
4720
  }
4661
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
+
4662
4890
  function updateCustomElmHook(oldVnode, vnode) {
4663
4891
  // Attrs need to be applied to element before props
4664
4892
  // IE11 will wipe out value on radio inputs if value
@@ -4766,7 +4994,26 @@
4766
4994
  update: updateNodeHook,
4767
4995
  insert: insertNodeHook,
4768
4996
  move: insertNodeHook,
4769
- 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
+ }
4770
5017
  };
4771
5018
  var CommentHook = {
4772
5019
  create: function create(vnode) {
@@ -4780,7 +5027,26 @@
4780
5027
  update: updateNodeHook,
4781
5028
  insert: insertNodeHook,
4782
5029
  move: insertNodeHook,
4783
- 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
+ }
4784
5050
  }; // insert is called after update, which is used somewhere else (via a module)
4785
5051
  // to mark the vm as inserted, that means we cannot use update as the main channel
4786
5052
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -4814,6 +5080,34 @@
4814
5080
  remove: function remove(vnode, parentNode) {
4815
5081
  removeNodeHook(vnode, parentNode);
4816
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
+ }
4817
5111
  }
4818
5112
  };
4819
5113
  var CustomElementHook = {
@@ -4901,6 +5195,42 @@
4901
5195
  // will take care of disconnecting any child VM attached to its shadow as well.
4902
5196
  removeVM(vm);
4903
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);
4904
5234
  }
4905
5235
  };
4906
5236
 
@@ -5101,7 +5431,7 @@
5101
5431
  next = iterator.next();
5102
5432
  last = next.done; // template factory logic based on the previous collected value
5103
5433
 
5104
- var vnode = factory(value, j, j === 0, last);
5434
+ var vnode = factory(value, j, j === 0, last === true);
5105
5435
 
5106
5436
  if (isArray$1(vnode)) {
5107
5437
  ArrayPush$1.apply(list, vnode);
@@ -5364,24 +5694,48 @@
5364
5694
  markAsDynamicChildren(vnodes);
5365
5695
  return vnodes;
5366
5696
  }
5697
+ /**
5698
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5699
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5700
+ * lwc:inner-html directive.
5701
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5702
+ */
5367
5703
 
5368
- var api = /*#__PURE__*/Object.freeze({
5369
- __proto__: null,
5370
- h: h,
5371
- ti: ti,
5704
+
5705
+ var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
5706
+ // locker-service patches this function during runtime to sanitize HTML content.
5707
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5708
+ };
5709
+ /**
5710
+ * Sets the sanitizeHtmlContentHook.
5711
+ */
5712
+
5713
+
5714
+ function setSanitizeHtmlContentHook(newHookImpl) {
5715
+ sanitizeHtmlContentHook = newHookImpl;
5716
+ } // [s]anitize [h]tml [c]ontent
5717
+
5718
+
5719
+ function shc(content) {
5720
+ return sanitizeHtmlContentHook(content);
5721
+ }
5722
+
5723
+ var api = freeze({
5372
5724
  s: s,
5725
+ h: h,
5373
5726
  c: c,
5374
5727
  i: i,
5375
5728
  f: f,
5376
5729
  t: t,
5377
- co: co,
5378
5730
  d: d,
5379
5731
  b: b,
5380
5732
  k: k,
5733
+ co: co,
5734
+ dc: dc,
5735
+ ti: ti,
5381
5736
  gid: gid,
5382
5737
  fid: fid,
5383
- dc: dc,
5384
- sc: sc
5738
+ shc: shc
5385
5739
  });
5386
5740
  /*
5387
5741
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5395,12 +5749,12 @@
5395
5749
  }
5396
5750
 
5397
5751
  function createInlineStyleVNode(content) {
5398
- return h('style', {
5752
+ return api.h('style', {
5399
5753
  key: 'style',
5400
5754
  attrs: {
5401
5755
  type: 'text/css'
5402
5756
  }
5403
- }, [t(content)]);
5757
+ }, [api.t(content)]);
5404
5758
  }
5405
5759
 
5406
5760
  function updateStylesheetToken(vm, template) {
@@ -5461,8 +5815,8 @@
5461
5815
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5462
5816
  var content = [];
5463
5817
 
5464
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
5465
- var stylesheet = stylesheets[_i14];
5818
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5819
+ var stylesheet = stylesheets[_i16];
5466
5820
 
5467
5821
  if (isArray$1(stylesheet)) {
5468
5822
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -5538,10 +5892,13 @@
5538
5892
  && shadowMode === 1
5539
5893
  /* Synthetic */
5540
5894
  ) {
5541
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
5542
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
5895
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5896
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
5543
5897
  }
5544
- } 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.
5545
5902
  // native shadow or light DOM, SSR
5546
5903
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5547
5904
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -5550,12 +5907,12 @@
5550
5907
  var root = getNearestNativeShadowComponent(vm);
5551
5908
  var isGlobal = isNull(root);
5552
5909
 
5553
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5910
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
5554
5911
  if (isGlobal) {
5555
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
5912
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
5556
5913
  } else {
5557
5914
  // local level
5558
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
5915
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
5559
5916
  }
5560
5917
  }
5561
5918
  }
@@ -5832,8 +6189,8 @@
5832
6189
  var stylesheets = template.stylesheets;
5833
6190
 
5834
6191
  if (!isUndefined$1(stylesheets)) {
5835
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5836
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
6192
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6193
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
5837
6194
  return true;
5838
6195
  }
5839
6196
  }
@@ -6063,8 +6420,8 @@
6063
6420
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6064
6421
  }
6065
6422
 
6066
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
6067
- var hookName = hooks[_i18];
6423
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6424
+ var hookName = hooks[_i20];
6068
6425
 
6069
6426
  if (hookName in service) {
6070
6427
  var l = Services[hookName];
@@ -6087,8 +6444,8 @@
6087
6444
  def = vm.def,
6088
6445
  context = vm.context;
6089
6446
 
6090
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
6091
- 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);
6092
6449
  }
6093
6450
  }
6094
6451
  /*
@@ -6141,6 +6498,12 @@
6141
6498
  , vm);
6142
6499
  }
6143
6500
 
6501
+ function hydrateRootElement(elm) {
6502
+ var vm = getAssociatedVM(elm);
6503
+ runConnectedCallback(vm);
6504
+ hydrateVM(vm);
6505
+ }
6506
+
6144
6507
  function disconnectRootElement(elm) {
6145
6508
  var vm = getAssociatedVM(elm);
6146
6509
  resetComponentStateWhenRemoved(vm);
@@ -6148,6 +6511,10 @@
6148
6511
 
6149
6512
  function appendVM(vm) {
6150
6513
  rehydrate(vm);
6514
+ }
6515
+
6516
+ function hydrateVM(vm) {
6517
+ hydrate(vm);
6151
6518
  } // just in case the component comes back, with this we guarantee re-rendering it
6152
6519
  // while preventing any attempt to rehydration until after reinsertion.
6153
6520
 
@@ -6371,6 +6738,22 @@
6371
6738
  }
6372
6739
  }
6373
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
+
6374
6757
  function patchShadowRoot(vm, newCh) {
6375
6758
  var oldCh = vm.children; // caching the new children collection
6376
6759
 
@@ -6451,19 +6834,19 @@
6451
6834
  });
6452
6835
  rehydrateQueue = []; // reset to a new queue
6453
6836
 
6454
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
6455
- var vm = vms[_i20];
6837
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
6838
+ var vm = vms[_i22];
6456
6839
 
6457
6840
  try {
6458
6841
  rehydrate(vm);
6459
6842
  } catch (error) {
6460
- if (_i20 + 1 < _len7) {
6843
+ if (_i22 + 1 < _len7) {
6461
6844
  // pieces of the queue are still pending to be rehydrated, those should have priority
6462
6845
  if (rehydrateQueue.length === 0) {
6463
6846
  addCallbackToNextTick(flushRehydrationQueue);
6464
6847
  }
6465
6848
 
6466
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
6849
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
6467
6850
  } // we need to end the measure before throwing.
6468
6851
 
6469
6852
 
@@ -6567,8 +6950,8 @@
6567
6950
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
6568
6951
  // inserted in reserved order.
6569
6952
 
6570
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
6571
- 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:
6572
6955
  // * when there is an error during the construction phase, and an error
6573
6956
  // boundary picks it, there is a possibility that the VCustomElement
6574
6957
  // is not properly initialized, and therefore is should be ignored.
@@ -6602,8 +6985,8 @@
6602
6985
 
6603
6986
 
6604
6987
  function recursivelyDisconnectChildren(vnodes) {
6605
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
6606
- var vnode = vnodes[_i22];
6988
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
6989
+ var vnode = vnodes[_i24];
6607
6990
 
6608
6991
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
6609
6992
  // vnode is a VElement with children
@@ -6627,8 +7010,8 @@
6627
7010
  renderer = vm.renderer;
6628
7011
  var rootNode = getRenderRoot(vm);
6629
7012
 
6630
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
6631
- var child = children[_i23];
7013
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
7014
+ var child = children[_i25];
6632
7015
 
6633
7016
  if (!isNull(child) && !isUndefined$1(child.elm)) {
6634
7017
  renderer.remove(child.elm, rootNode);
@@ -6673,8 +7056,8 @@
6673
7056
  var oldSlots = vm.cmpSlots;
6674
7057
  var cmpSlots = vm.cmpSlots = create(null);
6675
7058
 
6676
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
6677
- var vnode = children[_i24];
7059
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
7060
+ var vnode = children[_i26];
6678
7061
 
6679
7062
  if (isNull(vnode)) {
6680
7063
  continue;
@@ -6704,8 +7087,8 @@
6704
7087
  return;
6705
7088
  }
6706
7089
 
6707
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
6708
- var key = oldKeys[_i25];
7090
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
7091
+ var key = oldKeys[_i27];
6709
7092
 
6710
7093
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
6711
7094
  markComponentAsDirty(vm);
@@ -7068,8 +7451,8 @@
7068
7451
  function connectWireAdapters(vm) {
7069
7452
  var wiredConnecting = vm.context.wiredConnecting;
7070
7453
 
7071
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
7072
- wiredConnecting[_i26]();
7454
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
7455
+ wiredConnecting[_i28]();
7073
7456
  }
7074
7457
  }
7075
7458
 
@@ -7077,8 +7460,8 @@
7077
7460
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7078
7461
  runWithBoundaryProtection(vm, vm, noop, function () {
7079
7462
  // job
7080
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
7081
- wiredDisconnecting[_i27]();
7463
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
7464
+ wiredDisconnecting[_i29]();
7082
7465
  }
7083
7466
  }, noop);
7084
7467
  }
@@ -7153,7 +7536,22 @@
7153
7536
 
7154
7537
  return reactiveMembrane.getReadOnlyProxy(obj);
7155
7538
  }
7156
- /* version: 2.5.4 */
7539
+ /*
7540
+ * Copyright (c) 2018, salesforce.com, inc.
7541
+ * All rights reserved.
7542
+ * SPDX-License-Identifier: MIT
7543
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7544
+ */
7545
+
7546
+
7547
+ var hooksAreSet = false;
7548
+
7549
+ function setHooks(hooks) {
7550
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7551
+ hooksAreSet = true;
7552
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7553
+ }
7554
+ /* version: 2.5.8 */
7157
7555
 
7158
7556
  /*
7159
7557
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7168,15 +7566,18 @@
7168
7566
  if (process.env.NODE_ENV === 'development') {
7169
7567
  // @ts-ignore
7170
7568
  window.__lwcResetGlobalStylesheets = function () {
7171
- for (var _i28 = 0, _Object$keys = Object.keys(globalStylesheets); _i28 < _Object$keys.length; _i28++) {
7172
- 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];
7173
7571
  delete globalStylesheets[key];
7174
7572
  }
7175
7573
  };
7176
7574
  }
7177
7575
 
7178
- var globalStylesheetsParentElement = document.head || document.body || document;
7179
- var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync);
7576
+ var globalStylesheetsParentElement = document.head || document.body || document; // This check for constructable stylesheets is similar to Fast's:
7577
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
7578
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7579
+
7580
+ var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7180
7581
  var styleElements = create(null);
7181
7582
  var styleSheets = create(null);
7182
7583
  var nodesToStyleSheets = new WeakMap();
@@ -7305,8 +7706,19 @@
7305
7706
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7306
7707
  }
7307
7708
 
7709
+ var isHydrating = false;
7710
+
7711
+ function setIsHydrating(v) {
7712
+ isHydrating = v;
7713
+ }
7714
+
7308
7715
  var renderer = {
7309
7716
  ssr: false,
7717
+
7718
+ get isHydrating() {
7719
+ return isHydrating;
7720
+ },
7721
+
7310
7722
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7311
7723
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7312
7724
  createElement: function createElement(tagName, namespace) {
@@ -7328,6 +7740,10 @@
7328
7740
  return node.nextSibling;
7329
7741
  },
7330
7742
  attachShadow: function attachShadow(element, options) {
7743
+ if (isHydrating) {
7744
+ return element.shadowRoot;
7745
+ }
7746
+
7331
7747
  return element.attachShadow(options);
7332
7748
  },
7333
7749
  setText: function setText(node, content) {
@@ -7438,75 +7854,6 @@
7438
7854
  getCustomElement: getCustomElement,
7439
7855
  HTMLElement: HTMLElementConstructor
7440
7856
  };
7441
- /*
7442
- * Copyright (c) 2018, salesforce.com, inc.
7443
- * All rights reserved.
7444
- * SPDX-License-Identifier: MIT
7445
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7446
- */
7447
-
7448
- /**
7449
- * This function builds a Web Component class from a LWC constructor so it can be
7450
- * registered as a new element via customElements.define() at any given time.
7451
- *
7452
- * @deprecated since version 1.3.11
7453
- *
7454
- * @example
7455
- * ```
7456
- * import { buildCustomElementConstructor } from 'lwc';
7457
- * import Foo from 'ns/foo';
7458
- * const WC = buildCustomElementConstructor(Foo);
7459
- * customElements.define('x-foo', WC);
7460
- * const elm = document.createElement('x-foo');
7461
- * ```
7462
- */
7463
-
7464
- function deprecatedBuildCustomElementConstructor(Ctor) {
7465
- if (process.env.NODE_ENV !== 'production') {
7466
- /* eslint-disable-next-line no-console */
7467
- 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."));
7468
- }
7469
-
7470
- return Ctor.CustomElementConstructor;
7471
- }
7472
-
7473
- function buildCustomElementConstructor(Ctor) {
7474
- var def = getComponentInternalDef(Ctor);
7475
- return /*#__PURE__*/function (_def$bridge) {
7476
- _inherits(_class, _def$bridge);
7477
-
7478
- var _super8 = _createSuper(_class);
7479
-
7480
- function _class() {
7481
- var _this6;
7482
-
7483
- _classCallCheck(this, _class);
7484
-
7485
- _this6 = _super8.call(this);
7486
- createVM(_assertThisInitialized(_this6), def, {
7487
- mode: 'open',
7488
- owner: null,
7489
- tagName: _this6.tagName,
7490
- renderer: renderer
7491
- });
7492
- return _this6;
7493
- }
7494
-
7495
- _createClass(_class, [{
7496
- key: "connectedCallback",
7497
- value: function connectedCallback() {
7498
- connectRootElement(this);
7499
- }
7500
- }, {
7501
- key: "disconnectedCallback",
7502
- value: function disconnectedCallback() {
7503
- disconnectRootElement(this);
7504
- }
7505
- }]);
7506
-
7507
- return _class;
7508
- }(def.bridge);
7509
- }
7510
7857
  /*
7511
7858
  * Copyright (c) 2018, salesforce.com, inc.
7512
7859
  * All rights reserved.
@@ -7516,7 +7863,6 @@
7516
7863
  // TODO [#2472]: Remove this workaround when appropriate.
7517
7864
  // eslint-disable-next-line lwc-internal/no-global-node
7518
7865
 
7519
-
7520
7866
  var _Node$1 = Node;
7521
7867
  var ConnectingSlot = new WeakMap();
7522
7868
  var DisconnectingSlot = new WeakMap();
@@ -7626,6 +7972,142 @@
7626
7972
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7627
7973
  */
7628
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
+
7629
8111
  /**
7630
8112
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7631
8113
  * This API is subject to change or being removed.
@@ -7724,7 +8206,7 @@
7724
8206
  });
7725
8207
  freeze(LightningElement);
7726
8208
  seal(LightningElement.prototype);
7727
- /* version: 2.5.4 */
8209
+ /* version: 2.5.8 */
7728
8210
 
7729
8211
  exports.LightningElement = LightningElement;
7730
8212
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7734,6 +8216,7 @@
7734
8216
  exports.createElement = createElement;
7735
8217
  exports.getComponentConstructor = getComponentConstructor;
7736
8218
  exports.getComponentDef = getComponentDef;
8219
+ exports.hydrateComponent = hydrateComponent;
7737
8220
  exports.isComponentConstructor = isComponentConstructor;
7738
8221
  exports.isNodeFromTemplate = isNodeFromTemplate;
7739
8222
  exports.readonly = readonly;
@@ -7744,6 +8227,7 @@
7744
8227
  exports.sanitizeAttribute = sanitizeAttribute;
7745
8228
  exports.setFeatureFlag = setFeatureFlag;
7746
8229
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
8230
+ exports.setHooks = setHooks;
7747
8231
  exports.swapComponent = swapComponent;
7748
8232
  exports.swapStyle = swapStyle;
7749
8233
  exports.swapTemplate = swapTemplate;