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