lwc 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +309 -263
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +309 -263
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +264 -126
  5. package/dist/engine-dom/iife/es5/engine-dom.js +1104 -1047
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +391 -181
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +309 -263
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +264 -126
  11. package/dist/engine-dom/umd/es5/engine-dom.js +1104 -1047
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +391 -181
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +14 -11
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +14 -11
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +10 -10
@@ -52,6 +52,8 @@
52
52
 
53
53
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
54
54
 
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
+
55
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); }
56
58
 
57
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; }
@@ -348,7 +350,7 @@
348
350
  var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
349
351
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
350
352
  var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
351
- /** version: 2.11.0 */
353
+ /** version: 2.12.0 */
352
354
 
353
355
  /*
354
356
  * Copyright (c) 2018, salesforce.com, inc.
@@ -518,7 +520,7 @@
518
520
 
519
521
  function setFeatureFlagForTest(name, value) {
520
522
  }
521
- /** version: 2.11.0 */
523
+ /** version: 2.12.0 */
522
524
 
523
525
  /* proxy-compat-disable */
524
526
 
@@ -561,6 +563,42 @@
561
563
 
562
564
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
563
565
  } // Borrowed from Vue template compiler.
566
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
567
+
568
+
569
+ var DECLARATION_DELIMITER = /;(?![^(]*\))/g;
570
+ var PROPERTY_DELIMITER = /:(.+)/;
571
+
572
+ function parseStyleText(cssText) {
573
+ var styleMap = {};
574
+ var declarations = cssText.split(DECLARATION_DELIMITER);
575
+
576
+ var _iterator = _createForOfIteratorHelper(declarations),
577
+ _step;
578
+
579
+ try {
580
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
581
+ var declaration = _step.value;
582
+
583
+ if (declaration) {
584
+ var _declaration$split = declaration.split(PROPERTY_DELIMITER),
585
+ _declaration$split2 = _slicedToArray(_declaration$split, 2),
586
+ prop = _declaration$split2[0],
587
+ value = _declaration$split2[1];
588
+
589
+ if (prop !== undefined && value !== undefined) {
590
+ styleMap[prop.trim()] = value.trim();
591
+ }
592
+ }
593
+ }
594
+ } catch (err) {
595
+ _iterator.e(err);
596
+ } finally {
597
+ _iterator.f();
598
+ }
599
+
600
+ return styleMap;
601
+ } // Make a shallow copy of an object but omit the given key
564
602
 
565
603
 
566
604
  function cloneAndOmitKey(object, keyToOmit) {
@@ -1033,8 +1071,8 @@
1033
1071
  }
1034
1072
  }
1035
1073
 
1036
- function logWarn(message, vm) {
1037
- log('warn', message, vm);
1074
+ function logError(message, vm) {
1075
+ log('error', message, vm);
1038
1076
  }
1039
1077
  /*
1040
1078
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4952,12 +4990,17 @@
4952
4990
  * will prevent this function from being imported by userland code.
4953
4991
  */
4954
4992
 
4955
- function registerComponent(Ctor, _ref2) {
4993
+ function registerComponent( // We typically expect a LightningElementConstructor, but technically you can call this with anything
4994
+ Ctor, _ref2) {
4956
4995
  var tmpl = _ref2.tmpl;
4957
4996
 
4958
- signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
4997
+ if (isFunction$1(Ctor)) {
4998
+
4999
+ signedTemplateMap.set(Ctor, tmpl);
5000
+ } // chaining this method as a way to wrap existing assignment of component constructor easily,
4959
5001
  // without too much transformation
4960
5002
 
5003
+
4961
5004
  return Ctor;
4962
5005
  }
4963
5006
 
@@ -5052,140 +5095,6 @@
5052
5095
  cbs[_i22].call(undefined, component, {}, def, context);
5053
5096
  }
5054
5097
  }
