lwc 2.7.3 → 2.7.4

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 +866 -800
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +866 -800
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +654 -587
  5. package/dist/engine-dom/iife/es5/engine-dom.js +912 -848
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +698 -633
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +866 -800
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +654 -587
  11. package/dist/engine-dom/umd/es5/engine-dom.js +912 -848
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +698 -633
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +606 -903
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +606 -903
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +8 -8
@@ -348,7 +348,11 @@ var LWC = (function (exports) {
348
348
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
349
349
  return attributeName;
350
350
  }
351
- /** version: 2.7.3 */
351
+
352
+ var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
353
+ var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
354
+ var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
355
+ /** version: 2.7.4 */
352
356
 
353
357
  /*
354
358
  * Copyright (c) 2018, salesforce.com, inc.
@@ -357,7 +361,6 @@ var LWC = (function (exports) {
357
361
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
358
362
  */
359
363
 
360
-
361
364
  function detect(propName) {
362
365
  return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
363
366
  }
@@ -526,7 +529,7 @@ var LWC = (function (exports) {
526
529
  setFeatureFlag(name, value);
527
530
  }
528
531
  }
529
- /** version: 2.7.3 */
532
+ /** version: 2.7.4 */
530
533
 
531
534
  /* proxy-compat-disable */
532
535
 
@@ -1045,6 +1048,24 @@ var LWC = (function (exports) {
1045
1048
  */
1046
1049
 
1047
1050
 
1051
+ function addErrorComponentStack(vm, error) {
1052
+ if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
1053
+ var wcStack = getErrorComponentStack(vm);
1054
+ defineProperty(error, 'wcStack', {
1055
+ get: function get() {
1056
+ return wcStack;
1057
+ }
1058
+ });
1059
+ }
1060
+ }
1061
+ /*
1062
+ * Copyright (c) 2018, salesforce.com, inc.
1063
+ * All rights reserved.
1064
+ * SPDX-License-Identifier: MIT
1065
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1066
+ */
1067
+
1068
+
1048
1069
  function log(method, message, vm) {
1049
1070
  var msg = "[LWC ".concat(method, "]: ").concat(message);
1050
1071
 
@@ -1079,207 +1100,12 @@ var LWC = (function (exports) {
1079
1100
  * SPDX-License-Identifier: MIT
1080
1101
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1081
1102
  */
1103
+ // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
1104
+ // to inject at runtime.
1082
1105
 
1083
1106
 
1084
- function isUndef(s) {
1085
- return s === undefined;
1086
- }
1087
-
1088
- function sameVnode(vnode1, vnode2) {
1089
- return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
1090
- }
1091
-
1092
- function isVNode(vnode) {
1093
- return vnode != null;
1094
- }
1095
-
1096
- function createKeyToOldIdx(children, beginIdx, endIdx) {
1097
- var map = {};
1098
- var j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
1099
-
1100
- for (j = beginIdx; j <= endIdx; ++j) {
1101
- ch = children[j];
1102
-
1103
- if (isVNode(ch)) {
1104
- key = ch.key;
1105
-
1106
- if (key !== undefined) {
1107
- map[key] = j;
1108
- }
1109
- }
1110
- }
1111
-
1112
- return map;
1113
- }
1114
-
1115
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
1116
- for (; startIdx <= endIdx; ++startIdx) {
1117
- var ch = vnodes[startIdx];
1118
-
1119
- if (isVNode(ch)) {
1120
- ch.hook.create(ch);
1121
- ch.hook.insert(ch, parentElm, before);
1122
- }
1123
- }
1124
- }
1125
-
1126
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
1127
- for (; startIdx <= endIdx; ++startIdx) {
1128
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
1129
-
1130
- if (isVNode(ch)) {
1131
- ch.hook.remove(ch, parentElm);
1132
- }
1133
- }
1134
- }
1135
-
1136
- function updateDynamicChildren(parentElm, oldCh, newCh) {
1137
- var oldStartIdx = 0;
1138
- var newStartIdx = 0;
1139
- var oldEndIdx = oldCh.length - 1;
1140
- var oldStartVnode = oldCh[0];
1141
- var oldEndVnode = oldCh[oldEndIdx];
1142
- var newChEnd = newCh.length - 1;
1143
- var newEndIdx = newChEnd;
1144
- var newStartVnode = newCh[0];
1145
- var newEndVnode = newCh[newEndIdx];
1146
- var oldKeyToIdx;
1147
- var idxInOld;
1148
- var elmToMove;
1149
- var before;
1150
-
1151
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1152
- if (!isVNode(oldStartVnode)) {
1153
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
1154
- } else if (!isVNode(oldEndVnode)) {
1155
- oldEndVnode = oldCh[--oldEndIdx];
1156
- } else if (!isVNode(newStartVnode)) {
1157
- newStartVnode = newCh[++newStartIdx];
1158
- } else if (!isVNode(newEndVnode)) {
1159
- newEndVnode = newCh[--newEndIdx];
1160
- } else if (sameVnode(oldStartVnode, newStartVnode)) {
1161
- patchVnode(oldStartVnode, newStartVnode);
1162
- oldStartVnode = oldCh[++oldStartIdx];
1163
- newStartVnode = newCh[++newStartIdx];
1164
- } else if (sameVnode(oldEndVnode, newEndVnode)) {
1165
- patchVnode(oldEndVnode, newEndVnode);
1166
- oldEndVnode = oldCh[--oldEndIdx];
1167
- newEndVnode = newCh[--newEndIdx];
1168
- } else if (sameVnode(oldStartVnode, newEndVnode)) {
1169
- // Vnode moved right
1170
- patchVnode(oldStartVnode, newEndVnode);
1171
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
1172
- oldStartVnode = oldCh[++oldStartIdx];
1173
- newEndVnode = newCh[--newEndIdx];
1174
- } else if (sameVnode(oldEndVnode, newStartVnode)) {
1175
- // Vnode moved left
1176
- patchVnode(oldEndVnode, newStartVnode);
1177
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
1178
- oldEndVnode = oldCh[--oldEndIdx];
1179
- newStartVnode = newCh[++newStartIdx];
1180
- } else {
1181
- if (oldKeyToIdx === undefined) {
1182
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
1183
- }
1184
-
1185
- idxInOld = oldKeyToIdx[newStartVnode.key];
1186
-
1187
- if (isUndef(idxInOld)) {
1188
- // New element
1189
- newStartVnode.hook.create(newStartVnode);
1190
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1191
- newStartVnode = newCh[++newStartIdx];
1192
- } else {
1193
- elmToMove = oldCh[idxInOld];
1194
-
1195
- if (isVNode(elmToMove)) {
1196
- if (elmToMove.sel !== newStartVnode.sel) {
1197
- // New element
1198
- newStartVnode.hook.create(newStartVnode);
1199
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1200
- } else {
1201
- patchVnode(elmToMove, newStartVnode);
1202
- oldCh[idxInOld] = undefined;
1203
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
1204
- }
1205
- }
1206
-
1207
- newStartVnode = newCh[++newStartIdx];
1208
- }
1209
- }
1210
- }
1211
-
1212
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
1213
- if (oldStartIdx > oldEndIdx) {
1214
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
1215
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
1216
- var _i6 = newEndIdx;
1217
- var n;
1218
-
1219
- do {
1220
- n = newCh[++_i6];
1221
- } while (!isVNode(n) && _i6 < newChEnd);
1222
-
1223
- before = isVNode(n) ? n.elm : null;
1224
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
1225
- } else {
1226
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
1227
- }
1228
- }
1229
- }
1230
-
1231
- function updateStaticChildren(parentElm, oldCh, newCh) {
1232
- var oldChLength = oldCh.length;
1233
- var newChLength = newCh.length;
1234
-
1235
- if (oldChLength === 0) {
1236
- // the old list is empty, we can directly insert anything new
1237
- addVnodes(parentElm, null, newCh, 0, newChLength);
1238
- return;
1239
- }
1240
-
1241
- if (newChLength === 0) {
1242
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
1243
- // this is the case in which the dynamic children of an if-directive should be removed
1244
- removeVnodes(parentElm, oldCh, 0, oldChLength);
1245
- return;
1246
- } // if the old list is not empty, the new list MUST have the same
1247
- // amount of nodes, that's why we call this static children
1248
-
1249
-
1250
- var referenceElm = null;
1251
-
1252
- for (var _i7 = newChLength - 1; _i7 >= 0; _i7 -= 1) {
1253
- var vnode = newCh[_i7];
1254
- var oldVNode = oldCh[_i7];
1255
-
1256
- if (vnode !== oldVNode) {
1257
- if (isVNode(oldVNode)) {
1258
- if (isVNode(vnode)) {
1259
- // both vnodes must be equivalent, and se just need to patch them
1260
- patchVnode(oldVNode, vnode);
1261
- referenceElm = vnode.elm;
1262
- } else {
1263
- // removing the old vnode since the new one is null
1264
- oldVNode.hook.remove(oldVNode, parentElm);
1265
- }
1266
- } else if (isVNode(vnode)) {
1267
- // this condition is unnecessary
1268
- vnode.hook.create(vnode); // insert the new node one since the old one is null
1269
-
1270
- vnode.hook.insert(vnode, parentElm, referenceElm);
1271
- referenceElm = vnode.elm;
1272
- }
1273
- }
1274
- }
1275
- }
1276
-
1277
- function patchVnode(oldVnode, vnode) {
1278
- if (oldVnode !== vnode) {
1279
- vnode.elm = oldVnode.elm;
1280
- vnode.hook.update(oldVnode, vnode);
1281
- }
1282
- }
1107
+ var HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
1108
+ var HTMLElementPrototype = HTMLElementConstructor$1.prototype;
1283
1109
  /*
1284
1110
  * Copyright (c) 2018, salesforce.com, inc.
1285
1111
  * All rights reserved.
@@ -1287,7 +1113,6 @@ var LWC = (function (exports) {
1287
1113
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1288
1114
  */
1289
1115
 
1290
-
1291
1116
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1292
1117
 
1293
1118
  function offsetPropertyErrorMessage(name) {
@@ -1406,6 +1231,40 @@ var LWC = (function (exports) {
1406
1231
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1407
1232
  */
1408
1233
 
1234
+ /**
1235
+ * This is a descriptor map that contains
1236
+ * all standard properties that a Custom Element can support (including AOM properties), which
1237
+ * determines what kind of capabilities the Base HTML Element and
1238
+ * Base Lightning Element should support.
1239
+ */
1240
+
1241
+
1242
+ var HTMLElementOriginalDescriptors = create(null);
1243
+ forEach.call(keys(AriaPropNameToAttrNameMap), function (propName) {
1244
+ // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1245
+ // in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
1246
+ var descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
1247
+
1248
+ if (!isUndefined$1(descriptor)) {
1249
+ HTMLElementOriginalDescriptors[propName] = descriptor;
1250
+ }
1251
+ });
1252
+ forEach.call(defaultDefHTMLPropertyNames, function (propName) {
1253
+ // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1254
+ // in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
1255
+ // this category, so, better to be sure.
1256
+ var descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
1257
+
1258
+ if (!isUndefined$1(descriptor)) {
1259
+ HTMLElementOriginalDescriptors[propName] = descriptor;
1260
+ }
1261
+ });
1262
+ /*
1263
+ * Copyright (c) 2018, salesforce.com, inc.
1264
+ * All rights reserved.
1265
+ * SPDX-License-Identifier: MIT
1266
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1267
+ */
1409
1268
 
1410
1269
  function generateDataDescriptor(options) {
1411
1270
  return assign({
@@ -1733,56 +1592,11 @@ var LWC = (function (exports) {
1733
1592
  function patchLightningElementPrototypeWithRestrictions(proto) {
1734
1593
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1735
1594
  }
1736
- /*
1737
- * Copyright (c) 2018, salesforce.com, inc.
1738
- * All rights reserved.
1739
- * SPDX-License-Identifier: MIT
1740
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1595
+ /**
1596
+ * Copyright (C) 2017 salesforce.com, inc.
1741
1597
  */
1742
- // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
1743
- // to inject at runtime.
1744
1598
 
1745
1599
 
1746
- var HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
1747
- var HTMLElementPrototype = HTMLElementConstructor$1.prototype;
1748
- /*
1749
- * Copyright (c) 2018, salesforce.com, inc.
1750
- * All rights reserved.
1751
- * SPDX-License-Identifier: MIT
1752
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1753
- */
1754
-
1755
- /**
1756
- * This is a descriptor map that contains
1757
- * all standard properties that a Custom Element can support (including AOM properties), which
1758
- * determines what kind of capabilities the Base HTML Element and
1759
- * Base Lightning Element should support.
1760
- */
1761
-
1762
- var HTMLElementOriginalDescriptors = create(null);
1763
- forEach.call(keys(AriaPropNameToAttrNameMap), function (propName) {
1764
- // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1765
- // in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
1766
- var descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
1767
-
1768
- if (!isUndefined$1(descriptor)) {
1769
- HTMLElementOriginalDescriptors[propName] = descriptor;
1770
- }
1771
- });
1772
- forEach.call(defaultDefHTMLPropertyNames, function (propName) {
1773
- // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1774
- // in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
1775
- // this category, so, better to be sure.
1776
- var descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
1777
-
1778
- if (!isUndefined$1(descriptor)) {
1779
- HTMLElementOriginalDescriptors[propName] = descriptor;
1780
- }
1781
- });
1782
- /**
1783
- * Copyright (C) 2017 salesforce.com, inc.
1784
- */
1785
-
1786
1600
  var isArray = Array.isArray;
1787
1601
  var ObjectDotPrototype = Object.prototype,
1788
1602
  _getPrototypeOf = Object.getPrototypeOf,
@@ -2710,7 +2524,9 @@ var LWC = (function (exports) {
2710
2524
  if (vm.renderMode === 1
2711
2525
  /* Shadow */
2712
2526
  ) {
2713
- doAttachShadow(vm);
2527
+ vm.renderRoot = doAttachShadow(vm);
2528
+ } else {
2529
+ vm.renderRoot = elm;
2714
2530
  } // Adding extra guard rails in DEV mode.
2715
2531
 
2716
2532
 
@@ -2729,13 +2545,15 @@ var LWC = (function (exports) {
2729
2545
  mode = vm.mode,
2730
2546
  shadowMode = vm.shadowMode,
2731
2547
  ctor = vm.def.ctor;
2732
- var cmpRoot = attachShadow$1(elm, (_attachShadow$ = {}, _defineProperty(_attachShadow$, KEY__SYNTHETIC_MODE, shadowMode === 1), _defineProperty(_attachShadow$, "delegatesFocus", Boolean(ctor.delegatesFocus)), _defineProperty(_attachShadow$, "mode", mode), _attachShadow$));
2733
- vm.cmpRoot = cmpRoot;
2734
- associateVM(cmpRoot, vm);
2548
+ var shadowRoot = attachShadow$1(elm, (_attachShadow$ = {}, _defineProperty(_attachShadow$, KEY__SYNTHETIC_MODE, shadowMode === 1), _defineProperty(_attachShadow$, "delegatesFocus", Boolean(ctor.delegatesFocus)), _defineProperty(_attachShadow$, "mode", mode), _attachShadow$));
2549
+ vm.shadowRoot = shadowRoot;
2550
+ associateVM(shadowRoot, vm);
2735
2551
 
2736
2552
  if (process.env.NODE_ENV !== 'production') {
2737
- patchShadowRootWithRestrictions(cmpRoot);
2553
+ patchShadowRootWithRestrictions(shadowRoot);
2738
2554
  }
2555
+
2556
+ return shadowRoot;
2739
2557
  }
2740
2558
 
2741
2559
  function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
@@ -2880,7 +2698,7 @@ var LWC = (function (exports) {
2880
2698
  }
2881
2699
  }
2882
2700
 
2883
- return vm.cmpRoot;
2701
+ return vm.shadowRoot;
2884
2702
  },
2885
2703
 
2886
2704
  get shadowRoot() {
@@ -2928,7 +2746,7 @@ var LWC = (function (exports) {
2928
2746
 
2929
2747
 
2930
2748
  var _loop = function _loop() {
2931
- var childGetter = _childGetters[_i8];
2749
+ var childGetter = _childGetters[_i6];
2932
2750
  queryAndChildGetterDescriptors[childGetter] = {
2933
2751
  get: function get() {
2934
2752
  var vm = getAssociatedVM(this);
@@ -2945,7 +2763,7 @@ var LWC = (function (exports) {
2945
2763
  };
2946
2764
  };
2947
2765
 
2948
- for (var _i8 = 0, _childGetters = childGetters; _i8 < _childGetters.length; _i8++) {
2766
+ for (var _i6 = 0, _childGetters = childGetters; _i6 < _childGetters.length; _i6++) {
2949
2767
  _loop();
2950
2768
  }
2951
2769
 
@@ -2969,7 +2787,7 @@ var LWC = (function (exports) {
2969
2787
 
2970
2788
 
2971
2789
  var _loop2 = function _loop2() {
2972
- var queryMethod = _queryMethods[_i9];
2790
+ var queryMethod = _queryMethods[_i7];
2973
2791
  queryAndChildGetterDescriptors[queryMethod] = {
2974
2792
  value: function value(arg) {
2975
2793
  var vm = getAssociatedVM(this);
@@ -2987,7 +2805,7 @@ var LWC = (function (exports) {
2987
2805
  };
2988
2806
  };
2989
2807
 
2990
- for (var _i9 = 0, _queryMethods = queryMethods; _i9 < _queryMethods.length; _i9++) {
2808
+ for (var _i7 = 0, _queryMethods = queryMethods; _i7 < _queryMethods.length; _i7++) {
2991
2809
  _loop2();
2992
2810
  }
2993
2811
 
@@ -3510,8 +3328,8 @@ var LWC = (function (exports) {
3510
3328
  }
3511
3329
 
3512
3330
  if (!isUndefined$1(fields)) {
3513
- for (var _i10 = 0, n = fields.length; _i10 < n; _i10++) {
3514
- var _fieldName2 = fields[_i10];
3331
+ for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
3332
+ var _fieldName2 = fields[_i8];
3515
3333
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
3516
3334
 
3517
3335
  if (process.env.NODE_ENV !== 'production') {
@@ -3732,8 +3550,8 @@ var LWC = (function (exports) {
3732
3550
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
3733
3551
  var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
3734
3552
 
3735
- for (var _i11 = 0, _len3 = props.length; _i11 < _len3; _i11 += 1) {
3736
- var _propName2 = props[_i11];
3553
+ for (var _i9 = 0, _len3 = props.length; _i9 < _len3; _i9 += 1) {
3554
+ var _propName2 = props[_i9];
3737
3555
  attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
3738
3556
  descriptors[_propName2] = {
3739
3557
  get: createGetter(_propName2),
@@ -3744,8 +3562,8 @@ var LWC = (function (exports) {
3744
3562
  } // expose public methods as props on the new Element Bridge
3745
3563
 
3746
3564
 
3747
- for (var _i12 = 0, _len4 = methods.length; _i12 < _len4; _i12 += 1) {
3748
- var methodName = methods[_i12];
3565
+ for (var _i10 = 0, _len4 = methods.length; _i10 < _len4; _i10 += 1) {
3566
+ var methodName = methods[_i10];
3749
3567
  descriptors[methodName] = {
3750
3568
  value: createMethodCaller(methodName),
3751
3569
  writable: true,
@@ -4301,6 +4119,11 @@ var LWC = (function (exports) {
4301
4119
  return def;
4302
4120
  }
4303
4121
 
4122
+ function getComponentHtmlPrototype(Ctor) {
4123
+ var def = getComponentInternalDef(Ctor);
4124
+ return def.bridge;
4125
+ }
4126
+
4304
4127
  var lightingElementDef = {
4305
4128
  ctor: LightningElement,
4306
4129
  name: LightningElement.name,
@@ -4361,6 +4184,75 @@ var LWC = (function (exports) {
4361
4184
  methods: publicMethods
4362
4185
  };
4363
4186
  }
4187
+ /*
4188
+ * Copyright (c) 2020, salesforce.com, inc.
4189
+ * All rights reserved.
4190
+ * SPDX-License-Identifier: MIT
4191
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4192
+ */
4193
+
4194
+
4195
+ function getUpgradableConstructor(tagName) {
4196
+ // Should never get a tag with upper case letter at this point, the compiler should
4197
+ // produce only tags with lowercase letters
4198
+ // But, for backwards compatibility, we will lower case the tagName
4199
+ tagName = tagName.toLowerCase();
4200
+ var CE = getCustomElement$1(tagName);
4201
+
4202
+ if (!isUndefined$1(CE)) {
4203
+ return CE;
4204
+ }
4205
+ /**
4206
+ * LWC Upgradable Element reference to an element that was created
4207
+ * via the scoped registry mechanism, and that is ready to be upgraded.
4208
+ */
4209
+
4210
+
4211
+ CE = /*#__PURE__*/function (_HTMLElementExported$) {
4212
+ _inherits(LWCUpgradableElement, _HTMLElementExported$);
4213
+
4214
+ var _super5 = _createSuper(LWCUpgradableElement);
4215
+
4216
+ function LWCUpgradableElement(upgradeCallback) {
4217
+ var _this4;
4218
+
4219
+ _classCallCheck(this, LWCUpgradableElement);
4220
+
4221
+ _this4 = _super5.call(this);
4222
+
4223
+ if (isFunction$1(upgradeCallback)) {
4224
+ upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
4225
+ }
4226
+
4227
+ return _this4;
4228
+ }
4229
+
4230
+ return _createClass(LWCUpgradableElement);
4231
+ }(HTMLElementExported$1);
4232
+
4233
+ defineCustomElement$1(tagName, CE);
4234
+ return CE;
4235
+ }
4236
+ /*
4237
+ * Copyright (c) 2018, salesforce.com, inc.
4238
+ * All rights reserved.
4239
+ * SPDX-License-Identifier: MIT
4240
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4241
+ */
4242
+
4243
+
4244
+ function isVBaseElement(vnode) {
4245
+ var type = vnode.type;
4246
+ return type === 2
4247
+ /* Element */
4248
+ || type === 3
4249
+ /* CustomElement */
4250
+ ;
4251
+ }
4252
+
4253
+ function isSameVnode(vnode1, vnode2) {
4254
+ return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
4255
+ }
4364
4256
  /*
4365
4257
  * Copyright (c) 2018, salesforce.com, inc.
4366
4258
  * All rights reserved.
@@ -4369,8 +4261,6 @@ var LWC = (function (exports) {
4369
4261
  */
4370
4262
 
4371
4263
 
4372
- var xlinkNS = 'http://www.w3.org/1999/xlink';
4373
- var xmlNS = 'http://www.w3.org/XML/1998/namespace';
4374
4264
  var ColonCharCode = 58;
4375
4265
 
4376
4266
  function patchAttributes(oldVnode, vnode) {
@@ -4397,10 +4287,10 @@ var LWC = (function (exports) {
4397
4287
 
4398
4288
  if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
4399
4289
  // Assume xml namespace
4400
- setAttribute$1(elm, key, cur, xmlNS);
4290
+ setAttribute$1(elm, key, cur, XML_NAMESPACE);
4401
4291
  } else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
4402
4292
  // Assume xlink namespace
4403
- setAttribute$1(elm, key, cur, xlinkNS);
4293
+ setAttribute$1(elm, key, cur, XLINK_NAMESPACE);
4404
4294
  } else if (isNull(cur) || isUndefined$1(cur)) {
4405
4295
  removeAttribute$1(elm, key);
4406
4296
  } else {
@@ -4617,8 +4507,8 @@ var LWC = (function (exports) {
4617
4507
  return;
4618
4508
  }
4619
4509
 
4620
- for (var _i13 = 0; _i13 < styleDecls.length; _i13++) {
4621
- var _styleDecls$_i = _slicedToArray(styleDecls[_i13], 3),
4510
+ for (var _i11 = 0; _i11 < styleDecls.length; _i11++) {
4511
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i11], 3),
4622
4512
  prop = _styleDecls$_i[0],
4623
4513
  value = _styleDecls$_i[1],
4624
4514
  important = _styleDecls$_i[2];
@@ -4634,6 +4524,151 @@ var LWC = (function (exports) {
4634
4524
  */
4635
4525
 
4636
4526
 
4527
+ var TextHook = {
4528
+ create: function create(vnode) {
4529
+ var owner = vnode.owner;
4530
+ var elm = createText$1(vnode.text);
4531
+ linkNodeToShadow(elm, owner);
4532
+ vnode.elm = elm;
4533
+ },
4534
+ update: updateNodeHook,
4535
+ insert: insertNode,
4536
+ move: insertNode,
4537
+ remove: removeNode
4538
+ };
4539
+ var CommentHook = {
4540
+ create: function create(vnode) {
4541
+ var owner = vnode.owner,
4542
+ text = vnode.text;
4543
+ var elm = createComment$1(text);
4544
+ linkNodeToShadow(elm, owner);
4545
+ vnode.elm = elm;
4546
+ },
4547
+ update: updateNodeHook,
4548
+ insert: insertNode,
4549
+ move: insertNode,
4550
+ remove: removeNode
4551
+ }; // insert is called after update, which is used somewhere else (via a module)
4552
+ // to mark the vm as inserted, that means we cannot use update as the main channel
4553
+ // to rehydrate when dirty, because sometimes the element is not inserted just yet,
4554
+ // which breaks some invariants. For that reason, we have the following for any
4555
+ // Custom Element that is inserted via a template.
4556
+
4557
+ var ElementHook = {
4558
+ create: function create(vnode) {
4559
+ var sel = vnode.sel,
4560
+ owner = vnode.owner,
4561
+ svg = vnode.data.svg;
4562
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4563
+ var elm = createElement$2(sel, namespace);
4564
+ linkNodeToShadow(elm, owner);
4565
+ fallbackElmHook(elm, vnode);
4566
+ vnode.elm = elm;
4567
+ patchElementPropsAndAttrs$1(null, vnode);
4568
+ },
4569
+ update: function update(oldVnode, vnode) {
4570
+ patchElementPropsAndAttrs$1(oldVnode, vnode);
4571
+ patchChildren(vnode.elm, oldVnode.children, vnode.children);
4572
+ },
4573
+ insert: function insert(vnode, parentNode, referenceNode) {
4574
+ insertNode(vnode, parentNode, referenceNode);
4575
+ createChildrenHook(vnode);
4576
+ },
4577
+ move: insertNode,
4578
+ remove: function remove(vnode, parentNode) {
4579
+ removeNode(vnode, parentNode);
4580
+ removeChildren(vnode);
4581
+ }
4582
+ };
4583
+ var CustomElementHook = {
4584
+ create: function create(vnode) {
4585
+ var sel = vnode.sel,
4586
+ owner = vnode.owner;
4587
+ var UpgradableConstructor = getUpgradableConstructor(sel);
4588
+ /**
4589
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4590
+ * with a callback as the first argument, we could implement a more advanced
4591
+ * mechanism that only passes that argument if the constructor is known to be
4592
+ * an upgradable custom element.
4593
+ */
4594
+
4595
+ var vm;
4596
+ var elm = new UpgradableConstructor(function (elm) {
4597
+ // the custom element from the registry is expecting an upgrade callback
4598
+ vm = createViewModelHook(elm, vnode);
4599
+ });
4600
+ linkNodeToShadow(elm, owner);
4601
+ vnode.elm = elm;
4602
+
4603
+ if (vm) {
4604
+ allocateChildren(vnode, vm);
4605
+ } else if (vnode.ctor !== UpgradableConstructor) {
4606
+ throw new TypeError("Incorrect Component Constructor");
4607
+ }
4608
+
4609
+ patchElementPropsAndAttrs$1(null, vnode);
4610
+ },
4611
+ update: function update(oldVnode, vnode) {
4612
+ patchElementPropsAndAttrs$1(oldVnode, vnode);
4613
+ var vm = getAssociatedVMIfPresent(vnode.elm);
4614
+
4615
+ if (vm) {
4616
+ // in fallback mode, the allocation will always set children to
4617
+ // empty and delegate the real allocation to the slot elements
4618
+ allocateChildren(vnode, vm);
4619
+ } // in fallback mode, the children will be always empty, so, nothing
4620
+ // will happen, but in native, it does allocate the light dom
4621
+
4622
+
4623
+ patchChildren(vnode.elm, oldVnode.children, vnode.children);
4624
+
4625
+ if (vm) {
4626
+ if (process.env.NODE_ENV !== 'production') {
4627
+ assert.isTrue(isArray$1(vnode.children), "Invalid vnode for a custom element, it must have children defined.");
4628
+ } // this will probably update the shadowRoot, but only if the vm is in a dirty state
4629
+ // this is important to preserve the top to bottom synchronous rendering phase.
4630
+
4631
+
4632
+ rerenderVM(vm);
4633
+ }
4634
+ },
4635
+ insert: function insert(vnode, parentNode, referenceNode) {
4636
+ insertNode(vnode, parentNode, referenceNode);
4637
+ var vm = getAssociatedVMIfPresent(vnode.elm);
4638
+
4639
+ if (vm) {
4640
+ if (process.env.NODE_ENV !== 'production') {
4641
+ assert.isTrue(vm.state === 0
4642
+ /* created */
4643
+ , "".concat(vm, " cannot be recycled."));
4644
+ }
4645
+
4646
+ runConnectedCallback(vm);
4647
+ }
4648
+
4649
+ createChildrenHook(vnode);
4650
+
4651
+ if (vm) {
4652
+ appendVM(vm);
4653
+ }
4654
+ },
4655
+ move: insertNode,
4656
+ remove: function remove(vnode, parentNode) {
4657
+ removeNode(vnode, parentNode);
4658
+ var vm = getAssociatedVMIfPresent(vnode.elm);
4659
+
4660
+ if (vm) {
4661
+ // for custom elements we don't have to go recursively because the removeVM routine
4662
+ // will take care of disconnecting any child VM attached to its shadow as well.
4663
+ removeVM(vm);
4664
+ }
4665
+ }
4666
+ };
4667
+
4668
+ function isVNode(vnode) {
4669
+ return vnode != null;
4670
+ }
4671
+
4637
4672
  function observeElementChildNodes(elm) {
4638
4673
  elm.$domManual$ = true;
4639
4674
  }
@@ -4653,6 +4688,22 @@ var LWC = (function (exports) {
4653
4688
  }
4654
4689
  }
4655
4690
 
4691
+ function linkNodeToShadow(elm, owner) {
4692
+ var renderRoot = owner.renderRoot,
4693
+ renderMode = owner.renderMode,
4694
+ shadowMode = owner.shadowMode; // TODO [#1164]: this should eventually be done by the polyfill directly
4695
+
4696
+ if (isSyntheticShadowDefined$1) {
4697
+ if (shadowMode === 1
4698
+ /* Synthetic */
4699
+ || renderMode === 0
4700
+ /* Light */
4701
+ ) {
4702
+ elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
4703
+ }
4704
+ }
4705
+ }
4706
+
4656
4707
  function updateNodeHook(oldVnode, vnode) {
4657
4708
  var elm = vnode.elm,
4658
4709
  text = vnode.text;
@@ -4670,7 +4721,7 @@ var LWC = (function (exports) {
4670
4721
  }
4671
4722
  }
4672
4723
 
4673
- function insertNodeHook(vnode, parentNode, referenceNode) {
4724
+ function insertNode(vnode, parentNode, referenceNode) {
4674
4725
  if (process.env.NODE_ENV !== 'production') {
4675
4726
  unlockDomMutation();
4676
4727
  }
@@ -4682,7 +4733,7 @@ var LWC = (function (exports) {
4682
4733
  }
4683
4734
  }
4684
4735
 
4685
- function removeNodeHook(vnode, parentNode) {
4736
+ function removeNode(vnode, parentNode) {
4686
4737
  if (process.env.NODE_ENV !== 'production') {
4687
4738
  unlockDomMutation();
4688
4739
  }
@@ -4694,7 +4745,7 @@ var LWC = (function (exports) {
4694
4745
  }
4695
4746
  }
4696
4747
 
4697
- function patchElementPropsAndAttrs(oldVnode, vnode) {
4748
+ function patchElementPropsAndAttrs$1(oldVnode, vnode) {
4698
4749
  if (isNull(oldVnode)) {
4699
4750
  applyEventListeners(vnode);
4700
4751
  applyStaticClassAttribute(vnode);
@@ -4709,11 +4760,6 @@ var LWC = (function (exports) {
4709
4760
  patchProps(oldVnode, vnode);
4710
4761
  }
4711
4762
 
4712
- function hydrateElmHook(vnode) {
4713
- applyEventListeners(vnode);
4714
- patchProps(null, vnode);
4715
- }
4716
-
4717
4763
  function fallbackElmHook(elm, vnode) {
4718
4764
  var owner = vnode.owner;
4719
4765
  setScopeTokenClassIfNecessary(elm, owner);
@@ -4725,7 +4771,7 @@ var LWC = (function (exports) {
4725
4771
  var stylesheetToken = owner.context.stylesheetToken;
4726
4772
 
4727
4773
  if (!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
4728
- /* manual */
4774
+ /* Manual */
4729
4775
  ) {
4730
4776
  // this element will now accept any manual content inserted into it
4731
4777
  observeElementChildNodes(elm);
@@ -4739,7 +4785,7 @@ var LWC = (function (exports) {
4739
4785
  if (process.env.NODE_ENV !== 'production') {
4740
4786
  var _context = vnode.data.context;
4741
4787
  var isPortal = !isUndefined$1(_context) && !isUndefined$1(_context.lwc) && _context.lwc.dom === "manual"
4742
- /* manual */
4788
+ /* Manual */
4743
4789
  ;
4744
4790
  var isLight = owner.renderMode === 0
4745
4791
  /* Light */
@@ -4759,7 +4805,7 @@ var LWC = (function (exports) {
4759
4805
  }
4760
4806
  }
4761
4807
 
4762
- function allocateChildrenHook(vnode, vm) {
4808
+ function allocateChildren(vnode, vm) {
4763
4809
  // A component with slots will re-render because:
4764
4810
  // 1- There is a change of the internal state.
4765
4811
  // 2- There is a change on the external api (ex: slots)
@@ -4790,11 +4836,12 @@ var LWC = (function (exports) {
4790
4836
  }
4791
4837
 
4792
4838
  function createViewModelHook(elm, vnode) {
4793
- if (!isUndefined$1(getAssociatedVMIfPresent(elm))) {
4794
- // There is a possibility that a custom element is registered under tagName,
4795
- // in which case, the initialization is already carry on, and there is nothing else
4796
- // to do here since this hook is called right after invoking `document.createElement`.
4797
- return;
4839
+ var vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
4840
+ // initialization is already carry on, and there is nothing else to do here since this hook is
4841
+ // called right after invoking `document.createElement`.
4842
+
4843
+ if (!isUndefined$1(vm)) {
4844
+ return vm;
4798
4845
  }
4799
4846
 
4800
4847
  var sel = vnode.sel,
@@ -4812,8 +4859,7 @@ var LWC = (function (exports) {
4812
4859
  setElementShadowToken(elm, stylesheetToken);
4813
4860
  }
4814
4861
 
4815
- var def = getComponentInternalDef(ctor);
4816
- createVM(elm, def, {
4862
+ vm = createVM(elm, ctor, {
4817
4863
  mode: mode,
4818
4864
  owner: owner,
4819
4865
  tagName: sel
@@ -4822,6 +4868,8 @@ var LWC = (function (exports) {
4822
4868
  if (process.env.NODE_ENV !== 'production') {
4823
4869
  assert.isTrue(isArray$1(vnode.children), "Invalid vnode for a custom element, it must have children defined.");
4824
4870
  }
4871
+
4872
+ return vm;
4825
4873
  }
4826
4874
 
4827
4875
  function createChildrenHook(vnode) {
@@ -4838,177 +4886,12 @@ var LWC = (function (exports) {
4838
4886
  }
4839
4887
  }
4840
4888
 
4841
- function isElementNode(node) {
4842
- // eslint-disable-next-line lwc-internal/no-global-node
4843
- return node.nodeType === Node.ELEMENT_NODE;
4844
- }
4845
-
4846
- function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4847
- var _vnode$data$attrs = vnode.data.attrs,
4848
- attrs = _vnode$data$attrs === void 0 ? {} : _vnode$data$attrs;
4849
- var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4850
- // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4851
-
4852
- for (var _i14 = 0, _Object$entries = Object.entries(attrs); _i14 < _Object$entries.length; _i14++) {
4853
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i14], 2),
4854
- attrName = _Object$entries$_i[0],
4855
- attrValue = _Object$entries$_i[1];
4856
-
4857
- var elmAttrValue = getAttribute$1(elm, attrName);
4858
-
4859
- if (String(attrValue) !== elmAttrValue) {
4860
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
4861
- nodesAreCompatible = false;
4862
- }
4863
- }
4864
-
4865
- return nodesAreCompatible;
4866
- }
4867
-
4868
- function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4869
- var _vnode$data = vnode.data,
4870
- className = _vnode$data.className,
4871
- classMap = _vnode$data.classMap;
4872
- var nodesAreCompatible = true;
4873
- var vnodeClassName;
4874
-
4875
- if (!isUndefined$1(className) && String(className) !== elm.className) {
4876
- // className is used when class is bound to an expr.
4877
- nodesAreCompatible = false;
4878
- vnodeClassName = className;
4879
- } else if (!isUndefined$1(classMap)) {
4880
- // classMap is used when class is set to static value.
4881
- var classList = getClassList$1(elm);
4882
- var computedClassName = ''; // all classes from the vnode should be in the element.classList
4883
-
4884
- for (var name in classMap) {
4885
- computedClassName += ' ' + name;
4886
-
4887
- if (!classList.contains(name)) {
4888
- nodesAreCompatible = false;
4889
- }
4890
- }
4891
-
4892
- vnodeClassName = computedClassName.trim();
4893
-
4894
- if (classList.length > keys(classMap).length) {
4895
- nodesAreCompatible = false;
4896
- }
4897
- }
4898
-
4899
- if (!nodesAreCompatible) {
4900
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(elm.className, "\""), vnode.owner);
4901
- }
4902
-
4903
- return nodesAreCompatible;
4904
- }
4905
-
4906
- function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4907
- var _vnode$data2 = vnode.data,
4908
- style = _vnode$data2.style,
4909
- styleDecls = _vnode$data2.styleDecls;
4910
- var elmStyle = getAttribute$1(elm, 'style') || '';
4911
- var vnodeStyle;
4912
- var nodesAreCompatible = true;
4913
-
4914
- if (!isUndefined$1(style) && style !== elmStyle) {
4915
- nodesAreCompatible = false;
4916
- vnodeStyle = style;
4917
- } else if (!isUndefined$1(styleDecls)) {
4918
- var parsedVnodeStyle = parseStyleText(elmStyle);
4919
- var expectedStyle = []; // styleMap is used when style is set to static value.
4920
-
4921
- for (var _i15 = 0, n = styleDecls.length; _i15 < n; _i15++) {
4922
- var _styleDecls$_i2 = _slicedToArray(styleDecls[_i15], 3),
4923
- prop = _styleDecls$_i2[0],
4924
- value = _styleDecls$_i2[1],
4925
- important = _styleDecls$_i2[2];
4926
-
4927
- expectedStyle.push("".concat(prop, ": ").concat(value + (important ? ' important!' : '')));
4928
- var parsedPropValue = parsedVnodeStyle[prop];
4929
-
4930
- if (isUndefined$1(parsedPropValue)) {
4931
- nodesAreCompatible = false;
4932
- } else if (!parsedPropValue.startsWith(value)) {
4933
- nodesAreCompatible = false;
4934
- } else if (important && !parsedPropValue.endsWith('!important')) {
4935
- nodesAreCompatible = false;
4936
- }
4937
- }
4938
-
4939
- if (keys(parsedVnodeStyle).length > styleDecls.length) {
4940
- nodesAreCompatible = false;
4941
- }
4942
-
4943
- vnodeStyle = ArrayJoin.call(expectedStyle, ';');
4944
- }
4945
-
4946
- if (!nodesAreCompatible) {
4947
- // style is used when class is bound to an expr.
4948
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
4949
- }
4950
-
4951
- return nodesAreCompatible;
4952
- }
4953
-
4954
- function throwHydrationError() {
4955
- assert.fail('Server rendered elements do not match client side generated elements');
4956
- }
4957
-
4958
- function hydrateChildrenHook(elmChildren, children, vm) {
4959
- var _a, _b;
4960
-
4961
- if (process.env.NODE_ENV !== 'production') {
4962
- var filteredVNodes = ArrayFilter.call(children, function (vnode) {
4963
- return !!vnode;
4964
- });
4965
-
4966
- if (elmChildren.length !== filteredVNodes.length) {
4967
- logError("Hydration mismatch: incorrect number of rendered nodes, expected ".concat(filteredVNodes.length, " but found ").concat(elmChildren.length, "."), vm);
4968
- throwHydrationError();
4969
- }
4970
- }
4971
-
4972
- var elmCurrentChildIdx = 0;
4973
-
4974
- for (var j = 0, n = children.length; j < n; j++) {
4975
- var ch = children[j];
4976
-
4977
- if (ch != null) {
4978
- var childNode = elmChildren[elmCurrentChildIdx];
4979
-
4980
- if (process.env.NODE_ENV !== 'production') {
4981
- // VComments and VTexts validation is handled in their hooks
4982
- if (isElementNode(childNode)) {
4983
- if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
4984
- 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);
4985
- throwHydrationError();
4986
- } // Note: props are not yet set
4987
-
4988
-
4989
- var hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
4990
- var hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
4991
- var hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
4992
- var isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4993
-
4994
- if (!isVNodeAndElementCompatible) {
4995
- throwHydrationError();
4996
- }
4997
- }
4998
- }
4999
-
5000
- ch.hook.hydrate(ch, childNode);
5001
- elmCurrentChildIdx++;
5002
- }
5003
- }
5004
- }
5005
-
5006
- function removeElmHook(vnode) {
5007
- // this method only needs to search on child vnodes from template
5008
- // to trigger the remove hook just in case some of those children
5009
- // are custom elements.
5010
- var children = vnode.children,
5011
- elm = vnode.elm;
4889
+ function removeChildren(vnode) {
4890
+ // this method only needs to search on child vnodes from template
4891
+ // to trigger the remove hook just in case some of those children
4892
+ // are custom elements.
4893
+ var children = vnode.children,
4894
+ elm = vnode.elm;
5012
4895
 
5013
4896
  for (var j = 0, _len5 = children.length; j < _len5; ++j) {
5014
4897
  var ch = children[j];
@@ -5020,18 +4903,24 @@ var LWC = (function (exports) {
5020
4903
  }
5021
4904
 
5022
4905
  function allocateInSlot(vm, children) {
4906
+ var _a;
4907
+
5023
4908
  var oldSlots = vm.cmpSlots;
5024
4909
  var cmpSlots = vm.cmpSlots = create(null);
5025
4910
 
5026
- for (var _i16 = 0, _len6 = children.length; _i16 < _len6; _i16 += 1) {
5027
- var vnode = children[_i16];
4911
+ for (var _i12 = 0, _len6 = children.length; _i12 < _len6; _i12 += 1) {
4912
+ var vnode = children[_i12];
5028
4913
 
5029
4914
  if (isNull(vnode)) {
5030
4915
  continue;
5031
4916
  }
5032
4917
 
5033
- var data = vnode.data;
5034
- var slotName = data.attrs && data.attrs.slot || '';
4918
+ var slotName = '';
4919
+
4920
+ if (isVBaseElement(vnode)) {
4921
+ slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
4922
+ }
4923
+
5035
4924
  var vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
5036
4925
  // which might have similar keys. Each vnode will always have a key that
5037
4926
  // starts with a numeric character from compiler. In this case, we add a unique
@@ -5054,8 +4943,8 @@ var LWC = (function (exports) {
5054
4943
  return;
5055
4944
  }
5056
4945
 
5057
- for (var _i17 = 0, _len7 = oldKeys.length; _i17 < _len7; _i17 += 1) {
5058
- var key = oldKeys[_i17];
4946
+ for (var _i13 = 0, _len7 = oldKeys.length; _i13 < _len7; _i13 += 1) {
4947
+ var key = oldKeys[_i13];
5059
4948
 
5060
4949
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5061
4950
  markComponentAsDirty(vm);
@@ -5086,325 +4975,202 @@ var LWC = (function (exports) {
5086
4975
  function hasDynamicChildren(children) {
5087
4976
  return FromIteration.has(children);
5088
4977
  }
5089
- /*
5090
- * Copyright (c) 2020, salesforce.com, inc.
5091
- * All rights reserved.
5092
- * SPDX-License-Identifier: MIT
5093
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5094
- */
5095
-
5096
4978
 
5097
- function getUpgradableConstructor(tagName) {
5098
- // Should never get a tag with upper case letter at this point, the compiler should
5099
- // produce only tags with lowercase letters
5100
- // But, for backwards compatibility, we will lower case the tagName
5101
- tagName = tagName.toLowerCase();
5102
- var CE = getCustomElement$1(tagName);
5103
-
5104
- if (!isUndefined$1(CE)) {
5105
- return CE;
5106
- }
5107
- /**
5108
- * LWC Upgradable Element reference to an element that was created
5109
- * via the scoped registry mechanism, and that is ready to be upgraded.
5110
- */
5111
-
5112
-
5113
- CE = /*#__PURE__*/function (_HTMLElementExported$) {
5114
- _inherits(LWCUpgradableElement, _HTMLElementExported$);
5115
-
5116
- var _super5 = _createSuper(LWCUpgradableElement);
5117
-
5118
- function LWCUpgradableElement(upgradeCallback) {
5119
- var _this4;
4979
+ function createKeyToOldIdx(children, beginIdx, endIdx) {
4980
+ var map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
5120
4981
 
5121
- _classCallCheck(this, LWCUpgradableElement);
4982
+ for (var j = beginIdx; j <= endIdx; ++j) {
4983
+ var ch = children[j];
5122
4984
 
5123
- _this4 = _super5.call(this);
4985
+ if (isVNode(ch)) {
4986
+ var key = ch.key;
5124
4987
 
5125
- if (isFunction$1(upgradeCallback)) {
5126
- upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
4988
+ if (key !== undefined) {
4989
+ map[key] = j;
5127
4990
  }
5128
-
5129
- return _this4;
5130
4991
  }
4992
+ }
5131
4993
 
5132
- return _createClass(LWCUpgradableElement);
5133
- }(HTMLElementExported$1);
5134
-
5135
- defineCustomElement$1(tagName, CE);
5136
- return CE;
4994
+ return map;
5137
4995
  }
5138
- /*
5139
- * Copyright (c) 2018, salesforce.com, inc.
5140
- * All rights reserved.
5141
- * SPDX-License-Identifier: MIT
5142
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5143
- */
5144
-
5145
-
5146
- var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
5147
- var SymbolIterator = Symbol.iterator;
5148
- var TextHook = {
5149
- create: function create(vnode) {
5150
- var owner = vnode.owner;
5151
- var elm = createText$1(vnode.text);
5152
- linkNodeToShadow(elm, owner);
5153
- vnode.elm = elm;
5154
- },
5155
- update: updateNodeHook,
5156
- insert: insertNodeHook,
5157
- move: insertNodeHook,
5158
- remove: removeNodeHook,
5159
- hydrate: function hydrate(vNode, node) {
5160
- var _a;
5161
4996
 
5162
- if (process.env.NODE_ENV !== 'production') {
5163
- // eslint-disable-next-line lwc-internal/no-global-node
5164
- if (node.nodeType !== Node.TEXT_NODE) {
5165
- logError('Hydration mismatch: incorrect node type received', vNode.owner);
5166
- assert.fail('Hydration mismatch: incorrect node type received.');
5167
- }
4997
+ function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
4998
+ for (; startIdx <= endIdx; ++startIdx) {
4999
+ var ch = vnodes[startIdx];
5168
5000
 
5169
- if (node.nodeValue !== vNode.text) {
5170
- logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
5171
- }
5172
- } // always set the text value to the one from the vnode.
5001
+ if (isVNode(ch)) {
5002
+ ch.hook.create(ch);
5003
+ ch.hook.insert(ch, parentElm, before);
5004
+ }
5005
+ }
5006
+ }
5173
5007
 
5008
+ function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
5009
+ for (; startIdx <= endIdx; ++startIdx) {
5010
+ var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
5174
5011
 
5175
- node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5176
- vNode.elm = node;
5012
+ if (isVNode(ch)) {
5013
+ ch.hook.remove(ch, parentElm);
5014
+ }
5177
5015
  }
5178
- };
5179
- var CommentHook = {
5180
- create: function create(vnode) {
5181
- var owner = vnode.owner,
5182
- text = vnode.text;
5183
- var elm = createComment$1(text);
5184
- linkNodeToShadow(elm, owner);
5185
- vnode.elm = elm;
5186
- },
5187
- update: updateNodeHook,
5188
- insert: insertNodeHook,
5189
- move: insertNodeHook,
5190
- remove: removeNodeHook,
5191
- hydrate: function hydrate(vNode, node) {
5192
- var _a;
5016
+ }
5193
5017
 
5194
- if (process.env.NODE_ENV !== 'production') {
5195
- // eslint-disable-next-line lwc-internal/no-global-node
5196
- if (node.nodeType !== Node.COMMENT_NODE) {
5197
- logError('Hydration mismatch: incorrect node type received', vNode.owner);
5198
- assert.fail('Hydration mismatch: incorrect node type received.');
5199
- }
5018
+ function updateDynamicChildren(parentElm, oldCh, newCh) {
5019
+ var oldStartIdx = 0;
5020
+ var newStartIdx = 0;
5021
+ var oldEndIdx = oldCh.length - 1;
5022
+ var oldStartVnode = oldCh[0];
5023
+ var oldEndVnode = oldCh[oldEndIdx];
5024
+ var newChEnd = newCh.length - 1;
5025
+ var newEndIdx = newChEnd;
5026
+ var newStartVnode = newCh[0];
5027
+ var newEndVnode = newCh[newEndIdx];
5028
+ var oldKeyToIdx;
5029
+ var idxInOld;
5030
+ var elmToMove;
5031
+ var before;
5200
5032
 
5201
- if (node.nodeValue !== vNode.text) {
5202
- logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
5033
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
5034
+ if (!isVNode(oldStartVnode)) {
5035
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
5036
+ } else if (!isVNode(oldEndVnode)) {
5037
+ oldEndVnode = oldCh[--oldEndIdx];
5038
+ } else if (!isVNode(newStartVnode)) {
5039
+ newStartVnode = newCh[++newStartIdx];
5040
+ } else if (!isVNode(newEndVnode)) {
5041
+ newEndVnode = newCh[--newEndIdx];
5042
+ } else if (isSameVnode(oldStartVnode, newStartVnode)) {
5043
+ patchVnode(oldStartVnode, newStartVnode);
5044
+ oldStartVnode = oldCh[++oldStartIdx];
5045
+ newStartVnode = newCh[++newStartIdx];
5046
+ } else if (isSameVnode(oldEndVnode, newEndVnode)) {
5047
+ patchVnode(oldEndVnode, newEndVnode);
5048
+ oldEndVnode = oldCh[--oldEndIdx];
5049
+ newEndVnode = newCh[--newEndIdx];
5050
+ } else if (isSameVnode(oldStartVnode, newEndVnode)) {
5051
+ // Vnode moved right
5052
+ patchVnode(oldStartVnode, newEndVnode);
5053
+ newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5054
+ oldStartVnode = oldCh[++oldStartIdx];
5055
+ newEndVnode = newCh[--newEndIdx];
5056
+ } else if (isSameVnode(oldEndVnode, newStartVnode)) {
5057
+ // Vnode moved left
5058
+ patchVnode(oldEndVnode, newStartVnode);
5059
+ newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5060
+ oldEndVnode = oldCh[--oldEndIdx];
5061
+ newStartVnode = newCh[++newStartIdx];
5062
+ } else {
5063
+ if (oldKeyToIdx === undefined) {
5064
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
5203
5065
  }
5204
- } // always set the text value to the one from the vnode.
5205
5066
 
5067
+ idxInOld = oldKeyToIdx[newStartVnode.key];
5206
5068
 
5207
- node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5208
- vNode.elm = node;
5209
- }
5210
- }; // insert is called after update, which is used somewhere else (via a module)
5211
- // to mark the vm as inserted, that means we cannot use update as the main channel
5212
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
5213
- // which breaks some invariants. For that reason, we have the following for any
5214
- // Custom Element that is inserted via a template.
5069
+ if (isUndefined$1(idxInOld)) {
5070
+ // New element
5071
+ newStartVnode.hook.create(newStartVnode);
5072
+ newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5073
+ newStartVnode = newCh[++newStartIdx];
5074
+ } else {
5075
+ elmToMove = oldCh[idxInOld];
5215
5076
 
5216
- var ElementHook = {
5217
- create: function create(vnode) {
5218
- var sel = vnode.sel,
5219
- owner = vnode.owner,
5220
- svg = vnode.data.svg;
5221
- var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
5222
- var elm = createElement$2(sel, namespace);
5223
- linkNodeToShadow(elm, owner);
5224
- fallbackElmHook(elm, vnode);
5225
- vnode.elm = elm;
5226
- patchElementPropsAndAttrs(null, vnode);
5227
- },
5228
- update: function update(oldVnode, vnode) {
5229
- patchElementPropsAndAttrs(oldVnode, vnode);
5230
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
5231
- },
5232
- insert: function insert(vnode, parentNode, referenceNode) {
5233
- insertNodeHook(vnode, parentNode, referenceNode);
5234
- createChildrenHook(vnode);
5235
- },
5236
- move: function move(vnode, parentNode, referenceNode) {
5237
- insertNodeHook(vnode, parentNode, referenceNode);
5238
- },
5239
- remove: function remove(vnode, parentNode) {
5240
- removeNodeHook(vnode, parentNode);
5241
- removeElmHook(vnode);
5242
- },
5243
- hydrate: function hydrate(vnode, node) {
5244
- var elm = node;
5245
- vnode.elm = elm;
5246
- var context = vnode.data.context;
5247
- var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5248
- /* manual */
5249
- );
5250
-
5251
- if (isDomManual) {
5252
- // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5253
- // remove the innerHTML from props so it reuses the existing dom elements.
5254
- var props = vnode.data.props;
5255
-
5256
- if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5257
- if (elm.innerHTML === props.innerHTML) {
5258
- delete props.innerHTML;
5259
- } else {
5260
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5077
+ if (isVNode(elmToMove)) {
5078
+ if (elmToMove.sel !== newStartVnode.sel) {
5079
+ // New element
5080
+ newStartVnode.hook.create(newStartVnode);
5081
+ newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5082
+ } else {
5083
+ patchVnode(elmToMove, newStartVnode);
5084
+ oldCh[idxInOld] = undefined;
5085
+ newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5086
+ }
5261
5087
  }
5262
- }
5263
- }
5264
5088
 
5265
- hydrateElmHook(vnode);
5266
-
5267
- if (!isDomManual) {
5268
- hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
5089
+ newStartVnode = newCh[++newStartIdx];
5090
+ }
5269
5091
  }
5270
5092
  }
5271
- };
5272
- var CustomElementHook = {
5273
- create: function create(vnode) {
5274
- var sel = vnode.sel,
5275
- owner = vnode.owner;
5276
- var UpgradableConstructor = getUpgradableConstructor(sel);
5277
- /**
5278
- * Note: if the upgradable constructor does not expect, or throw when we new it
5279
- * with a callback as the first argument, we could implement a more advanced
5280
- * mechanism that only passes that argument if the constructor is known to be
5281
- * an upgradable custom element.
5282
- */
5283
-
5284
- var elm = new UpgradableConstructor(function (elm) {
5285
- // the custom element from the registry is expecting an upgrade callback
5286
- createViewModelHook(elm, vnode);
5287
- });
5288
- linkNodeToShadow(elm, owner);
5289
- vnode.elm = elm;
5290
- var vm = getAssociatedVMIfPresent(elm);
5291
-
5292
- if (vm) {
5293
- allocateChildrenHook(vnode, vm);
5294
- } else if (vnode.ctor !== UpgradableConstructor) {
5295
- throw new TypeError("Incorrect Component Constructor");
5296
- }
5297
5093
 
5298
- patchElementPropsAndAttrs(null, vnode);
5299
- },
5300
- update: function update(oldVnode, vnode) {
5301
- patchElementPropsAndAttrs(oldVnode, vnode);
5302
- var vm = getAssociatedVMIfPresent(vnode.elm);
5303
-
5304
- if (vm) {
5305
- // in fallback mode, the allocation will always set children to
5306
- // empty and delegate the real allocation to the slot elements
5307
- allocateChildrenHook(vnode, vm);
5308
- } // in fallback mode, the children will be always empty, so, nothing
5309
- // will happen, but in native, it does allocate the light dom
5310
-
5311
-
5312
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
5313
-
5314
- if (vm) {
5315
- if (process.env.NODE_ENV !== 'production') {
5316
- assert.isTrue(isArray$1(vnode.children), "Invalid vnode for a custom element, it must have children defined.");
5317
- } // this will probably update the shadowRoot, but only if the vm is in a dirty state
5318
- // this is important to preserve the top to bottom synchronous rendering phase.
5094
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
5095
+ if (oldStartIdx > oldEndIdx) {
5096
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
5097
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
5098
+ var _i14 = newEndIdx;
5099
+ var n;
5319
5100
 
5101
+ do {
5102
+ n = newCh[++_i14];
5103
+ } while (!isVNode(n) && _i14 < newChEnd);
5320
5104
 
5321
- rerenderVM(vm);
5105
+ before = isVNode(n) ? n.elm : null;
5106
+ addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5107
+ } else {
5108
+ removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5322
5109
  }
5323
- },
5324
- insert: function insert(vnode, parentNode, referenceNode) {
5325
- insertNodeHook(vnode, parentNode, referenceNode);
5326
- var vm = getAssociatedVMIfPresent(vnode.elm);
5110
+ }
5111
+ }
5327
5112
 
5328
- if (vm) {
5329
- if (process.env.NODE_ENV !== 'production') {
5330
- assert.isTrue(vm.state === 0
5331
- /* created */
5332
- , "".concat(vm, " cannot be recycled."));
5333
- }
5113
+ function updateStaticChildren(parentElm, oldCh, newCh) {
5114
+ var oldChLength = oldCh.length;
5115
+ var newChLength = newCh.length;
5334
5116
 
5335
- runConnectedCallback(vm);
5336
- }
5117
+ if (oldChLength === 0) {
5118
+ // the old list is empty, we can directly insert anything new
5119
+ addVnodes(parentElm, null, newCh, 0, newChLength);
5120
+ return;
5121
+ }
5337
5122
 
5338
- createChildrenHook(vnode);
5123
+ if (newChLength === 0) {
5124
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5125
+ // this is the case in which the dynamic children of an if-directive should be removed
5126
+ removeVnodes(parentElm, oldCh, 0, oldChLength);
5127
+ return;
5128
+ } // if the old list is not empty, the new list MUST have the same
5129
+ // amount of nodes, that's why we call this static children
5339
5130
 
5340
- if (vm) {
5341
- appendVM(vm);
5342
- }
5343
- },
5344
- move: function move(vnode, parentNode, referenceNode) {
5345
- insertNodeHook(vnode, parentNode, referenceNode);
5346
- },
5347
- remove: function remove(vnode, parentNode) {
5348
- removeNodeHook(vnode, parentNode);
5349
- var vm = getAssociatedVMIfPresent(vnode.elm);
5350
5131
 
5351
- if (vm) {
5352
- // for custom elements we don't have to go recursively because the removeVM routine
5353
- // will take care of disconnecting any child VM attached to its shadow as well.
5354
- removeVM(vm);
5355
- }
5356
- },
5357
- hydrate: function hydrate(vnode, elm) {
5358
- // the element is created, but the vm is not
5359
- var sel = vnode.sel,
5360
- mode = vnode.mode,
5361
- ctor = vnode.ctor,
5362
- owner = vnode.owner;
5363
- var def = getComponentInternalDef(ctor);
5364
- createVM(elm, def, {
5365
- mode: mode,
5366
- owner: owner,
5367
- tagName: sel
5368
- });
5369
- vnode.elm = elm;
5370
- var vm = getAssociatedVM(elm);
5371
- allocateChildrenHook(vnode, vm);
5372
- hydrateElmHook(vnode); // Insert hook section:
5132
+ var referenceElm = null;
5373
5133
 
5374
- if (process.env.NODE_ENV !== 'production') {
5375
- assert.isTrue(vm.state === 0
5376
- /* created */
5377
- , "".concat(vm, " cannot be recycled."));
5378
- }
5134
+ for (var _i15 = newChLength - 1; _i15 >= 0; _i15 -= 1) {
5135
+ var vnode = newCh[_i15];
5136
+ var oldVNode = oldCh[_i15];
5379
5137
 
5380
- runConnectedCallback(vm);
5138
+ if (vnode !== oldVNode) {
5139
+ if (isVNode(oldVNode)) {
5140
+ if (isVNode(vnode)) {
5141
+ // both vnodes must be equivalent, and se just need to patch them
5142
+ patchVnode(oldVNode, vnode);
5143
+ referenceElm = vnode.elm;
5144
+ } else {
5145
+ // removing the old vnode since the new one is null
5146
+ oldVNode.hook.remove(oldVNode, parentElm);
5147
+ }
5148
+ } else if (isVNode(vnode)) {
5149
+ // this condition is unnecessary
5150
+ vnode.hook.create(vnode); // insert the new node one since the old one is null
5381
5151
 
5382
- if (vm.renderMode !== 0
5383
- /* Light */
5384
- ) {
5385
- // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5386
- // Note: for Light DOM, this is handled while hydrating the VM
5387
- hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
5152
+ vnode.hook.insert(vnode, parentElm, referenceElm);
5153
+ referenceElm = vnode.elm;
5154
+ }
5388
5155
  }
5389
-
5390
- hydrateVM(vm);
5391
5156
  }
5392
- };
5393
-
5394
- function linkNodeToShadow(elm, owner) {
5395
- var renderMode = owner.renderMode,
5396
- shadowMode = owner.shadowMode; // TODO [#1164]: this should eventually be done by the polyfill directly
5157
+ }
5397
5158
 
5398
- if (isSyntheticShadowDefined$1) {
5399
- if (shadowMode === 1
5400
- /* Synthetic */
5401
- || renderMode === 0
5402
- /* Light */
5403
- ) {
5404
- elm[KEY__SHADOW_RESOLVER] = getRenderRoot(owner)[KEY__SHADOW_RESOLVER];
5405
- }
5159
+ function patchVnode(oldVnode, vnode) {
5160
+ if (oldVnode !== vnode) {
5161
+ vnode.elm = oldVnode.elm;
5162
+ vnode.hook.update(oldVnode, vnode);
5406
5163
  }
5407
5164
  }
5165
+ /*
5166
+ * Copyright (c) 2018, salesforce.com, inc.
5167
+ * All rights reserved.
5168
+ * SPDX-License-Identifier: MIT
5169
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5170
+ */
5171
+
5172
+
5173
+ var SymbolIterator = Symbol.iterator;
5408
5174
 
5409
5175
  function addVNodeToChildLWC(vnode) {
5410
5176
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
@@ -5429,18 +5195,20 @@ var LWC = (function (exports) {
5429
5195
 
5430
5196
  forEach.call(children, function (childVnode) {
5431
5197
  if (childVnode != null) {
5432
- assert.isTrue(childVnode && 'sel' in childVnode && 'data' in childVnode && 'children' in childVnode && 'text' in childVnode && 'elm' in childVnode && 'key' in childVnode, "".concat(childVnode, " is not a vnode."));
5198
+ assert.isTrue('type' in childVnode && 'sel' in childVnode && 'elm' in childVnode && 'key' in childVnode, "".concat(childVnode, " is not a vnode."));
5433
5199
  }
5434
5200
  });
5435
5201
  }
5436
5202
 
5437
- var text, elm;
5203
+ var elm;
5438
5204
  var key = data.key;
5439
5205
  return {
5206
+ type: 2
5207
+ /* Element */
5208
+ ,
5440
5209
  sel: sel,
5441
5210
  data: data,
5442
5211
  children: children,
5443
- text: text,
5444
5212
  elm: elm,
5445
5213
  key: key,
5446
5214
  hook: ElementHook,
@@ -5520,19 +5288,21 @@ var LWC = (function (exports) {
5520
5288
  if (arguments.length === 4) {
5521
5289
  forEach.call(children, function (childVnode) {
5522
5290
  if (childVnode != null) {
5523
- assert.isTrue(childVnode && 'sel' in childVnode && 'data' in childVnode && 'children' in childVnode && 'text' in childVnode && 'elm' in childVnode && 'key' in childVnode, "".concat(childVnode, " is not a vnode."));
5291
+ assert.isTrue('type' in childVnode && 'sel' in childVnode && 'elm' in childVnode && 'key' in childVnode, "".concat(childVnode, " is not a vnode."));
5524
5292
  }
5525
5293
  });
5526
5294
  }
5527
5295
  }
5528
5296
 
5529
5297
  var key = data.key;
5530
- var text, elm;
5298
+ var elm;
5531
5299
  var vnode = {
5300
+ type: 3
5301
+ /* CustomElement */
5302
+ ,
5532
5303
  sel: sel,
5533
5304
  data: data,
5534
5305
  children: children,
5535
- text: text,
5536
5306
  elm: elm,
5537
5307
  key: key,
5538
5308
  hook: CustomElementHook,
@@ -5657,12 +5427,12 @@ var LWC = (function (exports) {
5657
5427
 
5658
5428
 
5659
5429
  function t(text) {
5660
- var data = EmptyObject;
5661
- var sel, children, key, elm;
5430
+ var sel, key, elm;
5662
5431
  return {
5432
+ type: 0
5433
+ /* Text */
5434
+ ,
5663
5435
  sel: sel,
5664
- data: data,
5665
- children: children,
5666
5436
  text: text,
5667
5437
  elm: elm,
5668
5438
  key: key,
@@ -5673,12 +5443,12 @@ var LWC = (function (exports) {
5673
5443
 
5674
5444
 
5675
5445
  function co(text) {
5676
- var data = EmptyObject;
5677
- var sel, children, key, elm;
5446
+ var sel, key, elm;
5678
5447
  return {
5448
+ type: 1
5449
+ /* Comment */
5450
+ ,
5679
5451
  sel: sel,
5680
- data: data,
5681
- children: children,
5682
5452
  text: text,
5683
5453
  elm: elm,
5684
5454
  key: key,
@@ -5971,8 +5741,8 @@ var LWC = (function (exports) {
5971
5741
  var content = [];
5972
5742
  var root;
5973
5743
 
5974
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
5975
- var stylesheet = stylesheets[_i18];
5744
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5745
+ var stylesheet = stylesheets[_i16];
5976
5746
 
5977
5747
  if (isArray$1(stylesheet)) {
5978
5748
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -6082,8 +5852,8 @@ var LWC = (function (exports) {
6082
5852
  && shadowMode === 1
6083
5853
  /* Synthetic */
6084
5854
  ) {
6085
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6086
- insertGlobalStylesheet$1(stylesheets[_i19]);
5855
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5856
+ insertGlobalStylesheet$1(stylesheets[_i17]);
6087
5857
  }
6088
5858
  } else if (ssr$1 || isHydrating$1()) {
6089
5859
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -6097,12 +5867,12 @@ var LWC = (function (exports) {
6097
5867
  var root = getNearestNativeShadowComponent(vm);
6098
5868
  var isGlobal = isNull(root);
6099
5869
 
6100
- for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
5870
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
6101
5871
  if (isGlobal) {
6102
- insertGlobalStylesheet$1(stylesheets[_i20]);
5872
+ insertGlobalStylesheet$1(stylesheets[_i18]);
6103
5873
  } else {
6104
5874
  // local level
6105
- insertStylesheet$1(stylesheets[_i20], root.cmpRoot);
5875
+ insertStylesheet$1(stylesheets[_i18], root.shadowRoot);
6106
5876
  }
6107
5877
  }
6108
5878
  }
@@ -6379,8 +6149,8 @@ var LWC = (function (exports) {
6379
6149
  var stylesheets = template.stylesheets;
6380
6150
 
6381
6151
  if (!isUndefined$1(stylesheets)) {
6382
- for (var _i21 = 0; _i21 < stylesheets.length; _i21++) {
6383
- if (isTrue(stylesheets[_i21][KEY__SCOPED_CSS])) {
6152
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6153
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
6384
6154
  return true;
6385
6155
  }
6386
6156
  }
@@ -6396,24 +6166,6 @@ var LWC = (function (exports) {
6396
6166
  */
6397
6167
 
6398
6168
 
6399
- function addErrorComponentStack(vm, error) {
6400
- if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
6401
- var wcStack = getErrorComponentStack(vm);
6402
- defineProperty(error, 'wcStack', {
6403
- get: function get() {
6404
- return wcStack;
6405
- }
6406
- });
6407
- }
6408
- }
6409
- /*
6410
- * Copyright (c) 2018, salesforce.com, inc.
6411
- * All rights reserved.
6412
- * SPDX-License-Identifier: MIT
6413
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6414
- */
6415
-
6416
-
6417
6169
  var isInvokingRender = false;
6418
6170
  var vmBeingConstructed = null;
6419
6171
 
@@ -6610,8 +6362,8 @@ var LWC = (function (exports) {
6610
6362
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6611
6363
  }
6612
6364
 
6613
- for (var _i22 = 0; _i22 < hooks.length; ++_i22) {
6614
- var hookName = hooks[_i22];
6365
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6366
+ var hookName = hooks[_i20];
6615
6367
 
6616
6368
  if (hookName in service) {
6617
6369
  var l = Services[hookName];
@@ -6634,9 +6386,318 @@ var LWC = (function (exports) {
6634
6386
  def = vm.def,
6635
6387
  context = vm.context;
6636
6388
 
6637
- for (var _i23 = 0, _len8 = cbs.length; _i23 < _len8; ++_i23) {
6638
- cbs[_i23].call(undefined, component, {}, def, context);
6389
+ for (var _i21 = 0, _len8 = cbs.length; _i21 < _len8; ++_i21) {
6390
+ cbs[_i21].call(undefined, component, {}, def, context);
6391
+ }
6392
+ }
6393
+ /*
6394
+ * Copyright (c) 2022, salesforce.com, inc.
6395
+ * All rights reserved.
6396
+ * SPDX-License-Identifier: MIT
6397
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6398
+ */
6399
+
6400
+
6401
+ function hydrate$1(vnode, node) {
6402
+ switch (vnode.type) {
6403
+ case 0
6404
+ /* Text */
6405
+ :
6406
+ hydrateText(vnode, node);
6407
+ break;
6408
+
6409
+ case 1
6410
+ /* Comment */
6411
+ :
6412
+ hydrateComment(vnode, node);
6413
+ break;
6414
+
6415
+ case 2
6416
+ /* Element */
6417
+ :
6418
+ hydrateElement(vnode, node);
6419
+ break;
6420
+
6421
+ case 3
6422
+ /* CustomElement */
6423
+ :
6424
+ hydrateCustomElement(vnode, node);
6425
+ break;
6426
+ }
6427
+ }
6428
+
6429
+ function hydrateText(vnode, node) {
6430
+ var _a;
6431
+
6432
+ if (process.env.NODE_ENV !== 'production') {
6433
+ // eslint-disable-next-line lwc-internal/no-global-node
6434
+ validateNodeType(vnode, node, Node.TEXT_NODE);
6435
+
6436
+ if (node.nodeValue !== vnode.text && !(node.nodeValue === "\u200D" && vnode.text === '')) {
6437
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6438
+ }
6439
+ } // always set the text value to the one from the vnode.
6440
+
6441
+
6442
+ node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6443
+ vnode.elm = node;
6444
+ }
6445
+
6446
+ function hydrateComment(vnode, node) {
6447
+ var _a;
6448
+
6449
+ if (process.env.NODE_ENV !== 'production') {
6450
+ // eslint-disable-next-line lwc-internal/no-global-node
6451
+ validateNodeType(vnode, node, Node.COMMENT_NODE);
6452
+
6453
+ if (node.nodeValue !== vnode.text) {
6454
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6455
+ }
6456
+ } // always set the text value to the one from the vnode.
6457
+
6458
+
6459
+ node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6460
+ vnode.elm = node;
6461
+ }
6462
+
6463
+ function hydrateElement(vnode, node) {
6464
+ if (process.env.NODE_ENV !== 'production') {
6465
+ // eslint-disable-next-line lwc-internal/no-global-node
6466
+ validateNodeType(vnode, node, Node.ELEMENT_NODE);
6467
+ validateElement(vnode, node);
6468
+ }
6469
+
6470
+ var elm = node;
6471
+ vnode.elm = elm;
6472
+ var context = vnode.data.context;
6473
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
6474
+ /* Manual */
6475
+ );
6476
+
6477
+ if (isDomManual) {
6478
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
6479
+ // remove the innerHTML from props so it reuses the existing dom elements.
6480
+ var props = vnode.data.props;
6481
+
6482
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6483
+ if (elm.innerHTML === props.innerHTML) {
6484
+ delete props.innerHTML;
6485
+ } else {
6486
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6487
+ }
6488
+ }
6489
+ }
6490
+
6491
+ patchElementPropsAndAttrs(vnode);
6492
+
6493
+ if (!isDomManual) {
6494
+ hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
6495
+ }
6496
+ }
6497
+
6498
+ function hydrateCustomElement(vnode, node) {
6499
+ if (process.env.NODE_ENV !== 'production') {
6500
+ // eslint-disable-next-line lwc-internal/no-global-node
6501
+ validateNodeType(vnode, node, Node.ELEMENT_NODE);
6502
+ validateElement(vnode, node);
6503
+ }
6504
+
6505
+ var elm = node;
6506
+ vnode.elm = elm;
6507
+ var sel = vnode.sel,
6508
+ mode = vnode.mode,
6509
+ ctor = vnode.ctor,
6510
+ owner = vnode.owner;
6511
+ var vm = createVM(elm, ctor, {
6512
+ mode: mode,
6513
+ owner: owner,
6514
+ tagName: sel
6515
+ });
6516
+ allocateChildren(vnode, vm);
6517
+ patchElementPropsAndAttrs(vnode); // Insert hook section:
6518
+
6519
+ if (process.env.NODE_ENV !== 'production') {
6520
+ assert.isTrue(vm.state === 0
6521
+ /* created */
6522
+ , "".concat(vm, " cannot be recycled."));
6523
+ }
6524
+
6525
+ runConnectedCallback(vm);
6526
+
6527
+ if (vm.renderMode !== 0
6528
+ /* Light */
6529
+ ) {
6530
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6531
+ // Note: for Light DOM, this is handled while hydrating the VM
6532
+ hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
6533
+ }
6534
+
6535
+ hydrateVM(vm);
6536
+ }
6537
+
6538
+ function hydrateChildren(elmChildren, children, vm) {
6539
+ if (process.env.NODE_ENV !== 'production') {
6540
+ var filteredVNodes = ArrayFilter.call(children, function (vnode) {
6541
+ return !!vnode;
6542
+ });
6543
+
6544
+ if (elmChildren.length !== filteredVNodes.length) {
6545
+ logError("Hydration mismatch: incorrect number of rendered nodes, expected ".concat(filteredVNodes.length, " but found ").concat(elmChildren.length, "."), vm);
6546
+ throwHydrationError();
6547
+ }
6548
+ }
6549
+
6550
+ var childNodeIndex = 0;
6551
+
6552
+ for (var _i22 = 0; _i22 < children.length; _i22++) {
6553
+ var childVnode = children[_i22];
6554
+
6555
+ if (!isNull(childVnode)) {
6556
+ var childNode = elmChildren[childNodeIndex];
6557
+ hydrate$1(childVnode, childNode);
6558
+ childNodeIndex++;
6559
+ }
6560
+ }
6561
+ }
6562
+
6563
+ function patchElementPropsAndAttrs(vnode) {
6564
+ applyEventListeners(vnode);
6565
+ patchProps(null, vnode);
6566
+ }
6567
+
6568
+ function throwHydrationError() {
6569
+ assert.fail('Server rendered elements do not match client side generated elements');
6570
+ }
6571
+
6572
+ function validateNodeType(vnode, node, nodeType) {
6573
+ if (node.nodeType !== nodeType) {
6574
+ logError('Hydration mismatch: incorrect node type received', vnode.owner);
6575
+ assert.fail('Hydration mismatch: incorrect node type received.');
6576
+ }
6577
+ }
6578
+
6579
+ function validateElement(vnode, elm) {
6580
+ if (vnode.sel.toLowerCase() !== elm.tagName.toLowerCase()) {
6581
+ logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(elm.tagName.toLowerCase(), "\"."), vnode.owner);
6582
+ throwHydrationError();
6583
+ }
6584
+
6585
+ var hasIncompatibleAttrs = validateAttrs(vnode, elm);
6586
+ var hasIncompatibleClass = validateClassAttr(vnode, elm);
6587
+ var hasIncompatibleStyle = validateStyleAttr(vnode, elm);
6588
+ var isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6589
+
6590
+ if (!isVNodeAndElementCompatible) {
6591
+ throwHydrationError();
6592
+ }
6593
+ }
6594
+
6595
+ function validateAttrs(vnode, elm) {
6596
+ var _vnode$data$attrs = vnode.data.attrs,
6597
+ attrs = _vnode$data$attrs === void 0 ? {} : _vnode$data$attrs;
6598
+ var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
6599
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6600
+
6601
+ for (var _i23 = 0, _Object$entries = Object.entries(attrs); _i23 < _Object$entries.length; _i23++) {
6602
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i23], 2),
6603
+ attrName = _Object$entries$_i[0],
6604
+ attrValue = _Object$entries$_i[1];
6605
+
6606
+ var elmAttrValue = getAttribute$1(elm, attrName);
6607
+
6608
+ if (String(attrValue) !== elmAttrValue) {
6609
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
6610
+ nodesAreCompatible = false;
6611
+ }
6612
+ }
6613
+
6614
+ return nodesAreCompatible;
6615
+ }
6616
+
6617
+ function validateClassAttr(vnode, elm) {
6618
+ var _vnode$data = vnode.data,
6619
+ className = _vnode$data.className,
6620
+ classMap = _vnode$data.classMap;
6621
+ var nodesAreCompatible = true;
6622
+ var vnodeClassName;
6623
+
6624
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
6625
+ // className is used when class is bound to an expr.
6626
+ nodesAreCompatible = false;
6627
+ vnodeClassName = className;
6628
+ } else if (!isUndefined$1(classMap)) {
6629
+ // classMap is used when class is set to static value.
6630
+ var classList = getClassList$1(elm);
6631
+ var computedClassName = ''; // all classes from the vnode should be in the element.classList
6632
+
6633
+ for (var name in classMap) {
6634
+ computedClassName += ' ' + name;
6635
+
6636
+ if (!classList.contains(name)) {
6637
+ nodesAreCompatible = false;
6638
+ }
6639
+ }
6640
+
6641
+ vnodeClassName = computedClassName.trim();
6642
+
6643
+ if (classList.length > keys(classMap).length) {
6644
+ nodesAreCompatible = false;
6645
+ }
6646
+ }
6647
+
6648
+ if (!nodesAreCompatible) {
6649
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(elm.className, "\""), vnode.owner);
6650
+ }
6651
+
6652
+ return nodesAreCompatible;
6653
+ }
6654
+
6655
+ function validateStyleAttr(vnode, elm) {
6656
+ var _vnode$data2 = vnode.data,
6657
+ style = _vnode$data2.style,
6658
+ styleDecls = _vnode$data2.styleDecls;
6659
+ var elmStyle = getAttribute$1(elm, 'style') || '';
6660
+ var vnodeStyle;
6661
+ var nodesAreCompatible = true;
6662
+
6663
+ if (!isUndefined$1(style) && style !== elmStyle) {
6664
+ nodesAreCompatible = false;
6665
+ vnodeStyle = style;
6666
+ } else if (!isUndefined$1(styleDecls)) {
6667
+ var parsedVnodeStyle = parseStyleText(elmStyle);
6668
+ var expectedStyle = []; // styleMap is used when style is set to static value.
6669
+
6670
+ for (var _i24 = 0, n = styleDecls.length; _i24 < n; _i24++) {
6671
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i24], 3),
6672
+ prop = _styleDecls$_i2[0],
6673
+ value = _styleDecls$_i2[1],
6674
+ important = _styleDecls$_i2[2];
6675
+
6676
+ expectedStyle.push("".concat(prop, ": ").concat(value + (important ? ' important!' : '')));
6677
+ var parsedPropValue = parsedVnodeStyle[prop];
6678
+
6679
+ if (isUndefined$1(parsedPropValue)) {
6680
+ nodesAreCompatible = false;
6681
+ } else if (!parsedPropValue.startsWith(value)) {
6682
+ nodesAreCompatible = false;
6683
+ } else if (important && !parsedPropValue.endsWith('!important')) {
6684
+ nodesAreCompatible = false;
6685
+ }
6686
+ }
6687
+
6688
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
6689
+ nodesAreCompatible = false;
6690
+ }
6691
+
6692
+ vnodeStyle = ArrayJoin.call(expectedStyle, ';');
6693
+ }
6694
+
6695
+ if (!nodesAreCompatible) {
6696
+ // style is used when class is bound to an expr.
6697
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
6639
6698
  }
6699
+
6700
+ return nodesAreCompatible;
6640
6701
  }
6641
6702
  /*
6642
6703
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6761,10 +6822,11 @@ var LWC = (function (exports) {
6761
6822
  return ancestor;
6762
6823
  }
6763
6824
 
6764
- function createVM(elm, def, options) {
6825
+ function createVM(elm, ctor, options) {
6765
6826
  var mode = options.mode,
6766
6827
  owner = options.owner,
6767
6828
  tagName = options.tagName;
6829
+ var def = getComponentInternalDef(ctor);
6768
6830
  var vm = {
6769
6831
  elm: elm,
6770
6832
  def: def,
@@ -6786,7 +6848,6 @@ var LWC = (function (exports) {
6786
6848
  oar: create(null),
6787
6849
  cmpTemplate: null,
6788
6850
  renderMode: def.renderMode,
6789
- shadowMode: null,
6790
6851
  context: {
6791
6852
  stylesheetToken: undefined,
6792
6853
  hasTokenInClass: undefined,
@@ -6797,9 +6858,13 @@ var LWC = (function (exports) {
6797
6858
  wiredConnecting: EmptyArray,
6798
6859
  wiredDisconnecting: EmptyArray
6799
6860
  },
6861
+ // Properties set right after VM creation.
6800
6862
  tro: null,
6863
+ shadowMode: null,
6864
+ // Properties set by the LightningElement constructor.
6801
6865
  component: null,
6802
- cmpRoot: null,
6866
+ shadowRoot: null,
6867
+ renderRoot: null,
6803
6868
  callHook: callHook,
6804
6869
  setHook: setHook,
6805
6870
  getHook: getHook
@@ -6885,7 +6950,7 @@ var LWC = (function (exports) {
6885
6950
  }
6886
6951
 
6887
6952
  function assertIsVM(obj) {
6888
- if (isNull(obj) || !isObject(obj) || !('cmpRoot' in obj)) {
6953
+ if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
6889
6954
  throw new TypeError("".concat(obj, " is not a VM."));
6890
6955
  }
6891
6956
  }
@@ -6934,13 +6999,14 @@ var LWC = (function (exports) {
6934
6999
  var vmChildren = vm.renderMode === 0
6935
7000
  /* Light */
6936
7001
  ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
6937
- hydrateChildrenHook(vmChildren, children, vm);
7002
+ hydrateChildren(vmChildren, children, vm);
6938
7003
  runRenderedCallback(vm);
6939
7004
  }
6940
7005
  }
6941
7006
 
6942
7007
  function patchShadowRoot(vm, newCh) {
6943
- var oldCh = vm.children; // caching the new children collection
7008
+ var renderRoot = vm.renderRoot,
7009
+ oldCh = vm.children; // caching the new children collection
6944
7010
 
6945
7011
  vm.children = newCh;
6946
7012
 
@@ -6955,7 +7021,6 @@ var LWC = (function (exports) {
6955
7021
  , vm);
6956
7022
  }, function () {
6957
7023
  // job
6958
- var renderRoot = getRenderRoot(vm);
6959
7024
  patchChildren(renderRoot, oldCh, newCh);
6960
7025
  }, function () {
6961
7026
  // post
@@ -7017,19 +7082,19 @@ var LWC = (function (exports) {
7017
7082
  });
7018
7083
  rehydrateQueue = []; // reset to a new queue
7019
7084
 
7020
- for (var _i24 = 0, _len9 = vms.length; _i24 < _len9; _i24 += 1) {
7021
- var vm = vms[_i24];
7085
+ for (var _i25 = 0, _len9 = vms.length; _i25 < _len9; _i25 += 1) {
7086
+ var vm = vms[_i25];
7022
7087
 
7023
7088
  try {
7024
7089
  rehydrate(vm);
7025
7090
  } catch (error) {
7026
- if (_i24 + 1 < _len9) {
7091
+ if (_i25 + 1 < _len9) {
7027
7092
  // pieces of the queue are still pending to be rehydrated, those should have priority
7028
7093
  if (rehydrateQueue.length === 0) {
7029
7094
  addCallbackToNextTick(flushRehydrationQueue);
7030
7095
  }
7031
7096
 
7032
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i24 + 1));
7097
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i25 + 1));
7033
7098
  } // we need to end the measure before throwing.
7034
7099
 
7035
7100
 
@@ -7133,8 +7198,8 @@ var LWC = (function (exports) {
7133
7198
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
7134
7199
  // inserted in reserved order.
7135
7200
 
7136
- for (var _i25 = vCustomElementCollection.length - 1; _i25 >= 0; _i25 -= 1) {
7137
- var elm = vCustomElementCollection[_i25].elm; // There are two cases where the element could be undefined:
7201
+ for (var _i26 = vCustomElementCollection.length - 1; _i26 >= 0; _i26 -= 1) {
7202
+ var elm = vCustomElementCollection[_i26].elm; // There are two cases where the element could be undefined:
7138
7203
  // * when there is an error during the construction phase, and an error
7139
7204
  // boundary picks it, there is a possibility that the VCustomElement
7140
7205
  // is not properly initialized, and therefore is should be ignored.
@@ -7168,17 +7233,25 @@ var LWC = (function (exports) {
7168
7233
 
7169
7234
 
7170
7235
  function recursivelyDisconnectChildren(vnodes) {
7171
- for (var _i26 = 0, _len10 = vnodes.length; _i26 < _len10; _i26 += 1) {
7172
- var vnode = vnodes[_i26];
7173
-
7174
- if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
7175
- // vnode is a VElement with children
7176
- if (isUndefined$1(vnode.ctor)) {
7177
- // it is a VElement, just keep looking (recursively)
7178
- recursivelyDisconnectChildren(vnode.children);
7179
- } else {
7180
- // it is a VCustomElement, disconnect it and ignore its children
7181
- resetComponentStateWhenRemoved(getAssociatedVM(vnode.elm));
7236
+ for (var _i27 = 0, _len10 = vnodes.length; _i27 < _len10; _i27 += 1) {
7237
+ var vnode = vnodes[_i27];
7238
+
7239
+ if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
7240
+ switch (vnode.type) {
7241
+ case 2
7242
+ /* Element */
7243
+ :
7244
+ recursivelyDisconnectChildren(vnode.children);
7245
+ break;
7246
+
7247
+ case 3
7248
+ /* CustomElement */
7249
+ :
7250
+ {
7251
+ var vm = getAssociatedVM(vnode.elm);
7252
+ resetComponentStateWhenRemoved(vm);
7253
+ break;
7254
+ }
7182
7255
  }
7183
7256
  }
7184
7257
  }
@@ -7189,14 +7262,14 @@ var LWC = (function (exports) {
7189
7262
 
7190
7263
 
7191
7264
  function resetComponentRoot(vm) {
7192
- var children = vm.children;
7193
- var rootNode = getRenderRoot(vm);
7265
+ var children = vm.children,
7266
+ renderRoot = vm.renderRoot;
7194
7267
 
7195
- for (var _i27 = 0, _len11 = children.length; _i27 < _len11; _i27++) {
7196
- var child = children[_i27];
7268
+ for (var _i28 = 0, _len11 = children.length; _i28 < _len11; _i28++) {
7269
+ var child = children[_i28];
7197
7270
 
7198
7271
  if (!isNull(child) && !isUndefined$1(child.elm)) {
7199
- remove$1(child.elm, rootNode);
7272
+ remove$1(child.elm, renderRoot);
7200
7273
  }
7201
7274
  }
7202
7275
 
@@ -7284,12 +7357,6 @@ var LWC = (function (exports) {
7284
7357
  scheduleRehydration(vm);
7285
7358
  }
7286
7359
  }
7287
-
7288
- function getRenderRoot(vm) {
7289
- return vm.renderMode === 1
7290
- /* Shadow */
7291
- ? vm.cmpRoot : vm.elm;
7292
- }
7293
7360
  /*
7294
7361
  * Copyright (c) 2018, salesforce.com, inc.
7295
7362
  * All rights reserved.
@@ -7573,8 +7640,8 @@ var LWC = (function (exports) {
7573
7640
  function connectWireAdapters(vm) {
7574
7641
  var wiredConnecting = vm.context.wiredConnecting;
7575
7642
 
7576
- for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
7577
- wiredConnecting[_i28]();
7643
+ for (var _i29 = 0, _len12 = wiredConnecting.length; _i29 < _len12; _i29 += 1) {
7644
+ wiredConnecting[_i29]();
7578
7645
  }
7579
7646
  }
7580
7647
 
@@ -7582,8 +7649,8 @@ var LWC = (function (exports) {
7582
7649
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7583
7650
  runWithBoundaryProtection(vm, vm, noop, function () {
7584
7651
  // job
7585
- for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
7586
- wiredDisconnecting[_i29]();
7652
+ for (var _i30 = 0, _len13 = wiredDisconnecting.length; _i30 < _len13; _i30 += 1) {
7653
+ wiredDisconnecting[_i30]();
7587
7654
  }
7588
7655
  }, noop);
7589
7656
  }
@@ -7673,7 +7740,7 @@ var LWC = (function (exports) {
7673
7740
  hooksAreSet = true;
7674
7741
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7675
7742
  }
7676
- /* version: 2.7.3 */
7743
+ /* version: 2.7.4 */
7677
7744
 
7678
7745
  /*
7679
7746
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7688,8 +7755,8 @@ var LWC = (function (exports) {
7688
7755
  if (process.env.NODE_ENV === 'development') {
7689
7756
  // @ts-ignore
7690
7757
  window.__lwcResetGlobalStylesheets = function () {
7691
- for (var _i30 = 0, _Object$keys = Object.keys(globalStylesheets); _i30 < _Object$keys.length; _i30++) {
7692
- var key = _Object$keys[_i30];
7758
+ for (var _i31 = 0, _Object$keys = Object.keys(globalStylesheets); _i31 < _Object$keys.length; _i31++) {
7759
+ var key = _Object$keys[_i31];
7693
7760
  delete globalStylesheets[key];
7694
7761
  }
7695
7762
  };
@@ -8147,8 +8214,7 @@ var LWC = (function (exports) {
8147
8214
  */
8148
8215
 
8149
8216
  var element = new UpgradableConstructor(function (elm) {
8150
- var def = getComponentInternalDef(Ctor);
8151
- createVM(elm, def, {
8217
+ createVM(elm, Ctor, {
8152
8218
  tagName: sel,
8153
8219
  mode: options.mode !== 'closed' ? 'open' : 'closed',
8154
8220
  owner: null
@@ -8188,20 +8254,18 @@ var LWC = (function (exports) {
8188
8254
  throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8189
8255
  }
8190
8256
 
8191
- var def = getComponentInternalDef(Ctor);
8192
-
8193
8257
  try {
8194
8258
  // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8195
8259
  // and uses the same algo to create the stylesheets as in SSR.
8196
8260
  setIsHydrating(true);
8197
- createVM(element, def, {
8261
+ createVM(element, Ctor, {
8198
8262
  mode: 'open',
8199
8263
  owner: null,
8200
8264
  tagName: element.tagName.toLowerCase()
8201
8265
  });
8202
8266
 
8203
- for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
8204
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
8267
+ for (var _i32 = 0, _Object$entries2 = Object.entries(props); _i32 < _Object$entries2.length; _i32++) {
8268
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i32], 2),
8205
8269
  key = _Object$entries2$_i[0],
8206
8270
  value = _Object$entries2$_i[1];
8207
8271
 
@@ -8223,8 +8287,8 @@ var LWC = (function (exports) {
8223
8287
  mode: 'open'
8224
8288
  });
8225
8289
 
8226
- for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
8227
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
8290
+ for (var _i33 = 0, _Object$entries3 = Object.entries(props); _i33 < _Object$entries3.length; _i33++) {
8291
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i33], 2),
8228
8292
  _key3 = _Object$entries3$_i[0],
8229
8293
  _value2 = _Object$entries3$_i[1];
8230
8294
 
@@ -8268,9 +8332,9 @@ var LWC = (function (exports) {
8268
8332
  }
8269
8333
 
8270
8334
  function buildCustomElementConstructor(Ctor) {
8271
- var def = getComponentInternalDef(Ctor);
8272
- return /*#__PURE__*/function (_def$bridge) {
8273
- _inherits(_class, _def$bridge);
8335
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8336
+ return /*#__PURE__*/function (_HtmlPrototype) {
8337
+ _inherits(_class, _HtmlPrototype);
8274
8338
 
8275
8339
  var _super8 = _createSuper(_class);
8276
8340
 
@@ -8280,7 +8344,7 @@ var LWC = (function (exports) {
8280
8344
  _classCallCheck(this, _class);
8281
8345
 
8282
8346
  _this6 = _super8.call(this);
8283
- createVM(_assertThisInitialized(_this6), def, {
8347
+ createVM(_assertThisInitialized(_this6), Ctor, {
8284
8348
  mode: 'open',
8285
8349
  owner: null,
8286
8350
  tagName: _this6.tagName
@@ -8301,7 +8365,7 @@ var LWC = (function (exports) {
8301
8365
  }]);
8302
8366
 
8303
8367
  return _class;
8304
- }(def.bridge);
8368
+ }(HtmlPrototype);
8305
8369
  }
8306
8370
  /*
8307
8371
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8408,7 +8472,7 @@ var LWC = (function (exports) {
8408
8472
  });
8409
8473
  freeze(LightningElement);
8410
8474
  seal(LightningElement.prototype);
8411
- /* version: 2.7.3 */
8475
+ /* version: 2.7.4 */
8412
8476
 
8413
8477
  exports.LightningElement = LightningElement;
8414
8478
  exports.__unstable__ProfilerControl = profilerControl;