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.
- package/dist/engine-dom/esm/es2017/engine-dom.js +866 -800
- package/dist/engine-dom/iife/es2017/engine-dom.js +866 -800
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +654 -587
- package/dist/engine-dom/iife/es5/engine-dom.js +912 -848
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +698 -633
- package/dist/engine-dom/umd/es2017/engine-dom.js +866 -800
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +654 -587
- package/dist/engine-dom/umd/es5/engine-dom.js +912 -848
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +698 -633
- package/dist/engine-server/commonjs/es2017/engine-server.js +606 -903
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +606 -903
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +8 -8
|
@@ -299,7 +299,11 @@ function htmlPropertyToAttribute(propName) {
|
|
|
299
299
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
300
300
|
return attributeName;
|
|
301
301
|
}
|
|
302
|
-
|
|
302
|
+
|
|
303
|
+
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
304
|
+
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
305
|
+
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
306
|
+
/** version: 2.7.4 */
|
|
303
307
|
|
|
304
308
|
/*
|
|
305
309
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -308,7 +312,6 @@ function htmlPropertyToAttribute(propName) {
|
|
|
308
312
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
309
313
|
*/
|
|
310
314
|
|
|
311
|
-
|
|
312
315
|
function detect(propName) {
|
|
313
316
|
return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
|
|
314
317
|
}
|
|
@@ -477,7 +480,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
477
480
|
setFeatureFlag(name, value);
|
|
478
481
|
}
|
|
479
482
|
}
|
|
480
|
-
/** version: 2.7.
|
|
483
|
+
/** version: 2.7.4 */
|
|
481
484
|
|
|
482
485
|
/* proxy-compat-disable */
|
|
483
486
|
|
|
@@ -975,6 +978,25 @@ function getErrorComponentStack(vm) {
|
|
|
975
978
|
*/
|
|
976
979
|
|
|
977
980
|
|
|
981
|
+
function addErrorComponentStack(vm, error) {
|
|
982
|
+
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
983
|
+
const wcStack = getErrorComponentStack(vm);
|
|
984
|
+
defineProperty(error, 'wcStack', {
|
|
985
|
+
get() {
|
|
986
|
+
return wcStack;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
/*
|
|
993
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
994
|
+
* All rights reserved.
|
|
995
|
+
* SPDX-License-Identifier: MIT
|
|
996
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
997
|
+
*/
|
|
998
|
+
|
|
999
|
+
|
|
978
1000
|
function log(method, message, vm) {
|
|
979
1001
|
let msg = `[LWC ${method}]: ${message}`;
|
|
980
1002
|
|
|
@@ -1009,207 +1031,12 @@ function logWarn(message, vm) {
|
|
|
1009
1031
|
* SPDX-License-Identifier: MIT
|
|
1010
1032
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1011
1033
|
*/
|
|
1034
|
+
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
1035
|
+
// to inject at runtime.
|
|
1012
1036
|
|
|
1013
1037
|
|
|
1014
|
-
function
|
|
1015
|
-
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
function sameVnode(vnode1, vnode2) {
|
|
1019
|
-
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
function isVNode(vnode) {
|
|
1023
|
-
return vnode != null;
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
1027
|
-
const map = {};
|
|
1028
|
-
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
1029
|
-
|
|
1030
|
-
for (j = beginIdx; j <= endIdx; ++j) {
|
|
1031
|
-
ch = children[j];
|
|
1032
|
-
|
|
1033
|
-
if (isVNode(ch)) {
|
|
1034
|
-
key = ch.key;
|
|
1035
|
-
|
|
1036
|
-
if (key !== undefined) {
|
|
1037
|
-
map[key] = j;
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
return map;
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
1046
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
1047
|
-
const ch = vnodes[startIdx];
|
|
1048
|
-
|
|
1049
|
-
if (isVNode(ch)) {
|
|
1050
|
-
ch.hook.create(ch);
|
|
1051
|
-
ch.hook.insert(ch, parentElm, before);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
1057
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
1058
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
1059
|
-
|
|
1060
|
-
if (isVNode(ch)) {
|
|
1061
|
-
ch.hook.remove(ch, parentElm);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
1067
|
-
let oldStartIdx = 0;
|
|
1068
|
-
let newStartIdx = 0;
|
|
1069
|
-
let oldEndIdx = oldCh.length - 1;
|
|
1070
|
-
let oldStartVnode = oldCh[0];
|
|
1071
|
-
let oldEndVnode = oldCh[oldEndIdx];
|
|
1072
|
-
const newChEnd = newCh.length - 1;
|
|
1073
|
-
let newEndIdx = newChEnd;
|
|
1074
|
-
let newStartVnode = newCh[0];
|
|
1075
|
-
let newEndVnode = newCh[newEndIdx];
|
|
1076
|
-
let oldKeyToIdx;
|
|
1077
|
-
let idxInOld;
|
|
1078
|
-
let elmToMove;
|
|
1079
|
-
let before;
|
|
1080
|
-
|
|
1081
|
-
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
1082
|
-
if (!isVNode(oldStartVnode)) {
|
|
1083
|
-
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
1084
|
-
} else if (!isVNode(oldEndVnode)) {
|
|
1085
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1086
|
-
} else if (!isVNode(newStartVnode)) {
|
|
1087
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1088
|
-
} else if (!isVNode(newEndVnode)) {
|
|
1089
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1090
|
-
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
1091
|
-
patchVnode(oldStartVnode, newStartVnode);
|
|
1092
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1093
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1094
|
-
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
1095
|
-
patchVnode(oldEndVnode, newEndVnode);
|
|
1096
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1097
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1098
|
-
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
1099
|
-
// Vnode moved right
|
|
1100
|
-
patchVnode(oldStartVnode, newEndVnode);
|
|
1101
|
-
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
|
|
1102
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1103
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1104
|
-
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
1105
|
-
// Vnode moved left
|
|
1106
|
-
patchVnode(oldEndVnode, newStartVnode);
|
|
1107
|
-
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
1108
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1109
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1110
|
-
} else {
|
|
1111
|
-
if (oldKeyToIdx === undefined) {
|
|
1112
|
-
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
1116
|
-
|
|
1117
|
-
if (isUndef(idxInOld)) {
|
|
1118
|
-
// New element
|
|
1119
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1120
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1121
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1122
|
-
} else {
|
|
1123
|
-
elmToMove = oldCh[idxInOld];
|
|
1124
|
-
|
|
1125
|
-
if (isVNode(elmToMove)) {
|
|
1126
|
-
if (elmToMove.sel !== newStartVnode.sel) {
|
|
1127
|
-
// New element
|
|
1128
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1129
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1130
|
-
} else {
|
|
1131
|
-
patchVnode(elmToMove, newStartVnode);
|
|
1132
|
-
oldCh[idxInOld] = undefined;
|
|
1133
|
-
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
1143
|
-
if (oldStartIdx > oldEndIdx) {
|
|
1144
|
-
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
1145
|
-
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
1146
|
-
let i = newEndIdx;
|
|
1147
|
-
let n;
|
|
1148
|
-
|
|
1149
|
-
do {
|
|
1150
|
-
n = newCh[++i];
|
|
1151
|
-
} while (!isVNode(n) && i < newChEnd);
|
|
1152
|
-
|
|
1153
|
-
before = isVNode(n) ? n.elm : null;
|
|
1154
|
-
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
1155
|
-
} else {
|
|
1156
|
-
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
1162
|
-
const oldChLength = oldCh.length;
|
|
1163
|
-
const newChLength = newCh.length;
|
|
1164
|
-
|
|
1165
|
-
if (oldChLength === 0) {
|
|
1166
|
-
// the old list is empty, we can directly insert anything new
|
|
1167
|
-
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
1168
|
-
return;
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
if (newChLength === 0) {
|
|
1172
|
-
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
1173
|
-
// this is the case in which the dynamic children of an if-directive should be removed
|
|
1174
|
-
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
1175
|
-
return;
|
|
1176
|
-
} // if the old list is not empty, the new list MUST have the same
|
|
1177
|
-
// amount of nodes, that's why we call this static children
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
let referenceElm = null;
|
|
1181
|
-
|
|
1182
|
-
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
1183
|
-
const vnode = newCh[i];
|
|
1184
|
-
const oldVNode = oldCh[i];
|
|
1185
|
-
|
|
1186
|
-
if (vnode !== oldVNode) {
|
|
1187
|
-
if (isVNode(oldVNode)) {
|
|
1188
|
-
if (isVNode(vnode)) {
|
|
1189
|
-
// both vnodes must be equivalent, and se just need to patch them
|
|
1190
|
-
patchVnode(oldVNode, vnode);
|
|
1191
|
-
referenceElm = vnode.elm;
|
|
1192
|
-
} else {
|
|
1193
|
-
// removing the old vnode since the new one is null
|
|
1194
|
-
oldVNode.hook.remove(oldVNode, parentElm);
|
|
1195
|
-
}
|
|
1196
|
-
} else if (isVNode(vnode)) {
|
|
1197
|
-
// this condition is unnecessary
|
|
1198
|
-
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
1199
|
-
|
|
1200
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
1201
|
-
referenceElm = vnode.elm;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
function patchVnode(oldVnode, vnode) {
|
|
1208
|
-
if (oldVnode !== vnode) {
|
|
1209
|
-
vnode.elm = oldVnode.elm;
|
|
1210
|
-
vnode.hook.update(oldVnode, vnode);
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1038
|
+
const HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
|
1039
|
+
const HTMLElementPrototype = HTMLElementConstructor$1.prototype;
|
|
1213
1040
|
/*
|
|
1214
1041
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1215
1042
|
* All rights reserved.
|
|
@@ -1217,7 +1044,6 @@ function patchVnode(oldVnode, vnode) {
|
|
|
1217
1044
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1218
1045
|
*/
|
|
1219
1046
|
|
|
1220
|
-
|
|
1221
1047
|
const defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
|
|
1222
1048
|
|
|
1223
1049
|
function offsetPropertyErrorMessage(name) {
|
|
@@ -1336,6 +1162,40 @@ function unlockAttribute(elm, key) {
|
|
|
1336
1162
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1337
1163
|
*/
|
|
1338
1164
|
|
|
1165
|
+
/**
|
|
1166
|
+
* This is a descriptor map that contains
|
|
1167
|
+
* all standard properties that a Custom Element can support (including AOM properties), which
|
|
1168
|
+
* determines what kind of capabilities the Base HTML Element and
|
|
1169
|
+
* Base Lightning Element should support.
|
|
1170
|
+
*/
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
const HTMLElementOriginalDescriptors = create(null);
|
|
1174
|
+
forEach.call(keys(AriaPropNameToAttrNameMap), propName => {
|
|
1175
|
+
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1176
|
+
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
|
|
1177
|
+
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1178
|
+
|
|
1179
|
+
if (!isUndefined$1(descriptor)) {
|
|
1180
|
+
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1183
|
+
forEach.call(defaultDefHTMLPropertyNames, propName => {
|
|
1184
|
+
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1185
|
+
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
|
|
1186
|
+
// this category, so, better to be sure.
|
|
1187
|
+
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1188
|
+
|
|
1189
|
+
if (!isUndefined$1(descriptor)) {
|
|
1190
|
+
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
/*
|
|
1194
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1195
|
+
* All rights reserved.
|
|
1196
|
+
* SPDX-License-Identifier: MIT
|
|
1197
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1198
|
+
*/
|
|
1339
1199
|
|
|
1340
1200
|
function generateDataDescriptor(options) {
|
|
1341
1201
|
return assign({
|
|
@@ -1698,56 +1558,11 @@ function patchComponentWithRestrictions(cmp) {
|
|
|
1698
1558
|
function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
1699
1559
|
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
1700
1560
|
}
|
|
1701
|
-
|
|
1702
|
-
* Copyright (
|
|
1703
|
-
* All rights reserved.
|
|
1704
|
-
* SPDX-License-Identifier: MIT
|
|
1705
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1561
|
+
/**
|
|
1562
|
+
* Copyright (C) 2017 salesforce.com, inc.
|
|
1706
1563
|
*/
|
|
1707
|
-
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
1708
|
-
// to inject at runtime.
|
|
1709
1564
|
|
|
1710
1565
|
|
|
1711
|
-
const HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
|
1712
|
-
const HTMLElementPrototype = HTMLElementConstructor$1.prototype;
|
|
1713
|
-
/*
|
|
1714
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1715
|
-
* All rights reserved.
|
|
1716
|
-
* SPDX-License-Identifier: MIT
|
|
1717
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1718
|
-
*/
|
|
1719
|
-
|
|
1720
|
-
/**
|
|
1721
|
-
* This is a descriptor map that contains
|
|
1722
|
-
* all standard properties that a Custom Element can support (including AOM properties), which
|
|
1723
|
-
* determines what kind of capabilities the Base HTML Element and
|
|
1724
|
-
* Base Lightning Element should support.
|
|
1725
|
-
*/
|
|
1726
|
-
|
|
1727
|
-
const HTMLElementOriginalDescriptors = create(null);
|
|
1728
|
-
forEach.call(keys(AriaPropNameToAttrNameMap), propName => {
|
|
1729
|
-
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1730
|
-
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
|
|
1731
|
-
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1732
|
-
|
|
1733
|
-
if (!isUndefined$1(descriptor)) {
|
|
1734
|
-
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1735
|
-
}
|
|
1736
|
-
});
|
|
1737
|
-
forEach.call(defaultDefHTMLPropertyNames, propName => {
|
|
1738
|
-
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1739
|
-
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
|
|
1740
|
-
// this category, so, better to be sure.
|
|
1741
|
-
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1742
|
-
|
|
1743
|
-
if (!isUndefined$1(descriptor)) {
|
|
1744
|
-
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1745
|
-
}
|
|
1746
|
-
});
|
|
1747
|
-
/**
|
|
1748
|
-
* Copyright (C) 2017 salesforce.com, inc.
|
|
1749
|
-
*/
|
|
1750
|
-
|
|
1751
1566
|
const {
|
|
1752
1567
|
isArray
|
|
1753
1568
|
} = Array;
|
|
@@ -2664,7 +2479,9 @@ const LightningElement = function () {
|
|
|
2664
2479
|
if (vm.renderMode === 1
|
|
2665
2480
|
/* Shadow */
|
|
2666
2481
|
) {
|
|
2667
|
-
doAttachShadow(vm);
|
|
2482
|
+
vm.renderRoot = doAttachShadow(vm);
|
|
2483
|
+
} else {
|
|
2484
|
+
vm.renderRoot = elm;
|
|
2668
2485
|
} // Adding extra guard rails in DEV mode.
|
|
2669
2486
|
|
|
2670
2487
|
|
|
@@ -2685,19 +2502,21 @@ function doAttachShadow(vm) {
|
|
|
2685
2502
|
ctor
|
|
2686
2503
|
}
|
|
2687
2504
|
} = vm;
|
|
2688
|
-
const
|
|
2505
|
+
const shadowRoot = attachShadow$1(elm, {
|
|
2689
2506
|
[KEY__SYNTHETIC_MODE]: shadowMode === 1
|
|
2690
2507
|
/* Synthetic */
|
|
2691
2508
|
,
|
|
2692
2509
|
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
2693
2510
|
mode
|
|
2694
2511
|
});
|
|
2695
|
-
vm.
|
|
2696
|
-
associateVM(
|
|
2512
|
+
vm.shadowRoot = shadowRoot;
|
|
2513
|
+
associateVM(shadowRoot, vm);
|
|
2697
2514
|
|
|
2698
2515
|
if (process.env.NODE_ENV !== 'production') {
|
|
2699
|
-
patchShadowRootWithRestrictions(
|
|
2516
|
+
patchShadowRootWithRestrictions(shadowRoot);
|
|
2700
2517
|
}
|
|
2518
|
+
|
|
2519
|
+
return shadowRoot;
|
|
2701
2520
|
}
|
|
2702
2521
|
|
|
2703
2522
|
function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
@@ -2865,7 +2684,7 @@ LightningElement.prototype = {
|
|
|
2865
2684
|
}
|
|
2866
2685
|
}
|
|
2867
2686
|
|
|
2868
|
-
return vm.
|
|
2687
|
+
return vm.shadowRoot;
|
|
2869
2688
|
},
|
|
2870
2689
|
|
|
2871
2690
|
get shadowRoot() {
|
|
@@ -4277,6 +4096,11 @@ function getComponentInternalDef(Ctor) {
|
|
|
4277
4096
|
return def;
|
|
4278
4097
|
}
|
|
4279
4098
|
|
|
4099
|
+
function getComponentHtmlPrototype(Ctor) {
|
|
4100
|
+
const def = getComponentInternalDef(Ctor);
|
|
4101
|
+
return def.bridge;
|
|
4102
|
+
}
|
|
4103
|
+
|
|
4280
4104
|
const lightingElementDef = {
|
|
4281
4105
|
ctor: LightningElement,
|
|
4282
4106
|
name: LightningElement.name,
|
|
@@ -4339,6 +4163,65 @@ function getComponentDef(Ctor) {
|
|
|
4339
4163
|
methods: publicMethods
|
|
4340
4164
|
};
|
|
4341
4165
|
}
|
|
4166
|
+
/*
|
|
4167
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4168
|
+
* All rights reserved.
|
|
4169
|
+
* SPDX-License-Identifier: MIT
|
|
4170
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4171
|
+
*/
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
function getUpgradableConstructor(tagName) {
|
|
4175
|
+
// Should never get a tag with upper case letter at this point, the compiler should
|
|
4176
|
+
// produce only tags with lowercase letters
|
|
4177
|
+
// But, for backwards compatibility, we will lower case the tagName
|
|
4178
|
+
tagName = tagName.toLowerCase();
|
|
4179
|
+
let CE = getCustomElement$1(tagName);
|
|
4180
|
+
|
|
4181
|
+
if (!isUndefined$1(CE)) {
|
|
4182
|
+
return CE;
|
|
4183
|
+
}
|
|
4184
|
+
/**
|
|
4185
|
+
* LWC Upgradable Element reference to an element that was created
|
|
4186
|
+
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
4187
|
+
*/
|
|
4188
|
+
|
|
4189
|
+
|
|
4190
|
+
CE = class LWCUpgradableElement extends HTMLElementExported$1 {
|
|
4191
|
+
constructor(upgradeCallback) {
|
|
4192
|
+
super();
|
|
4193
|
+
|
|
4194
|
+
if (isFunction$1(upgradeCallback)) {
|
|
4195
|
+
upgradeCallback(this); // nothing to do with the result for now
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
};
|
|
4200
|
+
defineCustomElement$1(tagName, CE);
|
|
4201
|
+
return CE;
|
|
4202
|
+
}
|
|
4203
|
+
/*
|
|
4204
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4205
|
+
* All rights reserved.
|
|
4206
|
+
* SPDX-License-Identifier: MIT
|
|
4207
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4208
|
+
*/
|
|
4209
|
+
|
|
4210
|
+
|
|
4211
|
+
function isVBaseElement(vnode) {
|
|
4212
|
+
const {
|
|
4213
|
+
type
|
|
4214
|
+
} = vnode;
|
|
4215
|
+
return type === 2
|
|
4216
|
+
/* Element */
|
|
4217
|
+
|| type === 3
|
|
4218
|
+
/* CustomElement */
|
|
4219
|
+
;
|
|
4220
|
+
}
|
|
4221
|
+
|
|
4222
|
+
function isSameVnode(vnode1, vnode2) {
|
|
4223
|
+
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
4224
|
+
}
|
|
4342
4225
|
/*
|
|
4343
4226
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4344
4227
|
* All rights reserved.
|
|
@@ -4347,8 +4230,6 @@ function getComponentDef(Ctor) {
|
|
|
4347
4230
|
*/
|
|
4348
4231
|
|
|
4349
4232
|
|
|
4350
|
-
const xlinkNS = 'http://www.w3.org/1999/xlink';
|
|
4351
|
-
const xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
|
4352
4233
|
const ColonCharCode = 58;
|
|
4353
4234
|
|
|
4354
4235
|
function patchAttributes(oldVnode, vnode) {
|
|
@@ -4379,10 +4260,10 @@ function patchAttributes(oldVnode, vnode) {
|
|
|
4379
4260
|
|
|
4380
4261
|
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
|
|
4381
4262
|
// Assume xml namespace
|
|
4382
|
-
setAttribute$1(elm, key, cur,
|
|
4263
|
+
setAttribute$1(elm, key, cur, XML_NAMESPACE);
|
|
4383
4264
|
} else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
|
|
4384
4265
|
// Assume xlink namespace
|
|
4385
|
-
setAttribute$1(elm, key, cur,
|
|
4266
|
+
setAttribute$1(elm, key, cur, XLINK_NAMESPACE);
|
|
4386
4267
|
} else if (isNull(cur) || isUndefined$1(cur)) {
|
|
4387
4268
|
removeAttribute$1(elm, key);
|
|
4388
4269
|
} else {
|
|
@@ -4636,6 +4517,161 @@ function applyStaticStyleAttribute(vnode) {
|
|
|
4636
4517
|
*/
|
|
4637
4518
|
|
|
4638
4519
|
|
|
4520
|
+
const TextHook = {
|
|
4521
|
+
create: vnode => {
|
|
4522
|
+
const {
|
|
4523
|
+
owner
|
|
4524
|
+
} = vnode;
|
|
4525
|
+
const elm = createText$1(vnode.text);
|
|
4526
|
+
linkNodeToShadow(elm, owner);
|
|
4527
|
+
vnode.elm = elm;
|
|
4528
|
+
},
|
|
4529
|
+
update: updateNodeHook,
|
|
4530
|
+
insert: insertNode,
|
|
4531
|
+
move: insertNode,
|
|
4532
|
+
remove: removeNode
|
|
4533
|
+
};
|
|
4534
|
+
const CommentHook = {
|
|
4535
|
+
create: vnode => {
|
|
4536
|
+
const {
|
|
4537
|
+
owner,
|
|
4538
|
+
text
|
|
4539
|
+
} = vnode;
|
|
4540
|
+
const elm = createComment$1(text);
|
|
4541
|
+
linkNodeToShadow(elm, owner);
|
|
4542
|
+
vnode.elm = elm;
|
|
4543
|
+
},
|
|
4544
|
+
update: updateNodeHook,
|
|
4545
|
+
insert: insertNode,
|
|
4546
|
+
move: insertNode,
|
|
4547
|
+
remove: removeNode
|
|
4548
|
+
}; // insert is called after update, which is used somewhere else (via a module)
|
|
4549
|
+
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
4550
|
+
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
4551
|
+
// which breaks some invariants. For that reason, we have the following for any
|
|
4552
|
+
// Custom Element that is inserted via a template.
|
|
4553
|
+
|
|
4554
|
+
const ElementHook = {
|
|
4555
|
+
create: vnode => {
|
|
4556
|
+
const {
|
|
4557
|
+
sel,
|
|
4558
|
+
owner,
|
|
4559
|
+
data: {
|
|
4560
|
+
svg
|
|
4561
|
+
}
|
|
4562
|
+
} = vnode;
|
|
4563
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4564
|
+
const elm = createElement$2(sel, namespace);
|
|
4565
|
+
linkNodeToShadow(elm, owner);
|
|
4566
|
+
fallbackElmHook(elm, vnode);
|
|
4567
|
+
vnode.elm = elm;
|
|
4568
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4569
|
+
},
|
|
4570
|
+
update: (oldVnode, vnode) => {
|
|
4571
|
+
patchElementPropsAndAttrs$1(oldVnode, vnode);
|
|
4572
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
4573
|
+
},
|
|
4574
|
+
insert: (vnode, parentNode, referenceNode) => {
|
|
4575
|
+
insertNode(vnode, parentNode, referenceNode);
|
|
4576
|
+
createChildrenHook(vnode);
|
|
4577
|
+
},
|
|
4578
|
+
move: insertNode,
|
|
4579
|
+
remove: (vnode, parentNode) => {
|
|
4580
|
+
removeNode(vnode, parentNode);
|
|
4581
|
+
removeChildren(vnode);
|
|
4582
|
+
}
|
|
4583
|
+
};
|
|
4584
|
+
const CustomElementHook = {
|
|
4585
|
+
create: vnode => {
|
|
4586
|
+
const {
|
|
4587
|
+
sel,
|
|
4588
|
+
owner
|
|
4589
|
+
} = vnode;
|
|
4590
|
+
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
4591
|
+
/**
|
|
4592
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4593
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
4594
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
4595
|
+
* an upgradable custom element.
|
|
4596
|
+
*/
|
|
4597
|
+
|
|
4598
|
+
let vm;
|
|
4599
|
+
const elm = new UpgradableConstructor(elm => {
|
|
4600
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
4601
|
+
vm = createViewModelHook(elm, vnode);
|
|
4602
|
+
});
|
|
4603
|
+
linkNodeToShadow(elm, owner);
|
|
4604
|
+
vnode.elm = elm;
|
|
4605
|
+
|
|
4606
|
+
if (vm) {
|
|
4607
|
+
allocateChildren(vnode, vm);
|
|
4608
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4609
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
4610
|
+
}
|
|
4611
|
+
|
|
4612
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4613
|
+
},
|
|
4614
|
+
update: (oldVnode, vnode) => {
|
|
4615
|
+
patchElementPropsAndAttrs$1(oldVnode, vnode);
|
|
4616
|
+
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
4617
|
+
|
|
4618
|
+
if (vm) {
|
|
4619
|
+
// in fallback mode, the allocation will always set children to
|
|
4620
|
+
// empty and delegate the real allocation to the slot elements
|
|
4621
|
+
allocateChildren(vnode, vm);
|
|
4622
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
4623
|
+
// will happen, but in native, it does allocate the light dom
|
|
4624
|
+
|
|
4625
|
+
|
|
4626
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
4627
|
+
|
|
4628
|
+
if (vm) {
|
|
4629
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4630
|
+
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4631
|
+
} // this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4632
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
4633
|
+
|
|
4634
|
+
|
|
4635
|
+
rerenderVM(vm);
|
|
4636
|
+
}
|
|
4637
|
+
},
|
|
4638
|
+
insert: (vnode, parentNode, referenceNode) => {
|
|
4639
|
+
insertNode(vnode, parentNode, referenceNode);
|
|
4640
|
+
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
4641
|
+
|
|
4642
|
+
if (vm) {
|
|
4643
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4644
|
+
assert.isTrue(vm.state === 0
|
|
4645
|
+
/* created */
|
|
4646
|
+
, `${vm} cannot be recycled.`);
|
|
4647
|
+
}
|
|
4648
|
+
|
|
4649
|
+
runConnectedCallback(vm);
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4652
|
+
createChildrenHook(vnode);
|
|
4653
|
+
|
|
4654
|
+
if (vm) {
|
|
4655
|
+
appendVM(vm);
|
|
4656
|
+
}
|
|
4657
|
+
},
|
|
4658
|
+
move: insertNode,
|
|
4659
|
+
remove: (vnode, parentNode) => {
|
|
4660
|
+
removeNode(vnode, parentNode);
|
|
4661
|
+
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
4662
|
+
|
|
4663
|
+
if (vm) {
|
|
4664
|
+
// for custom elements we don't have to go recursively because the removeVM routine
|
|
4665
|
+
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
4666
|
+
removeVM(vm);
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
};
|
|
4670
|
+
|
|
4671
|
+
function isVNode(vnode) {
|
|
4672
|
+
return vnode != null;
|
|
4673
|
+
}
|
|
4674
|
+
|
|
4639
4675
|
function observeElementChildNodes(elm) {
|
|
4640
4676
|
elm.$domManual$ = true;
|
|
4641
4677
|
}
|
|
@@ -4657,6 +4693,24 @@ function setScopeTokenClassIfNecessary(elm, owner) {
|
|
|
4657
4693
|
}
|
|
4658
4694
|
}
|
|
4659
4695
|
|
|
4696
|
+
function linkNodeToShadow(elm, owner) {
|
|
4697
|
+
const {
|
|
4698
|
+
renderRoot,
|
|
4699
|
+
renderMode,
|
|
4700
|
+
shadowMode
|
|
4701
|
+
} = owner; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4702
|
+
|
|
4703
|
+
if (isSyntheticShadowDefined$1) {
|
|
4704
|
+
if (shadowMode === 1
|
|
4705
|
+
/* Synthetic */
|
|
4706
|
+
|| renderMode === 0
|
|
4707
|
+
/* Light */
|
|
4708
|
+
) {
|
|
4709
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
|
|
4660
4714
|
function updateNodeHook(oldVnode, vnode) {
|
|
4661
4715
|
const {
|
|
4662
4716
|
elm,
|
|
@@ -4676,7 +4730,7 @@ function updateNodeHook(oldVnode, vnode) {
|
|
|
4676
4730
|
}
|
|
4677
4731
|
}
|
|
4678
4732
|
|
|
4679
|
-
function
|
|
4733
|
+
function insertNode(vnode, parentNode, referenceNode) {
|
|
4680
4734
|
if (process.env.NODE_ENV !== 'production') {
|
|
4681
4735
|
unlockDomMutation();
|
|
4682
4736
|
}
|
|
@@ -4688,7 +4742,7 @@ function insertNodeHook(vnode, parentNode, referenceNode) {
|
|
|
4688
4742
|
}
|
|
4689
4743
|
}
|
|
4690
4744
|
|
|
4691
|
-
function
|
|
4745
|
+
function removeNode(vnode, parentNode) {
|
|
4692
4746
|
if (process.env.NODE_ENV !== 'production') {
|
|
4693
4747
|
unlockDomMutation();
|
|
4694
4748
|
}
|
|
@@ -4700,7 +4754,7 @@ function removeNodeHook(vnode, parentNode) {
|
|
|
4700
4754
|
}
|
|
4701
4755
|
}
|
|
4702
4756
|
|
|
4703
|
-
function patchElementPropsAndAttrs(oldVnode, vnode) {
|
|
4757
|
+
function patchElementPropsAndAttrs$1(oldVnode, vnode) {
|
|
4704
4758
|
if (isNull(oldVnode)) {
|
|
4705
4759
|
applyEventListeners(vnode);
|
|
4706
4760
|
applyStaticClassAttribute(vnode);
|
|
@@ -4715,11 +4769,6 @@ function patchElementPropsAndAttrs(oldVnode, vnode) {
|
|
|
4715
4769
|
patchProps(oldVnode, vnode);
|
|
4716
4770
|
}
|
|
4717
4771
|
|
|
4718
|
-
function hydrateElmHook(vnode) {
|
|
4719
|
-
applyEventListeners(vnode);
|
|
4720
|
-
patchProps(null, vnode);
|
|
4721
|
-
}
|
|
4722
|
-
|
|
4723
4772
|
function fallbackElmHook(elm, vnode) {
|
|
4724
4773
|
const {
|
|
4725
4774
|
owner
|
|
@@ -4739,7 +4788,7 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4739
4788
|
} = owner.context;
|
|
4740
4789
|
|
|
4741
4790
|
if (!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
4742
|
-
/*
|
|
4791
|
+
/* Manual */
|
|
4743
4792
|
) {
|
|
4744
4793
|
// this element will now accept any manual content inserted into it
|
|
4745
4794
|
observeElementChildNodes(elm);
|
|
@@ -4757,7 +4806,7 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4757
4806
|
}
|
|
4758
4807
|
} = vnode;
|
|
4759
4808
|
const isPortal = !isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
4760
|
-
/*
|
|
4809
|
+
/* Manual */
|
|
4761
4810
|
;
|
|
4762
4811
|
const isLight = owner.renderMode === 0
|
|
4763
4812
|
/* Light */
|
|
@@ -4777,7 +4826,7 @@ function patchChildren(parent, oldCh, newCh) {
|
|
|
4777
4826
|
}
|
|
4778
4827
|
}
|
|
4779
4828
|
|
|
4780
|
-
function
|
|
4829
|
+
function allocateChildren(vnode, vm) {
|
|
4781
4830
|
// A component with slots will re-render because:
|
|
4782
4831
|
// 1- There is a change of the internal state.
|
|
4783
4832
|
// 2- There is a change on the external api (ex: slots)
|
|
@@ -4810,11 +4859,12 @@ function allocateChildrenHook(vnode, vm) {
|
|
|
4810
4859
|
}
|
|
4811
4860
|
|
|
4812
4861
|
function createViewModelHook(elm, vnode) {
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4862
|
+
let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4863
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4864
|
+
// called right after invoking `document.createElement`.
|
|
4865
|
+
|
|
4866
|
+
if (!isUndefined$1(vm)) {
|
|
4867
|
+
return vm;
|
|
4818
4868
|
}
|
|
4819
4869
|
|
|
4820
4870
|
const {
|
|
@@ -4836,8 +4886,7 @@ function createViewModelHook(elm, vnode) {
|
|
|
4836
4886
|
setElementShadowToken(elm, stylesheetToken);
|
|
4837
4887
|
}
|
|
4838
4888
|
|
|
4839
|
-
|
|
4840
|
-
createVM(elm, def, {
|
|
4889
|
+
vm = createVM(elm, ctor, {
|
|
4841
4890
|
mode,
|
|
4842
4891
|
owner,
|
|
4843
4892
|
tagName: sel
|
|
@@ -4846,7 +4895,9 @@ function createViewModelHook(elm, vnode) {
|
|
|
4846
4895
|
if (process.env.NODE_ENV !== 'production') {
|
|
4847
4896
|
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4848
4897
|
}
|
|
4849
|
-
|
|
4898
|
+
|
|
4899
|
+
return vm;
|
|
4900
|
+
}
|
|
4850
4901
|
|
|
4851
4902
|
function createChildrenHook(vnode) {
|
|
4852
4903
|
const {
|
|
@@ -4864,171 +4915,7 @@ function createChildrenHook(vnode) {
|
|
|
4864
4915
|
}
|
|
4865
4916
|
}
|
|
4866
4917
|
|
|
4867
|
-
function
|
|
4868
|
-
// eslint-disable-next-line lwc-internal/no-global-node
|
|
4869
|
-
return node.nodeType === Node.ELEMENT_NODE;
|
|
4870
|
-
}
|
|
4871
|
-
|
|
4872
|
-
function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
|
|
4873
|
-
const {
|
|
4874
|
-
data: {
|
|
4875
|
-
attrs = {}
|
|
4876
|
-
}
|
|
4877
|
-
} = vnode;
|
|
4878
|
-
let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
|
|
4879
|
-
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
4880
|
-
|
|
4881
|
-
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
4882
|
-
const elmAttrValue = getAttribute$1(elm, attrName);
|
|
4883
|
-
|
|
4884
|
-
if (String(attrValue) !== elmAttrValue) {
|
|
4885
|
-
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
4886
|
-
nodesAreCompatible = false;
|
|
4887
|
-
}
|
|
4888
|
-
}
|
|
4889
|
-
|
|
4890
|
-
return nodesAreCompatible;
|
|
4891
|
-
}
|
|
4892
|
-
|
|
4893
|
-
function vnodesAndElementHaveCompatibleClass(vnode, elm) {
|
|
4894
|
-
const {
|
|
4895
|
-
data: {
|
|
4896
|
-
className,
|
|
4897
|
-
classMap
|
|
4898
|
-
}
|
|
4899
|
-
} = vnode;
|
|
4900
|
-
let nodesAreCompatible = true;
|
|
4901
|
-
let vnodeClassName;
|
|
4902
|
-
|
|
4903
|
-
if (!isUndefined$1(className) && String(className) !== elm.className) {
|
|
4904
|
-
// className is used when class is bound to an expr.
|
|
4905
|
-
nodesAreCompatible = false;
|
|
4906
|
-
vnodeClassName = className;
|
|
4907
|
-
} else if (!isUndefined$1(classMap)) {
|
|
4908
|
-
// classMap is used when class is set to static value.
|
|
4909
|
-
const classList = getClassList$1(elm);
|
|
4910
|
-
let computedClassName = ''; // all classes from the vnode should be in the element.classList
|
|
4911
|
-
|
|
4912
|
-
for (const name in classMap) {
|
|
4913
|
-
computedClassName += ' ' + name;
|
|
4914
|
-
|
|
4915
|
-
if (!classList.contains(name)) {
|
|
4916
|
-
nodesAreCompatible = false;
|
|
4917
|
-
}
|
|
4918
|
-
}
|
|
4919
|
-
|
|
4920
|
-
vnodeClassName = computedClassName.trim();
|
|
4921
|
-
|
|
4922
|
-
if (classList.length > keys(classMap).length) {
|
|
4923
|
-
nodesAreCompatible = false;
|
|
4924
|
-
}
|
|
4925
|
-
}
|
|
4926
|
-
|
|
4927
|
-
if (!nodesAreCompatible) {
|
|
4928
|
-
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
|
|
4929
|
-
}
|
|
4930
|
-
|
|
4931
|
-
return nodesAreCompatible;
|
|
4932
|
-
}
|
|
4933
|
-
|
|
4934
|
-
function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
|
|
4935
|
-
const {
|
|
4936
|
-
data: {
|
|
4937
|
-
style,
|
|
4938
|
-
styleDecls
|
|
4939
|
-
}
|
|
4940
|
-
} = vnode;
|
|
4941
|
-
const elmStyle = getAttribute$1(elm, 'style') || '';
|
|
4942
|
-
let vnodeStyle;
|
|
4943
|
-
let nodesAreCompatible = true;
|
|
4944
|
-
|
|
4945
|
-
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
4946
|
-
nodesAreCompatible = false;
|
|
4947
|
-
vnodeStyle = style;
|
|
4948
|
-
} else if (!isUndefined$1(styleDecls)) {
|
|
4949
|
-
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
4950
|
-
const expectedStyle = []; // styleMap is used when style is set to static value.
|
|
4951
|
-
|
|
4952
|
-
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
4953
|
-
const [prop, value, important] = styleDecls[i];
|
|
4954
|
-
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
4955
|
-
const parsedPropValue = parsedVnodeStyle[prop];
|
|
4956
|
-
|
|
4957
|
-
if (isUndefined$1(parsedPropValue)) {
|
|
4958
|
-
nodesAreCompatible = false;
|
|
4959
|
-
} else if (!parsedPropValue.startsWith(value)) {
|
|
4960
|
-
nodesAreCompatible = false;
|
|
4961
|
-
} else if (important && !parsedPropValue.endsWith('!important')) {
|
|
4962
|
-
nodesAreCompatible = false;
|
|
4963
|
-
}
|
|
4964
|
-
}
|
|
4965
|
-
|
|
4966
|
-
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
4967
|
-
nodesAreCompatible = false;
|
|
4968
|
-
}
|
|
4969
|
-
|
|
4970
|
-
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
4971
|
-
}
|
|
4972
|
-
|
|
4973
|
-
if (!nodesAreCompatible) {
|
|
4974
|
-
// style is used when class is bound to an expr.
|
|
4975
|
-
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
4976
|
-
}
|
|
4977
|
-
|
|
4978
|
-
return nodesAreCompatible;
|
|
4979
|
-
}
|
|
4980
|
-
|
|
4981
|
-
function throwHydrationError() {
|
|
4982
|
-
assert.fail('Server rendered elements do not match client side generated elements');
|
|
4983
|
-
}
|
|
4984
|
-
|
|
4985
|
-
function hydrateChildrenHook(elmChildren, children, vm) {
|
|
4986
|
-
var _a, _b;
|
|
4987
|
-
|
|
4988
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4989
|
-
const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
|
|
4990
|
-
|
|
4991
|
-
if (elmChildren.length !== filteredVNodes.length) {
|
|
4992
|
-
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
4993
|
-
throwHydrationError();
|
|
4994
|
-
}
|
|
4995
|
-
}
|
|
4996
|
-
|
|
4997
|
-
let elmCurrentChildIdx = 0;
|
|
4998
|
-
|
|
4999
|
-
for (let j = 0, n = children.length; j < n; j++) {
|
|
5000
|
-
const ch = children[j];
|
|
5001
|
-
|
|
5002
|
-
if (ch != null) {
|
|
5003
|
-
const childNode = elmChildren[elmCurrentChildIdx];
|
|
5004
|
-
|
|
5005
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5006
|
-
// VComments and VTexts validation is handled in their hooks
|
|
5007
|
-
if (isElementNode(childNode)) {
|
|
5008
|
-
if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
|
|
5009
|
-
logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
|
|
5010
|
-
throwHydrationError();
|
|
5011
|
-
} // Note: props are not yet set
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
|
|
5015
|
-
const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
|
|
5016
|
-
const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
|
|
5017
|
-
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
5018
|
-
|
|
5019
|
-
if (!isVNodeAndElementCompatible) {
|
|
5020
|
-
throwHydrationError();
|
|
5021
|
-
}
|
|
5022
|
-
}
|
|
5023
|
-
}
|
|
5024
|
-
|
|
5025
|
-
ch.hook.hydrate(ch, childNode);
|
|
5026
|
-
elmCurrentChildIdx++;
|
|
5027
|
-
}
|
|
5028
|
-
}
|
|
5029
|
-
}
|
|
5030
|
-
|
|
5031
|
-
function removeElmHook(vnode) {
|
|
4918
|
+
function removeChildren(vnode) {
|
|
5032
4919
|
// this method only needs to search on child vnodes from template
|
|
5033
4920
|
// to trigger the remove hook just in case some of those children
|
|
5034
4921
|
// are custom elements.
|
|
@@ -5047,6 +4934,8 @@ function removeElmHook(vnode) {
|
|
|
5047
4934
|
}
|
|
5048
4935
|
|
|
5049
4936
|
function allocateInSlot(vm, children) {
|
|
4937
|
+
var _a;
|
|
4938
|
+
|
|
5050
4939
|
const {
|
|
5051
4940
|
cmpSlots: oldSlots
|
|
5052
4941
|
} = vm;
|
|
@@ -5059,10 +4948,12 @@ function allocateInSlot(vm, children) {
|
|
|
5059
4948
|
continue;
|
|
5060
4949
|
}
|
|
5061
4950
|
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
4951
|
+
let slotName = '';
|
|
4952
|
+
|
|
4953
|
+
if (isVBaseElement(vnode)) {
|
|
4954
|
+
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
|
|
4955
|
+
}
|
|
4956
|
+
|
|
5066
4957
|
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
|
|
5067
4958
|
// which might have similar keys. Each vnode will always have a key that
|
|
5068
4959
|
// starts with a numeric character from compiler. In this case, we add a unique
|
|
@@ -5117,331 +5008,204 @@ function markAsDynamicChildren(children) {
|
|
|
5117
5008
|
function hasDynamicChildren(children) {
|
|
5118
5009
|
return FromIteration.has(children);
|
|
5119
5010
|
}
|
|
5120
|
-
/*
|
|
5121
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
5122
|
-
* All rights reserved.
|
|
5123
|
-
* SPDX-License-Identifier: MIT
|
|
5124
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5125
|
-
*/
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
function getUpgradableConstructor(tagName) {
|
|
5129
|
-
// Should never get a tag with upper case letter at this point, the compiler should
|
|
5130
|
-
// produce only tags with lowercase letters
|
|
5131
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
5132
|
-
tagName = tagName.toLowerCase();
|
|
5133
|
-
let CE = getCustomElement$1(tagName);
|
|
5134
5011
|
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
}
|
|
5138
|
-
/**
|
|
5139
|
-
* LWC Upgradable Element reference to an element that was created
|
|
5140
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
5141
|
-
*/
|
|
5012
|
+
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
5013
|
+
const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
5142
5014
|
|
|
5015
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
5016
|
+
const ch = children[j];
|
|
5143
5017
|
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5018
|
+
if (isVNode(ch)) {
|
|
5019
|
+
const {
|
|
5020
|
+
key
|
|
5021
|
+
} = ch;
|
|
5147
5022
|
|
|
5148
|
-
if (
|
|
5149
|
-
|
|
5023
|
+
if (key !== undefined) {
|
|
5024
|
+
map[key] = j;
|
|
5150
5025
|
}
|
|
5151
5026
|
}
|
|
5027
|
+
}
|
|
5152
5028
|
|
|
5153
|
-
|
|
5154
|
-
defineCustomElement$1(tagName, CE);
|
|
5155
|
-
return CE;
|
|
5029
|
+
return map;
|
|
5156
5030
|
}
|
|
5157
|
-
/*
|
|
5158
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
5159
|
-
* All rights reserved.
|
|
5160
|
-
* SPDX-License-Identifier: MIT
|
|
5161
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5162
|
-
*/
|
|
5163
5031
|
|
|
5032
|
+
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
5033
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
5034
|
+
const ch = vnodes[startIdx];
|
|
5164
5035
|
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
} = vnode;
|
|
5172
|
-
const elm = createText$1(vnode.text);
|
|
5173
|
-
linkNodeToShadow(elm, owner);
|
|
5174
|
-
vnode.elm = elm;
|
|
5175
|
-
},
|
|
5176
|
-
update: updateNodeHook,
|
|
5177
|
-
insert: insertNodeHook,
|
|
5178
|
-
move: insertNodeHook,
|
|
5179
|
-
remove: removeNodeHook,
|
|
5180
|
-
hydrate: (vNode, node) => {
|
|
5181
|
-
var _a;
|
|
5182
|
-
|
|
5183
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5184
|
-
// eslint-disable-next-line lwc-internal/no-global-node
|
|
5185
|
-
if (node.nodeType !== Node.TEXT_NODE) {
|
|
5186
|
-
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
5187
|
-
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
5188
|
-
}
|
|
5189
|
-
|
|
5190
|
-
if (node.nodeValue !== vNode.text) {
|
|
5191
|
-
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
|
|
5192
|
-
}
|
|
5193
|
-
} // always set the text value to the one from the vnode.
|
|
5036
|
+
if (isVNode(ch)) {
|
|
5037
|
+
ch.hook.create(ch);
|
|
5038
|
+
ch.hook.insert(ch, parentElm, before);
|
|
5039
|
+
}
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5194
5042
|
|
|
5043
|
+
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
5044
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
5045
|
+
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
5195
5046
|
|
|
5196
|
-
|
|
5197
|
-
|
|
5047
|
+
if (isVNode(ch)) {
|
|
5048
|
+
ch.hook.remove(ch, parentElm);
|
|
5049
|
+
}
|
|
5198
5050
|
}
|
|
5199
|
-
}
|
|
5200
|
-
const CommentHook = {
|
|
5201
|
-
create: vnode => {
|
|
5202
|
-
const {
|
|
5203
|
-
owner,
|
|
5204
|
-
text
|
|
5205
|
-
} = vnode;
|
|
5206
|
-
const elm = createComment$1(text);
|
|
5207
|
-
linkNodeToShadow(elm, owner);
|
|
5208
|
-
vnode.elm = elm;
|
|
5209
|
-
},
|
|
5210
|
-
update: updateNodeHook,
|
|
5211
|
-
insert: insertNodeHook,
|
|
5212
|
-
move: insertNodeHook,
|
|
5213
|
-
remove: removeNodeHook,
|
|
5214
|
-
hydrate: (vNode, node) => {
|
|
5215
|
-
var _a;
|
|
5051
|
+
}
|
|
5216
5052
|
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5053
|
+
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
5054
|
+
let oldStartIdx = 0;
|
|
5055
|
+
let newStartIdx = 0;
|
|
5056
|
+
let oldEndIdx = oldCh.length - 1;
|
|
5057
|
+
let oldStartVnode = oldCh[0];
|
|
5058
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
5059
|
+
const newChEnd = newCh.length - 1;
|
|
5060
|
+
let newEndIdx = newChEnd;
|
|
5061
|
+
let newStartVnode = newCh[0];
|
|
5062
|
+
let newEndVnode = newCh[newEndIdx];
|
|
5063
|
+
let oldKeyToIdx;
|
|
5064
|
+
let idxInOld;
|
|
5065
|
+
let elmToMove;
|
|
5066
|
+
let before;
|
|
5223
5067
|
|
|
5224
|
-
|
|
5225
|
-
|
|
5068
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
5069
|
+
if (!isVNode(oldStartVnode)) {
|
|
5070
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
5071
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
5072
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
5073
|
+
} else if (!isVNode(newStartVnode)) {
|
|
5074
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5075
|
+
} else if (!isVNode(newEndVnode)) {
|
|
5076
|
+
newEndVnode = newCh[--newEndIdx];
|
|
5077
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
5078
|
+
patchVnode(oldStartVnode, newStartVnode);
|
|
5079
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
5080
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5081
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
5082
|
+
patchVnode(oldEndVnode, newEndVnode);
|
|
5083
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
5084
|
+
newEndVnode = newCh[--newEndIdx];
|
|
5085
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
5086
|
+
// Vnode moved right
|
|
5087
|
+
patchVnode(oldStartVnode, newEndVnode);
|
|
5088
|
+
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
|
|
5089
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
5090
|
+
newEndVnode = newCh[--newEndIdx];
|
|
5091
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
5092
|
+
// Vnode moved left
|
|
5093
|
+
patchVnode(oldEndVnode, newStartVnode);
|
|
5094
|
+
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
5095
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
5096
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5097
|
+
} else {
|
|
5098
|
+
if (oldKeyToIdx === undefined) {
|
|
5099
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
5226
5100
|
}
|
|
5227
|
-
} // always set the text value to the one from the vnode.
|
|
5228
|
-
|
|
5229
5101
|
|
|
5230
|
-
|
|
5231
|
-
vNode.elm = node;
|
|
5232
|
-
}
|
|
5233
|
-
}; // insert is called after update, which is used somewhere else (via a module)
|
|
5234
|
-
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
5235
|
-
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
5236
|
-
// which breaks some invariants. For that reason, we have the following for any
|
|
5237
|
-
// Custom Element that is inserted via a template.
|
|
5238
|
-
|
|
5239
|
-
const ElementHook = {
|
|
5240
|
-
create: vnode => {
|
|
5241
|
-
const {
|
|
5242
|
-
sel,
|
|
5243
|
-
owner,
|
|
5244
|
-
data: {
|
|
5245
|
-
svg
|
|
5246
|
-
}
|
|
5247
|
-
} = vnode;
|
|
5248
|
-
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
5249
|
-
const elm = createElement$2(sel, namespace);
|
|
5250
|
-
linkNodeToShadow(elm, owner);
|
|
5251
|
-
fallbackElmHook(elm, vnode);
|
|
5252
|
-
vnode.elm = elm;
|
|
5253
|
-
patchElementPropsAndAttrs(null, vnode);
|
|
5254
|
-
},
|
|
5255
|
-
update: (oldVnode, vnode) => {
|
|
5256
|
-
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
5257
|
-
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
5258
|
-
},
|
|
5259
|
-
insert: (vnode, parentNode, referenceNode) => {
|
|
5260
|
-
insertNodeHook(vnode, parentNode, referenceNode);
|
|
5261
|
-
createChildrenHook(vnode);
|
|
5262
|
-
},
|
|
5263
|
-
move: (vnode, parentNode, referenceNode) => {
|
|
5264
|
-
insertNodeHook(vnode, parentNode, referenceNode);
|
|
5265
|
-
},
|
|
5266
|
-
remove: (vnode, parentNode) => {
|
|
5267
|
-
removeNodeHook(vnode, parentNode);
|
|
5268
|
-
removeElmHook(vnode);
|
|
5269
|
-
},
|
|
5270
|
-
hydrate: (vnode, node) => {
|
|
5271
|
-
const elm = node;
|
|
5272
|
-
vnode.elm = elm;
|
|
5273
|
-
const {
|
|
5274
|
-
context
|
|
5275
|
-
} = vnode.data;
|
|
5276
|
-
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
5277
|
-
/* manual */
|
|
5278
|
-
);
|
|
5102
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
5279
5103
|
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
}
|
|
5104
|
+
if (isUndefined$1(idxInOld)) {
|
|
5105
|
+
// New element
|
|
5106
|
+
newStartVnode.hook.create(newStartVnode);
|
|
5107
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
5108
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5109
|
+
} else {
|
|
5110
|
+
elmToMove = oldCh[idxInOld];
|
|
5286
5111
|
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5112
|
+
if (isVNode(elmToMove)) {
|
|
5113
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
5114
|
+
// New element
|
|
5115
|
+
newStartVnode.hook.create(newStartVnode);
|
|
5116
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
5117
|
+
} else {
|
|
5118
|
+
patchVnode(elmToMove, newStartVnode);
|
|
5119
|
+
oldCh[idxInOld] = undefined;
|
|
5120
|
+
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
5121
|
+
}
|
|
5292
5122
|
}
|
|
5293
|
-
}
|
|
5294
|
-
}
|
|
5295
5123
|
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
if (!isDomManual) {
|
|
5299
|
-
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
5124
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5125
|
+
}
|
|
5300
5126
|
}
|
|
5301
5127
|
}
|
|
5302
|
-
};
|
|
5303
|
-
const CustomElementHook = {
|
|
5304
|
-
create: vnode => {
|
|
5305
|
-
const {
|
|
5306
|
-
sel,
|
|
5307
|
-
owner
|
|
5308
|
-
} = vnode;
|
|
5309
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
5310
|
-
/**
|
|
5311
|
-
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
5312
|
-
* with a callback as the first argument, we could implement a more advanced
|
|
5313
|
-
* mechanism that only passes that argument if the constructor is known to be
|
|
5314
|
-
* an upgradable custom element.
|
|
5315
|
-
*/
|
|
5316
5128
|
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
const vm = getAssociatedVMIfPresent(elm);
|
|
5324
|
-
|
|
5325
|
-
if (vm) {
|
|
5326
|
-
allocateChildrenHook(vnode, vm);
|
|
5327
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
5328
|
-
throw new TypeError(`Incorrect Component Constructor`);
|
|
5329
|
-
}
|
|
5330
|
-
|
|
5331
|
-
patchElementPropsAndAttrs(null, vnode);
|
|
5332
|
-
},
|
|
5333
|
-
update: (oldVnode, vnode) => {
|
|
5334
|
-
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
5335
|
-
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
5336
|
-
|
|
5337
|
-
if (vm) {
|
|
5338
|
-
// in fallback mode, the allocation will always set children to
|
|
5339
|
-
// empty and delegate the real allocation to the slot elements
|
|
5340
|
-
allocateChildrenHook(vnode, vm);
|
|
5341
|
-
} // in fallback mode, the children will be always empty, so, nothing
|
|
5342
|
-
// will happen, but in native, it does allocate the light dom
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
5346
|
-
|
|
5347
|
-
if (vm) {
|
|
5348
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5349
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
5350
|
-
} // this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
5351
|
-
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
5129
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
5130
|
+
if (oldStartIdx > oldEndIdx) {
|
|
5131
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
5132
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
5133
|
+
let i = newEndIdx;
|
|
5134
|
+
let n;
|
|
5352
5135
|
|
|
5136
|
+
do {
|
|
5137
|
+
n = newCh[++i];
|
|
5138
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
5353
5139
|
|
|
5354
|
-
|
|
5140
|
+
before = isVNode(n) ? n.elm : null;
|
|
5141
|
+
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
5142
|
+
} else {
|
|
5143
|
+
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
5355
5144
|
}
|
|
5356
|
-
}
|
|
5357
|
-
|
|
5358
|
-
insertNodeHook(vnode, parentNode, referenceNode);
|
|
5359
|
-
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5360
5147
|
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
/* created */
|
|
5365
|
-
, `${vm} cannot be recycled.`);
|
|
5366
|
-
}
|
|
5148
|
+
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
5149
|
+
const oldChLength = oldCh.length;
|
|
5150
|
+
const newChLength = newCh.length;
|
|
5367
5151
|
|
|
5368
|
-
|
|
5369
|
-
|
|
5152
|
+
if (oldChLength === 0) {
|
|
5153
|
+
// the old list is empty, we can directly insert anything new
|
|
5154
|
+
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
5155
|
+
return;
|
|
5156
|
+
}
|
|
5370
5157
|
|
|
5371
|
-
|
|
5158
|
+
if (newChLength === 0) {
|
|
5159
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
5160
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
5161
|
+
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
5162
|
+
return;
|
|
5163
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
5164
|
+
// amount of nodes, that's why we call this static children
|
|
5372
5165
|
|
|
5373
|
-
if (vm) {
|
|
5374
|
-
appendVM(vm);
|
|
5375
|
-
}
|
|
5376
|
-
},
|
|
5377
|
-
move: (vnode, parentNode, referenceNode) => {
|
|
5378
|
-
insertNodeHook(vnode, parentNode, referenceNode);
|
|
5379
|
-
},
|
|
5380
|
-
remove: (vnode, parentNode) => {
|
|
5381
|
-
removeNodeHook(vnode, parentNode);
|
|
5382
|
-
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
5383
5166
|
|
|
5384
|
-
|
|
5385
|
-
// for custom elements we don't have to go recursively because the removeVM routine
|
|
5386
|
-
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
5387
|
-
removeVM(vm);
|
|
5388
|
-
}
|
|
5389
|
-
},
|
|
5390
|
-
hydrate: (vnode, elm) => {
|
|
5391
|
-
// the element is created, but the vm is not
|
|
5392
|
-
const {
|
|
5393
|
-
sel,
|
|
5394
|
-
mode,
|
|
5395
|
-
ctor,
|
|
5396
|
-
owner
|
|
5397
|
-
} = vnode;
|
|
5398
|
-
const def = getComponentInternalDef(ctor);
|
|
5399
|
-
createVM(elm, def, {
|
|
5400
|
-
mode,
|
|
5401
|
-
owner,
|
|
5402
|
-
tagName: sel
|
|
5403
|
-
});
|
|
5404
|
-
vnode.elm = elm;
|
|
5405
|
-
const vm = getAssociatedVM(elm);
|
|
5406
|
-
allocateChildrenHook(vnode, vm);
|
|
5407
|
-
hydrateElmHook(vnode); // Insert hook section:
|
|
5167
|
+
let referenceElm = null;
|
|
5408
5168
|
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
, `${vm} cannot be recycled.`);
|
|
5413
|
-
}
|
|
5169
|
+
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
5170
|
+
const vnode = newCh[i];
|
|
5171
|
+
const oldVNode = oldCh[i];
|
|
5414
5172
|
|
|
5415
|
-
|
|
5173
|
+
if (vnode !== oldVNode) {
|
|
5174
|
+
if (isVNode(oldVNode)) {
|
|
5175
|
+
if (isVNode(vnode)) {
|
|
5176
|
+
// both vnodes must be equivalent, and se just need to patch them
|
|
5177
|
+
patchVnode(oldVNode, vnode);
|
|
5178
|
+
referenceElm = vnode.elm;
|
|
5179
|
+
} else {
|
|
5180
|
+
// removing the old vnode since the new one is null
|
|
5181
|
+
oldVNode.hook.remove(oldVNode, parentElm);
|
|
5182
|
+
}
|
|
5183
|
+
} else if (isVNode(vnode)) {
|
|
5184
|
+
// this condition is unnecessary
|
|
5185
|
+
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
5416
5186
|
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5421
|
-
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5422
|
-
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
|
|
5187
|
+
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
5188
|
+
referenceElm = vnode.elm;
|
|
5189
|
+
}
|
|
5423
5190
|
}
|
|
5424
|
-
|
|
5425
|
-
hydrateVM(vm);
|
|
5426
5191
|
}
|
|
5427
|
-
}
|
|
5428
|
-
|
|
5429
|
-
function linkNodeToShadow(elm, owner) {
|
|
5430
|
-
const {
|
|
5431
|
-
renderMode,
|
|
5432
|
-
shadowMode
|
|
5433
|
-
} = owner; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
5192
|
+
}
|
|
5434
5193
|
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
/* Light */
|
|
5440
|
-
) {
|
|
5441
|
-
elm[KEY__SHADOW_RESOLVER] = getRenderRoot(owner)[KEY__SHADOW_RESOLVER];
|
|
5442
|
-
}
|
|
5194
|
+
function patchVnode(oldVnode, vnode) {
|
|
5195
|
+
if (oldVnode !== vnode) {
|
|
5196
|
+
vnode.elm = oldVnode.elm;
|
|
5197
|
+
vnode.hook.update(oldVnode, vnode);
|
|
5443
5198
|
}
|
|
5444
5199
|
}
|
|
5200
|
+
/*
|
|
5201
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
5202
|
+
* All rights reserved.
|
|
5203
|
+
* SPDX-License-Identifier: MIT
|
|
5204
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5205
|
+
*/
|
|
5206
|
+
|
|
5207
|
+
|
|
5208
|
+
const SymbolIterator = Symbol.iterator;
|
|
5445
5209
|
|
|
5446
5210
|
function addVNodeToChildLWC(vnode) {
|
|
5447
5211
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
|
@@ -5466,20 +5230,22 @@ function h(sel, data, children) {
|
|
|
5466
5230
|
|
|
5467
5231
|
forEach.call(children, childVnode => {
|
|
5468
5232
|
if (childVnode != null) {
|
|
5469
|
-
assert.isTrue(
|
|
5233
|
+
assert.isTrue('type' in childVnode && 'sel' in childVnode && 'elm' in childVnode && 'key' in childVnode, `${childVnode} is not a vnode.`);
|
|
5470
5234
|
}
|
|
5471
5235
|
});
|
|
5472
5236
|
}
|
|
5473
5237
|
|
|
5474
|
-
let
|
|
5238
|
+
let elm;
|
|
5475
5239
|
const {
|
|
5476
5240
|
key
|
|
5477
5241
|
} = data;
|
|
5478
5242
|
return {
|
|
5243
|
+
type: 2
|
|
5244
|
+
/* Element */
|
|
5245
|
+
,
|
|
5479
5246
|
sel,
|
|
5480
5247
|
data,
|
|
5481
5248
|
children,
|
|
5482
|
-
text,
|
|
5483
5249
|
elm,
|
|
5484
5250
|
key,
|
|
5485
5251
|
hook: ElementHook,
|
|
@@ -5560,7 +5326,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
5560
5326
|
if (arguments.length === 4) {
|
|
5561
5327
|
forEach.call(children, childVnode => {
|
|
5562
5328
|
if (childVnode != null) {
|
|
5563
|
-
assert.isTrue(
|
|
5329
|
+
assert.isTrue('type' in childVnode && 'sel' in childVnode && 'elm' in childVnode && 'key' in childVnode, `${childVnode} is not a vnode.`);
|
|
5564
5330
|
}
|
|
5565
5331
|
});
|
|
5566
5332
|
}
|
|
@@ -5569,12 +5335,14 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
5569
5335
|
const {
|
|
5570
5336
|
key
|
|
5571
5337
|
} = data;
|
|
5572
|
-
let
|
|
5338
|
+
let elm;
|
|
5573
5339
|
const vnode = {
|
|
5340
|
+
type: 3
|
|
5341
|
+
/* CustomElement */
|
|
5342
|
+
,
|
|
5574
5343
|
sel,
|
|
5575
5344
|
data,
|
|
5576
5345
|
children,
|
|
5577
|
-
text,
|
|
5578
5346
|
elm,
|
|
5579
5347
|
key,
|
|
5580
5348
|
hook: CustomElementHook,
|
|
@@ -5702,12 +5470,12 @@ function f(items) {
|
|
|
5702
5470
|
|
|
5703
5471
|
|
|
5704
5472
|
function t(text) {
|
|
5705
|
-
|
|
5706
|
-
let sel, children, key, elm;
|
|
5473
|
+
let sel, key, elm;
|
|
5707
5474
|
return {
|
|
5475
|
+
type: 0
|
|
5476
|
+
/* Text */
|
|
5477
|
+
,
|
|
5708
5478
|
sel,
|
|
5709
|
-
data,
|
|
5710
|
-
children,
|
|
5711
5479
|
text,
|
|
5712
5480
|
elm,
|
|
5713
5481
|
key,
|
|
@@ -5718,12 +5486,12 @@ function t(text) {
|
|
|
5718
5486
|
|
|
5719
5487
|
|
|
5720
5488
|
function co(text) {
|
|
5721
|
-
|
|
5722
|
-
let sel, children, key, elm;
|
|
5489
|
+
let sel, key, elm;
|
|
5723
5490
|
return {
|
|
5491
|
+
type: 1
|
|
5492
|
+
/* Comment */
|
|
5493
|
+
,
|
|
5724
5494
|
sel,
|
|
5725
|
-
data,
|
|
5726
|
-
children,
|
|
5727
5495
|
text,
|
|
5728
5496
|
elm,
|
|
5729
5497
|
key,
|
|
@@ -6161,7 +5929,7 @@ function createStylesheet(vm, stylesheets) {
|
|
|
6161
5929
|
insertGlobalStylesheet$1(stylesheets[i]);
|
|
6162
5930
|
} else {
|
|
6163
5931
|
// local level
|
|
6164
|
-
insertStylesheet$1(stylesheets[i], root.
|
|
5932
|
+
insertStylesheet$1(stylesheets[i], root.shadowRoot);
|
|
6165
5933
|
}
|
|
6166
5934
|
}
|
|
6167
5935
|
}
|
|
@@ -6468,25 +6236,6 @@ function computeHasScopedStyles(template) {
|
|
|
6468
6236
|
*/
|
|
6469
6237
|
|
|
6470
6238
|
|
|
6471
|
-
function addErrorComponentStack(vm, error) {
|
|
6472
|
-
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
6473
|
-
const wcStack = getErrorComponentStack(vm);
|
|
6474
|
-
defineProperty(error, 'wcStack', {
|
|
6475
|
-
get() {
|
|
6476
|
-
return wcStack;
|
|
6477
|
-
}
|
|
6478
|
-
|
|
6479
|
-
});
|
|
6480
|
-
}
|
|
6481
|
-
}
|
|
6482
|
-
/*
|
|
6483
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
6484
|
-
* All rights reserved.
|
|
6485
|
-
* SPDX-License-Identifier: MIT
|
|
6486
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6487
|
-
*/
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
6239
|
let isInvokingRender = false;
|
|
6491
6240
|
let vmBeingConstructed = null;
|
|
6492
6241
|
|
|
@@ -6723,6 +6472,320 @@ function invokeServiceHook(vm, cbs) {
|
|
|
6723
6472
|
cbs[i].call(undefined, component, {}, def, context);
|
|
6724
6473
|
}
|
|
6725
6474
|
}
|
|
6475
|
+
/*
|
|
6476
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
6477
|
+
* All rights reserved.
|
|
6478
|
+
* SPDX-License-Identifier: MIT
|
|
6479
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6480
|
+
*/
|
|
6481
|
+
|
|
6482
|
+
|
|
6483
|
+
function hydrate$1(vnode, node) {
|
|
6484
|
+
switch (vnode.type) {
|
|
6485
|
+
case 0
|
|
6486
|
+
/* Text */
|
|
6487
|
+
:
|
|
6488
|
+
hydrateText(vnode, node);
|
|
6489
|
+
break;
|
|
6490
|
+
|
|
6491
|
+
case 1
|
|
6492
|
+
/* Comment */
|
|
6493
|
+
:
|
|
6494
|
+
hydrateComment(vnode, node);
|
|
6495
|
+
break;
|
|
6496
|
+
|
|
6497
|
+
case 2
|
|
6498
|
+
/* Element */
|
|
6499
|
+
:
|
|
6500
|
+
hydrateElement(vnode, node);
|
|
6501
|
+
break;
|
|
6502
|
+
|
|
6503
|
+
case 3
|
|
6504
|
+
/* CustomElement */
|
|
6505
|
+
:
|
|
6506
|
+
hydrateCustomElement(vnode, node);
|
|
6507
|
+
break;
|
|
6508
|
+
}
|
|
6509
|
+
}
|
|
6510
|
+
|
|
6511
|
+
function hydrateText(vnode, node) {
|
|
6512
|
+
var _a;
|
|
6513
|
+
|
|
6514
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6515
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6516
|
+
validateNodeType(vnode, node, Node.TEXT_NODE);
|
|
6517
|
+
|
|
6518
|
+
if (node.nodeValue !== vnode.text && !(node.nodeValue === '\u200D' && vnode.text === '')) {
|
|
6519
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
6520
|
+
}
|
|
6521
|
+
} // always set the text value to the one from the vnode.
|
|
6522
|
+
|
|
6523
|
+
|
|
6524
|
+
node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
|
|
6525
|
+
vnode.elm = node;
|
|
6526
|
+
}
|
|
6527
|
+
|
|
6528
|
+
function hydrateComment(vnode, node) {
|
|
6529
|
+
var _a;
|
|
6530
|
+
|
|
6531
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6532
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6533
|
+
validateNodeType(vnode, node, Node.COMMENT_NODE);
|
|
6534
|
+
|
|
6535
|
+
if (node.nodeValue !== vnode.text) {
|
|
6536
|
+
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
6537
|
+
}
|
|
6538
|
+
} // always set the text value to the one from the vnode.
|
|
6539
|
+
|
|
6540
|
+
|
|
6541
|
+
node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
|
|
6542
|
+
vnode.elm = node;
|
|
6543
|
+
}
|
|
6544
|
+
|
|
6545
|
+
function hydrateElement(vnode, node) {
|
|
6546
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6547
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6548
|
+
validateNodeType(vnode, node, Node.ELEMENT_NODE);
|
|
6549
|
+
validateElement(vnode, node);
|
|
6550
|
+
}
|
|
6551
|
+
|
|
6552
|
+
const elm = node;
|
|
6553
|
+
vnode.elm = elm;
|
|
6554
|
+
const {
|
|
6555
|
+
context
|
|
6556
|
+
} = vnode.data;
|
|
6557
|
+
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
6558
|
+
/* Manual */
|
|
6559
|
+
);
|
|
6560
|
+
|
|
6561
|
+
if (isDomManual) {
|
|
6562
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
6563
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
6564
|
+
const {
|
|
6565
|
+
props
|
|
6566
|
+
} = vnode.data;
|
|
6567
|
+
|
|
6568
|
+
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
6569
|
+
if (elm.innerHTML === props.innerHTML) {
|
|
6570
|
+
delete props.innerHTML;
|
|
6571
|
+
} else {
|
|
6572
|
+
logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
6573
|
+
}
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
|
|
6577
|
+
patchElementPropsAndAttrs(vnode);
|
|
6578
|
+
|
|
6579
|
+
if (!isDomManual) {
|
|
6580
|
+
hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
6581
|
+
}
|
|
6582
|
+
}
|
|
6583
|
+
|
|
6584
|
+
function hydrateCustomElement(vnode, node) {
|
|
6585
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6586
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6587
|
+
validateNodeType(vnode, node, Node.ELEMENT_NODE);
|
|
6588
|
+
validateElement(vnode, node);
|
|
6589
|
+
}
|
|
6590
|
+
|
|
6591
|
+
const elm = node;
|
|
6592
|
+
vnode.elm = elm;
|
|
6593
|
+
const {
|
|
6594
|
+
sel,
|
|
6595
|
+
mode,
|
|
6596
|
+
ctor,
|
|
6597
|
+
owner
|
|
6598
|
+
} = vnode;
|
|
6599
|
+
const vm = createVM(elm, ctor, {
|
|
6600
|
+
mode,
|
|
6601
|
+
owner,
|
|
6602
|
+
tagName: sel
|
|
6603
|
+
});
|
|
6604
|
+
allocateChildren(vnode, vm);
|
|
6605
|
+
patchElementPropsAndAttrs(vnode); // Insert hook section:
|
|
6606
|
+
|
|
6607
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6608
|
+
assert.isTrue(vm.state === 0
|
|
6609
|
+
/* created */
|
|
6610
|
+
, `${vm} cannot be recycled.`);
|
|
6611
|
+
}
|
|
6612
|
+
|
|
6613
|
+
runConnectedCallback(vm);
|
|
6614
|
+
|
|
6615
|
+
if (vm.renderMode !== 0
|
|
6616
|
+
/* Light */
|
|
6617
|
+
) {
|
|
6618
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
6619
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
6620
|
+
hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
|
|
6621
|
+
}
|
|
6622
|
+
|
|
6623
|
+
hydrateVM(vm);
|
|
6624
|
+
}
|
|
6625
|
+
|
|
6626
|
+
function hydrateChildren(elmChildren, children, vm) {
|
|
6627
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6628
|
+
const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
|
|
6629
|
+
|
|
6630
|
+
if (elmChildren.length !== filteredVNodes.length) {
|
|
6631
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
6632
|
+
throwHydrationError();
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
6635
|
+
|
|
6636
|
+
let childNodeIndex = 0;
|
|
6637
|
+
|
|
6638
|
+
for (let i = 0; i < children.length; i++) {
|
|
6639
|
+
const childVnode = children[i];
|
|
6640
|
+
|
|
6641
|
+
if (!isNull(childVnode)) {
|
|
6642
|
+
const childNode = elmChildren[childNodeIndex];
|
|
6643
|
+
hydrate$1(childVnode, childNode);
|
|
6644
|
+
childNodeIndex++;
|
|
6645
|
+
}
|
|
6646
|
+
}
|
|
6647
|
+
}
|
|
6648
|
+
|
|
6649
|
+
function patchElementPropsAndAttrs(vnode) {
|
|
6650
|
+
applyEventListeners(vnode);
|
|
6651
|
+
patchProps(null, vnode);
|
|
6652
|
+
}
|
|
6653
|
+
|
|
6654
|
+
function throwHydrationError() {
|
|
6655
|
+
assert.fail('Server rendered elements do not match client side generated elements');
|
|
6656
|
+
}
|
|
6657
|
+
|
|
6658
|
+
function validateNodeType(vnode, node, nodeType) {
|
|
6659
|
+
if (node.nodeType !== nodeType) {
|
|
6660
|
+
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6661
|
+
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
6662
|
+
}
|
|
6663
|
+
}
|
|
6664
|
+
|
|
6665
|
+
function validateElement(vnode, elm) {
|
|
6666
|
+
if (vnode.sel.toLowerCase() !== elm.tagName.toLowerCase()) {
|
|
6667
|
+
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${elm.tagName.toLowerCase()}".`, vnode.owner);
|
|
6668
|
+
throwHydrationError();
|
|
6669
|
+
}
|
|
6670
|
+
|
|
6671
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6672
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6673
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
6674
|
+
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6675
|
+
|
|
6676
|
+
if (!isVNodeAndElementCompatible) {
|
|
6677
|
+
throwHydrationError();
|
|
6678
|
+
}
|
|
6679
|
+
}
|
|
6680
|
+
|
|
6681
|
+
function validateAttrs(vnode, elm) {
|
|
6682
|
+
const {
|
|
6683
|
+
data: {
|
|
6684
|
+
attrs = {}
|
|
6685
|
+
}
|
|
6686
|
+
} = vnode;
|
|
6687
|
+
let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
|
|
6688
|
+
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6689
|
+
|
|
6690
|
+
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
6691
|
+
const elmAttrValue = getAttribute$1(elm, attrName);
|
|
6692
|
+
|
|
6693
|
+
if (String(attrValue) !== elmAttrValue) {
|
|
6694
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
6695
|
+
nodesAreCompatible = false;
|
|
6696
|
+
}
|
|
6697
|
+
}
|
|
6698
|
+
|
|
6699
|
+
return nodesAreCompatible;
|
|
6700
|
+
}
|
|
6701
|
+
|
|
6702
|
+
function validateClassAttr(vnode, elm) {
|
|
6703
|
+
const {
|
|
6704
|
+
data: {
|
|
6705
|
+
className,
|
|
6706
|
+
classMap
|
|
6707
|
+
}
|
|
6708
|
+
} = vnode;
|
|
6709
|
+
let nodesAreCompatible = true;
|
|
6710
|
+
let vnodeClassName;
|
|
6711
|
+
|
|
6712
|
+
if (!isUndefined$1(className) && String(className) !== elm.className) {
|
|
6713
|
+
// className is used when class is bound to an expr.
|
|
6714
|
+
nodesAreCompatible = false;
|
|
6715
|
+
vnodeClassName = className;
|
|
6716
|
+
} else if (!isUndefined$1(classMap)) {
|
|
6717
|
+
// classMap is used when class is set to static value.
|
|
6718
|
+
const classList = getClassList$1(elm);
|
|
6719
|
+
let computedClassName = ''; // all classes from the vnode should be in the element.classList
|
|
6720
|
+
|
|
6721
|
+
for (const name in classMap) {
|
|
6722
|
+
computedClassName += ' ' + name;
|
|
6723
|
+
|
|
6724
|
+
if (!classList.contains(name)) {
|
|
6725
|
+
nodesAreCompatible = false;
|
|
6726
|
+
}
|
|
6727
|
+
}
|
|
6728
|
+
|
|
6729
|
+
vnodeClassName = computedClassName.trim();
|
|
6730
|
+
|
|
6731
|
+
if (classList.length > keys(classMap).length) {
|
|
6732
|
+
nodesAreCompatible = false;
|
|
6733
|
+
}
|
|
6734
|
+
}
|
|
6735
|
+
|
|
6736
|
+
if (!nodesAreCompatible) {
|
|
6737
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
|
|
6738
|
+
}
|
|
6739
|
+
|
|
6740
|
+
return nodesAreCompatible;
|
|
6741
|
+
}
|
|
6742
|
+
|
|
6743
|
+
function validateStyleAttr(vnode, elm) {
|
|
6744
|
+
const {
|
|
6745
|
+
data: {
|
|
6746
|
+
style,
|
|
6747
|
+
styleDecls
|
|
6748
|
+
}
|
|
6749
|
+
} = vnode;
|
|
6750
|
+
const elmStyle = getAttribute$1(elm, 'style') || '';
|
|
6751
|
+
let vnodeStyle;
|
|
6752
|
+
let nodesAreCompatible = true;
|
|
6753
|
+
|
|
6754
|
+
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
6755
|
+
nodesAreCompatible = false;
|
|
6756
|
+
vnodeStyle = style;
|
|
6757
|
+
} else if (!isUndefined$1(styleDecls)) {
|
|
6758
|
+
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
6759
|
+
const expectedStyle = []; // styleMap is used when style is set to static value.
|
|
6760
|
+
|
|
6761
|
+
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
6762
|
+
const [prop, value, important] = styleDecls[i];
|
|
6763
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
6764
|
+
const parsedPropValue = parsedVnodeStyle[prop];
|
|
6765
|
+
|
|
6766
|
+
if (isUndefined$1(parsedPropValue)) {
|
|
6767
|
+
nodesAreCompatible = false;
|
|
6768
|
+
} else if (!parsedPropValue.startsWith(value)) {
|
|
6769
|
+
nodesAreCompatible = false;
|
|
6770
|
+
} else if (important && !parsedPropValue.endsWith('!important')) {
|
|
6771
|
+
nodesAreCompatible = false;
|
|
6772
|
+
}
|
|
6773
|
+
}
|
|
6774
|
+
|
|
6775
|
+
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
6776
|
+
nodesAreCompatible = false;
|
|
6777
|
+
}
|
|
6778
|
+
|
|
6779
|
+
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
6780
|
+
}
|
|
6781
|
+
|
|
6782
|
+
if (!nodesAreCompatible) {
|
|
6783
|
+
// style is used when class is bound to an expr.
|
|
6784
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6785
|
+
}
|
|
6786
|
+
|
|
6787
|
+
return nodesAreCompatible;
|
|
6788
|
+
}
|
|
6726
6789
|
/*
|
|
6727
6790
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6728
6791
|
* All rights reserved.
|
|
@@ -6849,12 +6912,13 @@ function getNearestShadowAncestor(vm) {
|
|
|
6849
6912
|
return ancestor;
|
|
6850
6913
|
}
|
|
6851
6914
|
|
|
6852
|
-
function createVM(elm,
|
|
6915
|
+
function createVM(elm, ctor, options) {
|
|
6853
6916
|
const {
|
|
6854
6917
|
mode,
|
|
6855
6918
|
owner,
|
|
6856
6919
|
tagName
|
|
6857
6920
|
} = options;
|
|
6921
|
+
const def = getComponentInternalDef(ctor);
|
|
6858
6922
|
const vm = {
|
|
6859
6923
|
elm,
|
|
6860
6924
|
def,
|
|
@@ -6876,7 +6940,6 @@ function createVM(elm, def, options) {
|
|
|
6876
6940
|
oar: create(null),
|
|
6877
6941
|
cmpTemplate: null,
|
|
6878
6942
|
renderMode: def.renderMode,
|
|
6879
|
-
shadowMode: null,
|
|
6880
6943
|
context: {
|
|
6881
6944
|
stylesheetToken: undefined,
|
|
6882
6945
|
hasTokenInClass: undefined,
|
|
@@ -6887,9 +6950,13 @@ function createVM(elm, def, options) {
|
|
|
6887
6950
|
wiredConnecting: EmptyArray,
|
|
6888
6951
|
wiredDisconnecting: EmptyArray
|
|
6889
6952
|
},
|
|
6953
|
+
// Properties set right after VM creation.
|
|
6890
6954
|
tro: null,
|
|
6955
|
+
shadowMode: null,
|
|
6956
|
+
// Properties set by the LightningElement constructor.
|
|
6891
6957
|
component: null,
|
|
6892
|
-
|
|
6958
|
+
shadowRoot: null,
|
|
6959
|
+
renderRoot: null,
|
|
6893
6960
|
callHook,
|
|
6894
6961
|
setHook,
|
|
6895
6962
|
getHook
|
|
@@ -6977,7 +7044,7 @@ function computeShadowMode(vm) {
|
|
|
6977
7044
|
}
|
|
6978
7045
|
|
|
6979
7046
|
function assertIsVM(obj) {
|
|
6980
|
-
if (isNull(obj) || !isObject(obj) || !('
|
|
7047
|
+
if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
|
|
6981
7048
|
throw new TypeError(`${obj} is not a VM.`);
|
|
6982
7049
|
}
|
|
6983
7050
|
}
|
|
@@ -7026,13 +7093,14 @@ function hydrate(vm) {
|
|
|
7026
7093
|
const vmChildren = vm.renderMode === 0
|
|
7027
7094
|
/* Light */
|
|
7028
7095
|
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
7029
|
-
|
|
7096
|
+
hydrateChildren(vmChildren, children, vm);
|
|
7030
7097
|
runRenderedCallback(vm);
|
|
7031
7098
|
}
|
|
7032
7099
|
}
|
|
7033
7100
|
|
|
7034
7101
|
function patchShadowRoot(vm, newCh) {
|
|
7035
7102
|
const {
|
|
7103
|
+
renderRoot,
|
|
7036
7104
|
children: oldCh
|
|
7037
7105
|
} = vm; // caching the new children collection
|
|
7038
7106
|
|
|
@@ -7049,7 +7117,6 @@ function patchShadowRoot(vm, newCh) {
|
|
|
7049
7117
|
, vm);
|
|
7050
7118
|
}, () => {
|
|
7051
7119
|
// job
|
|
7052
|
-
const renderRoot = getRenderRoot(vm);
|
|
7053
7120
|
patchChildren(renderRoot, oldCh, newCh);
|
|
7054
7121
|
}, () => {
|
|
7055
7122
|
// post
|
|
@@ -7285,14 +7352,22 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
7285
7352
|
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
7286
7353
|
const vnode = vnodes[i];
|
|
7287
7354
|
|
|
7288
|
-
if (!isNull(vnode) &&
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7355
|
+
if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
|
|
7356
|
+
switch (vnode.type) {
|
|
7357
|
+
case 2
|
|
7358
|
+
/* Element */
|
|
7359
|
+
:
|
|
7360
|
+
recursivelyDisconnectChildren(vnode.children);
|
|
7361
|
+
break;
|
|
7362
|
+
|
|
7363
|
+
case 3
|
|
7364
|
+
/* CustomElement */
|
|
7365
|
+
:
|
|
7366
|
+
{
|
|
7367
|
+
const vm = getAssociatedVM(vnode.elm);
|
|
7368
|
+
resetComponentStateWhenRemoved(vm);
|
|
7369
|
+
break;
|
|
7370
|
+
}
|
|
7296
7371
|
}
|
|
7297
7372
|
}
|
|
7298
7373
|
}
|
|
@@ -7304,15 +7379,15 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
7304
7379
|
|
|
7305
7380
|
function resetComponentRoot(vm) {
|
|
7306
7381
|
const {
|
|
7307
|
-
children
|
|
7382
|
+
children,
|
|
7383
|
+
renderRoot
|
|
7308
7384
|
} = vm;
|
|
7309
|
-
const rootNode = getRenderRoot(vm);
|
|
7310
7385
|
|
|
7311
7386
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
7312
7387
|
const child = children[i];
|
|
7313
7388
|
|
|
7314
7389
|
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
7315
|
-
remove$1(child.elm,
|
|
7390
|
+
remove$1(child.elm, renderRoot);
|
|
7316
7391
|
}
|
|
7317
7392
|
}
|
|
7318
7393
|
|
|
@@ -7398,12 +7473,6 @@ function forceRehydration(vm) {
|
|
|
7398
7473
|
scheduleRehydration(vm);
|
|
7399
7474
|
}
|
|
7400
7475
|
}
|
|
7401
|
-
|
|
7402
|
-
function getRenderRoot(vm) {
|
|
7403
|
-
return vm.renderMode === 1
|
|
7404
|
-
/* Shadow */
|
|
7405
|
-
? vm.cmpRoot : vm.elm;
|
|
7406
|
-
}
|
|
7407
7476
|
/*
|
|
7408
7477
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
7409
7478
|
* All rights reserved.
|
|
@@ -7795,7 +7864,7 @@ function setHooks(hooks) {
|
|
|
7795
7864
|
hooksAreSet = true;
|
|
7796
7865
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7797
7866
|
}
|
|
7798
|
-
/* version: 2.7.
|
|
7867
|
+
/* version: 2.7.4 */
|
|
7799
7868
|
|
|
7800
7869
|
/*
|
|
7801
7870
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8259,8 +8328,7 @@ function createElement(sel, options) {
|
|
|
8259
8328
|
*/
|
|
8260
8329
|
|
|
8261
8330
|
const element = new UpgradableConstructor(elm => {
|
|
8262
|
-
|
|
8263
|
-
createVM(elm, def, {
|
|
8331
|
+
createVM(elm, Ctor, {
|
|
8264
8332
|
tagName: sel,
|
|
8265
8333
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
8266
8334
|
owner: null
|
|
@@ -8298,13 +8366,11 @@ function hydrateComponent(element, Ctor, props = {}) {
|
|
|
8298
8366
|
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8299
8367
|
}
|
|
8300
8368
|
|
|
8301
|
-
const def = getComponentInternalDef(Ctor);
|
|
8302
|
-
|
|
8303
8369
|
try {
|
|
8304
8370
|
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8305
8371
|
// and uses the same algo to create the stylesheets as in SSR.
|
|
8306
8372
|
setIsHydrating(true);
|
|
8307
|
-
createVM(element,
|
|
8373
|
+
createVM(element, Ctor, {
|
|
8308
8374
|
mode: 'open',
|
|
8309
8375
|
owner: null,
|
|
8310
8376
|
tagName: element.tagName.toLowerCase()
|
|
@@ -8370,11 +8436,11 @@ function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
|
8370
8436
|
}
|
|
8371
8437
|
|
|
8372
8438
|
function buildCustomElementConstructor(Ctor) {
|
|
8373
|
-
const
|
|
8374
|
-
return class extends
|
|
8439
|
+
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
8440
|
+
return class extends HtmlPrototype {
|
|
8375
8441
|
constructor() {
|
|
8376
8442
|
super();
|
|
8377
|
-
createVM(this,
|
|
8443
|
+
createVM(this, Ctor, {
|
|
8378
8444
|
mode: 'open',
|
|
8379
8445
|
owner: null,
|
|
8380
8446
|
tagName: this.tagName
|
|
@@ -8497,6 +8563,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
8497
8563
|
});
|
|
8498
8564
|
freeze(LightningElement);
|
|
8499
8565
|
seal(LightningElement.prototype);
|
|
8500
|
-
/* version: 2.7.
|
|
8566
|
+
/* version: 2.7.4 */
|
|
8501
8567
|
|
|
8502
8568
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|