5055
- /*
5056
- * Copyright (c) 2022, salesforce.com, inc.
5057
- * All rights reserved.
5058
- * SPDX-License-Identifier: MIT
5059
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5060
- */
5061
-
5062
-
5063
- function hydrate(vnode, node) {
5064
- switch (vnode.type) {
5065
- case 0
5066
- /* Text */
5067
- :
5068
- hydrateText(vnode, node);
5069
- break;
5070
-
5071
- case 1
5072
- /* Comment */
5073
- :
5074
- hydrateComment(vnode, node);
5075
- break;
5076
-
5077
- case 2
5078
- /* Element */
5079
- :
5080
- hydrateElement(vnode, node);
5081
- break;
5082
-
5083
- case 3
5084
- /* CustomElement */
5085
- :
5086
- hydrateCustomElement(vnode, node);
5087
- break;
5088
- }
5089
- }
5090
-
5091
- function hydrateText(vnode, node) {
5092
- var _a;
5093
-
5094
-
5095
- setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5096
- vnode.elm = node;
5097
- }
5098
-
5099
- function hydrateComment(vnode, node) {
5100
- var _a;
5101
-
5102
-
5103
- setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5104
- vnode.elm = node;
5105
- }
5106
-
5107
- function hydrateElement(vnode, node) {
5108
-
5109
- var elm = node;
5110
- vnode.elm = elm;
5111
- var context = vnode.data.context;
5112
- var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5113
- /* Manual */
5114
- );
5115
-
5116
- if (isDomManual) {
5117
- // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5118
- // remove the innerHTML from props so it reuses the existing dom elements.
5119
- var props = vnode.data.props;
5120
-
5121
- if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5122
- if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
5123
- // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5124
- vnode.data = Object.assign(Object.assign({}, vnode.data), {
5125
- props: cloneAndOmitKey(props, 'innerHTML')
5126
- });
5127
- } else {
5128
- logWarn("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5129
- }
5130
- }
5131
- }
5132
-
5133
- patchElementPropsAndAttrs(vnode);
5134
-
5135
- if (!isDomManual) {
5136
- hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
5137
- }
5138
- }
5139
-
5140
- function hydrateCustomElement(vnode, node) {
5141
-
5142
- var elm = node;
5143
- var sel = vnode.sel,
5144
- mode = vnode.mode,
5145
- ctor = vnode.ctor,
5146
- owner = vnode.owner;
5147
- var vm = createVM(elm, ctor, {
5148
- mode: mode,
5149
- owner: owner,
5150
- tagName: sel
5151
- });
5152
- vnode.elm = elm;
5153
- vnode.vm = vm;
5154
- allocateChildren(vnode, vm);
5155
- patchElementPropsAndAttrs(vnode); // Insert hook section:
5156
-
5157
- runConnectedCallback(vm);
5158
-
5159
- if (vm.renderMode !== 0
5160
- /* Light */
5161
- ) {
5162
- // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5163
- // Note: for Light DOM, this is handled while hydrating the VM
5164
- hydrateChildren(getChildNodes$1(vnode.elm), vnode.children);
5165
- }
5166
-
5167
- hydrateVM(vm);
5168
- }
5169
-
5170
- function hydrateChildren(elmChildren, children, vm) {
5171
-
5172
- var childNodeIndex = 0;
5173
-
5174
- for (var _i23 = 0; _i23 < children.length; _i23++) {
5175
- var childVnode = children[_i23];
5176
-
5177
- if (!isNull(childVnode)) {
5178
- var childNode = elmChildren[childNodeIndex];
5179
- hydrate(childVnode, childNode);
5180
- childNodeIndex++;
5181
- }
5182
- }
5183
- }
5184
-
5185
- function patchElementPropsAndAttrs(vnode) {
5186
- applyEventListeners(vnode);
5187
- patchProps(null, vnode);
5188
- }
5189
5098
  /*
5190
5099
  * Copyright (c) 2018, salesforce.com, inc.
5191
5100
  * All rights reserved.
@@ -5236,12 +5145,6 @@
5236
5145
  , vm);
5237
5146
  }
5238
5147
 
5239
- function hydrateRootElement(elm) {
5240
- var vm = getAssociatedVM(elm);
5241
- runConnectedCallback(vm);
5242
- hydrateVM(vm);
5243
- }
5244
-
5245
5148
  function disconnectRootElement(elm) {
5246
5149
  var vm = getAssociatedVM(elm);
5247
5150
  resetComponentStateWhenRemoved(vm);
@@ -5249,22 +5152,6 @@
5249
5152
 
5250
5153
  function appendVM(vm) {
5251
5154
  rehydrate(vm);
5252
- }
5253
-
5254
- function hydrateVM(vm) {
5255
- if (isTrue(vm.isDirty)) {
5256
- // manually diffing/patching here.
5257
- // This routine is:
5258
- // patchShadowRoot(vm, children);
5259
- // -> addVnodes.
5260
- var children = renderComponent(vm);
5261
- vm.children = children;
5262
- var vmChildren = vm.renderMode === 0
5263
- /* Light */
5264
- ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
5265
- hydrateChildren(vmChildren, children);
5266
- runRenderedCallback(vm);
5267
- }
5268
5155
  } // just in case the component comes back, with this we guarantee re-rendering it
