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
|
@@ -305,7 +305,11 @@
|
|
|
305
305
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
306
306
|
return attributeName;
|
|
307
307
|
}
|
|
308
|
-
|
|
308
|
+
|
|
309
|
+
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
310
|
+
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
311
|
+
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
312
|
+
/** version: 2.7.4 */
|
|
309
313
|
|
|
310
314
|
/*
|
|
311
315
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -314,7 +318,6 @@
|
|
|
314
318
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
315
319
|
*/
|
|
316
320
|
|
|
317
|
-
|
|
318
321
|
function detect(propName) {
|
|
319
322
|
return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
|
|
320
323
|
}
|
|
@@ -483,7 +486,7 @@
|
|
|
483
486
|
setFeatureFlag(name, value);
|
|
484
487
|
}
|
|
485
488
|
}
|
|
486
|
-
/** version: 2.7.
|
|
489
|
+
/** version: 2.7.4 */
|
|
487
490
|
|
|
488
491
|
/* proxy-compat-disable */
|
|
489
492
|
|
|
@@ -981,6 +984,25 @@
|
|
|
981
984
|
*/
|
|
982
985
|
|
|
983
986
|
|
|
987
|
+
function addErrorComponentStack(vm, error) {
|
|
988
|
+
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
989
|
+
const wcStack = getErrorComponentStack(vm);
|
|
990
|
+
defineProperty(error, 'wcStack', {
|
|
991
|
+
get() {
|
|
992
|
+
return wcStack;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
/*
|
|
999
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1000
|
+
* All rights reserved.
|
|
1001
|
+
* SPDX-License-Identifier: MIT
|
|
1002
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1003
|
+
*/
|
|
1004
|
+
|
|
1005
|
+
|
|
984
1006
|
function log(method, message, vm) {
|
|
985
1007
|
let msg = `[LWC ${method}]: ${message}`;
|
|
986
1008
|
|
|
@@ -1015,207 +1037,12 @@
|
|
|
1015
1037
|
* SPDX-License-Identifier: MIT
|
|
1016
1038
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1017
1039
|
*/
|
|
1040
|
+
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
1041
|
+
// to inject at runtime.
|
|
1018
1042
|
|
|
1019
1043
|
|
|
1020
|
-
function
|
|
1021
|
-
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
function sameVnode(vnode1, vnode2) {
|
|
1025
|
-
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
function isVNode(vnode) {
|
|
1029
|
-
return vnode != null;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
1033
|
-
const map = {};
|
|
1034
|
-
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
1035
|
-
|
|
1036
|
-
for (j = beginIdx; j <= endIdx; ++j) {
|
|
1037
|
-
ch = children[j];
|
|
1038
|
-
|
|
1039
|
-
if (isVNode(ch)) {
|
|
1040
|
-
key = ch.key;
|
|
1041
|
-
|
|
1042
|
-
if (key !== undefined) {
|
|
1043
|
-
map[key] = j;
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
return map;
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
1052
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
1053
|
-
const ch = vnodes[startIdx];
|
|
1054
|
-
|
|
1055
|
-
if (isVNode(ch)) {
|
|
1056
|
-
ch.hook.create(ch);
|
|
1057
|
-
ch.hook.insert(ch, parentElm, before);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
1063
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
1064
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
1065
|
-
|
|
1066
|
-
if (isVNode(ch)) {
|
|
1067
|
-
ch.hook.remove(ch, parentElm);
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
1073
|
-
let oldStartIdx = 0;
|
|
1074
|
-
let newStartIdx = 0;
|
|
1075
|
-
let oldEndIdx = oldCh.length - 1;
|
|
1076
|
-
let oldStartVnode = oldCh[0];
|
|
1077
|
-
let oldEndVnode = oldCh[oldEndIdx];
|
|
1078
|
-
const newChEnd = newCh.length - 1;
|
|
1079
|
-
let newEndIdx = newChEnd;
|
|
1080
|
-
let newStartVnode = newCh[0];
|
|
1081
|
-
let newEndVnode = newCh[newEndIdx];
|
|
1082
|
-
let oldKeyToIdx;
|
|
1083
|
-
let idxInOld;
|
|
1084
|
-
let elmToMove;
|
|
1085
|
-
let before;
|
|
1086
|
-
|
|
1087
|
-
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
1088
|
-
if (!isVNode(oldStartVnode)) {
|
|
1089
|
-
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
1090
|
-
} else if (!isVNode(oldEndVnode)) {
|
|
1091
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1092
|
-
} else if (!isVNode(newStartVnode)) {
|
|
1093
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1094
|
-
} else if (!isVNode(newEndVnode)) {
|
|
1095
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1096
|
-
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
1097
|
-
patchVnode(oldStartVnode, newStartVnode);
|
|
1098
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1099
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1100
|
-
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
1101
|
-
patchVnode(oldEndVnode, newEndVnode);
|
|
1102
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1103
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1104
|
-
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
1105
|
-
// Vnode moved right
|
|
1106
|
-
patchVnode(oldStartVnode, newEndVnode);
|
|
1107
|
-
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
|
|
1108
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1109
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1110
|
-
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
1111
|
-
// Vnode moved left
|
|
1112
|
-
patchVnode(oldEndVnode, newStartVnode);
|
|
1113
|
-
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
1114
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1115
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1116
|
-
} else {
|
|
1117
|
-
if (oldKeyToIdx === undefined) {
|
|
1118
|
-
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
1122
|
-
|
|
1123
|
-
if (isUndef(idxInOld)) {
|
|
1124
|
-
// New element
|
|
1125
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1126
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1127
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1128
|
-
} else {
|
|
1129
|
-
elmToMove = oldCh[idxInOld];
|
|
1130
|
-
|
|
1131
|
-
if (isVNode(elmToMove)) {
|
|
1132
|
-
if (elmToMove.sel !== newStartVnode.sel) {
|
|
1133
|
-
// New element
|
|
1134
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1135
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1136
|
-
} else {
|
|
1137
|
-
patchVnode(elmToMove, newStartVnode);
|
|
1138
|
-
oldCh[idxInOld] = undefined;
|
|
1139
|
-
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
1149
|
-
if (oldStartIdx > oldEndIdx) {
|
|
1150
|
-
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
1151
|
-
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
1152
|
-
let i = newEndIdx;
|
|
1153
|
-
let n;
|
|
1154
|
-
|
|
1155
|
-
do {
|
|
1156
|
-
n = newCh[++i];
|
|
1157
|
-
} while (!isVNode(n) && i < newChEnd);
|
|
1158
|
-
|
|
1159
|
-
before = isVNode(n) ? n.elm : null;
|
|
1160
|
-
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
1161
|
-
} else {
|
|
1162
|
-
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
1168
|
-
const oldChLength = oldCh.length;
|
|
1169
|
-
const newChLength = newCh.length;
|
|
1170
|
-
|
|
1171
|
-
if (oldChLength === 0) {
|
|
1172
|
-
// the old list is empty, we can directly insert anything new
|
|
1173
|
-
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
1174
|
-
return;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
if (newChLength === 0) {
|
|
1178
|
-
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
1179
|
-
// this is the case in which the dynamic children of an if-directive should be removed
|
|
1180
|
-
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
1181
|
-
return;
|
|
1182
|
-
} // if the old list is not empty, the new list MUST have the same
|
|
1183
|
-
// amount of nodes, that's why we call this static children
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
let referenceElm = null;
|
|
1187
|
-
|
|
1188
|
-
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
1189
|
-
const vnode = newCh[i];
|
|
1190
|
-
const oldVNode = oldCh[i];
|
|
1191
|
-
|
|
1192
|
-
if (vnode !== oldVNode) {
|
|
1193
|
-
if (isVNode(oldVNode)) {
|
|
1194
|
-
if (isVNode(vnode)) {
|
|
1195
|
-
// both vnodes must be equivalent, and se just need to patch them
|
|
1196
|
-
patchVnode(oldVNode, vnode);
|
|
1197
|
-
referenceElm = vnode.elm;
|
|
1198
|
-
} else {
|
|
1199
|
-
// removing the old vnode since the new one is null
|
|
1200
|
-
oldVNode.hook.remove(oldVNode, parentElm);
|
|
1201
|
-
}
|
|
1202
|
-
} else if (isVNode(vnode)) {
|
|
1203
|
-
// this condition is unnecessary
|
|
1204
|
-
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
1205
|
-
|
|
1206
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
1207
|
-
referenceElm = vnode.elm;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
function patchVnode(oldVnode, vnode) {
|
|
1214
|
-
if (oldVnode !== vnode) {
|
|
1215
|
-
vnode.elm = oldVnode.elm;
|
|
1216
|
-
vnode.hook.update(oldVnode, vnode);
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1044
|
+
const HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
|
1045
|
+
const HTMLElementPrototype = HTMLElementConstructor$1.prototype;
|
|
1219
1046
|
/*
|
|
1220
1047
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1221
1048
|
* All rights reserved.
|
|
@@ -1223,7 +1050,6 @@
|
|
|
1223
1050
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1224
1051
|
*/
|
|
1225
1052
|
|
|
1226
|
-
|
|
1227
1053
|
const defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
|
|
1228
1054
|
|
|
1229
1055
|
function offsetPropertyErrorMessage(name) {
|
|
@@ -1342,6 +1168,40 @@
|
|
|
1342
1168
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1343
1169
|
*/
|
|
1344
1170
|
|
|
1171
|
+
/**
|
|
1172
|
+
* This is a descriptor map that contains
|
|
1173
|
+
* all standard properties that a Custom Element can support (including AOM properties), which
|
|
1174
|
+
* determines what kind of capabilities the Base HTML Element and
|
|
1175
|
+
* Base Lightning Element should support.
|
|
1176
|
+
*/
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
const HTMLElementOriginalDescriptors = create(null);
|
|
1180
|
+
forEach.call(keys(AriaPropNameToAttrNameMap), propName => {
|
|
1181
|
+
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1182
|
+
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
|
|
1183
|
+
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1184
|
+
|
|
1185
|
+
if (!isUndefined$1(descriptor)) {
|
|
1186
|
+
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1189
|
+
forEach.call(defaultDefHTMLPropertyNames, propName => {
|
|
1190
|
+
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1191
|
+
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
|
|
1192
|
+
// this category, so, better to be sure.
|
|
1193
|
+
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1194
|
+
|
|
1195
|
+
if (!isUndefined$1(descriptor)) {
|
|
1196
|
+
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1199
|
+
/*
|
|
1200
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1201
|
+
* All rights reserved.
|
|
1202
|
+
* SPDX-License-Identifier: MIT
|
|
1203
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1204
|
+
*/
|
|
1345
1205
|
|
|
1346
1206
|
function generateDataDescriptor(options) {
|
|
1347
1207
|
return assign({
|
|
@@ -1704,56 +1564,11 @@
|
|
|
1704
1564
|
function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
1705
1565
|
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
1706
1566
|
}
|
|
1707
|
-
|
|
1708
|
-
* Copyright (
|
|
1709
|
-
* All rights reserved.
|
|
1710
|
-
* SPDX-License-Identifier: MIT
|
|
1711
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1567
|
+
/**
|
|
1568
|
+
* Copyright (C) 2017 salesforce.com, inc.
|
|
1712
1569
|
*/
|
|
1713
|
-
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
1714
|
-
// to inject at runtime.
|
|
1715
1570
|
|
|
1716
1571
|
|
|
1717
|
-
const HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
|
1718
|
-
const HTMLElementPrototype = HTMLElementConstructor$1.prototype;
|
|
1719
|
-
/*
|
|
1720
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1721
|
-
* All rights reserved.
|
|
1722
|
-
* SPDX-License-Identifier: MIT
|
|
1723
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1724
|
-
*/
|
|
1725
|
-
|
|
1726
|
-
/**
|
|
1727
|
-
* This is a descriptor map that contains
|
|
1728
|
-
* all standard properties that a Custom Element can support (including AOM properties), which
|
|
1729
|
-
* determines what kind of capabilities the Base HTML Element and
|
|
1730
|
-
* Base Lightning Element should support.
|
|
1731
|
-
*/
|
|
1732
|
-
|
|
1733
|
-
const HTMLElementOriginalDescriptors = create(null);
|
|
1734
|
-
forEach.call(keys(AriaPropNameToAttrNameMap), propName => {
|
|
1735
|
-
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1736
|
-
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
|
|
1737
|
-
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1738
|
-
|
|
1739
|
-
if (!isUndefined$1(descriptor)) {
|
|
1740
|
-
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1741
|
-
}
|
|
1742
|
-
});
|
|
1743
|
-
forEach.call(defaultDefHTMLPropertyNames, propName => {
|
|
1744
|
-
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1745
|
-
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
|
|
1746
|
-
// this category, so, better to be sure.
|
|
1747
|
-
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1748
|
-
|
|
1749
|
-
if (!isUndefined$1(descriptor)) {
|
|
1750
|
-
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1751
|
-
}
|
|
1752
|
-
});
|
|
1753
|
-
/**
|
|
1754
|
-
* Copyright (C) 2017 salesforce.com, inc.
|
|
1755
|
-
*/
|
|
1756
|
-
|
|
1757
1572
|
const {
|
|
1758
1573
|
isArray
|
|
1759
1574
|
} = Array;
|
|
@@ -2670,7 +2485,9 @@
|
|
|
2670
2485
|
if (vm.renderMode === 1
|
|
2671
2486
|
/* Shadow */
|
|
2672
2487
|
) {
|
|
2673
|
-
doAttachShadow(vm);
|
|
2488
|
+
vm.renderRoot = doAttachShadow(vm);
|
|
2489
|
+
} else {
|
|
2490
|
+
vm.renderRoot = elm;
|
|
2674
2491
|
} // Adding extra guard rails in DEV mode.
|
|
2675
2492
|
|
|
2676
2493
|
|
|
@@ -2691,19 +2508,21 @@
|
|
|
2691
2508
|
ctor
|
|
2692
2509
|
}
|
|
2693
2510
|
} = vm;
|
|
2694
|
-
const
|
|
2511
|
+
const shadowRoot = attachShadow$1(elm, {
|
|
2695
2512
|
[KEY__SYNTHETIC_MODE]: shadowMode === 1
|
|
2696
2513
|
/* Synthetic */
|
|
2697
2514
|
,
|
|
2698
2515
|
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
2699
2516
|
mode
|
|
2700
2517
|
});
|
|
2701
|
-
vm.
|
|
2702
|
-
associateVM(
|
|
2518
|
+
vm.shadowRoot = shadowRoot;
|
|
2519
|
+
associateVM(shadowRoot, vm);
|
|
2703
2520
|
|
|
2704
2521
|
if (process.env.NODE_ENV !== 'production') {
|
|
2705
|
-
patchShadowRootWithRestrictions(
|
|
2522
|
+
patchShadowRootWithRestrictions(shadowRoot);
|
|
2706
2523
|
}
|
|
2524
|
+
|
|
2525
|
+
return shadowRoot;
|
|
2707
2526
|
}
|
|
2708
2527
|
|
|
2709
2528
|
function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
@@ -2871,7 +2690,7 @@
|
|
|
2871
2690
|
}
|
|
2872
2691
|
}
|
|
2873
2692
|
|
|
2874
|
-
return vm.
|
|
2693
|
+
return vm.shadowRoot;
|
|
2875
2694
|
},
|
|
2876
2695
|
|
|
2877
2696
|
get shadowRoot() {
|
|
@@ -4283,6 +4102,11 @@
|
|
|
4283
4102
|
return def;
|
|
4284
4103
|
}
|
|
4285
4104
|
|
|
4105
|
+
function getComponentHtmlPrototype(Ctor) {
|
|
4106
|
+
const def = getComponentInternalDef(Ctor);
|
|
4107
|
+
return def.bridge;
|
|
4108
|
+
}
|
|
4109
|
+
|
|
4286
4110
|
const lightingElementDef = {
|
|
4287
4111
|
ctor: LightningElement,
|
|
4288
4112
|
name: LightningElement.name,
|
|
@@ -4345,6 +4169,65 @@
|
|
|
4345
4169
|
methods: publicMethods
|
|
4346
4170
|
};
|
|
4347
4171
|
}
|
|
4172
|
+
/*
|
|
4173
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4174
|
+
* All rights reserved.
|
|
4175
|
+
* SPDX-License-Identifier: MIT
|
|
4176
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4177
|
+
*/
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
function getUpgradableConstructor(tagName) {
|
|
4181
|
+
// Should never get a tag with upper case letter at this point, the compiler should
|
|
4182
|
+
// produce only tags with lowercase letters
|
|
4183
|
+
// But, for backwards compatibility, we will lower case the tagName
|
|
4184
|
+
tagName = tagName.toLowerCase();
|
|
4185
|
+
let CE = getCustomElement$1(tagName);
|
|
4186
|
+
|
|
4187
|
+
if (!isUndefined$1(CE)) {
|
|
4188
|
+
return CE;
|
|
4189
|
+
}
|
|
4190
|
+
/**
|
|
4191
|
+
* LWC Upgradable Element reference to an element that was created
|
|
4192
|
+
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
4193
|
+
*/
|
|
4194
|
+
|
|
4195
|
+
|
|
4196
|
+
CE = class LWCUpgradableElement extends HTMLElementExported$1 {
|
|
4197
|
+
constructor(upgradeCallback) {
|
|
4198
|
+
super();
|
|
4199
|
+
|
|
4200
|
+
if (isFunction$1(upgradeCallback)) {
|
|
4201
|
+
upgradeCallback(this); // nothing to do with the result for now
|
|
4202
|
+
}
|
|
4203
|
+
}
|
|
4204
|
+
|
|
4205
|
+
};
|
|
4206
|
+
defineCustomElement$1(tagName, CE);
|
|
4207
|
+
return CE;
|
|
4208
|
+
}
|
|
4209
|
+
/*
|
|
4210
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4211
|
+
* All rights reserved.
|
|
4212
|
+
* SPDX-License-Identifier: MIT
|
|
4213
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4214
|
+
*/
|
|
4215
|
+
|
|
4216
|
+
|
|
4217
|
+
function isVBaseElement(vnode) {
|
|
4218
|
+
const {
|
|
4219
|
+
type
|
|
4220
|
+
} = vnode;
|
|
4221
|
+
return type === 2
|
|
4222
|
+
/* Element */
|
|
4223
|
+
|| type === 3
|
|
4224
|
+
/* CustomElement */
|
|
4225
|
+
;
|
|
4226
|
+
}
|
|
4227
|
+
|
|
4228
|
+
function isSameVnode(vnode1, vnode2) {
|
|
4229
|
+
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
4230
|
+
}
|
|
4348
4231
|
/*
|
|
4349
4232
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4350
4233
|
* All rights reserved.
|
|
@@ -4353,8 +4236,6 @@
|
|
|
4353
4236
|
*/
|
|
4354
4237
|
|
|
4355
4238
|
|
|
4356
|
-
const xlinkNS = 'http://www.w3.org/1999/xlink';
|
|
4357
|
-
const xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
|
4358
4239
|
const ColonCharCode = 58;
|
|
4359
4240
|
|
|
4360
4241
|
function patchAttributes(oldVnode, vnode) {
|
|
@@ -4385,10 +4266,10 @@
|
|
|
4385
4266
|
|
|
4386
4267
|
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
|
|
4387
4268
|
// Assume xml namespace
|
|
4388
|
-
setAttribute$1(elm, key, cur,
|
|
4269
|
+
setAttribute$1(elm, key, cur, XML_NAMESPACE);
|
|
4389
4270
|
} else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
|
|
4390
4271
|
// Assume xlink namespace
|
|
4391
|
-
setAttribute$1(elm, key, cur,
|
|
4272
|
+
setAttribute$1(elm, key, cur, XLINK_NAMESPACE);
|
|
4392
4273
|
} else if (isNull(cur) || isUndefined$1(cur)) {
|
|
4393
4274
|
removeAttribute$1(elm, key);
|
|
4394
4275
|
} else {
|
|
@@ -4642,6 +4523,161 @@
|
|
|
4642
4523
|
*/
|
|
4643
4524
|
|
|
4644
4525
|
|
|
4526
|
+
const TextHook = {
|
|
4527
|
+
create: vnode => {
|
|
4528
|
+
const {
|
|
4529
|
+
owner
|
|
4530
|
+
} = vnode;
|
|
4531
|
+
const elm = createText$1(vnode.text);
|
|
4532
|
+
linkNodeToShadow(elm, owner);
|
|
4533
|
+
vnode.elm = elm;
|
|
4534
|
+
},
|
|
4535
|
+
update: updateNodeHook,
|
|
4536
|
+
insert: insertNode,
|
|
4537
|
+
move: insertNode,
|
|
4538
|
+
remove: removeNode
|
|
4539
|
+
};
|
|
4540
|
+
const CommentHook = {
|
|
4541
|
+
create: vnode => {
|
|
4542
|
+
const {
|
|
4543
|
+
owner,
|
|
4544
|
+
text
|
|
4545
|
+
} = vnode;
|
|
4546
|
+
const elm = createComment$1(text);
|
|
4547
|
+
linkNodeToShadow(elm, owner);
|
|
4548
|
+
vnode.elm = elm;
|
|
4549
|
+
},
|
|
4550
|
+
update: updateNodeHook,
|
|
4551
|
+
insert: insertNode,
|
|
4552
|
+
move: insertNode,
|
|
4553
|
+
remove: removeNode
|
|
4554
|
+
}; // insert is called after update, which is used somewhere else (via a module)
|
|
4555
|
+
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
4556
|
+
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
4557
|
+
// which breaks some invariants. For that reason, we have the following for any
|
|
4558
|
+
// Custom Element that is inserted via a template.
|
|
4559
|
+
|
|
4560
|
+
const ElementHook = {
|
|
4561
|
+
create: vnode => {
|
|
4562
|
+
const {
|
|
4563
|
+
sel,
|
|
4564
|
+
owner,
|
|
4565
|
+
data: {
|
|
4566
|
+
svg
|
|
4567
|
+
}
|
|
4568
|
+
} = vnode;
|
|
4569
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4570
|
+
const elm = createElement$2(sel, namespace);
|
|
4571
|
+
linkNodeToShadow(elm, owner);
|
|
4572
|
+
fallbackElmHook(elm, vnode);
|
|
4573
|
+
vnode.elm = elm;
|
|
4574
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4575
|
+
},
|
|
4576
|
+
update: (oldVnode, vnode) => {
|
|
4577
|
+
patchElementPropsAndAttrs$1(oldVnode, vnode);
|
|
4578
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
4579
|
+
},
|
|
4580
|
+
insert: (vnode, parentNode, referenceNode) => {
|
|
4581
|
+
insertNode(vnode, parentNode, referenceNode);
|
|
4582
|
+
createChildrenHook(vnode);
|
|
4583
|
+
},
|
|
4584
|
+
move: insertNode,
|
|
4585
|
+
remove: (vnode, parentNode) => {
|
|
4586
|
+
removeNode(vnode, parentNode);
|
|
4587
|
+
removeChildren(vnode);
|
|
4588
|
+
}
|
|
4589
|
+
};
|
|
4590
|
+
const CustomElementHook = {
|
|
4591
|
+
create: vnode => {
|
|
4592
|
+
const {
|
|
4593
|
+
sel,
|
|
4594
|
+
owner
|
|
4595
|
+
} = vnode;
|
|
4596
|
+
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
4597
|
+
/**
|
|
4598
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4599
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
4600
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
4601
|
+
* an upgradable custom element.
|
|
4602
|
+
*/
|
|
4603
|
+
|
|
4604
|
+
let vm;
|
|
4605
|
+
const elm = new UpgradableConstructor(elm => {
|
|
4606
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
4607
|
+
vm = createViewModelHook(elm, vnode);
|
|
4608
|
+
});
|
|
4609
|
+
linkNodeToShadow(elm, owner);
|
|
4610
|
+
vnode.elm = elm;
|
|
4611
|
+
|
|
4612
|
+
if (vm) {
|
|
4613
|
+
allocateChildren(vnode, vm);
|
|
4614
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4615
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
4616
|
+
}
|
|
4617
|
+
|
|
4618
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4619
|
+
},
|
|
4620
|
+
update: (oldVnode, vnode) => {
|
|
4621
|
+
patchElementPropsAndAttrs$1(oldVnode, vnode);
|
|
4622
|
+
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
4623
|
+
|
|
4624
|
+
if (vm) {
|
|
4625
|
+
// in fallback mode, the allocation will always set children to
|
|
4626
|
+
// empty and delegate the real allocation to the slot elements
|
|
4627
|
+
allocateChildren(vnode, vm);
|
|
4628
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
4629
|
+
// will happen, but in native, it does allocate the light dom
|
|
4630
|
+
|
|
4631
|
+
|
|
4632
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
4633
|
+
|
|
4634
|
+
if (vm) {
|
|
4635
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4636
|
+
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4637
|
+
} // this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4638
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
4639
|
+
|
|
4640
|
+
|
|
4641
|
+
rerenderVM(vm);
|
|
4642
|
+
}
|
|
4643
|
+
},
|
|
4644
|
+
insert: (vnode, parentNode, referenceNode) => {
|
|
4645
|
+
insertNode(vnode, parentNode, referenceNode);
|
|
4646
|
+
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
4647
|
+
|
|
4648
|
+
if (vm) {
|
|
4649
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4650
|
+
assert.isTrue(vm.state === 0
|
|
4651
|
+
/* created */
|
|
4652
|
+
, `${vm} cannot be recycled.`);
|
|
4653
|
+
}
|
|
4654
|
+
|
|
4655
|
+
runConnectedCallback(vm);
|
|
4656
|
+
}
|
|
4657
|
+
|
|
4658
|
+
createChildrenHook(vnode);
|
|
4659
|
+
|
|
4660
|
+
if (vm) {
|
|
4661
|
+
appendVM(vm);
|
|
4662
|
+
}
|
|
4663
|
+
},
|
|
4664
|
+
move: insertNode,
|
|
4665
|
+
remove: (vnode, parentNode) => {
|
|
4666
|
+
removeNode(vnode, parentNode);
|
|
4667
|
+
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
4668
|
+
|
|
4669
|
+
if (vm) {
|
|
4670
|
+
// for custom elements we don't have to go recursively because the removeVM routine
|
|
4671
|
+
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
4672
|
+
removeVM(vm);
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
};
|
|
4676
|
+
|
|
4677
|
+
function isVNode(vnode) {
|
|
4678
|
+
return vnode != null;
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4645
4681
|
function observeElementChildNodes(elm) {
|
|
4646
4682
|
elm.$domManual$ = true;
|
|
4647
4683
|
}
|
|
@@ -4663,6 +4699,24 @@
|
|
|
4663
4699
|
}
|
|
4664
4700
|
}
|
|
4665
4701
|
|
|
4702
|
+
function linkNodeToShadow(elm, owner) {
|
|
4703
|
+
const {
|
|
4704
|
+
renderRoot,
|
|
4705
|
+
renderMode,
|
|
4706
|
+
shadowMode
|
|
4707
|
+
} = owner; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4708
|
+
|
|
4709
|
+
if (isSyntheticShadowDefined$1) {
|
|
4710
|
+
if (shadowMode === 1
|
|
4711
|
+
/* Synthetic */
|
|
4712
|
+
|| renderMode === 0
|
|
4713
|
+
/* Light */
|
|
4714
|
+
) {
|
|
4715
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
|
|
4666
4720
|
function updateNodeHook(oldVnode, vnode) {
|
|
4667
4721
|
const {
|
|
4668
4722
|
elm,
|
|
@@ -4682,7 +4736,7 @@
|
|
|
4682
4736
|
}
|
|
4683
4737
|
}
|
|
4684
4738
|
|
|
4685
|
-
function
|
|
4739
|
+
function insertNode(vnode, parentNode, referenceNode) {
|
|
4686
4740
|
if (process.env.NODE_ENV !== 'production') {
|
|
4687
4741
|
unlockDomMutation();
|
|
4688
4742
|
}
|
|
@@ -4694,7 +4748,7 @@
|
|
|
4694
4748
|
}
|
|
4695
4749
|
}
|
|
4696
4750
|
|
|
4697
|
-
function
|
|
4751
|
+
function removeNode(vnode, parentNode) {
|
|
4698
4752
|
if (process.env.NODE_ENV !== 'production') {
|
|
4699
4753
|
unlockDomMutation();
|
|
4700
4754
|
}
|
|
@@ -4706,7 +4760,7 @@
|
|
|
4706
4760
|
}
|
|
4707
4761
|
}
|
|
4708
4762
|
|
|
4709
|
-
function patchElementPropsAndAttrs(oldVnode, vnode) {
|
|
4763
|
+
function patchElementPropsAndAttrs$1(oldVnode, vnode) {
|
|
4710
4764
|
if (isNull(oldVnode)) {
|
|
4711
4765
|
applyEventListeners(vnode);
|
|
4712
4766
|
applyStaticClassAttribute(vnode);
|
|
@@ -4721,11 +4775,6 @@
|
|
|
4721
4775
|
patchProps(oldVnode, vnode);
|
|
4722
4776
|
}
|
|
4723
4777
|
|
|
4724
|
-
function hydrateElmHook(vnode) {
|
|
4725
|
-
applyEventListeners(vnode);
|
|
4726
|
-
patchProps(null, vnode);
|
|
4727
|
-
}
|
|
4728
|
-
|
|
4729
4778
|
function fallbackElmHook(elm, vnode) {
|
|
4730
4779
|
const {
|
|
4731
4780
|
owner
|
|
@@ -4745,7 +4794,7 @@
|
|
|
4745
4794
|
} = owner.context;
|
|
4746
4795
|
|
|
4747
4796
|
if (!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
4748
|
-
/*
|
|
4797
|
+
/* Manual */
|
|
4749
4798
|
) {
|
|
4750
4799
|
// this element will now accept any manual content inserted into it
|
|
4751
4800
|
observeElementChildNodes(elm);
|
|
@@ -4763,7 +4812,7 @@
|
|
|
4763
4812
|
}
|
|
4764
4813
|
} = vnode;
|
|
4765
4814
|
const isPortal = !isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
4766
|
-
/*
|
|
4815
|
+
/* Manual */
|
|
4767
4816
|
;
|
|
4768
4817
|
const isLight = owner.renderMode === 0
|
|
4769
4818
|
/* Light */
|
|
@@ -4783,7 +4832,7 @@
|
|
|
4783
4832
|
}
|
|
4784
4833
|
}
|
|
4785
4834
|
|
|
4786
|
-
function
|
|
4835
|
+
function allocateChildren(vnode, vm) {
|
|
4787
4836
|
// A component with slots will re-render because:
|
|
4788
4837
|
// 1- There is a change of the internal state.
|
|
4789
4838
|
// 2- There is a change on the external api (ex: slots)
|
|
@@ -4816,11 +4865,12 @@
|
|
|
4816
4865
|
}
|
|
4817
4866
|
|
|
4818
4867
|
function createViewModelHook(elm, vnode) {
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4868
|
+
let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4869
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4870
|
+
// called right after invoking `document.createElement`.
|
|
4871
|
+
|
|
4872
|
+
if (!isUndefined$1(vm)) {
|
|
4873
|
+
return vm;
|
|
4824
4874
|
}
|
|
4825
4875
|
|
|
4826
4876
|
const {
|
|
@@ -4842,8 +4892,7 @@
|
|
|
4842
4892
|
setElementShadowToken(elm, stylesheetToken);
|
|
4843
4893
|
}
|
|
4844
4894
|
|
|
4845
|
-
|
|
4846
|
-
createVM(elm, def, {
|
|
4895
|
+
vm = createVM(elm, ctor, {
|
|
4847
4896
|
mode,
|
|
4848
4897
|
owner,
|
|
4849
4898
|
tagName: sel
|
|
@@ -4852,7 +4901,9 @@
|
|
|
4852
4901
|
if (process.env.NODE_ENV !== 'production') {
|
|
4853
4902
|
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4854
4903
|
}
|
|
4855
|
-
|
|
4904
|
+
|
|
4905
|
+
return vm;
|
|
4906
|
+
}
|
|
4856
4907
|
|
|
4857
4908
|
function createChildrenHook(vnode) {
|
|
4858
4909
|
const {
|
|
@@ -4870,171 +4921,7 @@
|
|
|
4870
4921
|
}
|
|
4871
4922
|
}
|
|
4872
4923
|
|
|
4873
|
-
function
|
|
4874
|
-
// eslint-disable-next-line lwc-internal/no-global-node
|
|
4875
|
-
return node.nodeType === Node.ELEMENT_NODE;
|
|
4876
|
-
}
|
|
4877
|
-
|
|
4878
|
-
function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
|
|
4879
|
-
const {
|
|
4880
|
-
data: {
|
|
4881
|
-
attrs = {}
|
|
4882
|
-
}
|
|
4883
|
-
} = vnode;
|
|
4884
|
-
let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
|
|
4885
|
-
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
4886
|
-
|
|
4887
|
-
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
4888
|
-
const elmAttrValue = getAttribute$1(elm, attrName);
|
|
4889
|
-
|
|
4890
|
-
if (String(attrValue) !== elmAttrValue) {
|
|
4891
|
-
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
4892
|
-
nodesAreCompatible = false;
|
|
4893
|
-
}
|
|
4894
|
-
}
|
|
4895
|
-
|
|
4896
|
-
return nodesAreCompatible;
|
|
4897
|
-
}
|
|
4898
|
-
|
|
4899
|
-
function vnodesAndElementHaveCompatibleClass(vnode, elm) {
|
|
4900
|
-
const {
|
|
4901
|
-
data: {
|
|
4902
|
-
className,
|
|
4903
|
-
classMap
|
|
4904
|
-
}
|
|
4905
|
-
} = vnode;
|
|
4906
|
-
let nodesAreCompatible = true;
|
|
4907
|
-
let vnodeClassName;
|
|
4908
|
-
|
|
4909
|
-
if (!isUndefined$1(className) && String(className) !== elm.className) {
|
|
4910
|
-
// className is used when class is bound to an expr.
|
|
4911
|
-
nodesAreCompatible = false;
|
|
4912
|
-
vnodeClassName = className;
|
|
4913
|
-
} else if (!isUndefined$1(classMap)) {
|
|
4914
|
-
// classMap is used when class is set to static value.
|
|
4915
|
-
const classList = getClassList$1(elm);
|
|
4916
|
-
let computedClassName = ''; // all classes from the vnode should be in the element.classList
|
|
4917
|
-
|
|
4918
|
-
for (const name in classMap) {
|
|
4919
|
-
computedClassName += ' ' + name;
|
|
4920
|
-
|
|
4921
|
-
if (!classList.contains(name)) {
|
|
4922
|
-
nodesAreCompatible = false;
|
|
4923
|
-
}
|
|
4924
|
-
}
|
|
4925
|
-
|
|
4926
|
-
vnodeClassName = computedClassName.trim();
|
|
4927
|
-
|
|
4928
|
-
if (classList.length > keys(classMap).length) {
|
|
4929
|
-
nodesAreCompatible = false;
|
|
4930
|
-
}
|
|
4931
|
-
}
|
|
4932
|
-
|
|
4933
|
-
if (!nodesAreCompatible) {
|
|
4934
|
-
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
|
|
4935
|
-
}
|
|
4936
|
-
|
|
4937
|
-
return nodesAreCompatible;
|
|
4938
|
-
}
|
|
4939
|
-
|
|
4940
|
-
function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
|
|
4941
|
-
const {
|
|
4942
|
-
data: {
|
|
4943
|
-
style,
|
|
4944
|
-
styleDecls
|
|
4945
|
-
}
|
|
4946
|
-
} = vnode;
|
|
4947
|
-
const elmStyle = getAttribute$1(elm, 'style') || '';
|
|
4948
|
-
let vnodeStyle;
|
|
4949
|
-
let nodesAreCompatible = true;
|
|
4950
|
-
|
|
4951
|
-
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
4952
|
-
nodesAreCompatible = false;
|
|
4953
|
-
vnodeStyle = style;
|
|
4954
|
-
} else if (!isUndefined$1(styleDecls)) {
|
|
4955
|
-
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
4956
|
-
const expectedStyle = []; // styleMap is used when style is set to static value.
|
|
4957
|
-
|
|
4958
|
-
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
4959
|
-
const [prop, value, important] = styleDecls[i];
|
|
4960
|
-
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
4961
|
-
const parsedPropValue = parsedVnodeStyle[prop];
|
|
4962
|
-
|
|
4963
|
-
if (isUndefined$1(parsedPropValue)) {
|
|
4964
|
-
nodesAreCompatible = false;
|
|
4965
|
-
} else if (!parsedPropValue.startsWith(value)) {
|
|
4966
|
-
nodesAreCompatible = false;
|
|
4967
|
-
} else if (important && !parsedPropValue.endsWith('!important')) {
|
|
4968
|
-
nodesAreCompatible = false;
|
|
4969
|
-
}
|
|
4970
|
-
}
|
|
4971
|
-
|
|
4972
|
-
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
4973
|
-
nodesAreCompatible = false;
|
|
4974
|
-
}
|
|
4975
|
-
|
|
4976
|
-
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
4977
|
-
}
|
|
4978
|
-
|
|
4979
|
-
if (!nodesAreCompatible) {
|
|
4980
|
-
// style is used when class is bound to an expr.
|
|
4981
|
-
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
4982
|
-
}
|
|
4983
|
-
|
|
4984
|
-
return nodesAreCompatible;
|
|
4985
|
-
}
|
|
4986
|
-
|
|
4987
|
-
function throwHydrationError() {
|
|
4988
|
-
assert.fail('Server rendered elements do not match client side generated elements');
|
|
4989
|
-
}
|
|
4990
|
-
|
|
4991
|
-
function hydrateChildrenHook(elmChildren, children, vm) {
|
|
4992
|
-
var _a, _b;
|
|
4993
|
-
|
|
4994
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4995
|
-
const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
|
|
4996
|
-
|
|
4997
|
-
if (elmChildren.length !== filteredVNodes.length) {
|
|
4998
|
-
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
4999
|
-
throwHydrationError();
|
|
5000
|
-
}
|
|
5001
|
-
}
|
|
5002
|
-
|
|
5003
|
-
let elmCurrentChildIdx = 0;
|
|
5004
|
-
|
|
5005
|
-
for (let j = 0, n = children.length; j < n; j++) {
|
|
5006
|
-
const ch = children[j];
|
|
5007
|
-
|
|
5008
|
-
if (ch != null) {
|
|
5009
|
-
const childNode = elmChildren[elmCurrentChildIdx];
|
|
5010
|
-
|
|
5011
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5012
|
-
// VComments and VTexts validation is handled in their hooks
|
|
5013
|
-
if (isElementNode(childNode)) {
|
|
5014
|
-
if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
|
|
5015
|
-
logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
|
|
5016
|
-
throwHydrationError();
|
|
5017
|
-
} // Note: props are not yet set
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
|
|
5021
|
-
const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
|
|
5022
|
-
const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
|
|
5023
|
-
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
5024
|
-
|
|
5025
|
-
if (!isVNodeAndElementCompatible) {
|
|
5026
|
-
throwHydrationError();
|
|
5027
|
-
}
|
|
5028
|
-
}
|
|
5029
|
-
}
|
|
5030
|
-
|
|
5031
|
-
ch.hook.hydrate(ch, childNode);
|
|
5032
|
-
elmCurrentChildIdx++;
|
|
5033
|
-
}
|
|
5034
|
-
}
|
|
5035
|
-
}
|
|
5036
|
-
|
|
5037
|
-
function removeElmHook(vnode) {
|
|
4924
|
+
function removeChildren(vnode) {
|
|
5038
4925
|
// this method only needs to search on child vnodes from template
|
|
5039
4926
|
// to trigger the remove hook just in case some of those children
|
|
5040
4927
|
// are custom elements.
|
|
@@ -5053,6 +4940,8 @@
|
|
|
5053
4940
|
}
|
|
5054
4941
|
|
|
5055
4942
|
function allocateInSlot(vm, children) {
|
|
4943
|
+
var _a;
|
|
4944
|
+
|
|
5056
4945
|
const {
|
|
5057
4946
|
cmpSlots: oldSlots
|
|
5058
4947
|
} = vm;
|
|
@@ -5065,10 +4954,12 @@
|
|
|
5065
4954
|
continue;
|
|
5066
4955
|
}
|
|
5067
4956
|
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
4957
|
+
let slotName = '';
|
|
4958
|
+
|
|
4959
|
+
if (isVBaseElement(vnode)) {
|
|
4960
|
+
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
|
|
4961
|
+
}
|
|
4962
|
+
|
|
5072
4963
|
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
|
|
5073
4964
|
// which might have similar keys. Each vnode will always have a key that
|
|
5074
4965
|
// starts with a numeric character from compiler. In this case, we add a unique
|
|
@@ -5123,331 +5014,204 @@
|
|
|
5123
5014
|
function hasDynamicChildren(children) {
|
|
5124
5015
|
return FromIteration.has(children);
|
|
5125
5016
|
}
|
|
5126
|
-
/*
|
|
5127
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
5128
|
-
* All rights reserved.
|
|
5129
|
-
* SPDX-License-Identifier: MIT
|
|
5130
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5131
|
-
*/
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
function getUpgradableConstructor(tagName) {
|
|
5135
|
-
// Should never get a tag with upper case letter at this point, the compiler should
|
|
5136
|
-
// produce only tags with lowercase letters
|
|
5137
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
5138
|
-
tagName = tagName.toLowerCase();
|
|
5139
|
-
let CE = getCustomElement$1(tagName);
|
|
5140
5017
|
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
}
|
|
5144
|
-
/**
|
|
5145
|
-
* LWC Upgradable Element reference to an element that was created
|
|
5146
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
5147
|
-
*/
|
|
5018
|
+
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
5019
|
+
const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
5148
5020
|
|
|
5021
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
5022
|
+
const ch = children[j];
|
|
5149
5023
|
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5024
|
+
if (isVNode(ch)) {
|
|
5025
|
+
const {
|
|
5026
|
+
key
|
|
5027
|
+
} = ch;
|
|
5153
5028
|
|
|
5154
|
-
if (
|
|
5155
|
-
|
|
5029
|
+
if (key !== undefined) {
|
|
5030
|
+
map[key] = j;
|
|
5156
5031
|
}
|
|
5157
5032
|
}
|
|
5033
|
+
}
|
|
5158
5034
|
|
|
5159
|
-
|
|
5160
|
-
defineCustomElement$1(tagName, CE);
|
|
5161
|
-
return CE;
|
|
5035
|
+
return map;
|
|
5162
5036
|
}
|
|
5163
|
-
/*
|
|
5164
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
5165
|
-
* All rights reserved.
|
|
5166
|
-
* SPDX-License-Identifier: MIT
|
|
5167
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5168
|
-
*/
|
|
5169
5037
|
|
|
5038
|
+
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
5039
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
5040
|
+
const ch = vnodes[startIdx];
|
|
5170
5041
|
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
} = vnode;
|
|
5178
|
-
const elm = createText$1(vnode.text);
|
|
5179
|
-
linkNodeToShadow(elm, owner);
|
|
5180
|
-
vnode.elm = elm;
|
|
5181
|
-
},
|
|
5182
|
-
update: updateNodeHook,
|
|
5183
|
-
insert: insertNodeHook,
|
|
5184
|
-
move: insertNodeHook,
|
|
5185
|
-
remove: removeNodeHook,
|
|
5186
|
-
hydrate: (vNode, node) => {
|
|
5187
|
-
var _a;
|
|
5188
|
-
|
|
5189
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5190
|
-
// eslint-disable-next-line lwc-internal/no-global-node
|
|
5191
|
-
if (node.nodeType !== Node.TEXT_NODE) {
|
|
5192
|
-
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
5193
|
-
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
5194
|
-
}
|
|
5195
|
-
|
|
5196
|
-
if (node.nodeValue !== vNode.text) {
|
|
5197
|
-
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
|
|
5198
|
-
}
|
|
5199
|
-
} // always set the text value to the one from the vnode.
|
|
5042
|
+
if (isVNode(ch)) {
|
|
5043
|
+
ch.hook.create(ch);
|
|
5044
|
+
ch.hook.insert(ch, parentElm, before);
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
}
|
|
5200
5048
|
|
|
5049
|
+
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
5050
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
5051
|
+
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
5201
5052
|
|
|
5202
|
-
|
|
5203
|
-
|
|
5053
|
+
if (isVNode(ch)) {
|
|
5054
|
+
ch.hook.remove(ch, parentElm);
|
|
5055
|
+
}
|
|
5204
5056
|
}
|
|
5205
|
-
}
|
|
5206
|
-
const CommentHook = {
|
|
5207
|
-
create: vnode => {
|
|
5208
|
-
const {
|
|
5209
|
-
owner,
|
|
5210
|
-
text
|
|
5211
|
-
} = vnode;
|
|
5212
|
-
const elm = createComment$1(text);
|
|
5213
|
-
linkNodeToShadow(elm, owner);
|
|
5214
|
-
vnode.elm = elm;
|
|
5215
|
-
},
|
|
5216
|
-
update: updateNodeHook,
|
|
5217
|
-
insert: insertNodeHook,
|
|
5218
|
-
move: insertNodeHook,
|
|
5219
|
-
remove: removeNodeHook,
|
|
5220
|
-
hydrate: (vNode, node) => {
|
|
5221
|
-
var _a;
|
|
5057
|
+
}
|
|
5222
5058
|
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5059
|
+
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
5060
|
+
let oldStartIdx = 0;
|
|
5061
|
+
let newStartIdx = 0;
|
|
5062
|
+
let oldEndIdx = oldCh.length - 1;
|
|
5063
|
+
let oldStartVnode = oldCh[0];
|
|
5064
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
5065
|
+
const newChEnd = newCh.length - 1;
|
|
5066
|
+
let newEndIdx = newChEnd;
|
|
5067
|
+
let newStartVnode = newCh[0];
|
|
5068
|
+
let newEndVnode = newCh[newEndIdx];
|
|
5069
|
+
let oldKeyToIdx;
|
|
5070
|
+
let idxInOld;
|
|
5071
|
+
let elmToMove;
|
|
5072
|
+
let before;
|
|
5229
5073
|
|
|
5230
|
-
|
|
5231
|
-
|
|
5074
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
5075
|
+
if (!isVNode(oldStartVnode)) {
|
|
5076
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
5077
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
5078
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
5079
|
+
} else if (!isVNode(newStartVnode)) {
|
|
5080
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5081
|
+
} else if (!isVNode(newEndVnode)) {
|
|
5082
|
+
newEndVnode = newCh[--newEndIdx];
|
|
5083
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
5084
|
+
patchVnode(oldStartVnode, newStartVnode);
|
|
5085
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
5086
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5087
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
5088
|
+
patchVnode(oldEndVnode, newEndVnode);
|
|
5089
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
5090
|
+
newEndVnode = newCh[--newEndIdx];
|
|
5091
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
5092
|
+
// Vnode moved right
|
|
5093
|
+
patchVnode(oldStartVnode, newEndVnode);
|
|
5094
|
+
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
|
|
5095
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
5096
|
+
newEndVnode = newCh[--newEndIdx];
|
|
5097
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
5098
|
+
// Vnode moved left
|
|
5099
|
+
patchVnode(oldEndVnode, newStartVnode);
|
|
5100
|
+
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
5101
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
5102
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5103
|
+
} else {
|
|
5104
|
+
if (oldKeyToIdx === undefined) {
|
|
5105
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
5232
5106
|
}
|
|
5233
|
-
} // always set the text value to the one from the vnode.
|
|
5234
|
-
|
|
5235
5107
|
|
|
5236
|
-
|
|
5237
|
-
vNode.elm = node;
|
|
5238
|
-
}
|
|
5239
|
-
}; // insert is called after update, which is used somewhere else (via a module)
|
|
5240
|
-
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
5241
|
-
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
5242
|
-
// which breaks some invariants. For that reason, we have the following for any
|
|
5243
|
-
// Custom Element that is inserted via a template.
|
|
5244
|
-
|
|
5245
|
-
const ElementHook = {
|
|
5246
|
-
create: vnode => {
|
|
5247
|
-
const {
|
|
5248
|
-
sel,
|
|
5249
|
-
owner,
|
|
5250
|
-
data: {
|
|
5251
|
-
svg
|
|
5252
|
-
}
|
|
5253
|
-
} = vnode;
|
|
5254
|
-
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
5255
|
-
const elm = createElement$2(sel, namespace);
|
|
5256
|
-
linkNodeToShadow(elm, owner);
|
|
5257
|
-
fallbackElmHook(elm, vnode);
|
|
5258
|
-
vnode.elm = elm;
|
|
5259
|
-
patchElementPropsAndAttrs(null, vnode);
|
|
5260
|
-
},
|
|
5261
|
-
update: (oldVnode, vnode) => {
|
|
5262
|
-
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
5263
|
-
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
5264
|
-
},
|
|
5265
|
-
insert: (vnode, parentNode, referenceNode) => {
|
|
5266
|
-
insertNodeHook(vnode, parentNode, referenceNode);
|
|
5267
|
-
createChildrenHook(vnode);
|
|
5268
|
-
},
|
|
5269
|
-
move: (vnode, parentNode, referenceNode) => {
|
|
5270
|
-
insertNodeHook(vnode, parentNode, referenceNode);
|
|
5271
|
-
},
|
|
5272
|
-
remove: (vnode, parentNode) => {
|
|
5273
|
-
removeNodeHook(vnode, parentNode);
|
|
5274
|
-
removeElmHook(vnode);
|
|
5275
|
-
},
|
|
5276
|
-
hydrate: (vnode, node) => {
|
|
5277
|
-
const elm = node;
|
|
5278
|
-
vnode.elm = elm;
|
|
5279
|
-
const {
|
|
5280
|
-
context
|
|
5281
|
-
} = vnode.data;
|
|
5282
|
-
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
5283
|
-
/* manual */
|
|
5284
|
-
);
|
|
5108
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
5285
5109
|
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
}
|
|
5110
|
+
if (isUndefined$1(idxInOld)) {
|
|
5111
|
+
// New element
|
|
5112
|
+
newStartVnode.hook.create(newStartVnode);
|
|
5113
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
5114
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5115
|
+
} else {
|
|
5116
|
+
elmToMove = oldCh[idxInOld];
|
|
5292
5117
|
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5118
|
+
if (isVNode(elmToMove)) {
|
|
5119
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
5120
|
+
// New element
|
|
5121
|
+
newStartVnode.hook.create(newStartVnode);
|
|
5122
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
5123
|
+
} else {
|
|
5124
|
+
patchVnode(elmToMove, newStartVnode);
|
|
5125
|
+
oldCh[idxInOld] = undefined;
|
|
5126
|
+
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
5127
|
+
}
|
|
5298
5128
|
}
|
|
5299
|
-
}
|
|
5300
|
-
}
|
|
5301
5129
|
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
if (!isDomManual) {
|
|
5305
|
-
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
5130
|
+
newStartVnode = newCh[++newStartIdx];
|
|
5131
|
+
}
|
|
5306
5132
|
}
|
|
5307
5133
|
}
|
|
5308
|
-
};
|
|
5309
|
-
const CustomElementHook = {
|
|
5310
|
-
create: vnode => {
|
|
5311
|
-
const {
|
|
5312
|
-
sel,
|
|
5313
|
-
owner
|
|
5314
|
-
} = vnode;
|
|
5315
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
5316
|
-
/**
|
|
5317
|
-
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
5318
|
-
* with a callback as the first argument, we could implement a more advanced
|
|
5319
|
-
* mechanism that only passes that argument if the constructor is known to be
|
|
5320
|
-
* an upgradable custom element.
|
|
5321
|
-
*/
|
|
5322
5134
|
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
const vm = getAssociatedVMIfPresent(elm);
|
|
5330
|
-
|
|
5331
|
-
if (vm) {
|
|
5332
|
-
allocateChildrenHook(vnode, vm);
|
|
5333
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
5334
|
-
throw new TypeError(`Incorrect Component Constructor`);
|
|
5335
|
-
}
|
|
5336
|
-
|
|
5337
|
-
patchElementPropsAndAttrs(null, vnode);
|
|
5338
|
-
},
|
|
5339
|
-
update: (oldVnode, vnode) => {
|
|
5340
|
-
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
5341
|
-
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
5342
|
-
|
|
5343
|
-
if (vm) {
|
|
5344
|
-
// in fallback mode, the allocation will always set children to
|
|
5345
|
-
// empty and delegate the real allocation to the slot elements
|
|
5346
|
-
allocateChildrenHook(vnode, vm);
|
|
5347
|
-
} // in fallback mode, the children will be always empty, so, nothing
|
|
5348
|
-
// will happen, but in native, it does allocate the light dom
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
5352
|
-
|
|
5353
|
-
if (vm) {
|
|
5354
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5355
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
5356
|
-
} // this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
5357
|
-
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
5135
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
5136
|
+
if (oldStartIdx > oldEndIdx) {
|
|
5137
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
5138
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
5139
|
+
let i = newEndIdx;
|
|
5140
|
+
let n;
|
|
5358
5141
|
|
|
5142
|
+
do {
|
|
5143
|
+
n = newCh[++i];
|
|
5144
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
5359
5145
|
|
|
5360
|
-
|
|
5146
|
+
before = isVNode(n) ? n.elm : null;
|
|
5147
|
+
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
5148
|
+
} else {
|
|
5149
|
+
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
5361
5150
|
}
|
|
5362
|
-
}
|
|
5363
|
-
|
|
5364
|
-
insertNodeHook(vnode, parentNode, referenceNode);
|
|
5365
|
-
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
5151
|
+
}
|
|
5152
|
+
}
|
|
5366
5153
|
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
/* created */
|
|
5371
|
-
, `${vm} cannot be recycled.`);
|
|
5372
|
-
}
|
|
5154
|
+
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
5155
|
+
const oldChLength = oldCh.length;
|
|
5156
|
+
const newChLength = newCh.length;
|
|
5373
5157
|
|
|
5374
|
-
|
|
5375
|
-
|
|
5158
|
+
if (oldChLength === 0) {
|
|
5159
|
+
// the old list is empty, we can directly insert anything new
|
|
5160
|
+
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
5161
|
+
return;
|
|
5162
|
+
}
|
|
5376
5163
|
|
|
5377
|
-
|
|
5164
|
+
if (newChLength === 0) {
|
|
5165
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
5166
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
5167
|
+
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
5168
|
+
return;
|
|
5169
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
5170
|
+
// amount of nodes, that's why we call this static children
|
|
5378
5171
|
|
|
5379
|
-
if (vm) {
|
|
5380
|
-
appendVM(vm);
|
|
5381
|
-
}
|
|
5382
|
-
},
|
|
5383
|
-
move: (vnode, parentNode, referenceNode) => {
|
|
5384
|
-
insertNodeHook(vnode, parentNode, referenceNode);
|
|
5385
|
-
},
|
|
5386
|
-
remove: (vnode, parentNode) => {
|
|
5387
|
-
removeNodeHook(vnode, parentNode);
|
|
5388
|
-
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
5389
5172
|
|
|
5390
|
-
|
|
5391
|
-
// for custom elements we don't have to go recursively because the removeVM routine
|
|
5392
|
-
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
5393
|
-
removeVM(vm);
|
|
5394
|
-
}
|
|
5395
|
-
},
|
|
5396
|
-
hydrate: (vnode, elm) => {
|
|
5397
|
-
// the element is created, but the vm is not
|
|
5398
|
-
const {
|
|
5399
|
-
sel,
|
|
5400
|
-
mode,
|
|
5401
|
-
ctor,
|
|
5402
|
-
owner
|
|
5403
|
-
} = vnode;
|
|
5404
|
-
const def = getComponentInternalDef(ctor);
|
|
5405
|
-
createVM(elm, def, {
|
|
5406
|
-
mode,
|
|
5407
|
-
owner,
|
|
5408
|
-
tagName: sel
|
|
5409
|
-
});
|
|
5410
|
-
vnode.elm = elm;
|
|
5411
|
-
const vm = getAssociatedVM(elm);
|
|
5412
|
-
allocateChildrenHook(vnode, vm);
|
|
5413
|
-
hydrateElmHook(vnode); // Insert hook section:
|
|
5173
|
+
let referenceElm = null;
|
|
5414
5174
|
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
, `${vm} cannot be recycled.`);
|
|
5419
|
-
}
|
|
5175
|
+
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
5176
|
+
const vnode = newCh[i];
|
|
5177
|
+
const oldVNode = oldCh[i];
|
|
5420
5178
|
|
|
5421
|
-
|
|
5179
|
+
if (vnode !== oldVNode) {
|
|
5180
|
+
if (isVNode(oldVNode)) {
|
|
5181
|
+
if (isVNode(vnode)) {
|
|
5182
|
+
// both vnodes must be equivalent, and se just need to patch them
|
|
5183
|
+
patchVnode(oldVNode, vnode);
|
|
5184
|
+
referenceElm = vnode.elm;
|
|
5185
|
+
} else {
|
|
5186
|
+
// removing the old vnode since the new one is null
|
|
5187
|
+
oldVNode.hook.remove(oldVNode, parentElm);
|
|
5188
|
+
}
|
|
5189
|
+
} else if (isVNode(vnode)) {
|
|
5190
|
+
// this condition is unnecessary
|
|
5191
|
+
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
5422
5192
|
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5427
|
-
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5428
|
-
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
|
|
5193
|
+
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
5194
|
+
referenceElm = vnode.elm;
|
|
5195
|
+
}
|
|
5429
5196
|
}
|
|
5430
|
-
|
|
5431
|
-
hydrateVM(vm);
|
|
5432
5197
|
}
|
|
5433
|
-
}
|
|
5434
|
-
|
|
5435
|
-
function linkNodeToShadow(elm, owner) {
|
|
5436
|
-
const {
|
|
5437
|
-
renderMode,
|
|
5438
|
-
shadowMode
|
|
5439
|
-
} = owner; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
5198
|
+
}
|
|
5440
5199
|
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
/* Light */
|
|
5446
|
-
) {
|
|
5447
|
-
elm[KEY__SHADOW_RESOLVER] = getRenderRoot(owner)[KEY__SHADOW_RESOLVER];
|
|
5448
|
-
}
|
|
5200
|
+
function patchVnode(oldVnode, vnode) {
|
|
5201
|
+
if (oldVnode !== vnode) {
|
|
5202
|
+
vnode.elm = oldVnode.elm;
|
|
5203
|
+
vnode.hook.update(oldVnode, vnode);
|
|
5449
5204
|
}
|
|
5450
5205
|
}
|
|
5206
|
+
/*
|
|
5207
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
5208
|
+
* All rights reserved.
|
|
5209
|
+
* SPDX-License-Identifier: MIT
|
|
5210
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5211
|
+
*/
|
|
5212
|
+
|
|
5213
|
+
|
|
5214
|
+
const SymbolIterator = Symbol.iterator;
|
|
5451
5215
|
|
|
5452
5216
|
function addVNodeToChildLWC(vnode) {
|
|
5453
5217
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
|
@@ -5472,20 +5236,22 @@
|
|
|
5472
5236
|
|
|
5473
5237
|
forEach.call(children, childVnode => {
|
|
5474
5238
|
if (childVnode != null) {
|
|
5475
|
-
assert.isTrue(
|
|
5239
|
+
assert.isTrue('type' in childVnode && 'sel' in childVnode && 'elm' in childVnode && 'key' in childVnode, `${childVnode} is not a vnode.`);
|
|
5476
5240
|
}
|
|
5477
5241
|
});
|
|
5478
5242
|
}
|
|
5479
5243
|
|
|
5480
|
-
let
|
|
5244
|
+
let elm;
|
|
5481
5245
|
const {
|
|
5482
5246
|
key
|
|
5483
5247
|
} = data;
|
|
5484
5248
|
return {
|
|
5249
|
+
type: 2
|
|
5250
|
+
/* Element */
|
|
5251
|
+
,
|
|
5485
5252
|
sel,
|
|
5486
5253
|
data,
|
|
5487
5254
|
children,
|
|
5488
|
-
text,
|
|
5489
5255
|
elm,
|
|
5490
5256
|
key,
|
|
5491
5257
|
hook: ElementHook,
|
|
@@ -5566,7 +5332,7 @@
|
|
|
5566
5332
|
if (arguments.length === 4) {
|
|
5567
5333
|
forEach.call(children, childVnode => {
|
|
5568
5334
|
if (childVnode != null) {
|
|
5569
|
-
assert.isTrue(
|
|
5335
|
+
assert.isTrue('type' in childVnode && 'sel' in childVnode && 'elm' in childVnode && 'key' in childVnode, `${childVnode} is not a vnode.`);
|
|
5570
5336
|
}
|
|
5571
5337
|
});
|
|
5572
5338
|
}
|
|
@@ -5575,12 +5341,14 @@
|
|
|
5575
5341
|
const {
|
|
5576
5342
|
key
|
|
5577
5343
|
} = data;
|
|
5578
|
-
let
|
|
5344
|
+
let elm;
|
|
5579
5345
|
const vnode = {
|
|
5346
|
+
type: 3
|
|
5347
|
+
/* CustomElement */
|
|
5348
|
+
,
|
|
5580
5349
|
sel,
|
|
5581
5350
|
data,
|
|
5582
5351
|
children,
|
|
5583
|
-
text,
|
|
5584
5352
|
elm,
|
|
5585
5353
|
key,
|
|
5586
5354
|
hook: CustomElementHook,
|
|
@@ -5708,12 +5476,12 @@
|
|
|
5708
5476
|
|
|
5709
5477
|
|
|
5710
5478
|
function t(text) {
|
|
5711
|
-
|
|
5712
|
-
let sel, children, key, elm;
|
|
5479
|
+
let sel, key, elm;
|
|
5713
5480
|
return {
|
|
5481
|
+
type: 0
|
|
5482
|
+
/* Text */
|
|
5483
|
+
,
|
|
5714
5484
|
sel,
|
|
5715
|
-
data,
|
|
5716
|
-
children,
|
|
5717
5485
|
text,
|
|
5718
5486
|
elm,
|
|
5719
5487
|
key,
|
|
@@ -5724,12 +5492,12 @@
|
|
|
5724
5492
|
|
|
5725
5493
|
|
|
5726
5494
|
function co(text) {
|
|
5727
|
-
|
|
5728
|
-
let sel, children, key, elm;
|
|
5495
|
+
let sel, key, elm;
|
|
5729
5496
|
return {
|
|
5497
|
+
type: 1
|
|
5498
|
+
/* Comment */
|
|
5499
|
+
,
|
|
5730
5500
|
sel,
|
|
5731
|
-
data,
|
|
5732
|
-
children,
|
|
5733
5501
|
text,
|
|
5734
5502
|
elm,
|
|
5735
5503
|
key,
|
|
@@ -6167,7 +5935,7 @@
|
|
|
6167
5935
|
insertGlobalStylesheet$1(stylesheets[i]);
|
|
6168
5936
|
} else {
|
|
6169
5937
|
// local level
|
|
6170
|
-
insertStylesheet$1(stylesheets[i], root.
|
|
5938
|
+
insertStylesheet$1(stylesheets[i], root.shadowRoot);
|
|
6171
5939
|
}
|
|
6172
5940
|
}
|
|
6173
5941
|
}
|
|
@@ -6474,25 +6242,6 @@
|
|
|
6474
6242
|
*/
|
|
6475
6243
|
|
|
6476
6244
|
|
|
6477
|
-
function addErrorComponentStack(vm, error) {
|
|
6478
|
-
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
6479
|
-
const wcStack = getErrorComponentStack(vm);
|
|
6480
|
-
defineProperty(error, 'wcStack', {
|
|
6481
|
-
get() {
|
|
6482
|
-
return wcStack;
|
|
6483
|
-
}
|
|
6484
|
-
|
|
6485
|
-
});
|
|
6486
|
-
}
|
|
6487
|
-
}
|
|
6488
|
-
/*
|
|
6489
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
6490
|
-
* All rights reserved.
|
|
6491
|
-
* SPDX-License-Identifier: MIT
|
|
6492
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6493
|
-
*/
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
6245
|
let isInvokingRender = false;
|
|
6497
6246
|
let vmBeingConstructed = null;
|
|
6498
6247
|
|
|
@@ -6729,6 +6478,320 @@
|
|
|
6729
6478
|
cbs[i].call(undefined, component, {}, def, context);
|
|
6730
6479
|
}
|
|
6731
6480
|
}
|
|
6481
|
+
/*
|
|
6482
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
6483
|
+
* All rights reserved.
|
|
6484
|
+
* SPDX-License-Identifier: MIT
|
|
6485
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6486
|
+
*/
|
|
6487
|
+
|
|
6488
|
+
|
|
6489
|
+
function hydrate$1(vnode, node) {
|
|
6490
|
+
switch (vnode.type) {
|
|
6491
|
+
case 0
|
|
6492
|
+
/* Text */
|
|
6493
|
+
:
|
|
6494
|
+
hydrateText(vnode, node);
|
|
6495
|
+
break;
|
|
6496
|
+
|
|
6497
|
+
case 1
|
|
6498
|
+
/* Comment */
|
|
6499
|
+
:
|
|
6500
|
+
hydrateComment(vnode, node);
|
|
6501
|
+
break;
|
|
6502
|
+
|
|
6503
|
+
case 2
|
|
6504
|
+
/* Element */
|
|
6505
|
+
:
|
|
6506
|
+
hydrateElement(vnode, node);
|
|
6507
|
+
break;
|
|
6508
|
+
|
|
6509
|
+
case 3
|
|
6510
|
+
/* CustomElement */
|
|
6511
|
+
:
|
|
6512
|
+
hydrateCustomElement(vnode, node);
|
|
6513
|
+
break;
|
|
6514
|
+
}
|
|
6515
|
+
}
|
|
6516
|
+
|
|
6517
|
+
function hydrateText(vnode, node) {
|
|
6518
|
+
var _a;
|
|
6519
|
+
|
|
6520
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6521
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6522
|
+
validateNodeType(vnode, node, Node.TEXT_NODE);
|
|
6523
|
+
|
|
6524
|
+
if (node.nodeValue !== vnode.text && !(node.nodeValue === '\u200D' && vnode.text === '')) {
|
|
6525
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
6526
|
+
}
|
|
6527
|
+
} // always set the text value to the one from the vnode.
|
|
6528
|
+
|
|
6529
|
+
|
|
6530
|
+
node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
|
|
6531
|
+
vnode.elm = node;
|
|
6532
|
+
}
|
|
6533
|
+
|
|
6534
|
+
function hydrateComment(vnode, node) {
|
|
6535
|
+
var _a;
|
|
6536
|
+
|
|
6537
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6538
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6539
|
+
validateNodeType(vnode, node, Node.COMMENT_NODE);
|
|
6540
|
+
|
|
6541
|
+
if (node.nodeValue !== vnode.text) {
|
|
6542
|
+
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
6543
|
+
}
|
|
6544
|
+
} // always set the text value to the one from the vnode.
|
|
6545
|
+
|
|
6546
|
+
|
|
6547
|
+
node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
|
|
6548
|
+
vnode.elm = node;
|
|
6549
|
+
}
|
|
6550
|
+
|
|
6551
|
+
function hydrateElement(vnode, node) {
|
|
6552
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6553
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6554
|
+
validateNodeType(vnode, node, Node.ELEMENT_NODE);
|
|
6555
|
+
validateElement(vnode, node);
|
|
6556
|
+
}
|
|
6557
|
+
|
|
6558
|
+
const elm = node;
|
|
6559
|
+
vnode.elm = elm;
|
|
6560
|
+
const {
|
|
6561
|
+
context
|
|
6562
|
+
} = vnode.data;
|
|
6563
|
+
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
6564
|
+
/* Manual */
|
|
6565
|
+
);
|
|
6566
|
+
|
|
6567
|
+
if (isDomManual) {
|
|
6568
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
6569
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
6570
|
+
const {
|
|
6571
|
+
props
|
|
6572
|
+
} = vnode.data;
|
|
6573
|
+
|
|
6574
|
+
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
6575
|
+
if (elm.innerHTML === props.innerHTML) {
|
|
6576
|
+
delete props.innerHTML;
|
|
6577
|
+
} else {
|
|
6578
|
+
logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
6579
|
+
}
|
|
6580
|
+
}
|
|
6581
|
+
}
|
|
6582
|
+
|
|
6583
|
+
patchElementPropsAndAttrs(vnode);
|
|
6584
|
+
|
|
6585
|
+
if (!isDomManual) {
|
|
6586
|
+
hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
6587
|
+
}
|
|
6588
|
+
}
|
|
6589
|
+
|
|
6590
|
+
function hydrateCustomElement(vnode, node) {
|
|
6591
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6592
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
6593
|
+
validateNodeType(vnode, node, Node.ELEMENT_NODE);
|
|
6594
|
+
validateElement(vnode, node);
|
|
6595
|
+
}
|
|
6596
|
+
|
|
6597
|
+
const elm = node;
|
|
6598
|
+
vnode.elm = elm;
|
|
6599
|
+
const {
|
|
6600
|
+
sel,
|
|
6601
|
+
mode,
|
|
6602
|
+
ctor,
|
|
6603
|
+
owner
|
|
6604
|
+
} = vnode;
|
|
6605
|
+
const vm = createVM(elm, ctor, {
|
|
6606
|
+
mode,
|
|
6607
|
+
owner,
|
|
6608
|
+
tagName: sel
|
|
6609
|
+
});
|
|
6610
|
+
allocateChildren(vnode, vm);
|
|
6611
|
+
patchElementPropsAndAttrs(vnode); // Insert hook section:
|
|
6612
|
+
|
|
6613
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6614
|
+
assert.isTrue(vm.state === 0
|
|
6615
|
+
/* created */
|
|
6616
|
+
, `${vm} cannot be recycled.`);
|
|
6617
|
+
}
|
|
6618
|
+
|
|
6619
|
+
runConnectedCallback(vm);
|
|
6620
|
+
|
|
6621
|
+
if (vm.renderMode !== 0
|
|
6622
|
+
/* Light */
|
|
6623
|
+
) {
|
|
6624
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
6625
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
6626
|
+
hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
|
|
6627
|
+
}
|
|
6628
|
+
|
|
6629
|
+
hydrateVM(vm);
|
|
6630
|
+
}
|
|
6631
|
+
|
|
6632
|
+
function hydrateChildren(elmChildren, children, vm) {
|
|
6633
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6634
|
+
const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
|
|
6635
|
+
|
|
6636
|
+
if (elmChildren.length !== filteredVNodes.length) {
|
|
6637
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
6638
|
+
throwHydrationError();
|
|
6639
|
+
}
|
|
6640
|
+
}
|
|
6641
|
+
|
|
6642
|
+
let childNodeIndex = 0;
|
|
6643
|
+
|
|
6644
|
+
for (let i = 0; i < children.length; i++) {
|
|
6645
|
+
const childVnode = children[i];
|
|
6646
|
+
|
|
6647
|
+
if (!isNull(childVnode)) {
|
|
6648
|
+
const childNode = elmChildren[childNodeIndex];
|
|
6649
|
+
hydrate$1(childVnode, childNode);
|
|
6650
|
+
childNodeIndex++;
|
|
6651
|
+
}
|
|
6652
|
+
}
|
|
6653
|
+
}
|
|
6654
|
+
|
|
6655
|
+
function patchElementPropsAndAttrs(vnode) {
|
|
6656
|
+
applyEventListeners(vnode);
|
|
6657
|
+
patchProps(null, vnode);
|
|
6658
|
+
}
|
|
6659
|
+
|
|
6660
|
+
function throwHydrationError() {
|
|
6661
|
+
assert.fail('Server rendered elements do not match client side generated elements');
|
|
6662
|
+
}
|
|
6663
|
+
|
|
6664
|
+
function validateNodeType(vnode, node, nodeType) {
|
|
6665
|
+
if (node.nodeType !== nodeType) {
|
|
6666
|
+
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6667
|
+
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
6668
|
+
}
|
|
6669
|
+
}
|
|
6670
|
+
|
|
6671
|
+
function validateElement(vnode, elm) {
|
|
6672
|
+
if (vnode.sel.toLowerCase() !== elm.tagName.toLowerCase()) {
|
|
6673
|
+
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${elm.tagName.toLowerCase()}".`, vnode.owner);
|
|
6674
|
+
throwHydrationError();
|
|
6675
|
+
}
|
|
6676
|
+
|
|
6677
|
+
const hasIncompatibleAttrs = validateAttrs(vnode, elm);
|
|
6678
|
+
const hasIncompatibleClass = validateClassAttr(vnode, elm);
|
|
6679
|
+
const hasIncompatibleStyle = validateStyleAttr(vnode, elm);
|
|
6680
|
+
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
6681
|
+
|
|
6682
|
+
if (!isVNodeAndElementCompatible) {
|
|
6683
|
+
throwHydrationError();
|
|
6684
|
+
}
|
|
6685
|
+
}
|
|
6686
|
+
|
|
6687
|
+
function validateAttrs(vnode, elm) {
|
|
6688
|
+
const {
|
|
6689
|
+
data: {
|
|
6690
|
+
attrs = {}
|
|
6691
|
+
}
|
|
6692
|
+
} = vnode;
|
|
6693
|
+
let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
|
|
6694
|
+
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
6695
|
+
|
|
6696
|
+
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
6697
|
+
const elmAttrValue = getAttribute$1(elm, attrName);
|
|
6698
|
+
|
|
6699
|
+
if (String(attrValue) !== elmAttrValue) {
|
|
6700
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
6701
|
+
nodesAreCompatible = false;
|
|
6702
|
+
}
|
|
6703
|
+
}
|
|
6704
|
+
|
|
6705
|
+
return nodesAreCompatible;
|
|
6706
|
+
}
|
|
6707
|
+
|
|
6708
|
+
function validateClassAttr(vnode, elm) {
|
|
6709
|
+
const {
|
|
6710
|
+
data: {
|
|
6711
|
+
className,
|
|
6712
|
+
classMap
|
|
6713
|
+
}
|
|
6714
|
+
} = vnode;
|
|
6715
|
+
let nodesAreCompatible = true;
|
|
6716
|
+
let vnodeClassName;
|
|
6717
|
+
|
|
6718
|
+
if (!isUndefined$1(className) && String(className) !== elm.className) {
|
|
6719
|
+
// className is used when class is bound to an expr.
|
|
6720
|
+
nodesAreCompatible = false;
|
|
6721
|
+
vnodeClassName = className;
|
|
6722
|
+
} else if (!isUndefined$1(classMap)) {
|
|
6723
|
+
// classMap is used when class is set to static value.
|
|
6724
|
+
const classList = getClassList$1(elm);
|
|
6725
|
+
let computedClassName = ''; // all classes from the vnode should be in the element.classList
|
|
6726
|
+
|
|
6727
|
+
for (const name in classMap) {
|
|
6728
|
+
computedClassName += ' ' + name;
|
|
6729
|
+
|
|
6730
|
+
if (!classList.contains(name)) {
|
|
6731
|
+
nodesAreCompatible = false;
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
|
|
6735
|
+
vnodeClassName = computedClassName.trim();
|
|
6736
|
+
|
|
6737
|
+
if (classList.length > keys(classMap).length) {
|
|
6738
|
+
nodesAreCompatible = false;
|
|
6739
|
+
}
|
|
6740
|
+
}
|
|
6741
|
+
|
|
6742
|
+
if (!nodesAreCompatible) {
|
|
6743
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
|
|
6744
|
+
}
|
|
6745
|
+
|
|
6746
|
+
return nodesAreCompatible;
|
|
6747
|
+
}
|
|
6748
|
+
|
|
6749
|
+
function validateStyleAttr(vnode, elm) {
|
|
6750
|
+
const {
|
|
6751
|
+
data: {
|
|
6752
|
+
style,
|
|
6753
|
+
styleDecls
|
|
6754
|
+
}
|
|
6755
|
+
} = vnode;
|
|
6756
|
+
const elmStyle = getAttribute$1(elm, 'style') || '';
|
|
6757
|
+
let vnodeStyle;
|
|
6758
|
+
let nodesAreCompatible = true;
|
|
6759
|
+
|
|
6760
|
+
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
6761
|
+
nodesAreCompatible = false;
|
|
6762
|
+
vnodeStyle = style;
|
|
6763
|
+
} else if (!isUndefined$1(styleDecls)) {
|
|
6764
|
+
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
6765
|
+
const expectedStyle = []; // styleMap is used when style is set to static value.
|
|
6766
|
+
|
|
6767
|
+
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
6768
|
+
const [prop, value, important] = styleDecls[i];
|
|
6769
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
6770
|
+
const parsedPropValue = parsedVnodeStyle[prop];
|
|
6771
|
+
|
|
6772
|
+
if (isUndefined$1(parsedPropValue)) {
|
|
6773
|
+
nodesAreCompatible = false;
|
|
6774
|
+
} else if (!parsedPropValue.startsWith(value)) {
|
|
6775
|
+
nodesAreCompatible = false;
|
|
6776
|
+
} else if (important && !parsedPropValue.endsWith('!important')) {
|
|
6777
|
+
nodesAreCompatible = false;
|
|
6778
|
+
}
|
|
6779
|
+
}
|
|
6780
|
+
|
|
6781
|
+
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
6782
|
+
nodesAreCompatible = false;
|
|
6783
|
+
}
|
|
6784
|
+
|
|
6785
|
+
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
6786
|
+
}
|
|
6787
|
+
|
|
6788
|
+
if (!nodesAreCompatible) {
|
|
6789
|
+
// style is used when class is bound to an expr.
|
|
6790
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6791
|
+
}
|
|
6792
|
+
|
|
6793
|
+
return nodesAreCompatible;
|
|
6794
|
+
}
|
|
6732
6795
|
/*
|
|
6733
6796
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6734
6797
|
* All rights reserved.
|
|
@@ -6855,12 +6918,13 @@
|
|
|
6855
6918
|
return ancestor;
|
|
6856
6919
|
}
|
|
6857
6920
|
|
|
6858
|
-
function createVM(elm,
|
|
6921
|
+
function createVM(elm, ctor, options) {
|
|
6859
6922
|
const {
|
|
6860
6923
|
mode,
|
|
6861
6924
|
owner,
|
|
6862
6925
|
tagName
|
|
6863
6926
|
} = options;
|
|
6927
|
+
const def = getComponentInternalDef(ctor);
|
|
6864
6928
|
const vm = {
|
|
6865
6929
|
elm,
|
|
6866
6930
|
def,
|
|
@@ -6882,7 +6946,6 @@
|
|
|
6882
6946
|
oar: create(null),
|
|
6883
6947
|
cmpTemplate: null,
|
|
6884
6948
|
renderMode: def.renderMode,
|
|
6885
|
-
shadowMode: null,
|
|
6886
6949
|
context: {
|
|
6887
6950
|
stylesheetToken: undefined,
|
|
6888
6951
|
hasTokenInClass: undefined,
|
|
@@ -6893,9 +6956,13 @@
|
|
|
6893
6956
|
wiredConnecting: EmptyArray,
|
|
6894
6957
|
wiredDisconnecting: EmptyArray
|
|
6895
6958
|
},
|
|
6959
|
+
// Properties set right after VM creation.
|
|
6896
6960
|
tro: null,
|
|
6961
|
+
shadowMode: null,
|
|
6962
|
+
// Properties set by the LightningElement constructor.
|
|
6897
6963
|
component: null,
|
|
6898
|
-
|
|
6964
|
+
shadowRoot: null,
|
|
6965
|
+
renderRoot: null,
|
|
6899
6966
|
callHook,
|
|
6900
6967
|
setHook,
|
|
6901
6968
|
getHook
|
|
@@ -6983,7 +7050,7 @@
|
|
|
6983
7050
|
}
|
|
6984
7051
|
|
|
6985
7052
|
function assertIsVM(obj) {
|
|
6986
|
-
if (isNull(obj) || !isObject(obj) || !('
|
|
7053
|
+
if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
|
|
6987
7054
|
throw new TypeError(`${obj} is not a VM.`);
|
|
6988
7055
|
}
|
|
6989
7056
|
}
|
|
@@ -7032,13 +7099,14 @@
|
|
|
7032
7099
|
const vmChildren = vm.renderMode === 0
|
|
7033
7100
|
/* Light */
|
|
7034
7101
|
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
7035
|
-
|
|
7102
|
+
hydrateChildren(vmChildren, children, vm);
|
|
7036
7103
|
runRenderedCallback(vm);
|
|
7037
7104
|
}
|
|
7038
7105
|
}
|
|
7039
7106
|
|
|
7040
7107
|
function patchShadowRoot(vm, newCh) {
|
|
7041
7108
|
const {
|
|
7109
|
+
renderRoot,
|
|
7042
7110
|
children: oldCh
|
|
7043
7111
|
} = vm; // caching the new children collection
|
|
7044
7112
|
|
|
@@ -7055,7 +7123,6 @@
|
|
|
7055
7123
|
, vm);
|
|
7056
7124
|
}, () => {
|
|
7057
7125
|
// job
|
|
7058
|
-
const renderRoot = getRenderRoot(vm);
|
|
7059
7126
|
patchChildren(renderRoot, oldCh, newCh);
|
|
7060
7127
|
}, () => {
|
|
7061
7128
|
// post
|
|
@@ -7291,14 +7358,22 @@
|
|
|
7291
7358
|
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
7292
7359
|
const vnode = vnodes[i];
|
|
7293
7360
|
|
|
7294
|
-
if (!isNull(vnode) &&
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7361
|
+
if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
|
|
7362
|
+
switch (vnode.type) {
|
|
7363
|
+
case 2
|
|
7364
|
+
/* Element */
|
|
7365
|
+
:
|
|
7366
|
+
recursivelyDisconnectChildren(vnode.children);
|
|
7367
|
+
break;
|
|
7368
|
+
|
|
7369
|
+
case 3
|
|
7370
|
+
/* CustomElement */
|
|
7371
|
+
:
|
|
7372
|
+
{
|
|
7373
|
+
const vm = getAssociatedVM(vnode.elm);
|
|
7374
|
+
resetComponentStateWhenRemoved(vm);
|
|
7375
|
+
break;
|
|
7376
|
+
}
|
|
7302
7377
|
}
|
|
7303
7378
|
}
|
|
7304
7379
|
}
|
|
@@ -7310,15 +7385,15 @@
|
|
|
7310
7385
|
|
|
7311
7386
|
function resetComponentRoot(vm) {
|
|
7312
7387
|
const {
|
|
7313
|
-
children
|
|
7388
|
+
children,
|
|
7389
|
+
renderRoot
|
|
7314
7390
|
} = vm;
|
|
7315
|
-
const rootNode = getRenderRoot(vm);
|
|
7316
7391
|
|
|
7317
7392
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
7318
7393
|
const child = children[i];
|
|
7319
7394
|
|
|
7320
7395
|
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
7321
|
-
remove$1(child.elm,
|
|
7396
|
+
remove$1(child.elm, renderRoot);
|
|
7322
7397
|
}
|
|
7323
7398
|
}
|
|
7324
7399
|
|
|
@@ -7404,12 +7479,6 @@
|
|
|
7404
7479
|
scheduleRehydration(vm);
|
|
7405
7480
|
}
|
|
7406
7481
|
}
|
|
7407
|
-
|
|
7408
|
-
function getRenderRoot(vm) {
|
|
7409
|
-
return vm.renderMode === 1
|
|
7410
|
-
/* Shadow */
|
|
7411
|
-
? vm.cmpRoot : vm.elm;
|
|
7412
|
-
}
|
|
7413
7482
|
/*
|
|
7414
7483
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
7415
7484
|
* All rights reserved.
|
|
@@ -7801,7 +7870,7 @@
|
|
|
7801
7870
|
hooksAreSet = true;
|
|
7802
7871
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7803
7872
|
}
|
|
7804
|
-
/* version: 2.7.
|
|
7873
|
+
/* version: 2.7.4 */
|
|
7805
7874
|
|
|
7806
7875
|
/*
|
|
7807
7876
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8265,8 +8334,7 @@
|
|
|
8265
8334
|
*/
|
|
8266
8335
|
|
|
8267
8336
|
const element = new UpgradableConstructor(elm => {
|
|
8268
|
-
|
|
8269
|
-
createVM(elm, def, {
|
|
8337
|
+
createVM(elm, Ctor, {
|
|
8270
8338
|
tagName: sel,
|
|
8271
8339
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
8272
8340
|
owner: null
|
|
@@ -8304,13 +8372,11 @@
|
|
|
8304
8372
|
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8305
8373
|
}
|
|
8306
8374
|
|
|
8307
|
-
const def = getComponentInternalDef(Ctor);
|
|
8308
|
-
|
|
8309
8375
|
try {
|
|
8310
8376
|
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8311
8377
|
// and uses the same algo to create the stylesheets as in SSR.
|
|
8312
8378
|
setIsHydrating(true);
|
|
8313
|
-
createVM(element,
|
|
8379
|
+
createVM(element, Ctor, {
|
|
8314
8380
|
mode: 'open',
|
|
8315
8381
|
owner: null,
|
|
8316
8382
|
tagName: element.tagName.toLowerCase()
|
|
@@ -8376,11 +8442,11 @@
|
|
|
8376
8442
|
}
|
|
8377
8443
|
|
|
8378
8444
|
function buildCustomElementConstructor(Ctor) {
|
|
8379
|
-
const
|
|
8380
|
-
return class extends
|
|
8445
|
+
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
8446
|
+
return class extends HtmlPrototype {
|
|
8381
8447
|
constructor() {
|
|
8382
8448
|
super();
|
|
8383
|
-
createVM(this,
|
|
8449
|
+
createVM(this, Ctor, {
|
|
8384
8450
|
mode: 'open',
|
|
8385
8451
|
owner: null,
|
|
8386
8452
|
tagName: this.tagName
|
|
@@ -8503,7 +8569,7 @@
|
|
|
8503
8569
|
});
|
|
8504
8570
|
freeze(LightningElement);
|
|
8505
8571
|
seal(LightningElement.prototype);
|
|
8506
|
-
/* version: 2.7.
|
|
8572
|
+
/* version: 2.7.4 */
|
|
8507
8573
|
|
|
8508
8574
|
exports.LightningElement = LightningElement;
|
|
8509
8575
|
exports.__unstable__ProfilerControl = profilerControl;
|