lwc 2.7.2 → 2.7.3
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 +1970 -2104
- package/dist/engine-dom/iife/es2017/engine-dom.js +1970 -2104
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +1157 -1283
- package/dist/engine-dom/iife/es5/engine-dom.js +1677 -1805
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +1949 -2069
- package/dist/engine-dom/umd/es2017/engine-dom.js +1970 -2104
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +1157 -1283
- package/dist/engine-dom/umd/es5/engine-dom.js +1677 -1805
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +1949 -2069
- package/dist/engine-server/commonjs/es2017/engine-server.js +1322 -1456
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +1322 -1456
- 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
|
@@ -335,7 +335,7 @@ function htmlPropertyToAttribute(propName) {
|
|
|
335
335
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
336
336
|
return attributeName;
|
|
337
337
|
}
|
|
338
|
-
/** version: 2.7.
|
|
338
|
+
/** version: 2.7.3 */
|
|
339
339
|
|
|
340
340
|
/*
|
|
341
341
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -457,7 +457,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
457
457
|
setFeatureFlag(name, value);
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
/** version: 2.7.
|
|
460
|
+
/** version: 2.7.3 */
|
|
461
461
|
|
|
462
462
|
/* proxy-compat-disable */
|
|
463
463
|
|
|
@@ -991,62 +991,205 @@ function logWarn(message, vm) {
|
|
|
991
991
|
*/
|
|
992
992
|
|
|
993
993
|
|
|
994
|
-
function
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
994
|
+
function isUndef(s) {
|
|
995
|
+
return s === undefined;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function sameVnode(vnode1, vnode2) {
|
|
999
|
+
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function isVNode(vnode) {
|
|
1003
|
+
return vnode != null;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
1007
|
+
const map = {};
|
|
1008
|
+
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
1009
|
+
|
|
1010
|
+
for (j = beginIdx; j <= endIdx; ++j) {
|
|
1011
|
+
ch = children[j];
|
|
1004
1012
|
|
|
1005
|
-
|
|
1006
|
-
|
|
1013
|
+
if (isVNode(ch)) {
|
|
1014
|
+
key = ch.key;
|
|
1015
|
+
|
|
1016
|
+
if (key !== undefined) {
|
|
1017
|
+
map[key] = j;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1007
1020
|
}
|
|
1021
|
+
|
|
1022
|
+
return map;
|
|
1008
1023
|
}
|
|
1009
1024
|
|
|
1010
|
-
function
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1025
|
+
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
1026
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
1027
|
+
const ch = vnodes[startIdx];
|
|
1028
|
+
|
|
1029
|
+
if (isVNode(ch)) {
|
|
1030
|
+
ch.hook.create(ch);
|
|
1031
|
+
ch.hook.insert(ch, parentElm, before);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1014
1034
|
}
|
|
1015
1035
|
|
|
1016
|
-
function
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1036
|
+
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
1037
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
1038
|
+
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
1039
|
+
|
|
1040
|
+
if (isVNode(ch)) {
|
|
1041
|
+
ch.hook.remove(ch, parentElm);
|
|
1042
|
+
}
|
|
1022
1043
|
}
|
|
1023
1044
|
}
|
|
1024
1045
|
|
|
1025
|
-
function
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1046
|
+
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
1047
|
+
let oldStartIdx = 0;
|
|
1048
|
+
let newStartIdx = 0;
|
|
1049
|
+
let oldEndIdx = oldCh.length - 1;
|
|
1050
|
+
let oldStartVnode = oldCh[0];
|
|
1051
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
1052
|
+
const newChEnd = newCh.length - 1;
|
|
1053
|
+
let newEndIdx = newChEnd;
|
|
1054
|
+
let newStartVnode = newCh[0];
|
|
1055
|
+
let newEndVnode = newCh[newEndIdx];
|
|
1056
|
+
let oldKeyToIdx;
|
|
1057
|
+
let idxInOld;
|
|
1058
|
+
let elmToMove;
|
|
1059
|
+
let before;
|
|
1060
|
+
|
|
1061
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
1062
|
+
if (!isVNode(oldStartVnode)) {
|
|
1063
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
1064
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
1065
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
1066
|
+
} else if (!isVNode(newStartVnode)) {
|
|
1067
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1068
|
+
} else if (!isVNode(newEndVnode)) {
|
|
1069
|
+
newEndVnode = newCh[--newEndIdx];
|
|
1070
|
+
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
1071
|
+
patchVnode(oldStartVnode, newStartVnode);
|
|
1072
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
1073
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1074
|
+
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
1075
|
+
patchVnode(oldEndVnode, newEndVnode);
|
|
1076
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
1077
|
+
newEndVnode = newCh[--newEndIdx];
|
|
1078
|
+
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
1079
|
+
// Vnode moved right
|
|
1080
|
+
patchVnode(oldStartVnode, newEndVnode);
|
|
1081
|
+
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
|
|
1082
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
1083
|
+
newEndVnode = newCh[--newEndIdx];
|
|
1084
|
+
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
1085
|
+
// Vnode moved left
|
|
1086
|
+
patchVnode(oldEndVnode, newStartVnode);
|
|
1087
|
+
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
1088
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
1089
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1090
|
+
} else {
|
|
1091
|
+
if (oldKeyToIdx === undefined) {
|
|
1092
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
1096
|
+
|
|
1097
|
+
if (isUndef(idxInOld)) {
|
|
1098
|
+
// New element
|
|
1099
|
+
newStartVnode.hook.create(newStartVnode);
|
|
1100
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1101
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1102
|
+
} else {
|
|
1103
|
+
elmToMove = oldCh[idxInOld];
|
|
1104
|
+
|
|
1105
|
+
if (isVNode(elmToMove)) {
|
|
1106
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
1107
|
+
// New element
|
|
1108
|
+
newStartVnode.hook.create(newStartVnode);
|
|
1109
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1110
|
+
} else {
|
|
1111
|
+
patchVnode(elmToMove, newStartVnode);
|
|
1112
|
+
oldCh[idxInOld] = undefined;
|
|
1113
|
+
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1118
|
+
}
|
|
1030
1119
|
}
|
|
1031
|
-
}
|
|
1120
|
+
}
|
|
1032
1121
|
|
|
1033
|
-
if (
|
|
1122
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
1123
|
+
if (oldStartIdx > oldEndIdx) {
|
|
1124
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
1125
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
1126
|
+
let i = newEndIdx;
|
|
1127
|
+
let n;
|
|
1128
|
+
|
|
1129
|
+
do {
|
|
1130
|
+
n = newCh[++i];
|
|
1131
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
1132
|
+
|
|
1133
|
+
before = isVNode(n) ? n.elm : null;
|
|
1134
|
+
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
1135
|
+
} else {
|
|
1136
|
+
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
1142
|
+
const oldChLength = oldCh.length;
|
|
1143
|
+
const newChLength = newCh.length;
|
|
1144
|
+
|
|
1145
|
+
if (oldChLength === 0) {
|
|
1146
|
+
// the old list is empty, we can directly insert anything new
|
|
1147
|
+
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
1034
1148
|
return;
|
|
1035
1149
|
}
|
|
1036
1150
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1151
|
+
if (newChLength === 0) {
|
|
1152
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
1153
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
1154
|
+
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
1155
|
+
return;
|
|
1156
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
1157
|
+
// amount of nodes, that's why we call this static children
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
let referenceElm = null;
|
|
1161
|
+
|
|
1162
|
+
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
1163
|
+
const vnode = newCh[i];
|
|
1164
|
+
const oldVNode = oldCh[i];
|
|
1165
|
+
|
|
1166
|
+
if (vnode !== oldVNode) {
|
|
1167
|
+
if (isVNode(oldVNode)) {
|
|
1168
|
+
if (isVNode(vnode)) {
|
|
1169
|
+
// both vnodes must be equivalent, and se just need to patch them
|
|
1170
|
+
patchVnode(oldVNode, vnode);
|
|
1171
|
+
referenceElm = vnode.elm;
|
|
1172
|
+
} else {
|
|
1173
|
+
// removing the old vnode since the new one is null
|
|
1174
|
+
oldVNode.hook.remove(oldVNode, parentElm);
|
|
1175
|
+
}
|
|
1176
|
+
} else if (isVNode(vnode)) {
|
|
1177
|
+
// this condition is unnecessary
|
|
1178
|
+
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
1040
1179
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1180
|
+
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
1181
|
+
referenceElm = vnode.elm;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1043
1184
|
}
|
|
1044
1185
|
}
|
|
1045
1186
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1187
|
+
function patchVnode(oldVnode, vnode) {
|
|
1188
|
+
if (oldVnode !== vnode) {
|
|
1189
|
+
vnode.elm = oldVnode.elm;
|
|
1190
|
+
vnode.hook.update(oldVnode, vnode);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1050
1193
|
/*
|
|
1051
1194
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1052
1195
|
* All rights reserved.
|
|
@@ -1054,6 +1197,7 @@ var modEvents = {
|
|
|
1054
1197
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1055
1198
|
*/
|
|
1056
1199
|
|
|
1200
|
+
|
|
1057
1201
|
const defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
|
|
1058
1202
|
|
|
1059
1203
|
function offsetPropertyErrorMessage(name) {
|
|
@@ -1173,313 +1317,379 @@ function unlockAttribute(elm, key) {
|
|
|
1173
1317
|
*/
|
|
1174
1318
|
|
|
1175
1319
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
attrs
|
|
1184
|
-
}
|
|
1185
|
-
} = vnode;
|
|
1320
|
+
function generateDataDescriptor(options) {
|
|
1321
|
+
return assign({
|
|
1322
|
+
configurable: true,
|
|
1323
|
+
enumerable: true,
|
|
1324
|
+
writable: true
|
|
1325
|
+
}, options);
|
|
1326
|
+
}
|
|
1186
1327
|
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1328
|
+
function generateAccessorDescriptor(options) {
|
|
1329
|
+
return assign({
|
|
1330
|
+
configurable: true,
|
|
1331
|
+
enumerable: true
|
|
1332
|
+
}, options);
|
|
1333
|
+
}
|
|
1190
1334
|
|
|
1191
|
-
|
|
1192
|
-
data: {
|
|
1193
|
-
attrs: oldAttrs
|
|
1194
|
-
}
|
|
1195
|
-
} = oldVnode;
|
|
1335
|
+
let isDomMutationAllowed = false;
|
|
1196
1336
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1337
|
+
function unlockDomMutation() {
|
|
1338
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1339
|
+
// this method should never leak to prod
|
|
1340
|
+
throw new ReferenceError();
|
|
1199
1341
|
}
|
|
1200
1342
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1343
|
+
isDomMutationAllowed = true;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
function lockDomMutation() {
|
|
1347
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1348
|
+
// this method should never leak to prod
|
|
1349
|
+
throw new ReferenceError();
|
|
1203
1350
|
}
|
|
1204
1351
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
oldAttrs = isUndefined$1(oldAttrs) ? EmptyObject : oldAttrs; // update modified attributes, add new attributes
|
|
1208
|
-
// this routine is only useful for data-* attributes in all kind of elements
|
|
1209
|
-
// and aria-* in standard elements (custom elements will use props for these)
|
|
1352
|
+
isDomMutationAllowed = false;
|
|
1353
|
+
}
|
|
1210
1354
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1355
|
+
function logMissingPortalError(name, type) {
|
|
1356
|
+
return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
|
|
1357
|
+
}
|
|
1214
1358
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1359
|
+
function patchElementWithRestrictions(elm, options) {
|
|
1360
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1361
|
+
// this method should never leak to prod
|
|
1362
|
+
throw new ReferenceError();
|
|
1363
|
+
}
|
|
1217
1364
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
setAttribute$1(elm, key, cur);
|
|
1365
|
+
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1366
|
+
const descriptors = {
|
|
1367
|
+
outerHTML: generateAccessorDescriptor({
|
|
1368
|
+
get() {
|
|
1369
|
+
return originalOuterHTMLDescriptor.get.call(this);
|
|
1370
|
+
},
|
|
1371
|
+
|
|
1372
|
+
set(_value) {
|
|
1373
|
+
throw new TypeError(`Invalid attempt to set outerHTML on Element.`);
|
|
1228
1374
|
}
|
|
1229
1375
|
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1376
|
+
})
|
|
1377
|
+
}; // Apply extra restriction related to DOM manipulation if the element is not a portal.
|
|
1234
1378
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1379
|
+
if (!options.isLight && !options.isPortal) {
|
|
1380
|
+
const {
|
|
1381
|
+
appendChild,
|
|
1382
|
+
insertBefore,
|
|
1383
|
+
removeChild,
|
|
1384
|
+
replaceChild
|
|
1385
|
+
} = elm;
|
|
1386
|
+
const originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
|
|
1387
|
+
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
1388
|
+
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
|
1389
|
+
assign(descriptors, {
|
|
1390
|
+
appendChild: generateDataDescriptor({
|
|
1391
|
+
value(aChild) {
|
|
1392
|
+
logMissingPortalError('appendChild', 'method');
|
|
1393
|
+
return appendChild.call(this, aChild);
|
|
1394
|
+
}
|
|
1248
1395
|
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1396
|
+
}),
|
|
1397
|
+
insertBefore: generateDataDescriptor({
|
|
1398
|
+
value(newNode, referenceNode) {
|
|
1399
|
+
if (!isDomMutationAllowed) {
|
|
1400
|
+
logMissingPortalError('insertBefore', 'method');
|
|
1401
|
+
}
|
|
1254
1402
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1403
|
+
return insertBefore.call(this, newNode, referenceNode);
|
|
1404
|
+
}
|
|
1257
1405
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1406
|
+
}),
|
|
1407
|
+
removeChild: generateDataDescriptor({
|
|
1408
|
+
value(aChild) {
|
|
1409
|
+
if (!isDomMutationAllowed) {
|
|
1410
|
+
logMissingPortalError('removeChild', 'method');
|
|
1411
|
+
}
|
|
1261
1412
|
|
|
1262
|
-
|
|
1413
|
+
return removeChild.call(this, aChild);
|
|
1414
|
+
}
|
|
1263
1415
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1416
|
+
}),
|
|
1417
|
+
replaceChild: generateDataDescriptor({
|
|
1418
|
+
value(newChild, oldChild) {
|
|
1419
|
+
logMissingPortalError('replaceChild', 'method');
|
|
1420
|
+
return replaceChild.call(this, newChild, oldChild);
|
|
1421
|
+
}
|
|
1267
1422
|
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1423
|
+
}),
|
|
1424
|
+
nodeValue: generateAccessorDescriptor({
|
|
1425
|
+
get() {
|
|
1426
|
+
return originalNodeValueDescriptor.get.call(this);
|
|
1427
|
+
},
|
|
1271
1428
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
} = vnode;
|
|
1429
|
+
set(value) {
|
|
1430
|
+
if (!isDomMutationAllowed) {
|
|
1431
|
+
logMissingPortalError('nodeValue', 'property');
|
|
1432
|
+
}
|
|
1277
1433
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1434
|
+
originalNodeValueDescriptor.set.call(this, value);
|
|
1435
|
+
}
|
|
1280
1436
|
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
}
|
|
1437
|
+
}),
|
|
1438
|
+
textContent: generateAccessorDescriptor({
|
|
1439
|
+
get() {
|
|
1440
|
+
return originalTextContentDescriptor.get.call(this);
|
|
1441
|
+
},
|
|
1286
1442
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
create: vnode => update(emptyVNode$2, vnode),
|
|
1292
|
-
update
|
|
1293
|
-
};
|
|
1294
|
-
/*
|
|
1295
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1296
|
-
* All rights reserved.
|
|
1297
|
-
* SPDX-License-Identifier: MIT
|
|
1298
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1299
|
-
*/
|
|
1443
|
+
set(value) {
|
|
1444
|
+
logMissingPortalError('textContent', 'property');
|
|
1445
|
+
originalTextContentDescriptor.set.call(this, value);
|
|
1446
|
+
}
|
|
1300
1447
|
|
|
1301
|
-
|
|
1448
|
+
}),
|
|
1449
|
+
innerHTML: generateAccessorDescriptor({
|
|
1450
|
+
get() {
|
|
1451
|
+
return originalInnerHTMLDescriptor.get.call(this);
|
|
1452
|
+
},
|
|
1302
1453
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
} // computed class names must be string
|
|
1454
|
+
set(value) {
|
|
1455
|
+
logMissingPortalError('innerHTML', 'property');
|
|
1456
|
+
return originalInnerHTMLDescriptor.set.call(this, value);
|
|
1457
|
+
}
|
|
1308
1458
|
|
|
1459
|
+
})
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1309
1462
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1463
|
+
defineProperties(elm, descriptors);
|
|
1464
|
+
}
|
|
1312
1465
|
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1466
|
+
function getShadowRootRestrictionsDescriptors(sr) {
|
|
1467
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1468
|
+
// this method should never leak to prod
|
|
1469
|
+
throw new ReferenceError();
|
|
1470
|
+
} // Disallowing properties in dev mode only to avoid people doing the wrong
|
|
1471
|
+
// thing when using the real shadow root, because if that's the case,
|
|
1472
|
+
// the component will not work when running with synthetic shadow.
|
|
1316
1473
|
|
|
1317
|
-
map = create(null);
|
|
1318
|
-
let start = 0;
|
|
1319
|
-
let o;
|
|
1320
|
-
const len = className.length;
|
|
1321
1474
|
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1475
|
+
const originalAddEventListener = sr.addEventListener;
|
|
1476
|
+
const originalInnerHTMLDescriptor = getPropertyDescriptor(sr, 'innerHTML');
|
|
1477
|
+
const originalTextContentDescriptor = getPropertyDescriptor(sr, 'textContent');
|
|
1478
|
+
return {
|
|
1479
|
+
innerHTML: generateAccessorDescriptor({
|
|
1480
|
+
get() {
|
|
1481
|
+
return originalInnerHTMLDescriptor.get.call(this);
|
|
1482
|
+
},
|
|
1483
|
+
|
|
1484
|
+
set(_value) {
|
|
1485
|
+
throw new TypeError(`Invalid attempt to set innerHTML on ShadowRoot.`);
|
|
1326
1486
|
}
|
|
1327
1487
|
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1488
|
+
}),
|
|
1489
|
+
textContent: generateAccessorDescriptor({
|
|
1490
|
+
get() {
|
|
1491
|
+
return originalTextContentDescriptor.get.call(this);
|
|
1492
|
+
},
|
|
1331
1493
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1494
|
+
set(_value) {
|
|
1495
|
+
throw new TypeError(`Invalid attempt to set textContent on ShadowRoot.`);
|
|
1496
|
+
}
|
|
1335
1497
|
|
|
1336
|
-
|
|
1498
|
+
}),
|
|
1499
|
+
addEventListener: generateDataDescriptor({
|
|
1500
|
+
value(type, listener, options) {
|
|
1501
|
+
// TODO [#420]: this is triggered when the component author attempts to add a listener
|
|
1502
|
+
// programmatically into its Component's shadow root
|
|
1503
|
+
if (!isUndefined$1(options)) {
|
|
1504
|
+
logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
|
|
1505
|
+
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1506
|
+
// @ts-ignore type-mismatch
|
|
1337
1507
|
|
|
1338
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1339
|
-
// just to make sure that this object never changes as part of the diffing algo
|
|
1340
|
-
freeze(map);
|
|
1341
|
-
}
|
|
1342
1508
|
|
|
1343
|
-
|
|
1344
|
-
}
|
|
1509
|
+
return originalAddEventListener.apply(this, arguments);
|
|
1510
|
+
}
|
|
1345
1511
|
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
className: newClass
|
|
1351
|
-
}
|
|
1352
|
-
} = vnode;
|
|
1353
|
-
const {
|
|
1354
|
-
data: {
|
|
1355
|
-
className: oldClass
|
|
1356
|
-
}
|
|
1357
|
-
} = oldVnode;
|
|
1512
|
+
})
|
|
1513
|
+
};
|
|
1514
|
+
} // Custom Elements Restrictions:
|
|
1515
|
+
// -----------------------------
|
|
1358
1516
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1517
|
+
|
|
1518
|
+
function getCustomElementRestrictionsDescriptors(elm) {
|
|
1519
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1520
|
+
// this method should never leak to prod
|
|
1521
|
+
throw new ReferenceError();
|
|
1361
1522
|
}
|
|
1362
1523
|
|
|
1363
|
-
const
|
|
1364
|
-
const
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1524
|
+
const originalAddEventListener = elm.addEventListener;
|
|
1525
|
+
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
1526
|
+
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1527
|
+
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
|
1528
|
+
return {
|
|
1529
|
+
innerHTML: generateAccessorDescriptor({
|
|
1530
|
+
get() {
|
|
1531
|
+
return originalInnerHTMLDescriptor.get.call(this);
|
|
1532
|
+
},
|
|
1367
1533
|
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
classList.remove(name);
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1534
|
+
set(_value) {
|
|
1535
|
+
throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
|
|
1536
|
+
}
|
|
1374
1537
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
}
|
|
1538
|
+
}),
|
|
1539
|
+
outerHTML: generateAccessorDescriptor({
|
|
1540
|
+
get() {
|
|
1541
|
+
return originalOuterHTMLDescriptor.get.call(this);
|
|
1542
|
+
},
|
|
1381
1543
|
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
}
|
|
1385
|
-
var modComputedClassName = {
|
|
1386
|
-
create: vnode => updateClassAttribute(emptyVNode$1, vnode),
|
|
1387
|
-
update: updateClassAttribute
|
|
1388
|
-
};
|
|
1389
|
-
/*
|
|
1390
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1391
|
-
* All rights reserved.
|
|
1392
|
-
* SPDX-License-Identifier: MIT
|
|
1393
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1394
|
-
*/
|
|
1544
|
+
set(_value) {
|
|
1545
|
+
throw new TypeError(`Invalid attempt to set outerHTML on HTMLElement.`);
|
|
1546
|
+
}
|
|
1395
1547
|
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
}
|
|
1402
|
-
} = vnode;
|
|
1548
|
+
}),
|
|
1549
|
+
textContent: generateAccessorDescriptor({
|
|
1550
|
+
get() {
|
|
1551
|
+
return originalTextContentDescriptor.get.call(this);
|
|
1552
|
+
},
|
|
1403
1553
|
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1554
|
+
set(_value) {
|
|
1555
|
+
throw new TypeError(`Invalid attempt to set textContent on HTMLElement.`);
|
|
1556
|
+
}
|
|
1407
1557
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1558
|
+
}),
|
|
1559
|
+
addEventListener: generateDataDescriptor({
|
|
1560
|
+
value(type, listener, options) {
|
|
1561
|
+
// TODO [#420]: this is triggered when the component author attempts to add a listener
|
|
1562
|
+
// programmatically into a lighting element node
|
|
1563
|
+
if (!isUndefined$1(options)) {
|
|
1564
|
+
logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
|
|
1565
|
+
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1566
|
+
// @ts-ignore type-mismatch
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
return originalAddEventListener.apply(this, arguments);
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
})
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
function getComponentRestrictionsDescriptors() {
|
|
1577
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1578
|
+
// this method should never leak to prod
|
|
1579
|
+
throw new ReferenceError();
|
|
1412
1580
|
}
|
|
1581
|
+
|
|
1582
|
+
return {
|
|
1583
|
+
tagName: generateAccessorDescriptor({
|
|
1584
|
+
get() {
|
|
1585
|
+
throw new Error(`Usage of property \`tagName\` is disallowed because the component itself does` + ` not know which tagName will be used to create the element, therefore writing` + ` code that check for that value is error prone.`);
|
|
1586
|
+
},
|
|
1587
|
+
|
|
1588
|
+
configurable: true,
|
|
1589
|
+
enumerable: false // no enumerable properties on component
|
|
1590
|
+
|
|
1591
|
+
})
|
|
1592
|
+
};
|
|
1413
1593
|
}
|
|
1414
1594
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
update: updateStyleAttribute
|
|
1421
|
-
};
|
|
1422
|
-
/*
|
|
1423
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1424
|
-
* All rights reserved.
|
|
1425
|
-
* SPDX-License-Identifier: MIT
|
|
1426
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1427
|
-
*/
|
|
1428
|
-
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
1429
|
-
// different classnames properties individually instead of via a string.
|
|
1595
|
+
function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
|
1596
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1597
|
+
// this method should never leak to prod
|
|
1598
|
+
throw new ReferenceError();
|
|
1599
|
+
}
|
|
1430
1600
|
|
|
1431
|
-
|
|
1432
|
-
const {
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1601
|
+
const originalDispatchEvent = proto.dispatchEvent;
|
|
1602
|
+
const descriptors = {
|
|
1603
|
+
dispatchEvent: generateDataDescriptor({
|
|
1604
|
+
value(event) {
|
|
1605
|
+
const vm = getAssociatedVM(this);
|
|
1606
|
+
|
|
1607
|
+
if (!isNull(event) && isObject(event)) {
|
|
1608
|
+
const {
|
|
1609
|
+
type
|
|
1610
|
+
} = event;
|
|
1611
|
+
|
|
1612
|
+
if (!/^[a-z][a-z0-9_]*$/.test(type)) {
|
|
1613
|
+
logError(`Invalid event type "${type}" dispatched in element ${getComponentTag(vm)}.` + ` Event name must start with a lowercase letter and followed only lowercase` + ` letters, numbers, and underscores`, vm);
|
|
1614
|
+
}
|
|
1615
|
+
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1616
|
+
// @ts-ignore type-mismatch
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
return originalDispatchEvent.apply(this, arguments);
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
})
|
|
1623
|
+
};
|
|
1624
|
+
forEach.call(getOwnPropertyNames$1(globalHTMLProperties), propName => {
|
|
1625
|
+
if (propName in proto) {
|
|
1626
|
+
return; // no need to redefine something that we are already exposing
|
|
1436
1627
|
}
|
|
1437
|
-
} = vnode;
|
|
1438
1628
|
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1629
|
+
descriptors[propName] = generateAccessorDescriptor({
|
|
1630
|
+
get() {
|
|
1631
|
+
const {
|
|
1632
|
+
error,
|
|
1633
|
+
attribute
|
|
1634
|
+
} = globalHTMLProperties[propName];
|
|
1635
|
+
const msg = [];
|
|
1636
|
+
msg.push(`Accessing the global HTML property "${propName}" is disabled.`);
|
|
1442
1637
|
|
|
1443
|
-
|
|
1638
|
+
if (error) {
|
|
1639
|
+
msg.push(error);
|
|
1640
|
+
} else if (attribute) {
|
|
1641
|
+
msg.push(`Instead access it via \`this.getAttribute("${attribute}")\`.`);
|
|
1642
|
+
}
|
|
1444
1643
|
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1644
|
+
logError(msg.join('\n'), getAssociatedVM(this));
|
|
1645
|
+
},
|
|
1646
|
+
|
|
1647
|
+
set() {
|
|
1648
|
+
const {
|
|
1649
|
+
readOnly
|
|
1650
|
+
} = globalHTMLProperties[propName];
|
|
1651
|
+
|
|
1652
|
+
if (readOnly) {
|
|
1653
|
+
logError(`The global HTML property \`${propName}\` is read-only.`, getAssociatedVM(this));
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
});
|
|
1658
|
+
});
|
|
1659
|
+
return descriptors;
|
|
1660
|
+
} // This routine will prevent access to certain properties on a shadow root instance to guarantee
|
|
1661
|
+
// that all components will work fine in IE11 and other browsers without shadow dom support.
|
|
1662
|
+
|
|
1663
|
+
|
|
1664
|
+
function patchShadowRootWithRestrictions(sr) {
|
|
1665
|
+
defineProperties(sr, getShadowRootRestrictionsDescriptors(sr));
|
|
1448
1666
|
}
|
|
1449
1667
|
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1668
|
+
function patchCustomElementWithRestrictions(elm) {
|
|
1669
|
+
const restrictionsDescriptors = getCustomElementRestrictionsDescriptors(elm);
|
|
1670
|
+
const elmProto = getPrototypeOf$1(elm);
|
|
1671
|
+
setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
function patchComponentWithRestrictions(cmp) {
|
|
1675
|
+
defineProperties(cmp, getComponentRestrictionsDescriptors());
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
1679
|
+
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
1680
|
+
}
|
|
1453
1681
|
/*
|
|
1454
1682
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1455
1683
|
* All rights reserved.
|
|
1456
1684
|
* SPDX-License-Identifier: MIT
|
|
1457
1685
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1458
1686
|
*/
|
|
1459
|
-
//
|
|
1460
|
-
//
|
|
1461
|
-
|
|
1462
|
-
function createStyleAttribute(vnode) {
|
|
1463
|
-
const {
|
|
1464
|
-
elm,
|
|
1465
|
-
data: {
|
|
1466
|
-
styleDecls
|
|
1467
|
-
}
|
|
1468
|
-
} = vnode;
|
|
1469
|
-
|
|
1470
|
-
if (isUndefined$1(styleDecls)) {
|
|
1471
|
-
return;
|
|
1472
|
-
}
|
|
1687
|
+
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
1688
|
+
// to inject at runtime.
|
|
1473
1689
|
|
|
1474
|
-
for (let i = 0; i < styleDecls.length; i++) {
|
|
1475
|
-
const [prop, value, important] = styleDecls[i];
|
|
1476
|
-
setCSSStyleProperty$1(elm, prop, value, important);
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
1690
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
};
|
|
1691
|
+
const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
|
1692
|
+
const HTMLElementPrototype = HTMLElementConstructor.prototype;
|
|
1483
1693
|
/*
|
|
1484
1694
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1485
1695
|
* All rights reserved.
|
|
@@ -1487,623 +1697,36 @@ var modStaticStyle = {
|
|
|
1487
1697
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1488
1698
|
*/
|
|
1489
1699
|
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
function isVNode(vnode) {
|
|
1499
|
-
return vnode != null;
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
1503
|
-
const map = {};
|
|
1504
|
-
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
1505
|
-
|
|
1506
|
-
for (j = beginIdx; j <= endIdx; ++j) {
|
|
1507
|
-
ch = children[j];
|
|
1700
|
+
/**
|
|
1701
|
+
* This is a descriptor map that contains
|
|
1702
|
+
* all standard properties that a Custom Element can support (including AOM properties), which
|
|
1703
|
+
* determines what kind of capabilities the Base HTML Element and
|
|
1704
|
+
* Base Lightning Element should support.
|
|
1705
|
+
*/
|
|
1508
1706
|
|
|
1509
|
-
|
|
1510
|
-
|
|
1707
|
+
const HTMLElementOriginalDescriptors = create(null);
|
|
1708
|
+
forEach.call(keys(AriaPropNameToAttrNameMap), propName => {
|
|
1709
|
+
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1710
|
+
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
|
|
1711
|
+
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1511
1712
|
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1713
|
+
if (!isUndefined$1(descriptor)) {
|
|
1714
|
+
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1516
1715
|
}
|
|
1716
|
+
});
|
|
1717
|
+
forEach.call(defaultDefHTMLPropertyNames, propName => {
|
|
1718
|
+
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1719
|
+
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
|
|
1720
|
+
// this category, so, better to be sure.
|
|
1721
|
+
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1517
1722
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
1522
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
1523
|
-
const ch = vnodes[startIdx];
|
|
1524
|
-
|
|
1525
|
-
if (isVNode(ch)) {
|
|
1526
|
-
ch.hook.create(ch);
|
|
1527
|
-
ch.hook.insert(ch, parentElm, before);
|
|
1528
|
-
}
|
|
1723
|
+
if (!isUndefined$1(descriptor)) {
|
|
1724
|
+
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1529
1725
|
}
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
1535
|
-
|
|
1536
|
-
if (isVNode(ch)) {
|
|
1537
|
-
ch.hook.remove(ch, parentElm);
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
1543
|
-
let oldStartIdx = 0;
|
|
1544
|
-
let newStartIdx = 0;
|
|
1545
|
-
let oldEndIdx = oldCh.length - 1;
|
|
1546
|
-
let oldStartVnode = oldCh[0];
|
|
1547
|
-
let oldEndVnode = oldCh[oldEndIdx];
|
|
1548
|
-
const newChEnd = newCh.length - 1;
|
|
1549
|
-
let newEndIdx = newChEnd;
|
|
1550
|
-
let newStartVnode = newCh[0];
|
|
1551
|
-
let newEndVnode = newCh[newEndIdx];
|
|
1552
|
-
let oldKeyToIdx;
|
|
1553
|
-
let idxInOld;
|
|
1554
|
-
let elmToMove;
|
|
1555
|
-
let before;
|
|
1556
|
-
|
|
1557
|
-
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
1558
|
-
if (!isVNode(oldStartVnode)) {
|
|
1559
|
-
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
1560
|
-
} else if (!isVNode(oldEndVnode)) {
|
|
1561
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1562
|
-
} else if (!isVNode(newStartVnode)) {
|
|
1563
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1564
|
-
} else if (!isVNode(newEndVnode)) {
|
|
1565
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1566
|
-
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
1567
|
-
patchVnode(oldStartVnode, newStartVnode);
|
|
1568
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1569
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1570
|
-
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
1571
|
-
patchVnode(oldEndVnode, newEndVnode);
|
|
1572
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1573
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1574
|
-
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
1575
|
-
// Vnode moved right
|
|
1576
|
-
patchVnode(oldStartVnode, newEndVnode);
|
|
1577
|
-
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
|
|
1578
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1579
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1580
|
-
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
1581
|
-
// Vnode moved left
|
|
1582
|
-
patchVnode(oldEndVnode, newStartVnode);
|
|
1583
|
-
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
1584
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1585
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1586
|
-
} else {
|
|
1587
|
-
if (oldKeyToIdx === undefined) {
|
|
1588
|
-
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
1592
|
-
|
|
1593
|
-
if (isUndef(idxInOld)) {
|
|
1594
|
-
// New element
|
|
1595
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1596
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1597
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1598
|
-
} else {
|
|
1599
|
-
elmToMove = oldCh[idxInOld];
|
|
1600
|
-
|
|
1601
|
-
if (isVNode(elmToMove)) {
|
|
1602
|
-
if (elmToMove.sel !== newStartVnode.sel) {
|
|
1603
|
-
// New element
|
|
1604
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1605
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1606
|
-
} else {
|
|
1607
|
-
patchVnode(elmToMove, newStartVnode);
|
|
1608
|
-
oldCh[idxInOld] = undefined;
|
|
1609
|
-
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
1619
|
-
if (oldStartIdx > oldEndIdx) {
|
|
1620
|
-
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
1621
|
-
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
1622
|
-
let i = newEndIdx;
|
|
1623
|
-
let n;
|
|
1624
|
-
|
|
1625
|
-
do {
|
|
1626
|
-
n = newCh[++i];
|
|
1627
|
-
} while (!isVNode(n) && i < newChEnd);
|
|
1628
|
-
|
|
1629
|
-
before = isVNode(n) ? n.elm : null;
|
|
1630
|
-
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
1631
|
-
} else {
|
|
1632
|
-
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
|
-
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
1638
|
-
const oldChLength = oldCh.length;
|
|
1639
|
-
const newChLength = newCh.length;
|
|
1640
|
-
|
|
1641
|
-
if (oldChLength === 0) {
|
|
1642
|
-
// the old list is empty, we can directly insert anything new
|
|
1643
|
-
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
1644
|
-
return;
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
|
-
if (newChLength === 0) {
|
|
1648
|
-
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
1649
|
-
// this is the case in which the dynamic children of an if-directive should be removed
|
|
1650
|
-
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
1651
|
-
return;
|
|
1652
|
-
} // if the old list is not empty, the new list MUST have the same
|
|
1653
|
-
// amount of nodes, that's why we call this static children
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
let referenceElm = null;
|
|
1657
|
-
|
|
1658
|
-
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
1659
|
-
const vnode = newCh[i];
|
|
1660
|
-
const oldVNode = oldCh[i];
|
|
1661
|
-
|
|
1662
|
-
if (vnode !== oldVNode) {
|
|
1663
|
-
if (isVNode(oldVNode)) {
|
|
1664
|
-
if (isVNode(vnode)) {
|
|
1665
|
-
// both vnodes must be equivalent, and se just need to patch them
|
|
1666
|
-
patchVnode(oldVNode, vnode);
|
|
1667
|
-
referenceElm = vnode.elm;
|
|
1668
|
-
} else {
|
|
1669
|
-
// removing the old vnode since the new one is null
|
|
1670
|
-
oldVNode.hook.remove(oldVNode, parentElm);
|
|
1671
|
-
}
|
|
1672
|
-
} else if (isVNode(vnode)) {
|
|
1673
|
-
// this condition is unnecessary
|
|
1674
|
-
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
1675
|
-
|
|
1676
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
1677
|
-
referenceElm = vnode.elm;
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
function patchVnode(oldVnode, vnode) {
|
|
1684
|
-
if (oldVnode !== vnode) {
|
|
1685
|
-
vnode.elm = oldVnode.elm;
|
|
1686
|
-
vnode.hook.update(oldVnode, vnode);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
/*
|
|
1690
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1691
|
-
* All rights reserved.
|
|
1692
|
-
* SPDX-License-Identifier: MIT
|
|
1693
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1694
|
-
*/
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
function generateDataDescriptor(options) {
|
|
1698
|
-
return assign({
|
|
1699
|
-
configurable: true,
|
|
1700
|
-
enumerable: true,
|
|
1701
|
-
writable: true
|
|
1702
|
-
}, options);
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
function generateAccessorDescriptor(options) {
|
|
1706
|
-
return assign({
|
|
1707
|
-
configurable: true,
|
|
1708
|
-
enumerable: true
|
|
1709
|
-
}, options);
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
let isDomMutationAllowed = false;
|
|
1713
|
-
|
|
1714
|
-
function unlockDomMutation() {
|
|
1715
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1716
|
-
// this method should never leak to prod
|
|
1717
|
-
throw new ReferenceError();
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
isDomMutationAllowed = true;
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
|
-
function lockDomMutation() {
|
|
1724
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1725
|
-
// this method should never leak to prod
|
|
1726
|
-
throw new ReferenceError();
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
isDomMutationAllowed = false;
|
|
1730
|
-
}
|
|
1731
|
-
|
|
1732
|
-
function logMissingPortalError(name, type) {
|
|
1733
|
-
return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
function patchElementWithRestrictions(elm, options) {
|
|
1737
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1738
|
-
// this method should never leak to prod
|
|
1739
|
-
throw new ReferenceError();
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1743
|
-
const descriptors = {
|
|
1744
|
-
outerHTML: generateAccessorDescriptor({
|
|
1745
|
-
get() {
|
|
1746
|
-
return originalOuterHTMLDescriptor.get.call(this);
|
|
1747
|
-
},
|
|
1748
|
-
|
|
1749
|
-
set(_value) {
|
|
1750
|
-
throw new TypeError(`Invalid attempt to set outerHTML on Element.`);
|
|
1751
|
-
}
|
|
1752
|
-
|
|
1753
|
-
})
|
|
1754
|
-
}; // Apply extra restriction related to DOM manipulation if the element is not a portal.
|
|
1755
|
-
|
|
1756
|
-
if (!options.isLight && !options.isPortal) {
|
|
1757
|
-
const {
|
|
1758
|
-
appendChild,
|
|
1759
|
-
insertBefore,
|
|
1760
|
-
removeChild,
|
|
1761
|
-
replaceChild
|
|
1762
|
-
} = elm;
|
|
1763
|
-
const originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
|
|
1764
|
-
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
1765
|
-
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
|
1766
|
-
assign(descriptors, {
|
|
1767
|
-
appendChild: generateDataDescriptor({
|
|
1768
|
-
value(aChild) {
|
|
1769
|
-
logMissingPortalError('appendChild', 'method');
|
|
1770
|
-
return appendChild.call(this, aChild);
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
}),
|
|
1774
|
-
insertBefore: generateDataDescriptor({
|
|
1775
|
-
value(newNode, referenceNode) {
|
|
1776
|
-
if (!isDomMutationAllowed) {
|
|
1777
|
-
logMissingPortalError('insertBefore', 'method');
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
return insertBefore.call(this, newNode, referenceNode);
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
}),
|
|
1784
|
-
removeChild: generateDataDescriptor({
|
|
1785
|
-
value(aChild) {
|
|
1786
|
-
if (!isDomMutationAllowed) {
|
|
1787
|
-
logMissingPortalError('removeChild', 'method');
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
return removeChild.call(this, aChild);
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
}),
|
|
1794
|
-
replaceChild: generateDataDescriptor({
|
|
1795
|
-
value(newChild, oldChild) {
|
|
1796
|
-
logMissingPortalError('replaceChild', 'method');
|
|
1797
|
-
return replaceChild.call(this, newChild, oldChild);
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
}),
|
|
1801
|
-
nodeValue: generateAccessorDescriptor({
|
|
1802
|
-
get() {
|
|
1803
|
-
return originalNodeValueDescriptor.get.call(this);
|
|
1804
|
-
},
|
|
1805
|
-
|
|
1806
|
-
set(value) {
|
|
1807
|
-
if (!isDomMutationAllowed) {
|
|
1808
|
-
logMissingPortalError('nodeValue', 'property');
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
originalNodeValueDescriptor.set.call(this, value);
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
}),
|
|
1815
|
-
textContent: generateAccessorDescriptor({
|
|
1816
|
-
get() {
|
|
1817
|
-
return originalTextContentDescriptor.get.call(this);
|
|
1818
|
-
},
|
|
1819
|
-
|
|
1820
|
-
set(value) {
|
|
1821
|
-
logMissingPortalError('textContent', 'property');
|
|
1822
|
-
originalTextContentDescriptor.set.call(this, value);
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
}),
|
|
1826
|
-
innerHTML: generateAccessorDescriptor({
|
|
1827
|
-
get() {
|
|
1828
|
-
return originalInnerHTMLDescriptor.get.call(this);
|
|
1829
|
-
},
|
|
1830
|
-
|
|
1831
|
-
set(value) {
|
|
1832
|
-
logMissingPortalError('innerHTML', 'property');
|
|
1833
|
-
return originalInnerHTMLDescriptor.set.call(this, value);
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
})
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
|
|
1840
|
-
defineProperties(elm, descriptors);
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
function getShadowRootRestrictionsDescriptors(sr) {
|
|
1844
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1845
|
-
// this method should never leak to prod
|
|
1846
|
-
throw new ReferenceError();
|
|
1847
|
-
} // Disallowing properties in dev mode only to avoid people doing the wrong
|
|
1848
|
-
// thing when using the real shadow root, because if that's the case,
|
|
1849
|
-
// the component will not work when running with synthetic shadow.
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
const originalAddEventListener = sr.addEventListener;
|
|
1853
|
-
const originalInnerHTMLDescriptor = getPropertyDescriptor(sr, 'innerHTML');
|
|
1854
|
-
const originalTextContentDescriptor = getPropertyDescriptor(sr, 'textContent');
|
|
1855
|
-
return {
|
|
1856
|
-
innerHTML: generateAccessorDescriptor({
|
|
1857
|
-
get() {
|
|
1858
|
-
return originalInnerHTMLDescriptor.get.call(this);
|
|
1859
|
-
},
|
|
1860
|
-
|
|
1861
|
-
set(_value) {
|
|
1862
|
-
throw new TypeError(`Invalid attempt to set innerHTML on ShadowRoot.`);
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
}),
|
|
1866
|
-
textContent: generateAccessorDescriptor({
|
|
1867
|
-
get() {
|
|
1868
|
-
return originalTextContentDescriptor.get.call(this);
|
|
1869
|
-
},
|
|
1870
|
-
|
|
1871
|
-
set(_value) {
|
|
1872
|
-
throw new TypeError(`Invalid attempt to set textContent on ShadowRoot.`);
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
}),
|
|
1876
|
-
addEventListener: generateDataDescriptor({
|
|
1877
|
-
value(type, listener, options) {
|
|
1878
|
-
// TODO [#420]: this is triggered when the component author attempts to add a listener
|
|
1879
|
-
// programmatically into its Component's shadow root
|
|
1880
|
-
if (!isUndefined$1(options)) {
|
|
1881
|
-
logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
|
|
1882
|
-
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1883
|
-
// @ts-ignore type-mismatch
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
return originalAddEventListener.apply(this, arguments);
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
})
|
|
1890
|
-
};
|
|
1891
|
-
} // Custom Elements Restrictions:
|
|
1892
|
-
// -----------------------------
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
function getCustomElementRestrictionsDescriptors(elm) {
|
|
1896
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1897
|
-
// this method should never leak to prod
|
|
1898
|
-
throw new ReferenceError();
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
const originalAddEventListener = elm.addEventListener;
|
|
1902
|
-
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
1903
|
-
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1904
|
-
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
|
1905
|
-
return {
|
|
1906
|
-
innerHTML: generateAccessorDescriptor({
|
|
1907
|
-
get() {
|
|
1908
|
-
return originalInnerHTMLDescriptor.get.call(this);
|
|
1909
|
-
},
|
|
1910
|
-
|
|
1911
|
-
set(_value) {
|
|
1912
|
-
throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
|
-
}),
|
|
1916
|
-
outerHTML: generateAccessorDescriptor({
|
|
1917
|
-
get() {
|
|
1918
|
-
return originalOuterHTMLDescriptor.get.call(this);
|
|
1919
|
-
},
|
|
1920
|
-
|
|
1921
|
-
set(_value) {
|
|
1922
|
-
throw new TypeError(`Invalid attempt to set outerHTML on HTMLElement.`);
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
}),
|
|
1926
|
-
textContent: generateAccessorDescriptor({
|
|
1927
|
-
get() {
|
|
1928
|
-
return originalTextContentDescriptor.get.call(this);
|
|
1929
|
-
},
|
|
1930
|
-
|
|
1931
|
-
set(_value) {
|
|
1932
|
-
throw new TypeError(`Invalid attempt to set textContent on HTMLElement.`);
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
}),
|
|
1936
|
-
addEventListener: generateDataDescriptor({
|
|
1937
|
-
value(type, listener, options) {
|
|
1938
|
-
// TODO [#420]: this is triggered when the component author attempts to add a listener
|
|
1939
|
-
// programmatically into a lighting element node
|
|
1940
|
-
if (!isUndefined$1(options)) {
|
|
1941
|
-
logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
|
|
1942
|
-
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1943
|
-
// @ts-ignore type-mismatch
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
return originalAddEventListener.apply(this, arguments);
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1949
|
-
})
|
|
1950
|
-
};
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
function getComponentRestrictionsDescriptors() {
|
|
1954
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1955
|
-
// this method should never leak to prod
|
|
1956
|
-
throw new ReferenceError();
|
|
1957
|
-
}
|
|
1958
|
-
|
|
1959
|
-
return {
|
|
1960
|
-
tagName: generateAccessorDescriptor({
|
|
1961
|
-
get() {
|
|
1962
|
-
throw new Error(`Usage of property \`tagName\` is disallowed because the component itself does` + ` not know which tagName will be used to create the element, therefore writing` + ` code that check for that value is error prone.`);
|
|
1963
|
-
},
|
|
1964
|
-
|
|
1965
|
-
configurable: true,
|
|
1966
|
-
enumerable: false // no enumerable properties on component
|
|
1967
|
-
|
|
1968
|
-
})
|
|
1969
|
-
};
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
|
1973
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1974
|
-
// this method should never leak to prod
|
|
1975
|
-
throw new ReferenceError();
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
|
-
const originalDispatchEvent = proto.dispatchEvent;
|
|
1979
|
-
const descriptors = {
|
|
1980
|
-
dispatchEvent: generateDataDescriptor({
|
|
1981
|
-
value(event) {
|
|
1982
|
-
const vm = getAssociatedVM(this);
|
|
1983
|
-
|
|
1984
|
-
if (!isNull(event) && isObject(event)) {
|
|
1985
|
-
const {
|
|
1986
|
-
type
|
|
1987
|
-
} = event;
|
|
1988
|
-
|
|
1989
|
-
if (!/^[a-z][a-z0-9_]*$/.test(type)) {
|
|
1990
|
-
logError(`Invalid event type "${type}" dispatched in element ${getComponentTag(vm)}.` + ` Event name must start with a lowercase letter and followed only lowercase` + ` letters, numbers, and underscores`, vm);
|
|
1991
|
-
}
|
|
1992
|
-
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1993
|
-
// @ts-ignore type-mismatch
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
return originalDispatchEvent.apply(this, arguments);
|
|
1997
|
-
}
|
|
1998
|
-
|
|
1999
|
-
})
|
|
2000
|
-
};
|
|
2001
|
-
forEach.call(getOwnPropertyNames$1(globalHTMLProperties), propName => {
|
|
2002
|
-
if (propName in proto) {
|
|
2003
|
-
return; // no need to redefine something that we are already exposing
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
descriptors[propName] = generateAccessorDescriptor({
|
|
2007
|
-
get() {
|
|
2008
|
-
const {
|
|
2009
|
-
error,
|
|
2010
|
-
attribute
|
|
2011
|
-
} = globalHTMLProperties[propName];
|
|
2012
|
-
const msg = [];
|
|
2013
|
-
msg.push(`Accessing the global HTML property "${propName}" is disabled.`);
|
|
2014
|
-
|
|
2015
|
-
if (error) {
|
|
2016
|
-
msg.push(error);
|
|
2017
|
-
} else if (attribute) {
|
|
2018
|
-
msg.push(`Instead access it via \`this.getAttribute("${attribute}")\`.`);
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
logError(msg.join('\n'), getAssociatedVM(this));
|
|
2022
|
-
},
|
|
2023
|
-
|
|
2024
|
-
set() {
|
|
2025
|
-
const {
|
|
2026
|
-
readOnly
|
|
2027
|
-
} = globalHTMLProperties[propName];
|
|
2028
|
-
|
|
2029
|
-
if (readOnly) {
|
|
2030
|
-
logError(`The global HTML property \`${propName}\` is read-only.`, getAssociatedVM(this));
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
|
|
2034
|
-
});
|
|
2035
|
-
});
|
|
2036
|
-
return descriptors;
|
|
2037
|
-
} // This routine will prevent access to certain properties on a shadow root instance to guarantee
|
|
2038
|
-
// that all components will work fine in IE11 and other browsers without shadow dom support.
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
function patchShadowRootWithRestrictions(sr) {
|
|
2042
|
-
defineProperties(sr, getShadowRootRestrictionsDescriptors(sr));
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
|
-
function patchCustomElementWithRestrictions(elm) {
|
|
2046
|
-
const restrictionsDescriptors = getCustomElementRestrictionsDescriptors(elm);
|
|
2047
|
-
const elmProto = getPrototypeOf$1(elm);
|
|
2048
|
-
setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
function patchComponentWithRestrictions(cmp) {
|
|
2052
|
-
defineProperties(cmp, getComponentRestrictionsDescriptors());
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
2056
|
-
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
2057
|
-
}
|
|
2058
|
-
/*
|
|
2059
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
2060
|
-
* All rights reserved.
|
|
2061
|
-
* SPDX-License-Identifier: MIT
|
|
2062
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2063
|
-
*/
|
|
2064
|
-
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
2065
|
-
// to inject at runtime.
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
|
2069
|
-
const HTMLElementPrototype = HTMLElementConstructor.prototype;
|
|
2070
|
-
/*
|
|
2071
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
2072
|
-
* All rights reserved.
|
|
2073
|
-
* SPDX-License-Identifier: MIT
|
|
2074
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2075
|
-
*/
|
|
2076
|
-
|
|
2077
|
-
/**
|
|
2078
|
-
* This is a descriptor map that contains
|
|
2079
|
-
* all standard properties that a Custom Element can support (including AOM properties), which
|
|
2080
|
-
* determines what kind of capabilities the Base HTML Element and
|
|
2081
|
-
* Base Lightning Element should support.
|
|
2082
|
-
*/
|
|
2083
|
-
|
|
2084
|
-
const HTMLElementOriginalDescriptors = create(null);
|
|
2085
|
-
forEach.call(keys(AriaPropNameToAttrNameMap), propName => {
|
|
2086
|
-
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
2087
|
-
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
|
|
2088
|
-
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
2089
|
-
|
|
2090
|
-
if (!isUndefined$1(descriptor)) {
|
|
2091
|
-
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
2092
|
-
}
|
|
2093
|
-
});
|
|
2094
|
-
forEach.call(defaultDefHTMLPropertyNames, propName => {
|
|
2095
|
-
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
2096
|
-
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
|
|
2097
|
-
// this category, so, better to be sure.
|
|
2098
|
-
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
2099
|
-
|
|
2100
|
-
if (!isUndefined$1(descriptor)) {
|
|
2101
|
-
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
2102
|
-
}
|
|
2103
|
-
});
|
|
2104
|
-
/**
|
|
2105
|
-
* Copyright (C) 2017 salesforce.com, inc.
|
|
2106
|
-
*/
|
|
1726
|
+
});
|
|
1727
|
+
/**
|
|
1728
|
+
* Copyright (C) 2017 salesforce.com, inc.
|
|
1729
|
+
*/
|
|
2107
1730
|
|
|
2108
1731
|
const {
|
|
2109
1732
|
isArray
|
|
@@ -4008,304 +3631,625 @@ function createAttributeChangedCallback(attributeToPropMap, superAttributeChange
|
|
|
4008
3631
|
superAttributeChangedCallback.apply(this, arguments);
|
|
4009
3632
|
}
|
|
4010
3633
|
|
|
4011
|
-
return;
|
|
4012
|
-
}
|
|
3634
|
+
return;
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
if (!isAttributeLocked(this, attrName)) {
|
|
3638
|
+
// Ignore changes triggered by the engine itself during:
|
|
3639
|
+
// * diffing when public props are attempting to reflect to the DOM
|
|
3640
|
+
// * component via `this.setAttribute()`, should never update the prop
|
|
3641
|
+
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
3642
|
+
// attribute to be changed
|
|
3643
|
+
return;
|
|
3644
|
+
} // Reflect attribute change to the corresponding property when changed from outside.
|
|
3645
|
+
|
|
3646
|
+
|
|
3647
|
+
this[propName] = newValue;
|
|
3648
|
+
};
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
3652
|
+
let HTMLBridgeElement;
|
|
3653
|
+
/**
|
|
3654
|
+
* Modern browsers will have all Native Constructors as regular Classes
|
|
3655
|
+
* and must be instantiated with the new keyword. In older browsers,
|
|
3656
|
+
* specifically IE11, those are objects with a prototype property defined,
|
|
3657
|
+
* since they are not supposed to be extended or instantiated with the
|
|
3658
|
+
* new keyword. This forking logic supports both cases, specifically because
|
|
3659
|
+
* wc.ts relies on the construction path of the bridges to create new
|
|
3660
|
+
* fully qualifying web components.
|
|
3661
|
+
*/
|
|
3662
|
+
|
|
3663
|
+
if (isFunction$1(SuperClass)) {
|
|
3664
|
+
HTMLBridgeElement = class extends SuperClass {};
|
|
3665
|
+
} else {
|
|
3666
|
+
HTMLBridgeElement = function () {
|
|
3667
|
+
// Bridge classes are not supposed to be instantiated directly in
|
|
3668
|
+
// browsers that do not support web components.
|
|
3669
|
+
throw new TypeError('Illegal constructor');
|
|
3670
|
+
}; // prototype inheritance dance
|
|
3671
|
+
|
|
3672
|
+
|
|
3673
|
+
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
3674
|
+
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
3675
|
+
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
3676
|
+
writable: true,
|
|
3677
|
+
configurable: true,
|
|
3678
|
+
value: HTMLBridgeElement
|
|
3679
|
+
});
|
|
3680
|
+
} // generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
|
3681
|
+
// and false positives in case of inheritance.
|
|
3682
|
+
|
|
3683
|
+
|
|
3684
|
+
const attributeToPropMap = create(null);
|
|
3685
|
+
const {
|
|
3686
|
+
attributeChangedCallback: superAttributeChangedCallback
|
|
3687
|
+
} = SuperClass.prototype;
|
|
3688
|
+
const {
|
|
3689
|
+
observedAttributes: superObservedAttributes = []
|
|
3690
|
+
} = SuperClass;
|
|
3691
|
+
const descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
|
|
3692
|
+
|
|
3693
|
+
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
3694
|
+
const propName = props[i];
|
|
3695
|
+
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
3696
|
+
descriptors[propName] = {
|
|
3697
|
+
get: createGetter(propName),
|
|
3698
|
+
set: createSetter(propName),
|
|
3699
|
+
enumerable: true,
|
|
3700
|
+
configurable: true
|
|
3701
|
+
};
|
|
3702
|
+
} // expose public methods as props on the new Element Bridge
|
|
3703
|
+
|
|
3704
|
+
|
|
3705
|
+
for (let i = 0, len = methods.length; i < len; i += 1) {
|
|
3706
|
+
const methodName = methods[i];
|
|
3707
|
+
descriptors[methodName] = {
|
|
3708
|
+
value: createMethodCaller(methodName),
|
|
3709
|
+
writable: true,
|
|
3710
|
+
configurable: true
|
|
3711
|
+
};
|
|
3712
|
+
} // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
3713
|
+
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
3714
|
+
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
3715
|
+
// to preserve this definition.
|
|
3716
|
+
|
|
3717
|
+
|
|
3718
|
+
descriptors.attributeChangedCallback = {
|
|
3719
|
+
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
|
|
3720
|
+
}; // Specify attributes for which we want to reflect changes back to their corresponding
|
|
3721
|
+
// properties via attributeChangedCallback.
|
|
3722
|
+
|
|
3723
|
+
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
3724
|
+
get() {
|
|
3725
|
+
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
});
|
|
3729
|
+
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
3730
|
+
return HTMLBridgeElement;
|
|
3731
|
+
}
|
|
3732
|
+
|
|
3733
|
+
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
3734
|
+
freeze(BaseBridgeElement);
|
|
3735
|
+
seal(BaseBridgeElement.prototype);
|
|
3736
|
+
/*
|
|
3737
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
3738
|
+
* All rights reserved.
|
|
3739
|
+
* SPDX-License-Identifier: MIT
|
|
3740
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3741
|
+
*/
|
|
3742
|
+
|
|
3743
|
+
function resolveCircularModuleDependency(fn) {
|
|
3744
|
+
const module = fn();
|
|
3745
|
+
return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
function isCircularModuleDependency(obj) {
|
|
3749
|
+
return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
|
|
3750
|
+
}
|
|
3751
|
+
/*
|
|
3752
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
3753
|
+
* All rights reserved.
|
|
3754
|
+
* SPDX-License-Identifier: MIT
|
|
3755
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3756
|
+
*/
|
|
3757
|
+
|
|
3758
|
+
|
|
3759
|
+
const swappedTemplateMap = new WeakMap();
|
|
3760
|
+
const swappedComponentMap = new WeakMap();
|
|
3761
|
+
const swappedStyleMap = new WeakMap();
|
|
3762
|
+
const activeTemplates = new WeakMap();
|
|
3763
|
+
const activeComponents = new WeakMap();
|
|
3764
|
+
const activeStyles = new WeakMap();
|
|
3765
|
+
|
|
3766
|
+
function flattenStylesheets(stylesheets) {
|
|
3767
|
+
const list = [];
|
|
3768
|
+
|
|
3769
|
+
for (const stylesheet of stylesheets) {
|
|
3770
|
+
if (!Array.isArray(stylesheet)) {
|
|
3771
|
+
list.push(stylesheet);
|
|
3772
|
+
} else {
|
|
3773
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
return list;
|
|
3778
|
+
}
|
|
3779
|
+
|
|
3780
|
+
function getTemplateOrSwappedTemplate(tpl) {
|
|
3781
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3782
|
+
// this method should never leak to prod
|
|
3783
|
+
throw new ReferenceError();
|
|
3784
|
+
}
|
|
3785
|
+
|
|
3786
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3787
|
+
const visited = new Set();
|
|
3788
|
+
|
|
3789
|
+
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
3790
|
+
visited.add(tpl);
|
|
3791
|
+
tpl = swappedTemplateMap.get(tpl);
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
|
|
3795
|
+
return tpl;
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3798
|
+
function getComponentOrSwappedComponent(Ctor) {
|
|
3799
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3800
|
+
// this method should never leak to prod
|
|
3801
|
+
throw new ReferenceError();
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3804
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3805
|
+
const visited = new Set();
|
|
3806
|
+
|
|
3807
|
+
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
3808
|
+
visited.add(Ctor);
|
|
3809
|
+
Ctor = swappedComponentMap.get(Ctor);
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
return Ctor;
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3816
|
+
function getStyleOrSwappedStyle(style) {
|
|
3817
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3818
|
+
// this method should never leak to prod
|
|
3819
|
+
throw new ReferenceError();
|
|
3820
|
+
}
|
|
3821
|
+
|
|
3822
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3823
|
+
const visited = new Set();
|
|
3824
|
+
|
|
3825
|
+
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
3826
|
+
visited.add(style);
|
|
3827
|
+
style = swappedStyleMap.get(style);
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
|
|
3831
|
+
return style;
|
|
3832
|
+
}
|
|
3833
|
+
|
|
3834
|
+
function setActiveVM(vm) {
|
|
3835
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3836
|
+
// this method should never leak to prod
|
|
3837
|
+
throw new ReferenceError();
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3841
|
+
// tracking active component
|
|
3842
|
+
const Ctor = vm.def.ctor;
|
|
3843
|
+
let componentVMs = activeComponents.get(Ctor);
|
|
3844
|
+
|
|
3845
|
+
if (isUndefined$1(componentVMs)) {
|
|
3846
|
+
componentVMs = new Set();
|
|
3847
|
+
activeComponents.set(Ctor, componentVMs);
|
|
3848
|
+
} // this will allow us to keep track of the hot components
|
|
3849
|
+
|
|
3850
|
+
|
|
3851
|
+
componentVMs.add(vm); // tracking active template
|
|
3852
|
+
|
|
3853
|
+
const tpl = vm.cmpTemplate;
|
|
3854
|
+
|
|
3855
|
+
if (tpl) {
|
|
3856
|
+
let templateVMs = activeTemplates.get(tpl);
|
|
3857
|
+
|
|
3858
|
+
if (isUndefined$1(templateVMs)) {
|
|
3859
|
+
templateVMs = new Set();
|
|
3860
|
+
activeTemplates.set(tpl, templateVMs);
|
|
3861
|
+
} // this will allow us to keep track of the templates that are
|
|
3862
|
+
// being used by a hot component
|
|
3863
|
+
|
|
4013
3864
|
|
|
4014
|
-
|
|
4015
|
-
// Ignore changes triggered by the engine itself during:
|
|
4016
|
-
// * diffing when public props are attempting to reflect to the DOM
|
|
4017
|
-
// * component via `this.setAttribute()`, should never update the prop
|
|
4018
|
-
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
4019
|
-
// attribute to be changed
|
|
4020
|
-
return;
|
|
4021
|
-
} // Reflect attribute change to the corresponding property when changed from outside.
|
|
3865
|
+
templateVMs.add(vm); // tracking active styles associated to template
|
|
4022
3866
|
|
|
3867
|
+
const stylesheets = tpl.stylesheets;
|
|
4023
3868
|
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
3869
|
+
if (!isUndefined$1(stylesheets)) {
|
|
3870
|
+
flattenStylesheets(stylesheets).forEach(stylesheet => {
|
|
3871
|
+
// this is necessary because we don't hold the list of styles
|
|
3872
|
+
// in the vm, we only hold the selected (already swapped template)
|
|
3873
|
+
// but the styles attached to the template might not be the actual
|
|
3874
|
+
// active ones, but the swapped versions of those.
|
|
3875
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3876
|
+
let stylesheetVMs = activeStyles.get(stylesheet);
|
|
4027
3877
|
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
* specifically IE11, those are objects with a prototype property defined,
|
|
4034
|
-
* since they are not supposed to be extended or instantiated with the
|
|
4035
|
-
* new keyword. This forking logic supports both cases, specifically because
|
|
4036
|
-
* wc.ts relies on the construction path of the bridges to create new
|
|
4037
|
-
* fully qualifying web components.
|
|
4038
|
-
*/
|
|
3878
|
+
if (isUndefined$1(stylesheetVMs)) {
|
|
3879
|
+
stylesheetVMs = new Set();
|
|
3880
|
+
activeStyles.set(stylesheet, stylesheetVMs);
|
|
3881
|
+
} // this will allow us to keep track of the stylesheet that are
|
|
3882
|
+
// being used by a hot component
|
|
4039
3883
|
|
|
4040
|
-
if (isFunction$1(SuperClass)) {
|
|
4041
|
-
HTMLBridgeElement = class extends SuperClass {};
|
|
4042
|
-
} else {
|
|
4043
|
-
HTMLBridgeElement = function () {
|
|
4044
|
-
// Bridge classes are not supposed to be instantiated directly in
|
|
4045
|
-
// browsers that do not support web components.
|
|
4046
|
-
throw new TypeError('Illegal constructor');
|
|
4047
|
-
}; // prototype inheritance dance
|
|
4048
3884
|
|
|
3885
|
+
stylesheetVMs.add(vm);
|
|
3886
|
+
});
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
4049
3891
|
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
value: HTMLBridgeElement
|
|
4056
|
-
});
|
|
4057
|
-
} // generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
|
4058
|
-
// and false positives in case of inheritance.
|
|
3892
|
+
function removeActiveVM(vm) {
|
|
3893
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3894
|
+
// this method should never leak to prod
|
|
3895
|
+
throw new ReferenceError();
|
|
3896
|
+
}
|
|
4059
3897
|
|
|
3898
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3899
|
+
// tracking inactive component
|
|
3900
|
+
const Ctor = vm.def.ctor;
|
|
3901
|
+
let list = activeComponents.get(Ctor);
|
|
4060
3902
|
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
const {
|
|
4066
|
-
observedAttributes: superObservedAttributes = []
|
|
4067
|
-
} = SuperClass;
|
|
4068
|
-
const descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
|
|
3903
|
+
if (!isUndefined$1(list)) {
|
|
3904
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3905
|
+
list.delete(vm);
|
|
3906
|
+
} // removing inactive template
|
|
4069
3907
|
|
|
4070
|
-
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
4071
|
-
const propName = props[i];
|
|
4072
|
-
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
4073
|
-
descriptors[propName] = {
|
|
4074
|
-
get: createGetter(propName),
|
|
4075
|
-
set: createSetter(propName),
|
|
4076
|
-
enumerable: true,
|
|
4077
|
-
configurable: true
|
|
4078
|
-
};
|
|
4079
|
-
} // expose public methods as props on the new Element Bridge
|
|
4080
3908
|
|
|
3909
|
+
const tpl = vm.cmpTemplate;
|
|
4081
3910
|
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
descriptors[methodName] = {
|
|
4085
|
-
value: createMethodCaller(methodName),
|
|
4086
|
-
writable: true,
|
|
4087
|
-
configurable: true
|
|
4088
|
-
};
|
|
4089
|
-
} // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
4090
|
-
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
4091
|
-
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
4092
|
-
// to preserve this definition.
|
|
3911
|
+
if (tpl) {
|
|
3912
|
+
list = activeTemplates.get(tpl);
|
|
4093
3913
|
|
|
3914
|
+
if (!isUndefined$1(list)) {
|
|
3915
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3916
|
+
list.delete(vm);
|
|
3917
|
+
} // removing active styles associated to template
|
|
4094
3918
|
|
|
4095
|
-
descriptors.attributeChangedCallback = {
|
|
4096
|
-
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
|
|
4097
|
-
}; // Specify attributes for which we want to reflect changes back to their corresponding
|
|
4098
|
-
// properties via attributeChangedCallback.
|
|
4099
3919
|
|
|
4100
|
-
|
|
4101
|
-
get() {
|
|
4102
|
-
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
4103
|
-
}
|
|
3920
|
+
const styles = tpl.stylesheets;
|
|
4104
3921
|
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
}
|
|
3922
|
+
if (!isUndefined$1(styles)) {
|
|
3923
|
+
flattenStylesheets(styles).forEach(style => {
|
|
3924
|
+
list = activeStyles.get(style);
|
|
4109
3925
|
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
3926
|
+
if (!isUndefined$1(list)) {
|
|
3927
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3928
|
+
list.delete(vm);
|
|
3929
|
+
}
|
|
3930
|
+
});
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
4113
3935
|
/*
|
|
4114
|
-
* Copyright (c)
|
|
3936
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4115
3937
|
* All rights reserved.
|
|
4116
3938
|
* SPDX-License-Identifier: MIT
|
|
4117
3939
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4118
3940
|
*/
|
|
4119
3941
|
|
|
4120
|
-
function resolveCircularModuleDependency(fn) {
|
|
4121
|
-
const module = fn();
|
|
4122
|
-
return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
|
|
4123
|
-
}
|
|
4124
3942
|
|
|
4125
|
-
|
|
4126
|
-
|
|
3943
|
+
const CtorToDefMap = new WeakMap();
|
|
3944
|
+
|
|
3945
|
+
function getCtorProto(Ctor) {
|
|
3946
|
+
let proto = getPrototypeOf$1(Ctor);
|
|
3947
|
+
|
|
3948
|
+
if (isNull(proto)) {
|
|
3949
|
+
throw new ReferenceError(`Invalid prototype chain for ${Ctor.name}, you must extend LightningElement.`);
|
|
3950
|
+
} // covering the cases where the ref is circular in AMD
|
|
3951
|
+
|
|
3952
|
+
|
|
3953
|
+
if (isCircularModuleDependency(proto)) {
|
|
3954
|
+
const p = resolveCircularModuleDependency(proto);
|
|
3955
|
+
|
|
3956
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3957
|
+
if (isNull(p)) {
|
|
3958
|
+
throw new ReferenceError(`Circular module dependency for ${Ctor.name}, must resolve to a constructor that extends LightningElement.`);
|
|
3959
|
+
}
|
|
3960
|
+
} // escape hatch for Locker and other abstractions to provide their own base class instead
|
|
3961
|
+
// of our Base class without having to leak it to user-land. If the circular function returns
|
|
3962
|
+
// itself, that's the signal that we have hit the end of the proto chain, which must always
|
|
3963
|
+
// be base.
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
proto = p === proto ? LightningElement : p;
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3969
|
+
return proto;
|
|
4127
3970
|
}
|
|
4128
|
-
/*
|
|
4129
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
4130
|
-
* All rights reserved.
|
|
4131
|
-
* SPDX-License-Identifier: MIT
|
|
4132
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4133
|
-
*/
|
|
4134
3971
|
|
|
3972
|
+
function createComponentDef(Ctor) {
|
|
3973
|
+
const {
|
|
3974
|
+
shadowSupportMode: ctorShadowSupportMode,
|
|
3975
|
+
renderMode: ctorRenderMode
|
|
3976
|
+
} = Ctor;
|
|
4135
3977
|
|
|
4136
|
-
|
|
4137
|
-
const
|
|
4138
|
-
|
|
4139
|
-
const activeTemplates = new WeakMap();
|
|
4140
|
-
const activeComponents = new WeakMap();
|
|
4141
|
-
const activeStyles = new WeakMap();
|
|
3978
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3979
|
+
const ctorName = Ctor.name; // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
|
|
3980
|
+
// assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
|
|
4142
3981
|
|
|
4143
|
-
|
|
4144
|
-
const list = [];
|
|
3982
|
+
assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
|
|
4145
3983
|
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
3984
|
+
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
3985
|
+
assert.invariant(ctorShadowSupportMode === "any"
|
|
3986
|
+
/* Any */
|
|
3987
|
+
|| ctorShadowSupportMode === "reset"
|
|
3988
|
+
/* Default */
|
|
3989
|
+
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
4151
3990
|
}
|
|
3991
|
+
|
|
3992
|
+
if (!isUndefined$1(ctorRenderMode)) {
|
|
3993
|
+
assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', `Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
|
|
3997
|
+
const decoratorsMeta = getDecoratorsMeta(Ctor);
|
|
3998
|
+
const {
|
|
3999
|
+
apiFields,
|
|
4000
|
+
apiFieldsConfig,
|
|
4001
|
+
apiMethods,
|
|
4002
|
+
wiredFields,
|
|
4003
|
+
wiredMethods,
|
|
4004
|
+
observedFields
|
|
4005
|
+
} = decoratorsMeta;
|
|
4006
|
+
const proto = Ctor.prototype;
|
|
4007
|
+
let {
|
|
4008
|
+
connectedCallback,
|
|
4009
|
+
disconnectedCallback,
|
|
4010
|
+
renderedCallback,
|
|
4011
|
+
errorCallback,
|
|
4012
|
+
render
|
|
4013
|
+
} = proto;
|
|
4014
|
+
const superProto = getCtorProto(Ctor);
|
|
4015
|
+
const superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
|
|
4016
|
+
const bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
|
|
4017
|
+
const props = assign(create(null), superDef.props, apiFields);
|
|
4018
|
+
const propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
|
|
4019
|
+
const methods = assign(create(null), superDef.methods, apiMethods);
|
|
4020
|
+
const wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
|
|
4021
|
+
connectedCallback = connectedCallback || superDef.connectedCallback;
|
|
4022
|
+
disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
|
|
4023
|
+
renderedCallback = renderedCallback || superDef.renderedCallback;
|
|
4024
|
+
errorCallback = errorCallback || superDef.errorCallback;
|
|
4025
|
+
render = render || superDef.render;
|
|
4026
|
+
let shadowSupportMode = superDef.shadowSupportMode;
|
|
4027
|
+
|
|
4028
|
+
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
4029
|
+
shadowSupportMode = ctorShadowSupportMode;
|
|
4030
|
+
}
|
|
4031
|
+
|
|
4032
|
+
let renderMode = superDef.renderMode;
|
|
4033
|
+
|
|
4034
|
+
if (!isUndefined$1(ctorRenderMode)) {
|
|
4035
|
+
renderMode = ctorRenderMode === 'light' ? 0
|
|
4036
|
+
/* Light */
|
|
4037
|
+
: 1
|
|
4038
|
+
/* Shadow */
|
|
4039
|
+
;
|
|
4152
4040
|
}
|
|
4153
4041
|
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
function getTemplateOrSwappedTemplate(tpl) {
|
|
4158
|
-
if (process.env.NODE_ENV === 'production') {
|
|
4159
|
-
// this method should never leak to prod
|
|
4160
|
-
throw new ReferenceError();
|
|
4161
|
-
}
|
|
4042
|
+
const template = getComponentRegisteredTemplate(Ctor) || superDef.template;
|
|
4043
|
+
const name = Ctor.name || superDef.name; // installing observed fields into the prototype.
|
|
4162
4044
|
|
|
4163
|
-
|
|
4164
|
-
|
|
4045
|
+
defineProperties(proto, observedFields);
|
|
4046
|
+
const def = {
|
|
4047
|
+
ctor: Ctor,
|
|
4048
|
+
name,
|
|
4049
|
+
wire,
|
|
4050
|
+
props,
|
|
4051
|
+
propsConfig,
|
|
4052
|
+
methods,
|
|
4053
|
+
bridge,
|
|
4054
|
+
template,
|
|
4055
|
+
renderMode,
|
|
4056
|
+
shadowSupportMode,
|
|
4057
|
+
connectedCallback,
|
|
4058
|
+
disconnectedCallback,
|
|
4059
|
+
renderedCallback,
|
|
4060
|
+
errorCallback,
|
|
4061
|
+
render
|
|
4062
|
+
};
|
|
4165
4063
|
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
tpl = swappedTemplateMap.get(tpl);
|
|
4169
|
-
}
|
|
4064
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4065
|
+
freeze(Ctor.prototype);
|
|
4170
4066
|
}
|
|
4171
4067
|
|
|
4172
|
-
return
|
|
4068
|
+
return def;
|
|
4173
4069
|
}
|
|
4070
|
+
/**
|
|
4071
|
+
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
|
4072
|
+
* subject to change or being removed.
|
|
4073
|
+
*/
|
|
4174
4074
|
|
|
4175
|
-
function getComponentOrSwappedComponent(Ctor) {
|
|
4176
|
-
if (process.env.NODE_ENV === 'production') {
|
|
4177
|
-
// this method should never leak to prod
|
|
4178
|
-
throw new ReferenceError();
|
|
4179
|
-
}
|
|
4180
4075
|
|
|
4181
|
-
|
|
4182
|
-
|
|
4076
|
+
function isComponentConstructor(ctor) {
|
|
4077
|
+
if (!isFunction$1(ctor)) {
|
|
4078
|
+
return false;
|
|
4079
|
+
} // Fast path: LightningElement is part of the prototype chain of the constructor.
|
|
4183
4080
|
|
|
4184
|
-
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
4185
|
-
visited.add(Ctor);
|
|
4186
|
-
Ctor = swappedComponentMap.get(Ctor);
|
|
4187
|
-
}
|
|
4188
|
-
}
|
|
4189
4081
|
|
|
4190
|
-
|
|
4191
|
-
|
|
4082
|
+
if (ctor.prototype instanceof LightningElement) {
|
|
4083
|
+
return true;
|
|
4084
|
+
} // Slow path: LightningElement is not part of the prototype chain of the constructor, we need
|
|
4085
|
+
// climb up the constructor prototype chain to check in case there are circular dependencies
|
|
4086
|
+
// to resolve.
|
|
4192
4087
|
|
|
4193
|
-
function getStyleOrSwappedStyle(style) {
|
|
4194
|
-
if (process.env.NODE_ENV === 'production') {
|
|
4195
|
-
// this method should never leak to prod
|
|
4196
|
-
throw new ReferenceError();
|
|
4197
|
-
}
|
|
4198
4088
|
|
|
4199
|
-
|
|
4200
|
-
const visited = new Set();
|
|
4089
|
+
let current = ctor;
|
|
4201
4090
|
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
}
|
|
4091
|
+
do {
|
|
4092
|
+
if (isCircularModuleDependency(current)) {
|
|
4093
|
+
const circularResolved = resolveCircularModuleDependency(current); // If the circular function returns itself, that's the signal that we have hit the end
|
|
4094
|
+
// of the proto chain, which must always be a valid base constructor.
|
|
4207
4095
|
|
|
4208
|
-
|
|
4209
|
-
|
|
4096
|
+
if (circularResolved === current) {
|
|
4097
|
+
return true;
|
|
4098
|
+
}
|
|
4210
4099
|
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
// this method should never leak to prod
|
|
4214
|
-
throw new ReferenceError();
|
|
4215
|
-
}
|
|
4100
|
+
current = circularResolved;
|
|
4101
|
+
}
|
|
4216
4102
|
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4103
|
+
if (current === LightningElement) {
|
|
4104
|
+
return true;
|
|
4105
|
+
}
|
|
4106
|
+
} while (!isNull(current) && (current = getPrototypeOf$1(current))); // Finally return false if the LightningElement is not part of the prototype chain.
|
|
4221
4107
|
|
|
4222
|
-
if (isUndefined$1(componentVMs)) {
|
|
4223
|
-
componentVMs = new Set();
|
|
4224
|
-
activeComponents.set(Ctor, componentVMs);
|
|
4225
|
-
} // this will allow us to keep track of the hot components
|
|
4226
4108
|
|
|
4109
|
+
return false;
|
|
4110
|
+
}
|
|
4227
4111
|
|
|
4228
|
-
|
|
4112
|
+
function getComponentInternalDef(Ctor) {
|
|
4113
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4114
|
+
Ctor = getComponentOrSwappedComponent(Ctor);
|
|
4115
|
+
}
|
|
4229
4116
|
|
|
4230
|
-
|
|
4117
|
+
let def = CtorToDefMap.get(Ctor);
|
|
4231
4118
|
|
|
4232
|
-
|
|
4233
|
-
|
|
4119
|
+
if (isUndefined$1(def)) {
|
|
4120
|
+
if (isCircularModuleDependency(Ctor)) {
|
|
4121
|
+
const resolvedCtor = resolveCircularModuleDependency(Ctor);
|
|
4122
|
+
def = getComponentInternalDef(resolvedCtor); // Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
|
|
4123
|
+
// look up the definition in cache instead of re-resolving and recreating the def.
|
|
4234
4124
|
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
} // this will allow us to keep track of the templates that are
|
|
4239
|
-
// being used by a hot component
|
|
4125
|
+
CtorToDefMap.set(Ctor, def);
|
|
4126
|
+
return def;
|
|
4127
|
+
}
|
|
4240
4128
|
|
|
4129
|
+
if (!isComponentConstructor(Ctor)) {
|
|
4130
|
+
throw new TypeError(`${Ctor} is not a valid component, or does not extends LightningElement from "lwc". You probably forgot to add the extend clause on the class declaration.`);
|
|
4131
|
+
}
|
|
4241
4132
|
|
|
4242
|
-
|
|
4133
|
+
def = createComponentDef(Ctor);
|
|
4134
|
+
CtorToDefMap.set(Ctor, def);
|
|
4135
|
+
}
|
|
4243
4136
|
|
|
4244
|
-
|
|
4137
|
+
return def;
|
|
4138
|
+
}
|
|
4245
4139
|
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4140
|
+
const lightingElementDef = {
|
|
4141
|
+
ctor: LightningElement,
|
|
4142
|
+
name: LightningElement.name,
|
|
4143
|
+
props: lightningBasedDescriptors,
|
|
4144
|
+
propsConfig: EmptyObject,
|
|
4145
|
+
methods: EmptyObject,
|
|
4146
|
+
renderMode: 1
|
|
4147
|
+
/* Shadow */
|
|
4148
|
+
,
|
|
4149
|
+
shadowSupportMode: "reset"
|
|
4150
|
+
/* Default */
|
|
4151
|
+
,
|
|
4152
|
+
wire: EmptyObject,
|
|
4153
|
+
bridge: BaseBridgeElement,
|
|
4154
|
+
template: defaultEmptyTemplate,
|
|
4155
|
+
render: LightningElement.prototype.render
|
|
4156
|
+
};
|
|
4157
|
+
/**
|
|
4158
|
+
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
|
4159
|
+
* subject to change or being removed.
|
|
4160
|
+
*/
|
|
4254
4161
|
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4162
|
+
function getComponentDef(Ctor) {
|
|
4163
|
+
const def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
|
|
4164
|
+
// for some external services, e.g.: Locker Service, usually, all they care
|
|
4165
|
+
// is about the shape of the constructor, the internals of it are not relevant
|
|
4166
|
+
// because they don't have a way to mess with that.
|
|
4260
4167
|
|
|
4168
|
+
const {
|
|
4169
|
+
ctor,
|
|
4170
|
+
name,
|
|
4171
|
+
props,
|
|
4172
|
+
propsConfig,
|
|
4173
|
+
methods
|
|
4174
|
+
} = def;
|
|
4175
|
+
const publicProps = {};
|
|
4261
4176
|
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4177
|
+
for (const key in props) {
|
|
4178
|
+
// avoid leaking the reference to the public props descriptors
|
|
4179
|
+
publicProps[key] = {
|
|
4180
|
+
config: propsConfig[key] || 0,
|
|
4181
|
+
type: "any"
|
|
4182
|
+
/* any */
|
|
4183
|
+
,
|
|
4184
|
+
attr: htmlPropertyToAttribute(key)
|
|
4185
|
+
};
|
|
4266
4186
|
}
|
|
4267
|
-
}
|
|
4268
4187
|
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4188
|
+
const publicMethods = {};
|
|
4189
|
+
|
|
4190
|
+
for (const key in methods) {
|
|
4191
|
+
// avoid leaking the reference to the public method descriptors
|
|
4192
|
+
publicMethods[key] = methods[key].value;
|
|
4273
4193
|
}
|
|
4274
4194
|
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4195
|
+
return {
|
|
4196
|
+
ctor,
|
|
4197
|
+
name,
|
|
4198
|
+
props: publicProps,
|
|
4199
|
+
methods: publicMethods
|
|
4200
|
+
};
|
|
4201
|
+
}
|
|
4202
|
+
/*
|
|
4203
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4204
|
+
* All rights reserved.
|
|
4205
|
+
* SPDX-License-Identifier: MIT
|
|
4206
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4207
|
+
*/
|
|
4279
4208
|
|
|
4280
|
-
if (!isUndefined$1(list)) {
|
|
4281
|
-
// deleting the vm from the set to avoid leaking memory
|
|
4282
|
-
list.delete(vm);
|
|
4283
|
-
} // removing inactive template
|
|
4284
4209
|
|
|
4210
|
+
const xlinkNS = 'http://www.w3.org/1999/xlink';
|
|
4211
|
+
const xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
|
4212
|
+
const ColonCharCode = 58;
|
|
4285
4213
|
|
|
4286
|
-
|
|
4214
|
+
function patchAttributes(oldVnode, vnode) {
|
|
4215
|
+
const {
|
|
4216
|
+
attrs
|
|
4217
|
+
} = vnode.data;
|
|
4287
4218
|
|
|
4288
|
-
|
|
4289
|
-
|
|
4219
|
+
if (isUndefined$1(attrs)) {
|
|
4220
|
+
return;
|
|
4221
|
+
}
|
|
4290
4222
|
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4223
|
+
const oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
|
|
4224
|
+
|
|
4225
|
+
if (oldAttrs === attrs) {
|
|
4226
|
+
return;
|
|
4227
|
+
}
|
|
4295
4228
|
|
|
4229
|
+
const {
|
|
4230
|
+
elm
|
|
4231
|
+
} = vnode;
|
|
4296
4232
|
|
|
4297
|
-
|
|
4233
|
+
for (const key in attrs) {
|
|
4234
|
+
const cur = attrs[key];
|
|
4235
|
+
const old = oldAttrs[key];
|
|
4298
4236
|
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
list = activeStyles.get(style);
|
|
4237
|
+
if (old !== cur) {
|
|
4238
|
+
unlockAttribute(elm, key);
|
|
4302
4239
|
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4240
|
+
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
|
|
4241
|
+
// Assume xml namespace
|
|
4242
|
+
setAttribute$1(elm, key, cur, xmlNS);
|
|
4243
|
+
} else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
|
|
4244
|
+
// Assume xlink namespace
|
|
4245
|
+
setAttribute$1(elm, key, cur, xlinkNS);
|
|
4246
|
+
} else if (isNull(cur) || isUndefined$1(cur)) {
|
|
4247
|
+
removeAttribute$1(elm, key);
|
|
4248
|
+
} else {
|
|
4249
|
+
setAttribute$1(elm, key, cur);
|
|
4308
4250
|
}
|
|
4251
|
+
|
|
4252
|
+
lockAttribute();
|
|
4309
4253
|
}
|
|
4310
4254
|
}
|
|
4311
4255
|
}
|
|
@@ -4317,264 +4261,232 @@ function removeActiveVM(vm) {
|
|
|
4317
4261
|
*/
|
|
4318
4262
|
|
|
4319
4263
|
|
|
4320
|
-
|
|
4264
|
+
function isLiveBindingProp(sel, key) {
|
|
4265
|
+
// For properties with live bindings, we read values from the DOM element
|
|
4266
|
+
// instead of relying on internally tracked values.
|
|
4267
|
+
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
4268
|
+
}
|
|
4321
4269
|
|
|
4322
|
-
function
|
|
4323
|
-
|
|
4270
|
+
function patchProps(oldVnode, vnode) {
|
|
4271
|
+
const {
|
|
4272
|
+
props
|
|
4273
|
+
} = vnode.data;
|
|
4324
4274
|
|
|
4325
|
-
if (
|
|
4326
|
-
|
|
4327
|
-
}
|
|
4275
|
+
if (isUndefined$1(props)) {
|
|
4276
|
+
return;
|
|
4277
|
+
}
|
|
4328
4278
|
|
|
4279
|
+
const oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
|
|
4329
4280
|
|
|
4330
|
-
if (
|
|
4331
|
-
|
|
4281
|
+
if (oldProps === props) {
|
|
4282
|
+
return;
|
|
4283
|
+
}
|
|
4332
4284
|
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
// of our Base class without having to leak it to user-land. If the circular function returns
|
|
4339
|
-
// itself, that's the signal that we have hit the end of the proto chain, which must always
|
|
4340
|
-
// be base.
|
|
4285
|
+
const isFirstPatch = isNull(oldVnode);
|
|
4286
|
+
const {
|
|
4287
|
+
elm,
|
|
4288
|
+
sel
|
|
4289
|
+
} = vnode;
|
|
4341
4290
|
|
|
4291
|
+
for (const key in props) {
|
|
4292
|
+
const cur = props[key]; // Set the property if it's the first time is is patched or if the previous property is
|
|
4293
|
+
// different than the one previously set.
|
|
4342
4294
|
|
|
4343
|
-
|
|
4295
|
+
if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
|
|
4296
|
+
setProperty$1(elm, key, cur);
|
|
4297
|
+
}
|
|
4344
4298
|
}
|
|
4345
|
-
|
|
4346
|
-
return proto;
|
|
4347
4299
|
}
|
|
4300
|
+
/*
|
|
4301
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4302
|
+
* All rights reserved.
|
|
4303
|
+
* SPDX-License-Identifier: MIT
|
|
4304
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4305
|
+
*/
|
|
4348
4306
|
|
|
4349
|
-
function createComponentDef(Ctor) {
|
|
4350
|
-
const {
|
|
4351
|
-
shadowSupportMode: ctorShadowSupportMode,
|
|
4352
|
-
renderMode: ctorRenderMode
|
|
4353
|
-
} = Ctor;
|
|
4354
|
-
|
|
4355
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4356
|
-
const ctorName = Ctor.name; // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
|
|
4357
|
-
// assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
|
|
4358
4307
|
|
|
4359
|
-
|
|
4308
|
+
const classNameToClassMap = create(null);
|
|
4360
4309
|
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
4367
|
-
}
|
|
4310
|
+
function getMapFromClassName(className) {
|
|
4311
|
+
// Intentionally using == to match undefined and null values from computed style attribute
|
|
4312
|
+
if (className == null) {
|
|
4313
|
+
return EmptyObject;
|
|
4314
|
+
} // computed class names must be string
|
|
4368
4315
|
|
|
4369
|
-
if (!isUndefined$1(ctorRenderMode)) {
|
|
4370
|
-
assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', `Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
|
|
4371
|
-
}
|
|
4372
|
-
}
|
|
4373
4316
|
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
apiFields,
|
|
4377
|
-
apiFieldsConfig,
|
|
4378
|
-
apiMethods,
|
|
4379
|
-
wiredFields,
|
|
4380
|
-
wiredMethods,
|
|
4381
|
-
observedFields
|
|
4382
|
-
} = decoratorsMeta;
|
|
4383
|
-
const proto = Ctor.prototype;
|
|
4384
|
-
let {
|
|
4385
|
-
connectedCallback,
|
|
4386
|
-
disconnectedCallback,
|
|
4387
|
-
renderedCallback,
|
|
4388
|
-
errorCallback,
|
|
4389
|
-
render
|
|
4390
|
-
} = proto;
|
|
4391
|
-
const superProto = getCtorProto(Ctor);
|
|
4392
|
-
const superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
|
|
4393
|
-
const bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
|
|
4394
|
-
const props = assign(create(null), superDef.props, apiFields);
|
|
4395
|
-
const propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
|
|
4396
|
-
const methods = assign(create(null), superDef.methods, apiMethods);
|
|
4397
|
-
const wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
|
|
4398
|
-
connectedCallback = connectedCallback || superDef.connectedCallback;
|
|
4399
|
-
disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
|
|
4400
|
-
renderedCallback = renderedCallback || superDef.renderedCallback;
|
|
4401
|
-
errorCallback = errorCallback || superDef.errorCallback;
|
|
4402
|
-
render = render || superDef.render;
|
|
4403
|
-
let shadowSupportMode = superDef.shadowSupportMode;
|
|
4317
|
+
className = isString(className) ? className : className + '';
|
|
4318
|
+
let map = classNameToClassMap[className];
|
|
4404
4319
|
|
|
4405
|
-
if (
|
|
4406
|
-
|
|
4320
|
+
if (map) {
|
|
4321
|
+
return map;
|
|
4407
4322
|
}
|
|
4408
4323
|
|
|
4409
|
-
|
|
4324
|
+
map = create(null);
|
|
4325
|
+
let start = 0;
|
|
4326
|
+
let o;
|
|
4327
|
+
const len = className.length;
|
|
4410
4328
|
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4329
|
+
for (o = 0; o < len; o++) {
|
|
4330
|
+
if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
|
|
4331
|
+
if (o > start) {
|
|
4332
|
+
map[StringSlice.call(className, start, o)] = true;
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4335
|
+
start = o + 1;
|
|
4336
|
+
}
|
|
4417
4337
|
}
|
|
4418
4338
|
|
|
4419
|
-
|
|
4420
|
-
|
|
4339
|
+
if (o > start) {
|
|
4340
|
+
map[StringSlice.call(className, start, o)] = true;
|
|
4341
|
+
}
|
|
4421
4342
|
|
|
4422
|
-
|
|
4423
|
-
const def = {
|
|
4424
|
-
ctor: Ctor,
|
|
4425
|
-
name,
|
|
4426
|
-
wire,
|
|
4427
|
-
props,
|
|
4428
|
-
propsConfig,
|
|
4429
|
-
methods,
|
|
4430
|
-
bridge,
|
|
4431
|
-
template,
|
|
4432
|
-
renderMode,
|
|
4433
|
-
shadowSupportMode,
|
|
4434
|
-
connectedCallback,
|
|
4435
|
-
disconnectedCallback,
|
|
4436
|
-
renderedCallback,
|
|
4437
|
-
errorCallback,
|
|
4438
|
-
render
|
|
4439
|
-
};
|
|
4343
|
+
classNameToClassMap[className] = map;
|
|
4440
4344
|
|
|
4441
4345
|
if (process.env.NODE_ENV !== 'production') {
|
|
4442
|
-
|
|
4346
|
+
// just to make sure that this object never changes as part of the diffing algo
|
|
4347
|
+
freeze(map);
|
|
4443
4348
|
}
|
|
4444
4349
|
|
|
4445
|
-
return
|
|
4350
|
+
return map;
|
|
4446
4351
|
}
|
|
4447
|
-
/**
|
|
4448
|
-
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
|
4449
|
-
* subject to change or being removed.
|
|
4450
|
-
*/
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
function isComponentConstructor(ctor) {
|
|
4454
|
-
if (!isFunction$1(ctor)) {
|
|
4455
|
-
return false;
|
|
4456
|
-
} // Fast path: LightningElement is part of the prototype chain of the constructor.
|
|
4457
4352
|
|
|
4353
|
+
function patchClassAttribute(oldVnode, vnode) {
|
|
4354
|
+
const {
|
|
4355
|
+
elm,
|
|
4356
|
+
data: {
|
|
4357
|
+
className: newClass
|
|
4358
|
+
}
|
|
4359
|
+
} = vnode;
|
|
4360
|
+
const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
|
|
4458
4361
|
|
|
4459
|
-
if (
|
|
4460
|
-
return
|
|
4461
|
-
}
|
|
4462
|
-
// climb up the constructor prototype chain to check in case there are circular dependencies
|
|
4463
|
-
// to resolve.
|
|
4362
|
+
if (oldClass === newClass) {
|
|
4363
|
+
return;
|
|
4364
|
+
}
|
|
4464
4365
|
|
|
4366
|
+
const classList = getClassList$1(elm);
|
|
4367
|
+
const newClassMap = getMapFromClassName(newClass);
|
|
4368
|
+
const oldClassMap = getMapFromClassName(oldClass);
|
|
4369
|
+
let name;
|
|
4465
4370
|
|
|
4466
|
-
|
|
4371
|
+
for (name in oldClassMap) {
|
|
4372
|
+
// remove only if it is not in the new class collection and it is not set from within the instance
|
|
4373
|
+
if (isUndefined$1(newClassMap[name])) {
|
|
4374
|
+
classList.remove(name);
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4467
4377
|
|
|
4468
|
-
|
|
4469
|
-
if (
|
|
4470
|
-
|
|
4471
|
-
|
|
4378
|
+
for (name in newClassMap) {
|
|
4379
|
+
if (isUndefined$1(oldClassMap[name])) {
|
|
4380
|
+
classList.add(name);
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
/*
|
|
4385
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4386
|
+
* All rights reserved.
|
|
4387
|
+
* SPDX-License-Identifier: MIT
|
|
4388
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4389
|
+
*/
|
|
4472
4390
|
|
|
4473
|
-
if (circularResolved === current) {
|
|
4474
|
-
return true;
|
|
4475
|
-
}
|
|
4476
4391
|
|
|
4477
|
-
|
|
4392
|
+
function patchStyleAttribute(oldVnode, vnode) {
|
|
4393
|
+
const {
|
|
4394
|
+
elm,
|
|
4395
|
+
data: {
|
|
4396
|
+
style: newStyle
|
|
4478
4397
|
}
|
|
4398
|
+
} = vnode;
|
|
4399
|
+
const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
|
|
4479
4400
|
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4401
|
+
if (oldStyle === newStyle) {
|
|
4402
|
+
return;
|
|
4403
|
+
}
|
|
4404
|
+
|
|
4405
|
+
if (!isString(newStyle) || newStyle === '') {
|
|
4406
|
+
removeAttribute$1(elm, 'style');
|
|
4407
|
+
} else {
|
|
4408
|
+
setAttribute$1(elm, 'style', newStyle);
|
|
4409
|
+
}
|
|
4410
|
+
}
|
|
4411
|
+
/*
|
|
4412
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4413
|
+
* All rights reserved.
|
|
4414
|
+
* SPDX-License-Identifier: MIT
|
|
4415
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4416
|
+
*/
|
|
4484
4417
|
|
|
4485
4418
|
|
|
4486
|
-
|
|
4487
|
-
|
|
4419
|
+
function applyEventListeners(vnode) {
|
|
4420
|
+
const {
|
|
4421
|
+
elm,
|
|
4422
|
+
data: {
|
|
4423
|
+
on
|
|
4424
|
+
}
|
|
4425
|
+
} = vnode;
|
|
4488
4426
|
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
Ctor = getComponentOrSwappedComponent(Ctor);
|
|
4427
|
+
if (isUndefined$1(on)) {
|
|
4428
|
+
return;
|
|
4492
4429
|
}
|
|
4493
4430
|
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4431
|
+
for (const name in on) {
|
|
4432
|
+
const handler = on[name];
|
|
4433
|
+
addEventListener$1(elm, name, handler);
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
/*
|
|
4437
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4438
|
+
* All rights reserved.
|
|
4439
|
+
* SPDX-License-Identifier: MIT
|
|
4440
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4441
|
+
*/
|
|
4442
|
+
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
4443
|
+
// different classnames properties individually instead of via a string.
|
|
4501
4444
|
|
|
4502
|
-
CtorToDefMap.set(Ctor, def);
|
|
4503
|
-
return def;
|
|
4504
|
-
}
|
|
4505
4445
|
|
|
4506
|
-
|
|
4507
|
-
|
|
4446
|
+
function applyStaticClassAttribute(vnode) {
|
|
4447
|
+
const {
|
|
4448
|
+
elm,
|
|
4449
|
+
data: {
|
|
4450
|
+
classMap
|
|
4508
4451
|
}
|
|
4452
|
+
} = vnode;
|
|
4509
4453
|
|
|
4510
|
-
|
|
4511
|
-
|
|
4454
|
+
if (isUndefined$1(classMap)) {
|
|
4455
|
+
return;
|
|
4512
4456
|
}
|
|
4513
4457
|
|
|
4514
|
-
|
|
4515
|
-
}
|
|
4458
|
+
const classList = getClassList$1(elm);
|
|
4516
4459
|
|
|
4517
|
-
const
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
shadowSupportMode: "reset"
|
|
4527
|
-
/* Default */
|
|
4528
|
-
,
|
|
4529
|
-
wire: EmptyObject,
|
|
4530
|
-
bridge: BaseBridgeElement,
|
|
4531
|
-
template: defaultEmptyTemplate,
|
|
4532
|
-
render: LightningElement.prototype.render
|
|
4533
|
-
};
|
|
4534
|
-
/**
|
|
4535
|
-
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
|
4536
|
-
* subject to change or being removed.
|
|
4460
|
+
for (const name in classMap) {
|
|
4461
|
+
classList.add(name);
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
/*
|
|
4465
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4466
|
+
* All rights reserved.
|
|
4467
|
+
* SPDX-License-Identifier: MIT
|
|
4468
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4537
4469
|
*/
|
|
4470
|
+
// The compiler takes care of transforming the inline style into an object. It's faster to set the
|
|
4471
|
+
// different style properties individually instead of via a string.
|
|
4538
4472
|
|
|
4539
|
-
function getComponentDef(Ctor) {
|
|
4540
|
-
const def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
|
|
4541
|
-
// for some external services, e.g.: Locker Service, usually, all they care
|
|
4542
|
-
// is about the shape of the constructor, the internals of it are not relevant
|
|
4543
|
-
// because they don't have a way to mess with that.
|
|
4544
4473
|
|
|
4474
|
+
function applyStaticStyleAttribute(vnode) {
|
|
4545
4475
|
const {
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
} = def;
|
|
4552
|
-
const publicProps = {};
|
|
4476
|
+
elm,
|
|
4477
|
+
data: {
|
|
4478
|
+
styleDecls
|
|
4479
|
+
}
|
|
4480
|
+
} = vnode;
|
|
4553
4481
|
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
publicProps[key] = {
|
|
4557
|
-
config: propsConfig[key] || 0,
|
|
4558
|
-
type: "any"
|
|
4559
|
-
/* any */
|
|
4560
|
-
,
|
|
4561
|
-
attr: htmlPropertyToAttribute(key)
|
|
4562
|
-
};
|
|
4482
|
+
if (isUndefined$1(styleDecls)) {
|
|
4483
|
+
return;
|
|
4563
4484
|
}
|
|
4564
4485
|
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
// avoid leaking the reference to the public method descriptors
|
|
4569
|
-
publicMethods[key] = methods[key].value;
|
|
4486
|
+
for (let i = 0; i < styleDecls.length; i++) {
|
|
4487
|
+
const [prop, value, important] = styleDecls[i];
|
|
4488
|
+
setCSSStyleProperty$1(elm, prop, value, important);
|
|
4570
4489
|
}
|
|
4571
|
-
|
|
4572
|
-
return {
|
|
4573
|
-
ctor,
|
|
4574
|
-
name,
|
|
4575
|
-
props: publicProps,
|
|
4576
|
-
methods: publicMethods
|
|
4577
|
-
};
|
|
4578
4490
|
}
|
|
4579
4491
|
/*
|
|
4580
4492
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -4648,28 +4560,24 @@ function removeNodeHook(vnode, parentNode) {
|
|
|
4648
4560
|
}
|
|
4649
4561
|
}
|
|
4650
4562
|
|
|
4651
|
-
function
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4563
|
+
function patchElementPropsAndAttrs(oldVnode, vnode) {
|
|
4564
|
+
if (isNull(oldVnode)) {
|
|
4565
|
+
applyEventListeners(vnode);
|
|
4566
|
+
applyStaticClassAttribute(vnode);
|
|
4567
|
+
applyStaticStyleAttribute(vnode);
|
|
4568
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4569
|
+
// value is set before type=radio.
|
|
4655
4570
|
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
modComputedStyle.create(vnode);
|
|
4571
|
+
|
|
4572
|
+
patchClassAttribute(oldVnode, vnode);
|
|
4573
|
+
patchStyleAttribute(oldVnode, vnode);
|
|
4574
|
+
patchAttributes(oldVnode, vnode);
|
|
4575
|
+
patchProps(oldVnode, vnode);
|
|
4662
4576
|
}
|
|
4663
4577
|
|
|
4664
4578
|
function hydrateElmHook(vnode) {
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
modProps.create(vnode); // Already set.
|
|
4669
|
-
// modStaticClassName.create(vnode);
|
|
4670
|
-
// modStaticStyle.create(vnode);
|
|
4671
|
-
// modComputedClassName.create(vnode);
|
|
4672
|
-
// modComputedStyle.create(vnode);
|
|
4579
|
+
applyEventListeners(vnode);
|
|
4580
|
+
patchProps(null, vnode);
|
|
4673
4581
|
}
|
|
4674
4582
|
|
|
4675
4583
|
function fallbackElmHook(elm, vnode) {
|
|
@@ -4721,26 +4629,11 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4721
4629
|
}
|
|
4722
4630
|
}
|
|
4723
4631
|
|
|
4724
|
-
function
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
// is set before type=radio.
|
|
4728
|
-
modAttrs.update(oldVnode, vnode);
|
|
4729
|
-
modProps.update(oldVnode, vnode);
|
|
4730
|
-
modComputedClassName.update(oldVnode, vnode);
|
|
4731
|
-
modComputedStyle.update(oldVnode, vnode);
|
|
4732
|
-
}
|
|
4733
|
-
|
|
4734
|
-
function updateChildrenHook(oldVnode, vnode) {
|
|
4735
|
-
const {
|
|
4736
|
-
elm,
|
|
4737
|
-
children
|
|
4738
|
-
} = vnode;
|
|
4739
|
-
|
|
4740
|
-
if (hasDynamicChildren(children)) {
|
|
4741
|
-
updateDynamicChildren(elm, oldVnode.children, children);
|
|
4632
|
+
function patchChildren(parent, oldCh, newCh) {
|
|
4633
|
+
if (hasDynamicChildren(newCh)) {
|
|
4634
|
+
updateDynamicChildren(parent, oldCh, newCh);
|
|
4742
4635
|
} else {
|
|
4743
|
-
updateStaticChildren(
|
|
4636
|
+
updateStaticChildren(parent, oldCh, newCh);
|
|
4744
4637
|
}
|
|
4745
4638
|
}
|
|
4746
4639
|
|
|
@@ -4815,19 +4708,6 @@ function createViewModelHook(elm, vnode) {
|
|
|
4815
4708
|
}
|
|
4816
4709
|
}
|
|
4817
4710
|
|
|
4818
|
-
function createCustomElmHook(vnode) {
|
|
4819
|
-
modEvents.create(vnode); // Attrs need to be applied to element before props
|
|
4820
|
-
// IE11 will wipe out value on radio inputs if value
|
|
4821
|
-
// is set before type=radio.
|
|
4822
|
-
|
|
4823
|
-
modAttrs.create(vnode);
|
|
4824
|
-
modProps.create(vnode);
|
|
4825
|
-
modStaticClassName.create(vnode);
|
|
4826
|
-
modStaticStyle.create(vnode);
|
|
4827
|
-
modComputedClassName.create(vnode);
|
|
4828
|
-
modComputedStyle.create(vnode);
|
|
4829
|
-
}
|
|
4830
|
-
|
|
4831
4711
|
function createChildrenHook(vnode) {
|
|
4832
4712
|
const {
|
|
4833
4713
|
elm,
|
|
@@ -5008,16 +4888,6 @@ function hydrateChildrenHook(elmChildren, children, vm) {
|
|
|
5008
4888
|
}
|
|
5009
4889
|
}
|
|
5010
4890
|
|
|
5011
|
-
function updateCustomElmHook(oldVnode, vnode) {
|
|
5012
|
-
// Attrs need to be applied to element before props
|
|
5013
|
-
// IE11 will wipe out value on radio inputs if value
|
|
5014
|
-
// is set before type=radio.
|
|
5015
|
-
modAttrs.update(oldVnode, vnode);
|
|
5016
|
-
modProps.update(oldVnode, vnode);
|
|
5017
|
-
modComputedClassName.update(oldVnode, vnode);
|
|
5018
|
-
modComputedStyle.update(oldVnode, vnode);
|
|
5019
|
-
}
|
|
5020
|
-
|
|
5021
4891
|
function removeElmHook(vnode) {
|
|
5022
4892
|
// this method only needs to search on child vnodes from template
|
|
5023
4893
|
// to trigger the remove hook just in case some of those children
|
|
@@ -5034,6 +4904,66 @@ function removeElmHook(vnode) {
|
|
|
5034
4904
|
ch.hook.remove(ch, elm);
|
|
5035
4905
|
}
|
|
5036
4906
|
}
|
|
4907
|
+
}
|
|
4908
|
+
|
|
4909
|
+
function allocateInSlot(vm, children) {
|
|
4910
|
+
const {
|
|
4911
|
+
cmpSlots: oldSlots
|
|
4912
|
+
} = vm;
|
|
4913
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
4914
|
+
|
|
4915
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4916
|
+
const vnode = children[i];
|
|
4917
|
+
|
|
4918
|
+
if (isNull(vnode)) {
|
|
4919
|
+
continue;
|
|
4920
|
+
}
|
|
4921
|
+
|
|
4922
|
+
const {
|
|
4923
|
+
data
|
|
4924
|
+
} = vnode;
|
|
4925
|
+
const slotName = data.attrs && data.attrs.slot || '';
|
|
4926
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
|
|
4927
|
+
// which might have similar keys. Each vnode will always have a key that
|
|
4928
|
+
// starts with a numeric character from compiler. In this case, we add a unique
|
|
4929
|
+
// notation for slotted vnodes keys, e.g.: `@foo:1:1`
|
|
4930
|
+
|
|
4931
|
+
if (!isUndefined$1(vnode.key)) {
|
|
4932
|
+
vnode.key = `@${slotName}:${vnode.key}`;
|
|
4933
|
+
}
|
|
4934
|
+
|
|
4935
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
4936
|
+
}
|
|
4937
|
+
|
|
4938
|
+
if (isFalse(vm.isDirty)) {
|
|
4939
|
+
// We need to determine if the old allocation is really different from the new one
|
|
4940
|
+
// and mark the vm as dirty
|
|
4941
|
+
const oldKeys = keys(oldSlots);
|
|
4942
|
+
|
|
4943
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
4944
|
+
markComponentAsDirty(vm);
|
|
4945
|
+
return;
|
|
4946
|
+
}
|
|
4947
|
+
|
|
4948
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4949
|
+
const key = oldKeys[i];
|
|
4950
|
+
|
|
4951
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
4952
|
+
markComponentAsDirty(vm);
|
|
4953
|
+
return;
|
|
4954
|
+
}
|
|
4955
|
+
|
|
4956
|
+
const oldVNodes = oldSlots[key];
|
|
4957
|
+
const vnodes = cmpSlots[key];
|
|
4958
|
+
|
|
4959
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
4960
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
4961
|
+
markComponentAsDirty(vm);
|
|
4962
|
+
return;
|
|
4963
|
+
}
|
|
4964
|
+
}
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
5037
4967
|
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
5038
4968
|
|
|
5039
4969
|
|
|
@@ -5180,11 +5110,11 @@ const ElementHook = {
|
|
|
5180
5110
|
linkNodeToShadow(elm, owner);
|
|
5181
5111
|
fallbackElmHook(elm, vnode);
|
|
5182
5112
|
vnode.elm = elm;
|
|
5183
|
-
|
|
5113
|
+
patchElementPropsAndAttrs(null, vnode);
|
|
5184
5114
|
},
|
|
5185
5115
|
update: (oldVnode, vnode) => {
|
|
5186
|
-
|
|
5187
|
-
|
|
5116
|
+
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
5117
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
5188
5118
|
},
|
|
5189
5119
|
insert: (vnode, parentNode, referenceNode) => {
|
|
5190
5120
|
insertNodeHook(vnode, parentNode, referenceNode);
|
|
@@ -5258,10 +5188,10 @@ const CustomElementHook = {
|
|
|
5258
5188
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
5259
5189
|
}
|
|
5260
5190
|
|
|
5261
|
-
|
|
5191
|
+
patchElementPropsAndAttrs(null, vnode);
|
|
5262
5192
|
},
|
|
5263
5193
|
update: (oldVnode, vnode) => {
|
|
5264
|
-
|
|
5194
|
+
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
5265
5195
|
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
5266
5196
|
|
|
5267
5197
|
if (vm) {
|
|
@@ -5272,7 +5202,7 @@ const CustomElementHook = {
|
|
|
5272
5202
|
// will happen, but in native, it does allocate the light dom
|
|
5273
5203
|
|
|
5274
5204
|
|
|
5275
|
-
|
|
5205
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
5276
5206
|
|
|
5277
5207
|
if (vm) {
|
|
5278
5208
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -6914,7 +6844,6 @@ function patchShadowRoot(vm, newCh) {
|
|
|
6914
6844
|
// patch function mutates vnodes by adding the element reference,
|
|
6915
6845
|
// however, if patching fails it contains partial changes.
|
|
6916
6846
|
if (oldCh !== newCh) {
|
|
6917
|
-
const fn = hasDynamicChildren(newCh) ? updateDynamicChildren : updateStaticChildren;
|
|
6918
6847
|
runWithBoundaryProtection(vm, vm, () => {
|
|
6919
6848
|
// pre
|
|
6920
6849
|
logOperationStart(2
|
|
@@ -6922,8 +6851,8 @@ function patchShadowRoot(vm, newCh) {
|
|
|
6922
6851
|
, vm);
|
|
6923
6852
|
}, () => {
|
|
6924
6853
|
// job
|
|
6925
|
-
const
|
|
6926
|
-
|
|
6854
|
+
const renderRoot = getRenderRoot(vm);
|
|
6855
|
+
patchChildren(renderRoot, oldCh, newCh);
|
|
6927
6856
|
}, () => {
|
|
6928
6857
|
// post
|
|
6929
6858
|
logOperationEnd(2
|
|
@@ -7218,69 +7147,6 @@ function getErrorBoundaryVM(vm) {
|
|
|
7218
7147
|
|
|
7219
7148
|
currentVm = currentVm.owner;
|
|
7220
7149
|
}
|
|
7221
|
-
} // slow path routine
|
|
7222
|
-
// NOTE: we should probably more this routine to the synthetic shadow folder
|
|
7223
|
-
// and get the allocation to be cached by in the elm instead of in the VM
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
function allocateInSlot(vm, children) {
|
|
7227
|
-
const {
|
|
7228
|
-
cmpSlots: oldSlots
|
|
7229
|
-
} = vm;
|
|
7230
|
-
const cmpSlots = vm.cmpSlots = create(null);
|
|
7231
|
-
|
|
7232
|
-
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
7233
|
-
const vnode = children[i];
|
|
7234
|
-
|
|
7235
|
-
if (isNull(vnode)) {
|
|
7236
|
-
continue;
|
|
7237
|
-
}
|
|
7238
|
-
|
|
7239
|
-
const {
|
|
7240
|
-
data
|
|
7241
|
-
} = vnode;
|
|
7242
|
-
const slotName = data.attrs && data.attrs.slot || '';
|
|
7243
|
-
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
|
|
7244
|
-
// which might have similar keys. Each vnode will always have a key that
|
|
7245
|
-
// starts with a numeric character from compiler. In this case, we add a unique
|
|
7246
|
-
// notation for slotted vnodes keys, e.g.: `@foo:1:1`
|
|
7247
|
-
|
|
7248
|
-
if (!isUndefined$1(vnode.key)) {
|
|
7249
|
-
vnode.key = `@${slotName}:${vnode.key}`;
|
|
7250
|
-
}
|
|
7251
|
-
|
|
7252
|
-
ArrayPush$1.call(vnodes, vnode);
|
|
7253
|
-
}
|
|
7254
|
-
|
|
7255
|
-
if (isFalse(vm.isDirty)) {
|
|
7256
|
-
// We need to determine if the old allocation is really different from the new one
|
|
7257
|
-
// and mark the vm as dirty
|
|
7258
|
-
const oldKeys = keys(oldSlots);
|
|
7259
|
-
|
|
7260
|
-
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
7261
|
-
markComponentAsDirty(vm);
|
|
7262
|
-
return;
|
|
7263
|
-
}
|
|
7264
|
-
|
|
7265
|
-
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
7266
|
-
const key = oldKeys[i];
|
|
7267
|
-
|
|
7268
|
-
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
7269
|
-
markComponentAsDirty(vm);
|
|
7270
|
-
return;
|
|
7271
|
-
}
|
|
7272
|
-
|
|
7273
|
-
const oldVNodes = oldSlots[key];
|
|
7274
|
-
const vnodes = cmpSlots[key];
|
|
7275
|
-
|
|
7276
|
-
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
7277
|
-
if (oldVNodes[j] !== vnodes[j]) {
|
|
7278
|
-
markComponentAsDirty(vm);
|
|
7279
|
-
return;
|
|
7280
|
-
}
|
|
7281
|
-
}
|
|
7282
|
-
}
|
|
7283
|
-
}
|
|
7284
7150
|
}
|
|
7285
7151
|
|
|
7286
7152
|
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
@@ -7713,7 +7579,7 @@ function setHooks(hooks) {
|
|
|
7713
7579
|
hooksAreSet = true;
|
|
7714
7580
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7715
7581
|
}
|
|
7716
|
-
/* version: 2.7.
|
|
7582
|
+
/* version: 2.7.3 */
|
|
7717
7583
|
|
|
7718
7584
|
/*
|
|
7719
7585
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -8254,6 +8120,6 @@ function renderComponent(tagName, Ctor, props = {}) {
|
|
|
8254
8120
|
|
|
8255
8121
|
freeze(LightningElement);
|
|
8256
8122
|
seal(LightningElement.prototype);
|
|
8257
|
-
/* version: 2.7.
|
|
8123
|
+
/* version: 2.7.3 */
|
|
8258
8124
|
|
|
8259
8125
|
export { LightningElement, api$1 as api, createContextProvider, getComponentDef, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, track, unwrap, wire };
|