5269
5156
  // while preventing any attempt to rehydration until after reinsertion.
5270
5157
 
@@ -5530,19 +5417,19 @@
5530
5417
  });
5531
5418
  rehydrateQueue = []; // reset to a new queue
5532
5419
 
5533
- for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
5534
- var vm = vms[_i26];
5420
+ for (var _i23 = 0, _len8 = vms.length; _i23 < _len8; _i23 += 1) {
5421
+ var vm = vms[_i23];
5535
5422
 
5536
5423
  try {
5537
5424
  rehydrate(vm);
5538
5425
  } catch (error) {
5539
- if (_i26 + 1 < _len8) {
5426
+ if (_i23 + 1 < _len8) {
5540
5427
  // pieces of the queue are still pending to be rehydrated, those should have priority
5541
5428
  if (rehydrateQueue.length === 0) {
5542
5429
  addCallbackToNextTick(flushRehydrationQueue);
5543
5430
  }
5544
5431
 
5545
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i26 + 1));
5432
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i23 + 1));
5546
5433
  } // we need to end the measure before throwing.
5547
5434
 
5548
5435
 
@@ -5641,8 +5528,8 @@
5641
5528
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5642
5529
  // inserted in reserved order.
5643
5530
 
5644
- for (var _i27 = vCustomElementCollection.length - 1; _i27 >= 0; _i27 -= 1) {
5645
- var elm = vCustomElementCollection[_i27].elm; // There are two cases where the element could be undefined:
5531
+ for (var _i24 = vCustomElementCollection.length - 1; _i24 >= 0; _i24 -= 1) {
5532
+ var elm = vCustomElementCollection[_i24].elm; // There are two cases where the element could be undefined:
5646
5533
  // * when there is an error during the construction phase, and an error
5647
5534
  // boundary picks it, there is a possibility that the VCustomElement
5648
5535
  // is not properly initialized, and therefore is should be ignored.
@@ -5676,8 +5563,8 @@
5676
5563
 
5677
5564
 
5678
5565
  function recursivelyDisconnectChildren(vnodes) {
5679
- for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
5680
- var vnode = vnodes[_i28];
5566
+ for (var _i25 = 0, _len9 = vnodes.length; _i25 < _len9; _i25 += 1) {
5567
+ var vnode = vnodes[_i25];
5681
5568
 
5682
5569
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
5683
5570
  switch (vnode.type) {
@@ -5708,8 +5595,8 @@
5708
5595
  var children = vm.children,
5709
5596
  renderRoot = vm.renderRoot;
5710
5597
 
5711
- for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
5712
- var child = children[_i29];
5598
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26++) {
5599
+ var child = children[_i26];
5713
5600
 
5714
5601
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5715
5602
  remove$1(child.elm, renderRoot);
@@ -6059,8 +5946,8 @@
6059
5946
  function connectWireAdapters(vm) {
6060
5947
  var wiredConnecting = vm.context.wiredConnecting;
6061
5948
 
6062
- for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
6063
- wiredConnecting[_i30]();
5949
+ for (var _i27 = 0, _len11 = wiredConnecting.length; _i27 < _len11; _i27 += 1) {
5950
+ wiredConnecting[_i27]();
6064
5951
  }
6065
5952
  }
6066
5953
 
@@ -6068,8 +5955,8 @@
6068
5955
  var wiredDisconnecting = vm.context.wiredDisconnecting;
6069
5956
  runWithBoundaryProtection(vm, vm, noop, function () {
6070
5957
  // job
6071
- for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
6072
- wiredDisconnecting[_i31]();
5958
+ for (var _i28 = 0, _len12 = wiredDisconnecting.length; _i28 < _len12; _i28 += 1) {
5959
+ wiredDisconnecting[_i28]();
6073
5960
  }
6074
5961
  }, noop);
6075
5962
  }
@@ -6139,6 +6026,327 @@
6139
6026
 
6140
6027
  return reactiveMembrane.getReadOnlyProxy(obj);
6141
6028
  }
6029
+ /*
6030
+ * Copyright (c) 2022, salesforce.com, inc.
6031
+ * All rights reserved.
6032
+ * SPDX-License-Identifier: MIT
6033
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6034
+ */
6035
+ // flag indicating if the hydration recovered from the DOM mismatch
6036
+
6037
+
6038
+ var hasMismatch = false;
6039
+
6040
+ function hydrateRoot(vm) {
6041
+ hasMismatch = false;
6042
+ runConnectedCallback(vm);
6043
+ hydrateVM(vm);
6044
+
6045
+ if (hasMismatch) {
6046
+ logError('Hydration completed with errors.', vm);
6047
+ }
6048
+ }
6049
+
6050
+ function hydrateVM(vm) {
6051
+ var children = renderComponent(vm);
6052
+ vm.children = children;
6053
+ var parentNode = vm.renderRoot;
6054
+ hydrateChildren(getFirstChild$1(parentNode), children, parentNode);
6055
+ runRenderedCallback(vm);
6056
+ }
6057
+
6058
+ function hydrateNode(node, vnode) {
6059
+ var hydratedNode;
6060
+
6061
+ switch (vnode.type) {
6062
+ case 0
6063
+ /* Text */
6064
+ :
6065
+ hydratedNode = hydrateText(node, vnode);
6066
+ break;
6067
+
6068
+ case 1
6069
+ /* Comment */
6070
+ :
6071
+ hydratedNode = hydrateComment(node, vnode);
6072
+ break;
6073
+
6074
+ case 2
6075
+ /* Element */
6076
+ :
6077
+ hydratedNode = hydrateElement(node, vnode);
6078
+ break;
6079
+
6080
+ case 3
6081
+ /* CustomElement */
6082
+ :
6083
+ hydratedNode = hydrateCustomElement(node, vnode);
6084
+ break;
6085
+ }
6086
+
6087
+ return nextSibling$1(hydratedNode);
6088
+ }
6089
+
6090
+ function hydrateText(node, vnode) {
6091
+ var _a;
6092
+
6093
+ if (!hasCorrectNodeType(vnode, node, 3
6094
+ /* TEXT */
6095
+ )) {
6096
+ return handleMismatch(node, vnode);
6097
+ }
6098
+
6099
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6100
+ vnode.elm = node;
6101
+ return node;
6102
+ }
6103
+
6104
+ function hydrateComment(node, vnode) {
6105
+ var _a;
6106
+
6107
+ if (!hasCorrectNodeType(vnode, node, 8
6108
+ /* COMMENT */
6109
+ )) {
6110
+ return handleMismatch(node, vnode);
6111
+ }
6112
+
6113
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6114
+ vnode.elm = node;
6115
+ return node;
6116
+ }
6117
+
6118
+ function hydrateElement(elm, vnode) {
6119
+ if (!hasCorrectNodeType(vnode, elm, 1
6120
+ /* ELEMENT */
6121
+ ) || !isMatchingElement(vnode, elm)) {
6122
+ return handleMismatch(elm, vnode);
6123
+ }
6124
+
6125
+ vnode.elm = elm;
6126
+ var context = vnode.data.context;
6127
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
6128
+ /* Manual */
6129
+ );
6130
+
6131
+ if (isDomManual) {
6132
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
6133
+ // remove the innerHTML from props so it reuses the existing dom elements.
6134
+ var props = vnode.data.props;
6135
+
6136
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6137
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6138
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6139
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
6140
+ props: cloneAndOmitKey(props, 'innerHTML')
6141
+ });
6142
+ }
6143
+ }
6144
+ }
6145
+
6146
+ patchElementPropsAndAttrs(vnode);
6147
+
6148
+ if (!isDomManual) {
6149
+ hydrateChildren(getFirstChild$1(elm), vnode.children, elm, vnode.owner);
6150
+ }
6151
+
6152
+ return elm;
6153
+ }
6154
+
6155
+ function hydrateCustomElement(elm, vnode) {
6156
+ if (!hasCorrectNodeType(vnode, elm, 1
6157
+ /* ELEMENT */
6158
+ ) || !isMatchingElement(vnode, elm)) {
6159
+ return handleMismatch(elm, vnode);
6160
+ }
6161
+
6162
+ var sel = vnode.sel,
6163
+ mode = vnode.mode,
6164
+ ctor = vnode.ctor,
6165
+ owner = vnode.owner;
6166
+ var vm = createVM(elm, ctor, {
6167
+ mode: mode,
6168
+ owner: owner,
6169
+ tagName: sel
6170
+ });
6171
+ vnode.elm = elm;
6172
+ vnode.vm = vm;
6173
+ allocateChildren(vnode, vm);
6174
+ patchElementPropsAndAttrs(vnode); // Insert hook section:
6175
+
6176
+ runConnectedCallback(vm);
6177
+
6178
+ if (vm.renderMode !== 0
6179
+ /* Light */
6180
+ ) {
6181
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6182
+ // Note: for Light DOM, this is handled while hydrating the VM
6183
+ hydrateChildren(getFirstChild$1(elm), vnode.children, elm);
6184
+ }
6185
+
6186
+ hydrateVM(vm);
6187
+ return elm;
6188
+ }
6189
+
6190
+ function hydrateChildren(node, children, parentNode, owner) {
6191
+ var nextNode = node;
6192
+ var anchor = null;
6193
+
6194
+ for (var _i29 = 0; _i29 < children.length; _i29++) {
6195
+ var childVnode = children[_i29];
6196
+
6197
+ if (!isNull(childVnode)) {
6198
+ if (nextNode) {
6199
+ nextNode = hydrateNode(nextNode, childVnode);
6200
+ anchor = childVnode.elm;
6201
+ } else {
6202
+ hasMismatch = true;
6203
+
6204
+ mount(childVnode, parentNode, anchor);
6205
+ anchor = childVnode.elm;
6206
+ }
6207
+ }
6208
+ }
6209
+
6210
+ if (nextNode) {
6211
+ hasMismatch = true;
6212
+
6213
+ do {
6214
+ var current = nextNode;
6215
+ nextNode = nextSibling$1(nextNode);
6216
+ removeNode(current, parentNode);
6217
+ } while (nextNode);
6218
+ }
6219
+ }
6220
+
6221
+ function handleMismatch(node, vnode, msg) {
6222
+ hasMismatch = true;
6223
+
6224
+ var parentNode = getProperty$1(node, 'parentNode');
6225
+ mount(vnode, parentNode, node);
6226
+ removeNode(node, parentNode);
6227
+ return vnode.elm;
6228
+ }
6229
+
6230
+ function patchElementPropsAndAttrs(vnode) {
6231
+ applyEventListeners(vnode);
6232
+ patchProps(null, vnode);
6233
+ }
6234
+
6235
+ function hasCorrectNodeType(vnode, node, nodeType) {
6236
+ if (getProperty$1(node, 'nodeType') !== nodeType) {
6237
+
6238
+ return false;
6239
+ }
6240
+
6241
+ return true;
6242
+ }
6243
+
6244
+ function isMatchingElement(vnode, elm) {
6245
+ if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
6246
+
6247
+ return false;
6248
+ }
6249
+
6250
+ var hasIncompatibleAttrs = validateAttrs(vnode, elm);
6251
+ var hasIncompatibleClass = validateClassAttr(vnode, elm);
6252
+ var hasIncompatibleStyle = validateStyleAttr(vnode, elm);
6253
+ return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6254
+ }
6255
+
6256
+ function validateAttrs(vnode, elm) {
6257
+ var _vnode$data$attrs = vnode.data.attrs,
6258
+ attrs = _vnode$data$attrs === void 0 ? {} : _vnode$data$attrs;
6259
+ var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
6260
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6261
+
6262
+ for (var _i30 = 0, _Object$entries = Object.entries(attrs); _i30 < _Object$entries.length; _i30++) {
6263
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i30], 2),
6264
+ attrName = _Object$entries$_i[0],
6265
+ attrValue = _Object$entries$_i[1];
6266
+
6267
+ var elmAttrValue = getAttribute$1(elm, attrName);
6268
+
6269
+ if (String(attrValue) !== elmAttrValue) {
6270
+
6271
+ nodesAreCompatible = false;
6272
+ }
6273
+ }
6274
+
6275
+ return nodesAreCompatible;
6276
+ }
6277
+
6278
+ function validateClassAttr(vnode, elm) {
6279
+ var _vnode$data = vnode.data,
6280
+ className = _vnode$data.className,
6281
+ classMap = _vnode$data.classMap;
6282
+ var nodesAreCompatible = true;
6283
+
6284
+ if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6285
+ // className is used when class is bound to an expr.
6286
+ nodesAreCompatible = false;
6287
+ } else if (!isUndefined$1(classMap)) {
6288
+ // classMap is used when class is set to static value.
6289
+ var classList = getClassList$1(elm);
6290
+ var computedClassName = ''; // all classes from the vnode should be in the element.classList
6291
+
6292
+ for (var name in classMap) {
6293
+ computedClassName += ' ' + name;
6294
+
6295
+ if (!classList.contains(name)) {
6296
+ nodesAreCompatible = false;
6297
+ }
6298
+ }
6299
+
6300
+ computedClassName.trim();
6301
+
6302
+ if (classList.length > keys(classMap).length) {
6303
+ nodesAreCompatible = false;
6304
+ }
6305
+ }
6306
+
6307
+ return nodesAreCompatible;
6308
+ }
6309
+
6310
+ function validateStyleAttr(vnode, elm) {
6311
+ var _vnode$data2 = vnode.data,
6312
+ style = _vnode$data2.style,
6313
+ styleDecls = _vnode$data2.styleDecls;
6314
+ var elmStyle = getAttribute$1(elm, 'style') || '';
6315
+ var nodesAreCompatible = true;
6316
+
6317
+ if (!isUndefined$1(style) && style !== elmStyle) {
6318
+ nodesAreCompatible = false;
6319
+ } else if (!isUndefined$1(styleDecls)) {
6320
+ var parsedVnodeStyle = parseStyleText(elmStyle);
6321
+ var expectedStyle = []; // styleMap is used when style is set to static value.
6322
+
6323
+ for (var _i31 = 0, n = styleDecls.length; _i31 < n; _i31++) {
6324
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i31], 3),
6325
+ prop = _styleDecls$_i2[0],
6326
+ value = _styleDecls$_i2[1],
6327
+ important = _styleDecls$_i2[2];
6328
+
6329
+ expectedStyle.push("".concat(prop, ": ").concat(value + (important ? ' important!' : '')));
6330
+ var parsedPropValue = parsedVnodeStyle[prop];
6331
+
6332
+ if (isUndefined$1(parsedPropValue)) {
6333
+ nodesAreCompatible = false;
6334
+ } else if (!parsedPropValue.startsWith(value)) {
6335
+ nodesAreCompatible = false;
6336
+ } else if (important && !parsedPropValue.endsWith('!important')) {
6337
+ nodesAreCompatible = false;
6338
+ }
6339
+ }
6340
+
6341
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
6342
+ nodesAreCompatible = false;
6343
+ }
6344
+
6345
+ ArrayJoin.call(expectedStyle, ';');
6346
+ }
6347
+
6348
+ return nodesAreCompatible;
6349
+ }
6142
6350
  /*
6143
6351
  * Copyright (c) 2018, salesforce.com, inc.
6144
6352
  * All rights reserved.
@@ -6154,7 +6362,7 @@
6154
6362
  hooksAreSet = true;
6155
6363
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6156
6364
  }
6157
- /* version: 2.11.0 */
6365
+ /* version: 2.12.0 */
6158
6366
 
