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
@@ -341,7 +341,11 @@ var LWC = (function (exports) {
341
341
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
342
342
  return attributeName;
343
343
  }
344
- /** version: 2.7.3 */
344
+
345
+ var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
346
+ var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
347
+ var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
348
+ /** version: 2.7.4 */
345
349
 
346
350
  /*
347
351
  * Copyright (c) 2018, salesforce.com, inc.
@@ -350,7 +354,6 @@ var LWC = (function (exports) {
350
354
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
351
355
  */
352
356
 
353
-
354
357
  function detect(propName) {
355
358
  return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
356
359
  }
@@ -511,7 +514,7 @@ var LWC = (function (exports) {
511
514
 
512
515
  function setFeatureFlagForTest(name, value) {
513
516
  }
514
- /** version: 2.7.3 */
517
+ /** version: 2.7.4 */
515
518
 
516
519
  /* proxy-compat-disable */
517
520
 
@@ -978,6 +981,24 @@ var LWC = (function (exports) {
978
981
  */
979
982
 
980
983
 
984
+ function addErrorComponentStack(vm, error) {
985
+ if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
986
+ var wcStack = getErrorComponentStack(vm);
987
+ defineProperty(error, 'wcStack', {
988
+ get: function get() {
989
+ return wcStack;
990
+ }
991
+ });
992
+ }
993
+ }
994
+ /*
995
+ * Copyright (c) 2018, salesforce.com, inc.
996
+ * All rights reserved.
997
+ * SPDX-License-Identifier: MIT
998
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
999
+ */
1000
+
1001
+
981
1002
  function log(method, message, vm) {
982
1003
  var msg = "[LWC ".concat(method, "]: ").concat(message);
983
1004
 
@@ -1002,207 +1023,12 @@ var LWC = (function (exports) {
1002
1023
  * SPDX-License-Identifier: MIT
1003
1024
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1004
1025
  */
1026
+ // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
1027
+ // to inject at runtime.
1005
1028
 
1006
1029
 
1007
- function isUndef(s) {
1008
- return s === undefined;
1009
- }
1010
-
1011
- function sameVnode(vnode1, vnode2) {
1012
- return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
1013
- }
1014
-
1015
- function isVNode(vnode) {
1016
- return vnode != null;
1017
- }
1018
-
1019
- function createKeyToOldIdx(children, beginIdx, endIdx) {
1020
- var map = {};
1021
- var j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
1022
-
1023
- for (j = beginIdx; j <= endIdx; ++j) {
1024
- ch = children[j];
1025
-
1026
- if (isVNode(ch)) {
1027
- key = ch.key;
1028
-
1029
- if (key !== undefined) {
1030
- map[key] = j;
1031
- }
1032
- }
1033
- }
1034
-
1035
- return map;
1036
- }
1037
-
1038
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
1039
- for (; startIdx <= endIdx; ++startIdx) {
1040
- var ch = vnodes[startIdx];
1041
-
1042
- if (isVNode(ch)) {
1043
- ch.hook.create(ch);
1044
- ch.hook.insert(ch, parentElm, before);
1045
- }
1046
- }
1047
- }
1048
-
1049
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
1050
- for (; startIdx <= endIdx; ++startIdx) {
1051
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
1052
-
1053
- if (isVNode(ch)) {
1054
- ch.hook.remove(ch, parentElm);
1055
- }
1056
- }
1057
- }
1058
-
1059
- function updateDynamicChildren(parentElm, oldCh, newCh) {
1060
- var oldStartIdx = 0;
1061
- var newStartIdx = 0;
1062
- var oldEndIdx = oldCh.length - 1;
1063
- var oldStartVnode = oldCh[0];
1064
- var oldEndVnode = oldCh[oldEndIdx];
1065
- var newChEnd = newCh.length - 1;
1066
- var newEndIdx = newChEnd;
1067
- var newStartVnode = newCh[0];
1068
- var newEndVnode = newCh[newEndIdx];
1069
- var oldKeyToIdx;
1070
- var idxInOld;
1071
- var elmToMove;
1072
- var before;
1073
-
1074
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1075
- if (!isVNode(oldStartVnode)) {
1076
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
1077
- } else if (!isVNode(oldEndVnode)) {
1078
- oldEndVnode = oldCh[--oldEndIdx];
1079
- } else if (!isVNode(newStartVnode)) {
1080
- newStartVnode = newCh[++newStartIdx];
1081
- } else if (!isVNode(newEndVnode)) {
1082
- newEndVnode = newCh[--newEndIdx];
1083
- } else if (sameVnode(oldStartVnode, newStartVnode)) {
1084
- patchVnode(oldStartVnode, newStartVnode);
1085
- oldStartVnode = oldCh[++oldStartIdx];
1086
- newStartVnode = newCh[++newStartIdx];
1087
- } else if (sameVnode(oldEndVnode, newEndVnode)) {
1088
- patchVnode(oldEndVnode, newEndVnode);
1089
- oldEndVnode = oldCh[--oldEndIdx];
1090
- newEndVnode = newCh[--newEndIdx];
1091
- } else if (sameVnode(oldStartVnode, newEndVnode)) {
1092
- // Vnode moved right
1093
- patchVnode(oldStartVnode, newEndVnode);
1094
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
1095
- oldStartVnode = oldCh[++oldStartIdx];
1096
- newEndVnode = newCh[--newEndIdx];
1097
- } else if (sameVnode(oldEndVnode, newStartVnode)) {
1098
- // Vnode moved left
1099
- patchVnode(oldEndVnode, newStartVnode);
1100
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
1101
- oldEndVnode = oldCh[--oldEndIdx];
1102
- newStartVnode = newCh[++newStartIdx];
1103
- } else {
1104
- if (oldKeyToIdx === undefined) {
1105
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
1106
- }
1107
-
1108
- idxInOld = oldKeyToIdx[newStartVnode.key];
1109
-
1110
- if (isUndef(idxInOld)) {
1111
- // New element
1112
- newStartVnode.hook.create(newStartVnode);
1113
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1114
- newStartVnode = newCh[++newStartIdx];
1115
- } else {
1116
- elmToMove = oldCh[idxInOld];
1117
-
1118
- if (isVNode(elmToMove)) {
1119
- if (elmToMove.sel !== newStartVnode.sel) {
1120
- // New element
1121
- newStartVnode.hook.create(newStartVnode);
1122
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1123
- } else {
1124
- patchVnode(elmToMove, newStartVnode);
1125
- oldCh[idxInOld] = undefined;
1126
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
1127
- }
1128
- }
1129
-
1130
- newStartVnode = newCh[++newStartIdx];
1131
- }
1132
- }
1133
- }
1134
-
1135
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
1136
- if (oldStartIdx > oldEndIdx) {
1137
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
1138
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
1139
- var _i6 = newEndIdx;
1140
- var n;
1141
-
1142
- do {
1143
- n = newCh[++_i6];
1144
- } while (!isVNode(n) && _i6 < newChEnd);
1145
-
1146
- before = isVNode(n) ? n.elm : null;
1147
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
1148
- } else {
1149
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
1150
- }
1151
- }
1152
- }
1153
-
1154
- function updateStaticChildren(parentElm, oldCh, newCh) {
1155
- var oldChLength = oldCh.length;
1156
- var newChLength = newCh.length;
1157
-
1158
- if (oldChLength === 0) {
1159
- // the old list is empty, we can directly insert anything new
1160
- addVnodes(parentElm, null, newCh, 0, newChLength);
1161
- return;
1162
- }
1163
-
1164
- if (newChLength === 0) {
1165
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
1166
- // this is the case in which the dynamic children of an if-directive should be removed
1167
- removeVnodes(parentElm, oldCh, 0, oldChLength);
1168
- return;
1169
- } // if the old list is not empty, the new list MUST have the same
1170
- // amount of nodes, that's why we call this static children
1171
-
1172
-
1173
- var referenceElm = null;
1174
-
1175
- for (var _i7 = newChLength - 1; _i7 >= 0; _i7 -= 1) {
1176
- var vnode = newCh[_i7];
1177
- var oldVNode = oldCh[_i7];
1178
-
1179
- if (vnode !== oldVNode) {
1180
- if (isVNode(oldVNode)) {
1181
- if (isVNode(vnode)) {
1182
- // both vnodes must be equivalent, and se just need to patch them
1183
- patchVnode(oldVNode, vnode);
1184
- referenceElm = vnode.elm;
1185
- } else {
1186
- // removing the old vnode since the new one is null
1187
- oldVNode.hook.remove(oldVNode, parentElm);
1188
- }
1189
- } else if (isVNode(vnode)) {
1190
- // this condition is unnecessary
1191
- vnode.hook.create(vnode); // insert the new node one since the old one is null
1192
-
1193
- vnode.hook.insert(vnode, parentElm, referenceElm);
1194
- referenceElm = vnode.elm;
1195
- }
1196
- }
1197
- }
1198
- }
1199
-
1200
- function patchVnode(oldVnode, vnode) {
1201
- if (oldVnode !== vnode) {
1202
- vnode.elm = oldVnode.elm;
1203
- vnode.hook.update(oldVnode, vnode);
1204
- }
1205
- }
1030
+ var HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
1031
+ var HTMLElementPrototype = HTMLElementConstructor$1.prototype;
1206
1032
  /*
1207
1033
  * Copyright (c) 2018, salesforce.com, inc.
1208
1034
  * All rights reserved.
@@ -1210,7 +1036,6 @@ var LWC = (function (exports) {
1210
1036
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1211
1037
  */
1212
1038
 
1213
-
1214
1039
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1215
1040
 
1216
1041
  function offsetPropertyErrorMessage(name) {
@@ -1322,18 +1147,6 @@ var LWC = (function (exports) {
1322
1147
  controlledElement = elm;
1323
1148
  controlledAttributeName = key;
1324
1149
  }
1325
- /*
1326
- * Copyright (c) 2018, salesforce.com, inc.
1327
- * All rights reserved.
1328
- * SPDX-License-Identifier: MIT
1329
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1330
- */
1331
- // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
1332
- // to inject at runtime.
1333
-
1334
-
1335
- var HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
1336
- var HTMLElementPrototype = HTMLElementConstructor$1.prototype;
1337
1150
  /*
1338
1151
  * Copyright (c) 2018, salesforce.com, inc.
1339
1152
  * All rights reserved.
@@ -1348,6 +1161,7 @@ var LWC = (function (exports) {
1348
1161
  * Base Lightning Element should support.
1349
1162
  */
1350
1163
 
1164
+
1351
1165
  var HTMLElementOriginalDescriptors = create(null);
1352
1166
  forEach.call(keys(AriaPropNameToAttrNameMap), function (propName) {
1353
1167
  // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
@@ -1372,6 +1186,7 @@ var LWC = (function (exports) {
1372
1186
  * Copyright (C) 2017 salesforce.com, inc.
1373
1187
  */
1374
1188
 
1189
+
1375
1190
  var isArray = Array.isArray;
1376
1191
  var ObjectDotPrototype = Object.prototype,
1377
1192
  _getPrototypeOf = Object.getPrototypeOf,
@@ -2130,7 +1945,9 @@ var LWC = (function (exports) {
2130
1945
  if (vm.renderMode === 1
2131
1946
  /* Shadow */
2132
1947
  ) {
2133
- doAttachShadow(vm);
1948
+ vm.renderRoot = doAttachShadow(vm);
1949
+ } else {
1950
+ vm.renderRoot = elm;
2134
1951
  } // Adding extra guard rails in DEV mode.
2135
1952
 
2136
1953
  return this;
@@ -2143,9 +1960,11 @@ var LWC = (function (exports) {
2143
1960
  mode = vm.mode,
2144
1961
  shadowMode = vm.shadowMode,
2145
1962
  ctor = vm.def.ctor;
2146
- var cmpRoot = attachShadow$1(elm, (_attachShadow$ = {}, _defineProperty(_attachShadow$, KEY__SYNTHETIC_MODE, shadowMode === 1), _defineProperty(_attachShadow$, "delegatesFocus", Boolean(ctor.delegatesFocus)), _defineProperty(_attachShadow$, "mode", mode), _attachShadow$));
2147
- vm.cmpRoot = cmpRoot;
2148
- associateVM(cmpRoot, vm);
1963
+ var shadowRoot = attachShadow$1(elm, (_attachShadow$ = {}, _defineProperty(_attachShadow$, KEY__SYNTHETIC_MODE, shadowMode === 1), _defineProperty(_attachShadow$, "delegatesFocus", Boolean(ctor.delegatesFocus)), _defineProperty(_attachShadow$, "mode", mode), _attachShadow$));
1964
+ vm.shadowRoot = shadowRoot;
1965
+ associateVM(shadowRoot, vm);
1966
+
1967
+ return shadowRoot;
2149
1968
  }
2150
1969
 
2151
1970
 
@@ -2250,7 +2069,7 @@ var LWC = (function (exports) {
2250
2069
  get template() {
2251
2070
  var vm = getAssociatedVM(this);
2252
2071
 
2253
- return vm.cmpRoot;
2072
+ return vm.shadowRoot;
2254
2073
  },
2255
2074
 
2256
2075
  get shadowRoot() {
@@ -2298,7 +2117,7 @@ var LWC = (function (exports) {
2298
2117
 
2299
2118
 
2300
2119
  var _loop = function _loop() {
2301
- var childGetter = _childGetters[_i8];
2120
+ var childGetter = _childGetters[_i6];
2302
2121
  queryAndChildGetterDescriptors[childGetter] = {
2303
2122
  get: function get() {
2304
2123
  var vm = getAssociatedVM(this);
@@ -2311,7 +2130,7 @@ var LWC = (function (exports) {
2311
2130
  };
2312
2131
  };
2313
2132
 
2314
- for (var _i8 = 0, _childGetters = childGetters; _i8 < _childGetters.length; _i8++) {
2133
+ for (var _i6 = 0, _childGetters = childGetters; _i6 < _childGetters.length; _i6++) {
2315
2134
  _loop();
2316
2135
  }
2317
2136
 
@@ -2335,7 +2154,7 @@ var LWC = (function (exports) {
2335
2154
 
2336
2155
 
2337
2156
  var _loop2 = function _loop2() {
2338
- var queryMethod = _queryMethods[_i9];
2157
+ var queryMethod = _queryMethods[_i7];
2339
2158
  queryAndChildGetterDescriptors[queryMethod] = {
2340
2159
  value: function value(arg) {
2341
2160
  var vm = getAssociatedVM(this);
@@ -2349,7 +2168,7 @@ var LWC = (function (exports) {
2349
2168
  };
2350
2169
  };
2351
2170
 
2352
- for (var _i9 = 0, _queryMethods = queryMethods; _i9 < _queryMethods.length; _i9++) {
2171
+ for (var _i7 = 0, _queryMethods = queryMethods; _i7 < _queryMethods.length; _i7++) {
2353
2172
  _loop2();
2354
2173
  }
2355
2174
 
@@ -2710,8 +2529,8 @@ var LWC = (function (exports) {
2710
2529
  }
2711
2530
 
2712
2531
  if (!isUndefined$1(fields)) {
2713
- for (var _i10 = 0, n = fields.length; _i10 < n; _i10++) {
2714
- var _fieldName2 = fields[_i10];
2532
+ for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
2533
+ var _fieldName2 = fields[_i8];
2715
2534
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
2716
2535
  // tracked property. This is only here for backward compatibility purposes.
2717
2536
 
@@ -2928,8 +2747,8 @@ var LWC = (function (exports) {
2928
2747
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
2929
2748
  var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
2930
2749
 
2931
- for (var _i11 = 0, _len3 = props.length; _i11 < _len3; _i11 += 1) {
2932
- var _propName2 = props[_i11];
2750
+ for (var _i9 = 0, _len3 = props.length; _i9 < _len3; _i9 += 1) {
2751
+ var _propName2 = props[_i9];
2933
2752
  attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
2934
2753
  descriptors[_propName2] = {
2935
2754
  get: createGetter(_propName2),
@@ -2940,8 +2759,8 @@ var LWC = (function (exports) {
2940
2759
  } // expose public methods as props on the new Element Bridge
2941
2760
 
2942
2761
 
2943
- for (var _i12 = 0, _len4 = methods.length; _i12 < _len4; _i12 += 1) {
2944
- var methodName = methods[_i12];
2762
+ for (var _i10 = 0, _len4 = methods.length; _i10 < _len4; _i10 += 1) {
2763
+ var methodName = methods[_i10];
2945
2764
  descriptors[methodName] = {
2946
2765
  value: createMethodCaller(methodName),
2947
2766
  writable: true,
@@ -3186,6 +3005,11 @@ var LWC = (function (exports) {
3186
3005
  return def;
3187
3006
  }
3188
3007
 
3008
+ function getComponentHtmlPrototype(Ctor) {
3009
+ var def = getComponentInternalDef(Ctor);
3010
+ return def.bridge;
3011
+ }
3012
+
3189
3013
  var lightingElementDef = {
3190
3014
  ctor: LightningElement,
3191
3015
  name: LightningElement.name,
@@ -3247,45 +3071,112 @@ var LWC = (function (exports) {
3247
3071
  };
3248
3072
  }
3249
3073
  /*
3250
- * Copyright (c) 2018, salesforce.com, inc.
3074
+ * Copyright (c) 2020, salesforce.com, inc.
3251
3075
  * All rights reserved.
3252
3076
  * SPDX-License-Identifier: MIT
3253
3077
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3254
3078
  */
3255
3079
 
3256
3080
 
3257
- var xlinkNS = 'http://www.w3.org/1999/xlink';
3258
- var xmlNS = 'http://www.w3.org/XML/1998/namespace';
3259
- var ColonCharCode = 58;
3260
-
3261
- function patchAttributes(oldVnode, vnode) {
3262
- var attrs = vnode.data.attrs;
3081
+ function getUpgradableConstructor(tagName) {
3082
+ // Should never get a tag with upper case letter at this point, the compiler should
3083
+ // produce only tags with lowercase letters
3084
+ // But, for backwards compatibility, we will lower case the tagName
3085
+ tagName = tagName.toLowerCase();
3086
+ var CE = getCustomElement$1(tagName);
3263
3087
 
3264
- if (isUndefined$1(attrs)) {
3265
- return;
3088
+ if (!isUndefined$1(CE)) {
3089
+ return CE;
3266
3090
  }
3091
+ /**
3092
+ * LWC Upgradable Element reference to an element that was created
3093
+ * via the scoped registry mechanism, and that is ready to be upgraded.
3094
+ */
3267
3095
 
3268
- var oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
3269
3096
 
3270
- if (oldAttrs === attrs) {
3271
- return;
3272
- }
3097
+ CE = /*#__PURE__*/function (_HTMLElementExported$) {
3098
+ _inherits(LWCUpgradableElement, _HTMLElementExported$);
3273
3099
 
3274
- var elm = vnode.elm;
3100
+ var _super5 = _createSuper(LWCUpgradableElement);
3275
3101
 
3276
- for (var key in attrs) {
3277
- var cur = attrs[key];
3278
- var old = oldAttrs[key];
3102
+ function LWCUpgradableElement(upgradeCallback) {
3103
+ var _this4;
3104
+
3105
+ _classCallCheck(this, LWCUpgradableElement);
3106
+
3107
+ _this4 = _super5.call(this);
3108
+
3109
+ if (isFunction$1(upgradeCallback)) {
3110
+ upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
3111
+ }
3112
+
3113
+ return _this4;
3114
+ }
3115
+
3116
+ return _createClass(LWCUpgradableElement);
3117
+ }(HTMLElementExported$1);
3118
+
3119
+ defineCustomElement$1(tagName, CE);
3120
+ return CE;
3121
+ }
3122
+ /*
3123
+ * Copyright (c) 2018, salesforce.com, inc.
3124
+ * All rights reserved.
3125
+ * SPDX-License-Identifier: MIT
3126
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3127
+ */
3128
+
3129
+
3130
+ function isVBaseElement(vnode) {
3131
+ var type = vnode.type;
3132
+ return type === 2
3133
+ /* Element */
3134
+ || type === 3
3135
+ /* CustomElement */
3136
+ ;
3137
+ }
3138
+
3139
+ function isSameVnode(vnode1, vnode2) {
3140
+ return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
3141
+ }
3142
+ /*
3143
+ * Copyright (c) 2018, salesforce.com, inc.
3144
+ * All rights reserved.
3145
+ * SPDX-License-Identifier: MIT
3146
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3147
+ */
3148
+
3149
+
3150
+ var ColonCharCode = 58;
3151
+
3152
+ function patchAttributes(oldVnode, vnode) {
3153
+ var attrs = vnode.data.attrs;
3154
+
3155
+ if (isUndefined$1(attrs)) {
3156
+ return;
3157
+ }
3158
+
3159
+ var oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
3160
+
3161
+ if (oldAttrs === attrs) {
3162
+ return;
3163
+ }
3164
+
3165
+ var elm = vnode.elm;
3166
+
3167
+ for (var key in attrs) {
3168
+ var cur = attrs[key];
3169
+ var old = oldAttrs[key];
3279
3170
 
3280
3171
  if (old !== cur) {
3281
3172
  unlockAttribute(elm, key);
3282
3173
 
3283
3174
  if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
3284
3175
  // Assume xml namespace
3285
- setAttribute$1(elm, key, cur, xmlNS);
3176
+ setAttribute$1(elm, key, cur, XML_NAMESPACE);
3286
3177
  } else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
3287
3178
  // Assume xlink namespace
3288
- setAttribute$1(elm, key, cur, xlinkNS);
3179
+ setAttribute$1(elm, key, cur, XLINK_NAMESPACE);
3289
3180
  } else if (isNull(cur) || isUndefined$1(cur)) {
3290
3181
  removeAttribute$1(elm, key);
3291
3182
  } else {
@@ -3497,8 +3388,8 @@ var LWC = (function (exports) {
3497
3388
  return;
3498
3389
  }
3499
3390
 
3500
- for (var _i13 = 0; _i13 < styleDecls.length; _i13++) {
3501
- var _styleDecls$_i = _slicedToArray(styleDecls[_i13], 3),
3391
+ for (var _i11 = 0; _i11 < styleDecls.length; _i11++) {
3392
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i11], 3),
3502
3393
  prop = _styleDecls$_i[0],
3503
3394
  value = _styleDecls$_i[1],
3504
3395
  important = _styleDecls$_i[2];
@@ -3514,6 +3405,143 @@ var LWC = (function (exports) {
3514
3405
  */
3515
3406
 
3516
3407
 
3408
+ var TextHook = {
3409
+ create: function create(vnode) {
3410
+ var owner = vnode.owner;
3411
+ var elm = createText$1(vnode.text);
3412
+ linkNodeToShadow(elm, owner);
3413
+ vnode.elm = elm;
3414
+ },
3415
+ update: updateNodeHook,
3416
+ insert: insertNode,
3417
+ move: insertNode,
3418
+ remove: removeNode
3419
+ };
3420
+ var CommentHook = {
3421
+ create: function create(vnode) {
3422
+ var owner = vnode.owner,
3423
+ text = vnode.text;
3424
+ var elm = createComment$1(text);
3425
+ linkNodeToShadow(elm, owner);
3426
+ vnode.elm = elm;
3427
+ },
3428
+ update: updateNodeHook,
3429
+ insert: insertNode,
3430
+ move: insertNode,
3431
+ remove: removeNode
3432
+ }; // insert is called after update, which is used somewhere else (via a module)
3433
+ // to mark the vm as inserted, that means we cannot use update as the main channel
3434
+ // to rehydrate when dirty, because sometimes the element is not inserted just yet,
3435
+ // which breaks some invariants. For that reason, we have the following for any
3436
+ // Custom Element that is inserted via a template.
3437
+
3438
+ var ElementHook = {
3439
+ create: function create(vnode) {
3440
+ var sel = vnode.sel,
3441
+ owner = vnode.owner,
3442
+ svg = vnode.data.svg;
3443
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3444
+ var elm = createElement$2(sel, namespace);
3445
+ linkNodeToShadow(elm, owner);
3446
+ fallbackElmHook(elm, vnode);
3447
+ vnode.elm = elm;
3448
+ patchElementPropsAndAttrs$1(null, vnode);
3449
+ },
3450
+ update: function update(oldVnode, vnode) {
3451
+ patchElementPropsAndAttrs$1(oldVnode, vnode);
3452
+ patchChildren(vnode.elm, oldVnode.children, vnode.children);
3453
+ },
3454
+ insert: function insert(vnode, parentNode, referenceNode) {
3455
+ insertNode(vnode, parentNode, referenceNode);
3456
+ createChildrenHook(vnode);
3457
+ },
3458
+ move: insertNode,
3459
+ remove: function remove(vnode, parentNode) {
3460
+ removeNode(vnode, parentNode);
3461
+ removeChildren(vnode);
3462
+ }
3463
+ };
3464
+ var CustomElementHook = {
3465
+ create: function create(vnode) {
3466
+ var sel = vnode.sel,
3467
+ owner = vnode.owner;
3468
+ var UpgradableConstructor = getUpgradableConstructor(sel);
3469
+ /**
3470
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3471
+ * with a callback as the first argument, we could implement a more advanced
3472
+ * mechanism that only passes that argument if the constructor is known to be
3473
+ * an upgradable custom element.
3474
+ */
3475
+
3476
+ var vm;
3477
+ var elm = new UpgradableConstructor(function (elm) {
3478
+ // the custom element from the registry is expecting an upgrade callback
3479
+ vm = createViewModelHook(elm, vnode);
3480
+ });
3481
+ linkNodeToShadow(elm, owner);
3482
+ vnode.elm = elm;
3483
+
3484
+ if (vm) {
3485
+ allocateChildren(vnode, vm);
3486
+ } else if (vnode.ctor !== UpgradableConstructor) {
3487
+ throw new TypeError("Incorrect Component Constructor");
3488
+ }
3489
+
3490
+ patchElementPropsAndAttrs$1(null, vnode);
3491
+ },
3492
+ update: function update(oldVnode, vnode) {
3493
+ patchElementPropsAndAttrs$1(oldVnode, vnode);
3494
+ var vm = getAssociatedVMIfPresent(vnode.elm);
3495
+
3496
+ if (vm) {
3497
+ // in fallback mode, the allocation will always set children to
3498
+ // empty and delegate the real allocation to the slot elements
3499
+ allocateChildren(vnode, vm);
3500
+ } // in fallback mode, the children will be always empty, so, nothing
3501
+ // will happen, but in native, it does allocate the light dom
3502
+
3503
+
3504
+ patchChildren(vnode.elm, oldVnode.children, vnode.children);
3505
+
3506
+ if (vm) {
3507
+ // this is important to preserve the top to bottom synchronous rendering phase.
3508
+
3509
+
3510
+ rerenderVM(vm);
3511
+ }
3512
+ },
3513
+ insert: function insert(vnode, parentNode, referenceNode) {
3514
+ insertNode(vnode, parentNode, referenceNode);
3515
+ var vm = getAssociatedVMIfPresent(vnode.elm);
3516
+
3517
+ if (vm) {
3518
+
3519
+ runConnectedCallback(vm);
3520
+ }
3521
+
3522
+ createChildrenHook(vnode);
3523
+
3524
+ if (vm) {
3525
+ appendVM(vm);
3526
+ }
3527
+ },
3528
+ move: insertNode,
3529
+ remove: function remove(vnode, parentNode) {
3530
+ removeNode(vnode, parentNode);
3531
+ var vm = getAssociatedVMIfPresent(vnode.elm);
3532
+
3533
+ if (vm) {
3534
+ // for custom elements we don't have to go recursively because the removeVM routine
3535
+ // will take care of disconnecting any child VM attached to its shadow as well.
3536
+ removeVM(vm);
3537
+ }
3538
+ }
3539
+ };
3540
+
3541
+ function isVNode(vnode) {
3542
+ return vnode != null;
3543
+ }
3544
+
3517
3545
  function observeElementChildNodes(elm) {
3518
3546
  elm.$domManual$ = true;
3519
3547
  }
@@ -3533,6 +3561,22 @@ var LWC = (function (exports) {
3533
3561
  }
3534
3562
  }
3535
3563
 
3564
+ function linkNodeToShadow(elm, owner) {
3565
+ var renderRoot = owner.renderRoot,
3566
+ renderMode = owner.renderMode,
3567
+ shadowMode = owner.shadowMode; // TODO [#1164]: this should eventually be done by the polyfill directly
3568
+
3569
+ if (isSyntheticShadowDefined$1) {
3570
+ if (shadowMode === 1
3571
+ /* Synthetic */
3572
+ || renderMode === 0
3573
+ /* Light */
3574
+ ) {
3575
+ elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
3576
+ }
3577
+ }
3578
+ }
3579
+
3536
3580
  function updateNodeHook(oldVnode, vnode) {
3537
3581
  var elm = vnode.elm,
3538
3582
  text = vnode.text;
@@ -3543,17 +3587,17 @@ var LWC = (function (exports) {
3543
3587
  }
3544
3588
  }
3545
3589
 
3546
- function insertNodeHook(vnode, parentNode, referenceNode) {
3590
+ function insertNode(vnode, parentNode, referenceNode) {
3547
3591
 
3548
3592
  insert$1(vnode.elm, parentNode, referenceNode);
3549
3593
  }
3550
3594
 
3551
- function removeNodeHook(vnode, parentNode) {
3595
+ function removeNode(vnode, parentNode) {
3552
3596
 
3553
3597
  remove$1(vnode.elm, parentNode);
3554
3598
  }
3555
3599
 
3556
- function patchElementPropsAndAttrs(oldVnode, vnode) {
3600
+ function patchElementPropsAndAttrs$1(oldVnode, vnode) {
3557
3601
  if (isNull(oldVnode)) {
3558
3602
  applyEventListeners(vnode);
3559
3603
  applyStaticClassAttribute(vnode);
@@ -3568,11 +3612,6 @@ var LWC = (function (exports) {
3568
3612
  patchProps(oldVnode, vnode);
3569
3613
  }
3570
3614
 
3571
- function hydrateElmHook(vnode) {
3572
- applyEventListeners(vnode);
3573
- patchProps(null, vnode);
3574
- }
3575
-
3576
3615
  function fallbackElmHook(elm, vnode) {
3577
3616
  var owner = vnode.owner;
3578
3617
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3584,7 +3623,7 @@ var LWC = (function (exports) {
3584
3623
  var stylesheetToken = owner.context.stylesheetToken;
3585
3624
 
3586
3625
  if (!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3587
- /* manual */
3626
+ /* Manual */
3588
3627
  ) {
3589
3628
  // this element will now accept any manual content inserted into it
3590
3629
  observeElementChildNodes(elm);
@@ -3604,7 +3643,7 @@ var LWC = (function (exports) {
3604
3643
  }
3605
3644
  }
3606
3645
 
3607
- function allocateChildrenHook(vnode, vm) {
3646
+ function allocateChildren(vnode, vm) {
3608
3647
  // A component with slots will re-render because:
3609
3648
  // 1- There is a change of the internal state.
3610
3649
  // 2- There is a change on the external api (ex: slots)
@@ -3635,11 +3674,12 @@ var LWC = (function (exports) {
3635
3674
  }
3636
3675
 
3637
3676
  function createViewModelHook(elm, vnode) {
3638
- if (!isUndefined$1(getAssociatedVMIfPresent(elm))) {
3639
- // There is a possibility that a custom element is registered under tagName,
3640
- // in which case, the initialization is already carry on, and there is nothing else
3641
- // to do here since this hook is called right after invoking `document.createElement`.
3642
- return;
3677
+ var vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
3678
+ // initialization is already carry on, and there is nothing else to do here since this hook is
3679
+ // called right after invoking `document.createElement`.
3680
+
3681
+ if (!isUndefined$1(vm)) {
3682
+ return vm;
3643
3683
  }
3644
3684
 
3645
3685
  var sel = vnode.sel,
@@ -3657,12 +3697,13 @@ var LWC = (function (exports) {
3657
3697
  setElementShadowToken(elm, stylesheetToken);
3658
3698
  }
3659
3699
 
3660
- var def = getComponentInternalDef(ctor);
3661
- createVM(elm, def, {
3700
+ vm = createVM(elm, ctor, {
3662
3701
  mode: mode,
3663
3702
  owner: owner,
3664
3703
  tagName: sel
3665
3704
  });
3705
+
3706
+ return vm;
3666
3707
  }
3667
3708
 
3668
3709
  function createChildrenHook(vnode) {
@@ -3679,23 +3720,7 @@ var LWC = (function (exports) {
3679
3720
  }
3680
3721
  }
3681
3722
 
3682
- function hydrateChildrenHook(elmChildren, children, vm) {
3683
-
3684
- var elmCurrentChildIdx = 0;
3685
-
3686
- for (var j = 0, n = children.length; j < n; j++) {
3687
- var ch = children[j];
3688
-
3689
- if (ch != null) {
3690
- var childNode = elmChildren[elmCurrentChildIdx];
3691
-
3692
- ch.hook.hydrate(ch, childNode);
3693
- elmCurrentChildIdx++;
3694
- }
3695
- }
3696
- }
3697
-
3698
- function removeElmHook(vnode) {
3723
+ function removeChildren(vnode) {
3699
3724
  // this method only needs to search on child vnodes from template
3700
3725
  // to trigger the remove hook just in case some of those children
3701
3726
  // are custom elements.
@@ -3712,18 +3737,24 @@ var LWC = (function (exports) {
3712
3737
  }
3713
3738
 
3714
3739
  function allocateInSlot(vm, children) {
3740
+ var _a;
3741
+
3715
3742
  var oldSlots = vm.cmpSlots;
3716
3743
  var cmpSlots = vm.cmpSlots = create(null);
3717
3744
 
3718
- for (var _i16 = 0, _len6 = children.length; _i16 < _len6; _i16 += 1) {
3719
- var vnode = children[_i16];
3745
+ for (var _i12 = 0, _len6 = children.length; _i12 < _len6; _i12 += 1) {
3746
+ var vnode = children[_i12];
3720
3747
 
3721
3748
  if (isNull(vnode)) {
3722
3749
  continue;
3723
3750
  }
3724
3751
 
3725
- var data = vnode.data;
3726
- var slotName = data.attrs && data.attrs.slot || '';
3752
+ var slotName = '';
3753
+
3754
+ if (isVBaseElement(vnode)) {
3755
+ slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3756
+ }
3757
+
3727
3758
  var vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
3728
3759
  // which might have similar keys. Each vnode will always have a key that
3729
3760
  // starts with a numeric character from compiler. In this case, we add a unique
@@ -3746,8 +3777,8 @@ var LWC = (function (exports) {
3746
3777
  return;
3747
3778
  }
3748
3779
 
3749
- for (var _i17 = 0, _len7 = oldKeys.length; _i17 < _len7; _i17 += 1) {
3750
- var key = oldKeys[_i17];
3780
+ for (var _i13 = 0, _len7 = oldKeys.length; _i13 < _len7; _i13 += 1) {
3781
+ var key = oldKeys[_i13];
3751
3782
 
3752
3783
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3753
3784
  markComponentAsDirty(vm);
@@ -3778,288 +3809,203 @@ var LWC = (function (exports) {
3778
3809
  function hasDynamicChildren(children) {
3779
3810
  return FromIteration.has(children);
3780
3811
  }
3781
- /*
3782
- * Copyright (c) 2020, salesforce.com, inc.
3783
- * All rights reserved.
3784
- * SPDX-License-Identifier: MIT
3785
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3786
- */
3787
-
3788
-
3789
- function getUpgradableConstructor(tagName) {
3790
- // Should never get a tag with upper case letter at this point, the compiler should
3791
- // produce only tags with lowercase letters
3792
- // But, for backwards compatibility, we will lower case the tagName
3793
- tagName = tagName.toLowerCase();
3794
- var CE = getCustomElement$1(tagName);
3795
-
3796
- if (!isUndefined$1(CE)) {
3797
- return CE;
3798
- }
3799
- /**
3800
- * LWC Upgradable Element reference to an element that was created
3801
- * via the scoped registry mechanism, and that is ready to be upgraded.
3802
- */
3803
-
3804
-
3805
- CE = /*#__PURE__*/function (_HTMLElementExported$) {
3806
- _inherits(LWCUpgradableElement, _HTMLElementExported$);
3807
-
3808
- var _super5 = _createSuper(LWCUpgradableElement);
3809
3812
 
3810
- function LWCUpgradableElement(upgradeCallback) {
3811
- var _this4;
3813
+ function createKeyToOldIdx(children, beginIdx, endIdx) {
3814
+ var map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
3812
3815
 
3813
- _classCallCheck(this, LWCUpgradableElement);
3816
+ for (var j = beginIdx; j <= endIdx; ++j) {
3817
+ var ch = children[j];
3814
3818
 
3815
- _this4 = _super5.call(this);
3819
+ if (isVNode(ch)) {
3820
+ var key = ch.key;
3816
3821
 
3817
- if (isFunction$1(upgradeCallback)) {
3818
- upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
3822
+ if (key !== undefined) {
3823
+ map[key] = j;
3819
3824
  }
3820
-
3821
- return _this4;
3822
3825
  }
3823
-
3824
- return _createClass(LWCUpgradableElement);
3825
- }(HTMLElementExported$1);
3826
-
3827
- defineCustomElement$1(tagName, CE);
3828
- return CE;
3829
- }
3830
- /*
3831
- * Copyright (c) 2018, salesforce.com, inc.
3832
- * All rights reserved.
3833
- * SPDX-License-Identifier: MIT
3834
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3835
- */
3836
-
3837
-
3838
- var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
3839
- var SymbolIterator = Symbol.iterator;
3840
- var TextHook = {
3841
- create: function create(vnode) {
3842
- var owner = vnode.owner;
3843
- var elm = createText$1(vnode.text);
3844
- linkNodeToShadow(elm, owner);
3845
- vnode.elm = elm;
3846
- },
3847
- update: updateNodeHook,
3848
- insert: insertNodeHook,
3849
- move: insertNodeHook,
3850
- remove: removeNodeHook,
3851
- hydrate: function hydrate(vNode, node) {
3852
- var _a;
3853
-
3854
-
3855
- node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3856
- vNode.elm = node;
3857
- }
3858
- };
3859
- var CommentHook = {
3860
- create: function create(vnode) {
3861
- var owner = vnode.owner,
3862
- text = vnode.text;
3863
- var elm = createComment$1(text);
3864
- linkNodeToShadow(elm, owner);
3865
- vnode.elm = elm;
3866
- },
3867
- update: updateNodeHook,
3868
- insert: insertNodeHook,
3869
- move: insertNodeHook,
3870
- remove: removeNodeHook,
3871
- hydrate: function hydrate(vNode, node) {
3872
- var _a;
3873
-
3874
-
3875
- node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3876
- vNode.elm = node;
3877
3826
  }
3878
- }; // insert is called after update, which is used somewhere else (via a module)
3879
- // to mark the vm as inserted, that means we cannot use update as the main channel
3880
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
3881
- // which breaks some invariants. For that reason, we have the following for any
3882
- // Custom Element that is inserted via a template.
3883
3827
 
3884
- var ElementHook = {
3885
- create: function create(vnode) {
3886
- var sel = vnode.sel,
3887
- owner = vnode.owner,
3888
- svg = vnode.data.svg;
3889
- var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3890
- var elm = createElement$2(sel, namespace);
3891
- linkNodeToShadow(elm, owner);
3892
- fallbackElmHook(elm, vnode);
3893
- vnode.elm = elm;
3894
- patchElementPropsAndAttrs(null, vnode);
3895
- },
3896
- update: function update(oldVnode, vnode) {
3897
- patchElementPropsAndAttrs(oldVnode, vnode);
3898
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3899
- },
3900
- insert: function insert(vnode, parentNode, referenceNode) {
3901
- insertNodeHook(vnode, parentNode, referenceNode);
3902
- createChildrenHook(vnode);
3903
- },
3904
- move: function move(vnode, parentNode, referenceNode) {
3905
- insertNodeHook(vnode, parentNode, referenceNode);
3906
- },
3907
- remove: function remove(vnode, parentNode) {
3908
- removeNodeHook(vnode, parentNode);
3909
- removeElmHook(vnode);
3910
- },
3911
- hydrate: function hydrate(vnode, node) {
3912
- var elm = node;
3913
- vnode.elm = elm;
3914
- var context = vnode.data.context;
3915
- var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3916
- /* manual */
3917
- );
3918
-
3919
- if (isDomManual) {
3920
- // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3921
- // remove the innerHTML from props so it reuses the existing dom elements.
3922
- var props = vnode.data.props;
3923
-
3924
- if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3925
- if (elm.innerHTML === props.innerHTML) {
3926
- delete props.innerHTML;
3927
- } else {
3928
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
3929
- }
3930
- }
3931
- }
3828
+ return map;
3829
+ }
3932
3830
 
3933
- hydrateElmHook(vnode);
3831
+ function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
3832
+ for (; startIdx <= endIdx; ++startIdx) {
3833
+ var ch = vnodes[startIdx];
3934
3834
 
3935
- if (!isDomManual) {
3936
- hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3835
+ if (isVNode(ch)) {
3836
+ ch.hook.create(ch);
3837
+ ch.hook.insert(ch, parentElm, before);
3937
3838
  }
3938
3839
  }
3939
- };
3940
- var CustomElementHook = {
3941
- create: function create(vnode) {
3942
- var sel = vnode.sel,
3943
- owner = vnode.owner;
3944
- var UpgradableConstructor = getUpgradableConstructor(sel);
3945
- /**
3946
- * Note: if the upgradable constructor does not expect, or throw when we new it
3947
- * with a callback as the first argument, we could implement a more advanced
3948
- * mechanism that only passes that argument if the constructor is known to be
3949
- * an upgradable custom element.
3950
- */
3840
+ }
3951
3841
 
3952
- var elm = new UpgradableConstructor(function (elm) {
3953
- // the custom element from the registry is expecting an upgrade callback
3954
- createViewModelHook(elm, vnode);
3955
- });
3956
- linkNodeToShadow(elm, owner);
3957
- vnode.elm = elm;
3958
- var vm = getAssociatedVMIfPresent(elm);
3842
+ function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
3843
+ for (; startIdx <= endIdx; ++startIdx) {
3844
+ var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
3959
3845
 
3960
- if (vm) {
3961
- allocateChildrenHook(vnode, vm);
3962
- } else if (vnode.ctor !== UpgradableConstructor) {
3963
- throw new TypeError("Incorrect Component Constructor");
3846
+ if (isVNode(ch)) {
3847
+ ch.hook.remove(ch, parentElm);
3964
3848
  }
3849
+ }
3850
+ }
3965
3851
 
3966
- patchElementPropsAndAttrs(null, vnode);
3967
- },
3968
- update: function update(oldVnode, vnode) {
3969
- patchElementPropsAndAttrs(oldVnode, vnode);
3970
- var vm = getAssociatedVMIfPresent(vnode.elm);
3971
-
3972
- if (vm) {
3973
- // in fallback mode, the allocation will always set children to
3974
- // empty and delegate the real allocation to the slot elements
3975
- allocateChildrenHook(vnode, vm);
3976
- } // in fallback mode, the children will be always empty, so, nothing
3977
- // will happen, but in native, it does allocate the light dom
3852
+ function updateDynamicChildren(parentElm, oldCh, newCh) {
3853
+ var oldStartIdx = 0;
3854
+ var newStartIdx = 0;
3855
+ var oldEndIdx = oldCh.length - 1;
3856
+ var oldStartVnode = oldCh[0];
3857
+ var oldEndVnode = oldCh[oldEndIdx];
3858
+ var newChEnd = newCh.length - 1;
3859
+ var newEndIdx = newChEnd;
3860
+ var newStartVnode = newCh[0];
3861
+ var newEndVnode = newCh[newEndIdx];
3862
+ var oldKeyToIdx;
3863
+ var idxInOld;
3864
+ var elmToMove;
3865
+ var before;
3978
3866
 
3867
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3868
+ if (!isVNode(oldStartVnode)) {
3869
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
3870
+ } else if (!isVNode(oldEndVnode)) {
3871
+ oldEndVnode = oldCh[--oldEndIdx];
3872
+ } else if (!isVNode(newStartVnode)) {
3873
+ newStartVnode = newCh[++newStartIdx];
3874
+ } else if (!isVNode(newEndVnode)) {
3875
+ newEndVnode = newCh[--newEndIdx];
3876
+ } else if (isSameVnode(oldStartVnode, newStartVnode)) {
3877
+ patchVnode(oldStartVnode, newStartVnode);
3878
+ oldStartVnode = oldCh[++oldStartIdx];
3879
+ newStartVnode = newCh[++newStartIdx];
3880
+ } else if (isSameVnode(oldEndVnode, newEndVnode)) {
3881
+ patchVnode(oldEndVnode, newEndVnode);
3882
+ oldEndVnode = oldCh[--oldEndIdx];
3883
+ newEndVnode = newCh[--newEndIdx];
3884
+ } else if (isSameVnode(oldStartVnode, newEndVnode)) {
3885
+ // Vnode moved right
3886
+ patchVnode(oldStartVnode, newEndVnode);
3887
+ newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
3888
+ oldStartVnode = oldCh[++oldStartIdx];
3889
+ newEndVnode = newCh[--newEndIdx];
3890
+ } else if (isSameVnode(oldEndVnode, newStartVnode)) {
3891
+ // Vnode moved left
3892
+ patchVnode(oldEndVnode, newStartVnode);
3893
+ newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
3894
+ oldEndVnode = oldCh[--oldEndIdx];
3895
+ newStartVnode = newCh[++newStartIdx];
3896
+ } else {
3897
+ if (oldKeyToIdx === undefined) {
3898
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
3899
+ }
3979
3900
 
3980
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3901
+ idxInOld = oldKeyToIdx[newStartVnode.key];
3981
3902
 
3982
- if (vm) {
3983
- // this is important to preserve the top to bottom synchronous rendering phase.
3903
+ if (isUndefined$1(idxInOld)) {
3904
+ // New element
3905
+ newStartVnode.hook.create(newStartVnode);
3906
+ newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3907
+ newStartVnode = newCh[++newStartIdx];
3908
+ } else {
3909
+ elmToMove = oldCh[idxInOld];
3984
3910
 
3911
+ if (isVNode(elmToMove)) {
3912
+ if (elmToMove.sel !== newStartVnode.sel) {
3913
+ // New element
3914
+ newStartVnode.hook.create(newStartVnode);
3915
+ newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3916
+ } else {
3917
+ patchVnode(elmToMove, newStartVnode);
3918
+ oldCh[idxInOld] = undefined;
3919
+ newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
3920
+ }
3921
+ }
3985
3922
 
3986
- rerenderVM(vm);
3923
+ newStartVnode = newCh[++newStartIdx];
3924
+ }
3987
3925
  }
3988
- },
3989
- insert: function insert(vnode, parentNode, referenceNode) {
3990
- insertNodeHook(vnode, parentNode, referenceNode);
3991
- var vm = getAssociatedVMIfPresent(vnode.elm);
3926
+ }
3992
3927
 
3993
- if (vm) {
3928
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
3929
+ if (oldStartIdx > oldEndIdx) {
3930
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3931
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3932
+ var _i14 = newEndIdx;
3933
+ var n;
3994
3934
 
3995
- runConnectedCallback(vm);
3935
+ do {
3936
+ n = newCh[++_i14];
3937
+ } while (!isVNode(n) && _i14 < newChEnd);
3938
+
3939
+ before = isVNode(n) ? n.elm : null;
3940
+ addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
3941
+ } else {
3942
+ removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
3996
3943
  }
3944
+ }
3945
+ }
3997
3946
 
3998
- createChildrenHook(vnode);
3947
+ function updateStaticChildren(parentElm, oldCh, newCh) {
3948
+ var oldChLength = oldCh.length;
3949
+ var newChLength = newCh.length;
3999
3950
 
4000
- if (vm) {
4001
- appendVM(vm);
4002
- }
4003
- },
4004
- move: function move(vnode, parentNode, referenceNode) {
4005
- insertNodeHook(vnode, parentNode, referenceNode);
4006
- },
4007
- remove: function remove(vnode, parentNode) {
4008
- removeNodeHook(vnode, parentNode);
4009
- var vm = getAssociatedVMIfPresent(vnode.elm);
3951
+ if (oldChLength === 0) {
3952
+ // the old list is empty, we can directly insert anything new
3953
+ addVnodes(parentElm, null, newCh, 0, newChLength);
3954
+ return;
3955
+ }
4010
3956
 
4011
- if (vm) {
4012
- // for custom elements we don't have to go recursively because the removeVM routine
4013
- // will take care of disconnecting any child VM attached to its shadow as well.
4014
- removeVM(vm);
4015
- }
4016
- },
4017
- hydrate: function hydrate(vnode, elm) {
4018
- // the element is created, but the vm is not
4019
- var sel = vnode.sel,
4020
- mode = vnode.mode,
4021
- ctor = vnode.ctor,
4022
- owner = vnode.owner;
4023
- var def = getComponentInternalDef(ctor);
4024
- createVM(elm, def, {
4025
- mode: mode,
4026
- owner: owner,
4027
- tagName: sel
4028
- });
4029
- vnode.elm = elm;
4030
- var vm = getAssociatedVM(elm);
4031
- allocateChildrenHook(vnode, vm);
4032
- hydrateElmHook(vnode); // Insert hook section:
3957
+ if (newChLength === 0) {
3958
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3959
+ // this is the case in which the dynamic children of an if-directive should be removed
3960
+ removeVnodes(parentElm, oldCh, 0, oldChLength);
3961
+ return;
3962
+ } // if the old list is not empty, the new list MUST have the same
3963
+ // amount of nodes, that's why we call this static children
4033
3964
 
4034
- runConnectedCallback(vm);
4035
3965
 
4036
- if (vm.renderMode !== 0
4037
- /* Light */
4038
- ) {
4039
- // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
4040
- // Note: for Light DOM, this is handled while hydrating the VM
4041
- hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
4042
- }
3966
+ var referenceElm = null;
4043
3967
 
4044
- hydrateVM(vm);
4045
- }
4046
- };
3968
+ for (var _i15 = newChLength - 1; _i15 >= 0; _i15 -= 1) {
3969
+ var vnode = newCh[_i15];
3970
+ var oldVNode = oldCh[_i15];
4047
3971
 
4048
- function linkNodeToShadow(elm, owner) {
4049
- var renderMode = owner.renderMode,
4050
- shadowMode = owner.shadowMode; // TODO [#1164]: this should eventually be done by the polyfill directly
3972
+ if (vnode !== oldVNode) {
3973
+ if (isVNode(oldVNode)) {
3974
+ if (isVNode(vnode)) {
3975
+ // both vnodes must be equivalent, and se just need to patch them
3976
+ patchVnode(oldVNode, vnode);
3977
+ referenceElm = vnode.elm;
3978
+ } else {
3979
+ // removing the old vnode since the new one is null
3980
+ oldVNode.hook.remove(oldVNode, parentElm);
3981
+ }
3982
+ } else if (isVNode(vnode)) {
3983
+ // this condition is unnecessary
3984
+ vnode.hook.create(vnode); // insert the new node one since the old one is null
4051
3985
 
4052
- if (isSyntheticShadowDefined$1) {
4053
- if (shadowMode === 1
4054
- /* Synthetic */
4055
- || renderMode === 0
4056
- /* Light */
4057
- ) {
4058
- elm[KEY__SHADOW_RESOLVER] = getRenderRoot(owner)[KEY__SHADOW_RESOLVER];
3986
+ vnode.hook.insert(vnode, parentElm, referenceElm);
3987
+ referenceElm = vnode.elm;
3988
+ }
4059
3989
  }
4060
3990
  }
4061
3991
  }
4062
3992
 
3993
+ function patchVnode(oldVnode, vnode) {
3994
+ if (oldVnode !== vnode) {
3995
+ vnode.elm = oldVnode.elm;
3996
+ vnode.hook.update(oldVnode, vnode);
3997
+ }
3998
+ }
3999
+ /*
4000
+ * Copyright (c) 2018, salesforce.com, inc.
4001
+ * All rights reserved.
4002
+ * SPDX-License-Identifier: MIT
4003
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4004
+ */
4005
+
4006
+
4007
+ var SymbolIterator = Symbol.iterator;
4008
+
4063
4009
  function addVNodeToChildLWC(vnode) {
4064
4010
  ArrayPush$1.call(getVMBeingRendered().velements, vnode);
4065
4011
  } // [h]tml node
@@ -4068,13 +4014,15 @@ var LWC = (function (exports) {
4068
4014
  function h(sel, data, children) {
4069
4015
  var vmBeingRendered = getVMBeingRendered();
4070
4016
 
4071
- var text, elm;
4017
+ var elm;
4072
4018
  var key = data.key;
4073
4019
  return {
4020
+ type: 2
4021
+ /* Element */
4022
+ ,
4074
4023
  sel: sel,
4075
4024
  data: data,
4076
4025
  children: children,
4077
- text: text,
4078
4026
  elm: elm,
4079
4027
  key: key,
4080
4028
  hook: ElementHook,
@@ -4126,12 +4074,14 @@ var LWC = (function (exports) {
4126
4074
  var vmBeingRendered = getVMBeingRendered();
4127
4075
 
4128
4076
  var key = data.key;
4129
- var text, elm;
4077
+ var elm;
4130
4078
  var vnode = {
4079
+ type: 3
4080
+ /* CustomElement */
4081
+ ,
4131
4082
  sel: sel,
4132
4083
  data: data,
4133
4084
  children: children,
4134
- text: text,
4135
4085
  elm: elm,
4136
4086
  key: key,
4137
4087
  hook: CustomElementHook,
@@ -4210,12 +4160,12 @@ var LWC = (function (exports) {
4210
4160
 
4211
4161
 
4212
4162
  function t(text) {
4213
- var data = EmptyObject;
4214
- var sel, children, key, elm;
4163
+ var sel, key, elm;
4215
4164
  return {
4165
+ type: 0
4166
+ /* Text */
4167
+ ,
4216
4168
  sel: sel,
4217
- data: data,
4218
- children: children,
4219
4169
  text: text,
4220
4170
  elm: elm,
4221
4171
  key: key,
@@ -4226,12 +4176,12 @@ var LWC = (function (exports) {
4226
4176
 
4227
4177
 
4228
4178
  function co(text) {
4229
- var data = EmptyObject;
4230
- var sel, children, key, elm;
4179
+ var sel, key, elm;
4231
4180
  return {
4181
+ type: 1
4182
+ /* Comment */
4183
+ ,
4232
4184
  sel: sel,
4233
- data: data,
4234
- children: children,
4235
4185
  text: text,
4236
4186
  elm: elm,
4237
4187
  key: key,
@@ -4503,8 +4453,8 @@ var LWC = (function (exports) {
4503
4453
  var content = [];
4504
4454
  var root;
4505
4455
 
4506
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4507
- var stylesheet = stylesheets[_i18];
4456
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4457
+ var stylesheet = stylesheets[_i16];
4508
4458
 
4509
4459
  if (isArray$1(stylesheet)) {
4510
4460
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4608,8 +4558,8 @@ var LWC = (function (exports) {
4608
4558
  && shadowMode === 1
4609
4559
  /* Synthetic */
4610
4560
  ) {
4611
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4612
- insertGlobalStylesheet$1(stylesheets[_i19]);
4561
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4562
+ insertGlobalStylesheet$1(stylesheets[_i17]);
4613
4563
  }
4614
4564
  } else if (ssr$1 || isHydrating$1()) {
4615
4565
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -4623,12 +4573,12 @@ var LWC = (function (exports) {
4623
4573
  var root = getNearestNativeShadowComponent(vm);
4624
4574
  var isGlobal = isNull(root);
4625
4575
 
4626
- for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
4576
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4627
4577
  if (isGlobal) {
4628
- insertGlobalStylesheet$1(stylesheets[_i20]);
4578
+ insertGlobalStylesheet$1(stylesheets[_i18]);
4629
4579
  } else {
4630
4580
  // local level
4631
- insertStylesheet$1(stylesheets[_i20], root.cmpRoot);
4581
+ insertStylesheet$1(stylesheets[_i18], root.shadowRoot);
4632
4582
  }
4633
4583
  }
4634
4584
  }
@@ -4813,8 +4763,8 @@ var LWC = (function (exports) {
4813
4763
  var stylesheets = template.stylesheets;
4814
4764
 
4815
4765
  if (!isUndefined$1(stylesheets)) {
4816
- for (var _i21 = 0; _i21 < stylesheets.length; _i21++) {
4817
- if (isTrue(stylesheets[_i21][KEY__SCOPED_CSS])) {
4766
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4767
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4818
4768
  return true;
4819
4769
  }
4820
4770
  }
@@ -4822,24 +4772,6 @@ var LWC = (function (exports) {
4822
4772
 
4823
4773
  return false;
4824
4774
  }
4825
- /*
4826
- * Copyright (c) 2018, salesforce.com, inc.
4827
- * All rights reserved.
4828
- * SPDX-License-Identifier: MIT
4829
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4830
- */
4831
-
4832
-
4833
- function addErrorComponentStack(vm, error) {
4834
- if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
4835
- var wcStack = getErrorComponentStack(vm);
4836
- defineProperty(error, 'wcStack', {
4837
- get: function get() {
4838
- return wcStack;
4839
- }
4840
- });
4841
- }
4842
- }
4843
4775
  var vmBeingConstructed = null;
4844
4776
 
4845
4777
  function isBeingConstructed(vm) {
@@ -5015,8 +4947,8 @@ var LWC = (function (exports) {
5015
4947
 
5016
4948
  function register(service) {
5017
4949
 
5018
- for (var _i22 = 0; _i22 < hooks.length; ++_i22) {
5019
- var hookName = hooks[_i22];
4950
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4951
+ var hookName = hooks[_i20];
5020
4952
 
5021
4953
  if (hookName in service) {
5022
4954
  var l = Services[hookName];
@@ -5036,10 +4968,140 @@ var LWC = (function (exports) {
5036
4968
  def = vm.def,
5037
4969
  context = vm.context;
5038
4970
 
5039
- for (var _i23 = 0, _len8 = cbs.length; _i23 < _len8; ++_i23) {
5040
- cbs[_i23].call(undefined, component, {}, def, context);
4971
+ for (var _i21 = 0, _len8 = cbs.length; _i21 < _len8; ++_i21) {
4972
+ cbs[_i21].call(undefined, component, {}, def, context);
4973
+ }
4974
+ }
4975
+ /*
4976
+ * Copyright (c) 2022, salesforce.com, inc.
4977
+ * All rights reserved.
4978
+ * SPDX-License-Identifier: MIT
4979
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4980
+ */
4981
+
4982
+
4983
+ function hydrate$1(vnode, node) {
4984
+ switch (vnode.type) {
4985
+ case 0
4986
+ /* Text */
4987
+ :
4988
+ hydrateText(vnode, node);
4989
+ break;
4990
+
4991
+ case 1
4992
+ /* Comment */
4993
+ :
4994
+ hydrateComment(vnode, node);
4995
+ break;
4996
+
4997
+ case 2
4998
+ /* Element */
4999
+ :
5000
+ hydrateElement(vnode, node);
5001
+ break;
5002
+
5003
+ case 3
5004
+ /* CustomElement */
5005
+ :
5006
+ hydrateCustomElement(vnode, node);
5007
+ break;
5008
+ }
5009
+ }
5010
+
5011
+ function hydrateText(vnode, node) {
5012
+ var _a;
5013
+
5014
+
5015
+ node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5016
+ vnode.elm = node;
5017
+ }
5018
+
5019
+ function hydrateComment(vnode, node) {
5020
+ var _a;
5021
+
5022
+
5023
+ node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5024
+ vnode.elm = node;
5025
+ }
5026
+
5027
+ function hydrateElement(vnode, node) {
5028
+
5029
+ var elm = node;
5030
+ vnode.elm = elm;
5031
+ var context = vnode.data.context;
5032
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5033
+ /* Manual */
5034
+ );
5035
+
5036
+ if (isDomManual) {
5037
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5038
+ // remove the innerHTML from props so it reuses the existing dom elements.
5039
+ var props = vnode.data.props;
5040
+
5041
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5042
+ if (elm.innerHTML === props.innerHTML) {
5043
+ delete props.innerHTML;
5044
+ } else {
5045
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5046
+ }
5047
+ }
5048
+ }
5049
+
5050
+ patchElementPropsAndAttrs(vnode);
5051
+
5052
+ if (!isDomManual) {
5053
+ hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
5054
+ }
5055
+ }
5056
+
5057
+ function hydrateCustomElement(vnode, node) {
5058
+
5059
+ var elm = node;
5060
+ vnode.elm = elm;
5061
+ var sel = vnode.sel,
5062
+ mode = vnode.mode,
5063
+ ctor = vnode.ctor,
5064
+ owner = vnode.owner;
5065
+ var vm = createVM(elm, ctor, {
5066
+ mode: mode,
5067
+ owner: owner,
5068
+ tagName: sel
5069
+ });
5070
+ allocateChildren(vnode, vm);
5071
+ patchElementPropsAndAttrs(vnode); // Insert hook section:
5072
+
5073
+ runConnectedCallback(vm);
5074
+
5075
+ if (vm.renderMode !== 0
5076
+ /* Light */
5077
+ ) {
5078
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5079
+ // Note: for Light DOM, this is handled while hydrating the VM
5080
+ hydrateChildren(vnode.elm.childNodes, vnode.children);
5081
+ }
5082
+
5083
+ hydrateVM(vm);
5084
+ }
5085
+
5086
+ function hydrateChildren(elmChildren, children, vm) {
5087
+
5088
+ var childNodeIndex = 0;
5089
+
5090
+ for (var _i22 = 0; _i22 < children.length; _i22++) {
5091
+ var childVnode = children[_i22];
5092
+
5093
+ if (!isNull(childVnode)) {
5094
+ var childNode = elmChildren[childNodeIndex];
5095
+ hydrate$1(childVnode, childNode);
5096
+ childNodeIndex++;
5097
+ }
5041
5098
  }
5042
5099
  }
5100
+
5101
+ function patchElementPropsAndAttrs(vnode) {
5102
+ applyEventListeners(vnode);
5103
+ patchProps(null, vnode);
5104
+ }
5043
5105
  /*
5044
5106
  * Copyright (c) 2018, salesforce.com, inc.
5045
5107
  * All rights reserved.
@@ -5152,10 +5214,11 @@ var LWC = (function (exports) {
5152
5214
  return ancestor;
5153
5215
  }
5154
5216
 
5155
- function createVM(elm, def, options) {
5217
+ function createVM(elm, ctor, options) {
5156
5218
  var mode = options.mode,
5157
5219
  owner = options.owner,
5158
5220
  tagName = options.tagName;
5221
+ var def = getComponentInternalDef(ctor);
5159
5222
  var vm = {
5160
5223
  elm: elm,
5161
5224
  def: def,
@@ -5177,7 +5240,6 @@ var LWC = (function (exports) {
5177
5240
  oar: create(null),
5178
5241
  cmpTemplate: null,
5179
5242
  renderMode: def.renderMode,
5180
- shadowMode: null,
5181
5243
  context: {
5182
5244
  stylesheetToken: undefined,
5183
5245
  hasTokenInClass: undefined,
@@ -5188,9 +5250,13 @@ var LWC = (function (exports) {
5188
5250
  wiredConnecting: EmptyArray,
5189
5251
  wiredDisconnecting: EmptyArray
5190
5252
  },
5253
+ // Properties set right after VM creation.
5191
5254
  tro: null,
5255
+ shadowMode: null,
5256
+ // Properties set by the LightningElement constructor.
5192
5257
  component: null,
5193
- cmpRoot: null,
5258
+ shadowRoot: null,
5259
+ renderRoot: null,
5194
5260
  callHook: callHook,
5195
5261
  setHook: setHook,
5196
5262
  getHook: getHook
@@ -5297,13 +5363,14 @@ var LWC = (function (exports) {
5297
5363
  var vmChildren = vm.renderMode === 0
5298
5364
  /* Light */
5299
5365
  ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5300
- hydrateChildrenHook(vmChildren, children);
5366
+ hydrateChildren(vmChildren, children);
5301
5367
  runRenderedCallback(vm);
5302
5368
  }
5303
5369
  }
5304
5370
 
5305
5371
  function patchShadowRoot(vm, newCh) {
5306
- var oldCh = vm.children; // caching the new children collection
5372
+ var renderRoot = vm.renderRoot,
5373
+ oldCh = vm.children; // caching the new children collection
5307
5374
 
5308
5375
  vm.children = newCh;
5309
5376
 
@@ -5318,7 +5385,6 @@ var LWC = (function (exports) {
5318
5385
  , vm);
5319
5386
  }, function () {
5320
5387
  // job
5321
- var renderRoot = getRenderRoot(vm);
5322
5388
  patchChildren(renderRoot, oldCh, newCh);
5323
5389
  }, function () {
5324
5390
  // post
@@ -5376,19 +5442,19 @@ var LWC = (function (exports) {
5376
5442
  });
5377
5443
  rehydrateQueue = []; // reset to a new queue
5378
5444
 
5379
- for (var _i24 = 0, _len9 = vms.length; _i24 < _len9; _i24 += 1) {
5380
- var vm = vms[_i24];
5445
+ for (var _i25 = 0, _len9 = vms.length; _i25 < _len9; _i25 += 1) {
5446
+ var vm = vms[_i25];
5381
5447
 
5382
5448
  try {
5383
5449
  rehydrate(vm);
5384
5450
  } catch (error) {
5385
- if (_i24 + 1 < _len9) {
5451
+ if (_i25 + 1 < _len9) {
5386
5452
  // pieces of the queue are still pending to be rehydrated, those should have priority
5387
5453
  if (rehydrateQueue.length === 0) {
5388
5454
  addCallbackToNextTick(flushRehydrationQueue);
5389
5455
  }
5390
5456
 
5391
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i24 + 1));
5457
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i25 + 1));
5392
5458
  } // we need to end the measure before throwing.
5393
5459
 
5394
5460
 
@@ -5487,8 +5553,8 @@ var LWC = (function (exports) {
5487
5553
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5488
5554
  // inserted in reserved order.
5489
5555
 
5490
- for (var _i25 = vCustomElementCollection.length - 1; _i25 >= 0; _i25 -= 1) {
5491
- var elm = vCustomElementCollection[_i25].elm; // There are two cases where the element could be undefined:
5556
+ for (var _i26 = vCustomElementCollection.length - 1; _i26 >= 0; _i26 -= 1) {
5557
+ var elm = vCustomElementCollection[_i26].elm; // There are two cases where the element could be undefined:
5492
5558
  // * when there is an error during the construction phase, and an error
5493
5559
  // boundary picks it, there is a possibility that the VCustomElement
5494
5560
  // is not properly initialized, and therefore is should be ignored.
@@ -5522,17 +5588,25 @@ var LWC = (function (exports) {
5522
5588
 
5523
5589
 
5524
5590
  function recursivelyDisconnectChildren(vnodes) {
5525
- for (var _i26 = 0, _len10 = vnodes.length; _i26 < _len10; _i26 += 1) {
5526
- var vnode = vnodes[_i26];
5527
-
5528
- if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5529
- // vnode is a VElement with children
5530
- if (isUndefined$1(vnode.ctor)) {
5531
- // it is a VElement, just keep looking (recursively)
5532
- recursivelyDisconnectChildren(vnode.children);
5533
- } else {
5534
- // it is a VCustomElement, disconnect it and ignore its children
5535
- resetComponentStateWhenRemoved(getAssociatedVM(vnode.elm));
5591
+ for (var _i27 = 0, _len10 = vnodes.length; _i27 < _len10; _i27 += 1) {
5592
+ var vnode = vnodes[_i27];
5593
+
5594
+ if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
5595
+ switch (vnode.type) {
5596
+ case 2
5597
+ /* Element */
5598
+ :
5599
+ recursivelyDisconnectChildren(vnode.children);
5600
+ break;
5601
+
5602
+ case 3
5603
+ /* CustomElement */
5604
+ :
5605
+ {
5606
+ var vm = getAssociatedVM(vnode.elm);
5607
+ resetComponentStateWhenRemoved(vm);
5608
+ break;
5609
+ }
5536
5610
  }
5537
5611
  }
5538
5612
  }
@@ -5543,14 +5617,14 @@ var LWC = (function (exports) {
5543
5617
 
5544
5618
 
5545
5619
  function resetComponentRoot(vm) {
5546
- var children = vm.children;
5547
- var rootNode = getRenderRoot(vm);
5620
+ var children = vm.children,
5621
+ renderRoot = vm.renderRoot;
5548
5622
 
5549
- for (var _i27 = 0, _len11 = children.length; _i27 < _len11; _i27++) {
5550
- var child = children[_i27];
5623
+ for (var _i28 = 0, _len11 = children.length; _i28 < _len11; _i28++) {
5624
+ var child = children[_i28];
5551
5625
 
5552
5626
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5553
- remove$1(child.elm, rootNode);
5627
+ remove$1(child.elm, renderRoot);
5554
5628
  }
5555
5629
  }
5556
5630
 
@@ -5618,12 +5692,6 @@ var LWC = (function (exports) {
5618
5692
  }
5619
5693
  }
5620
5694
  }
5621
-
5622
- function getRenderRoot(vm) {
5623
- return vm.renderMode === 1
5624
- /* Shadow */
5625
- ? vm.cmpRoot : vm.elm;
5626
- }
5627
5695
  /*
5628
5696
  * Copyright (c) 2018, salesforce.com, inc.
5629
5697
  * All rights reserved.
@@ -5903,8 +5971,8 @@ var LWC = (function (exports) {
5903
5971
  function connectWireAdapters(vm) {
5904
5972
  var wiredConnecting = vm.context.wiredConnecting;
5905
5973
 
5906
- for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5907
- wiredConnecting[_i28]();
5974
+ for (var _i29 = 0, _len12 = wiredConnecting.length; _i29 < _len12; _i29 += 1) {
5975
+ wiredConnecting[_i29]();
5908
5976
  }
5909
5977
  }
5910
5978
 
@@ -5912,8 +5980,8 @@ var LWC = (function (exports) {
5912
5980
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5913
5981
  runWithBoundaryProtection(vm, vm, noop, function () {
5914
5982
  // job
5915
- for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5916
- wiredDisconnecting[_i29]();
5983
+ for (var _i30 = 0, _len13 = wiredDisconnecting.length; _i30 < _len13; _i30 += 1) {
5984
+ wiredDisconnecting[_i30]();
5917
5985
  }
5918
5986
  }, noop);
5919
5987
  }
@@ -5997,7 +6065,7 @@ var LWC = (function (exports) {
5997
6065
  hooksAreSet = true;
5998
6066
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5999
6067
  }
6000
- /* version: 2.7.3 */
6068
+ /* version: 2.7.4 */
6001
6069
 
6002
6070
  /*
6003
6071
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6440,8 +6508,7 @@ var LWC = (function (exports) {
6440
6508
  */
6441
6509
 
6442
6510
  var element = new UpgradableConstructor(function (elm) {
6443
- var def = getComponentInternalDef(Ctor);
6444
- createVM(elm, def, {
6511
+ createVM(elm, Ctor, {
6445
6512
  tagName: sel,
6446
6513
  mode: options.mode !== 'closed' ? 'open' : 'closed',
6447
6514
  owner: null
@@ -6481,20 +6548,18 @@ var LWC = (function (exports) {
6481
6548
  throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6482
6549
  }
6483
6550
 
6484
- var def = getComponentInternalDef(Ctor);
6485
-
6486
6551
  try {
6487
6552
  // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6488
6553
  // and uses the same algo to create the stylesheets as in SSR.
6489
6554
  setIsHydrating(true);
6490
- createVM(element, def, {
6555
+ createVM(element, Ctor, {
6491
6556
  mode: 'open',
6492
6557
  owner: null,
6493
6558
  tagName: element.tagName.toLowerCase()
6494
6559
  });
6495
6560
 
6496
- for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6497
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6561
+ for (var _i32 = 0, _Object$entries2 = Object.entries(props); _i32 < _Object$entries2.length; _i32++) {
6562
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i32], 2),
6498
6563
  key = _Object$entries2$_i[0],
6499
6564
  value = _Object$entries2$_i[1];
6500
6565
 
@@ -6516,8 +6581,8 @@ var LWC = (function (exports) {
6516
6581
  mode: 'open'
6517
6582
  });
6518
6583
 
6519
- for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6520
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6584
+ for (var _i33 = 0, _Object$entries3 = Object.entries(props); _i33 < _Object$entries3.length; _i33++) {
6585
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i33], 2),
6521
6586
  _key3 = _Object$entries3$_i[0],
6522
6587
  _value2 = _Object$entries3$_i[1];
6523
6588
 
@@ -6557,9 +6622,9 @@ var LWC = (function (exports) {
6557
6622
  }
6558
6623
 
6559
6624
  function buildCustomElementConstructor(Ctor) {
6560
- var def = getComponentInternalDef(Ctor);
6561
- return /*#__PURE__*/function (_def$bridge) {
6562
- _inherits(_class, _def$bridge);
6625
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
6626
+ return /*#__PURE__*/function (_HtmlPrototype) {
6627
+ _inherits(_class, _HtmlPrototype);
6563
6628
 
6564
6629
  var _super8 = _createSuper(_class);
6565
6630
 
@@ -6569,7 +6634,7 @@ var LWC = (function (exports) {
6569
6634
  _classCallCheck(this, _class);
6570
6635
 
6571
6636
  _this6 = _super8.call(this);
6572
- createVM(_assertThisInitialized(_this6), def, {
6637
+ createVM(_assertThisInitialized(_this6), Ctor, {
6573
6638
  mode: 'open',
6574
6639
  owner: null,
6575
6640
  tagName: _this6.tagName
@@ -6590,7 +6655,7 @@ var LWC = (function (exports) {
6590
6655
  }]);
6591
6656
 
6592
6657
  return _class;
6593
- }(def.bridge);
6658
+ }(HtmlPrototype);
6594
6659
  }
6595
6660
  /*
6596
6661
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6697,7 +6762,7 @@ var LWC = (function (exports) {
6697
6762
  });
6698
6763
  freeze(LightningElement);
6699
6764
  seal(LightningElement.prototype);
6700
- /* version: 2.7.3 */
6765
+ /* version: 2.7.4 */
6701
6766
 
6702
6767
  exports.LightningElement = LightningElement;
6703
6768
  exports.__unstable__ProfilerControl = profilerControl;