6159
6367
  /*
6160
6368
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6541,7 +6749,7 @@
6541
6749
  }
6542
6750
 
6543
6751
  function createVMWithProps(element, Ctor, props) {
6544
- createVM(element, Ctor, {
6752
+ var vm = createVM(element, Ctor, {
6545
6753
  mode: 'open',
6546
6754
  owner: null,
6547
6755
  tagName: element.tagName.toLowerCase()
@@ -6554,6 +6762,8 @@
6554
6762
 
6555
6763
  element[key] = value;
6556
6764
  }
6765
+
6766
+ return vm;
6557
6767
  }
6558
6768
 
6559
6769
  function hydrateComponent(element, Ctor) {
@@ -6581,8 +6791,8 @@
6581
6791
  // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6582
6792
  // and uses the same algo to create the stylesheets as in SSR.
6583
6793
  setIsHydrating(true);
6584
- createVMWithProps(element, Ctor, props);
6585
- hydrateRootElement(element); // set it back since now we finished hydration.
6794
+ var vm = createVMWithProps(element, Ctor, props);
6795
+ hydrateRoot(vm); // set it back since now we finished hydration.
6586
6796
 
6587
6797
  setIsHydrating(false);
6588
6798
  } catch (e) {
@@ -6897,7 +7107,7 @@
6897
7107
  });
6898
7108
  freeze(LightningElement);
6899
7109
  seal(LightningElement.prototype);
6900
- /* version: 2.11.0 */
7110
+ /* version: 2.12.0 */
6901
7111
 
6902
7112
  exports.LightningElement = LightningElement;
6903
7113
  exports.__unstable__ProfilerControl = profilerControl;