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
|
@@ -299,7 +299,7 @@ function htmlPropertyToAttribute(propName) {
|
|
|
299
299
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
300
300
|
return attributeName;
|
|
301
301
|
}
|
|
302
|
-
/** version: 2.7.
|
|
302
|
+
/** version: 2.7.3 */
|
|
303
303
|
|
|
304
304
|
/*
|
|
305
305
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -477,7 +477,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
477
477
|
setFeatureFlag(name, value);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
/** version: 2.7.
|
|
480
|
+
/** version: 2.7.3 */
|
|
481
481
|
|
|
482
482
|
/* proxy-compat-disable */
|
|
483
483
|
|
|
@@ -1011,62 +1011,205 @@ function logWarn(message, vm) {
|
|
|
1011
1011
|
*/
|
|
1012
1012
|
|
|
1013
1013
|
|
|
1014
|
-
function
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1014
|
+
function isUndef(s) {
|
|
1015
|
+
return s === undefined;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
function sameVnode(vnode1, vnode2) {
|
|
1019
|
+
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function isVNode(vnode) {
|
|
1023
|
+
return vnode != null;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
1027
|
+
const map = {};
|
|
1028
|
+
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
1029
|
+
|
|
1030
|
+
for (j = beginIdx; j <= endIdx; ++j) {
|
|
1031
|
+
ch = children[j];
|
|
1024
1032
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1033
|
+
if (isVNode(ch)) {
|
|
1034
|
+
key = ch.key;
|
|
1035
|
+
|
|
1036
|
+
if (key !== undefined) {
|
|
1037
|
+
map[key] = j;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1027
1040
|
}
|
|
1041
|
+
|
|
1042
|
+
return map;
|
|
1028
1043
|
}
|
|
1029
1044
|
|
|
1030
|
-
function
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1045
|
+
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
1046
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
1047
|
+
const ch = vnodes[startIdx];
|
|
1048
|
+
|
|
1049
|
+
if (isVNode(ch)) {
|
|
1050
|
+
ch.hook.create(ch);
|
|
1051
|
+
ch.hook.insert(ch, parentElm, before);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1034
1054
|
}
|
|
1035
1055
|
|
|
1036
|
-
function
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1056
|
+
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
1057
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
1058
|
+
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
1059
|
+
|
|
1060
|
+
if (isVNode(ch)) {
|
|
1061
|
+
ch.hook.remove(ch, parentElm);
|
|
1062
|
+
}
|
|
1042
1063
|
}
|
|
1043
1064
|
}
|
|
1044
1065
|
|
|
1045
|
-
function
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1066
|
+
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
1067
|
+
let oldStartIdx = 0;
|
|
1068
|
+
let newStartIdx = 0;
|
|
1069
|
+
let oldEndIdx = oldCh.length - 1;
|
|
1070
|
+
let oldStartVnode = oldCh[0];
|
|
1071
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
1072
|
+
const newChEnd = newCh.length - 1;
|
|
1073
|
+
let newEndIdx = newChEnd;
|
|
1074
|
+
let newStartVnode = newCh[0];
|
|
1075
|
+
let newEndVnode = newCh[newEndIdx];
|
|
1076
|
+
let oldKeyToIdx;
|
|
1077
|
+
let idxInOld;
|
|
1078
|
+
let elmToMove;
|
|
1079
|
+
let before;
|
|
1080
|
+
|
|
1081
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
1082
|
+
if (!isVNode(oldStartVnode)) {
|
|
1083
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
1084
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
1085
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
1086
|
+
} else if (!isVNode(newStartVnode)) {
|
|
1087
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1088
|
+
} else if (!isVNode(newEndVnode)) {
|
|
1089
|
+
newEndVnode = newCh[--newEndIdx];
|
|
1090
|
+
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
1091
|
+
patchVnode(oldStartVnode, newStartVnode);
|
|
1092
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
1093
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1094
|
+
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
1095
|
+
patchVnode(oldEndVnode, newEndVnode);
|
|
1096
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
1097
|
+
newEndVnode = newCh[--newEndIdx];
|
|
1098
|
+
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
1099
|
+
// Vnode moved right
|
|
1100
|
+
patchVnode(oldStartVnode, newEndVnode);
|
|
1101
|
+
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
|
|
1102
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
1103
|
+
newEndVnode = newCh[--newEndIdx];
|
|
1104
|
+
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
1105
|
+
// Vnode moved left
|
|
1106
|
+
patchVnode(oldEndVnode, newStartVnode);
|
|
1107
|
+
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
1108
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
1109
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1110
|
+
} else {
|
|
1111
|
+
if (oldKeyToIdx === undefined) {
|
|
1112
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
1116
|
+
|
|
1117
|
+
if (isUndef(idxInOld)) {
|
|
1118
|
+
// New element
|
|
1119
|
+
newStartVnode.hook.create(newStartVnode);
|
|
1120
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1121
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1122
|
+
} else {
|
|
1123
|
+
elmToMove = oldCh[idxInOld];
|
|
1124
|
+
|
|
1125
|
+
if (isVNode(elmToMove)) {
|
|
1126
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
1127
|
+
// New element
|
|
1128
|
+
newStartVnode.hook.create(newStartVnode);
|
|
1129
|
+
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1130
|
+
} else {
|
|
1131
|
+
patchVnode(elmToMove, newStartVnode);
|
|
1132
|
+
oldCh[idxInOld] = undefined;
|
|
1133
|
+
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
newStartVnode = newCh[++newStartIdx];
|
|
1138
|
+
}
|
|
1050
1139
|
}
|
|
1051
|
-
}
|
|
1140
|
+
}
|
|
1052
1141
|
|
|
1053
|
-
if (
|
|
1142
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
1143
|
+
if (oldStartIdx > oldEndIdx) {
|
|
1144
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
1145
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
1146
|
+
let i = newEndIdx;
|
|
1147
|
+
let n;
|
|
1148
|
+
|
|
1149
|
+
do {
|
|
1150
|
+
n = newCh[++i];
|
|
1151
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
1152
|
+
|
|
1153
|
+
before = isVNode(n) ? n.elm : null;
|
|
1154
|
+
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
1155
|
+
} else {
|
|
1156
|
+
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
1162
|
+
const oldChLength = oldCh.length;
|
|
1163
|
+
const newChLength = newCh.length;
|
|
1164
|
+
|
|
1165
|
+
if (oldChLength === 0) {
|
|
1166
|
+
// the old list is empty, we can directly insert anything new
|
|
1167
|
+
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
1054
1168
|
return;
|
|
1055
1169
|
}
|
|
1056
1170
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1171
|
+
if (newChLength === 0) {
|
|
1172
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
1173
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
1174
|
+
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
1175
|
+
return;
|
|
1176
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
1177
|
+
// amount of nodes, that's why we call this static children
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
let referenceElm = null;
|
|
1181
|
+
|
|
1182
|
+
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
1183
|
+
const vnode = newCh[i];
|
|
1184
|
+
const oldVNode = oldCh[i];
|
|
1185
|
+
|
|
1186
|
+
if (vnode !== oldVNode) {
|
|
1187
|
+
if (isVNode(oldVNode)) {
|
|
1188
|
+
if (isVNode(vnode)) {
|
|
1189
|
+
// both vnodes must be equivalent, and se just need to patch them
|
|
1190
|
+
patchVnode(oldVNode, vnode);
|
|
1191
|
+
referenceElm = vnode.elm;
|
|
1192
|
+
} else {
|
|
1193
|
+
// removing the old vnode since the new one is null
|
|
1194
|
+
oldVNode.hook.remove(oldVNode, parentElm);
|
|
1195
|
+
}
|
|
1196
|
+
} else if (isVNode(vnode)) {
|
|
1197
|
+
// this condition is unnecessary
|
|
1198
|
+
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
1060
1199
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1200
|
+
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
1201
|
+
referenceElm = vnode.elm;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1063
1204
|
}
|
|
1064
1205
|
}
|
|
1065
1206
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1207
|
+
function patchVnode(oldVnode, vnode) {
|
|
1208
|
+
if (oldVnode !== vnode) {
|
|
1209
|
+
vnode.elm = oldVnode.elm;
|
|
1210
|
+
vnode.hook.update(oldVnode, vnode);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1070
1213
|
/*
|
|
1071
1214
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1072
1215
|
* All rights reserved.
|
|
@@ -1074,6 +1217,7 @@ var modEvents = {
|
|
|
1074
1217
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1075
1218
|
*/
|
|
1076
1219
|
|
|
1220
|
+
|
|
1077
1221
|
const defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
|
|
1078
1222
|
|
|
1079
1223
|
function offsetPropertyErrorMessage(name) {
|
|
@@ -1193,313 +1337,379 @@ function unlockAttribute(elm, key) {
|
|
|
1193
1337
|
*/
|
|
1194
1338
|
|
|
1195
1339
|
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
attrs
|
|
1204
|
-
}
|
|
1205
|
-
} = vnode;
|
|
1340
|
+
function generateDataDescriptor(options) {
|
|
1341
|
+
return assign({
|
|
1342
|
+
configurable: true,
|
|
1343
|
+
enumerable: true,
|
|
1344
|
+
writable: true
|
|
1345
|
+
}, options);
|
|
1346
|
+
}
|
|
1206
1347
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1348
|
+
function generateAccessorDescriptor(options) {
|
|
1349
|
+
return assign({
|
|
1350
|
+
configurable: true,
|
|
1351
|
+
enumerable: true
|
|
1352
|
+
}, options);
|
|
1353
|
+
}
|
|
1210
1354
|
|
|
1211
|
-
|
|
1212
|
-
data: {
|
|
1213
|
-
attrs: oldAttrs
|
|
1214
|
-
}
|
|
1215
|
-
} = oldVnode;
|
|
1355
|
+
let isDomMutationAllowed = false;
|
|
1216
1356
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1357
|
+
function unlockDomMutation() {
|
|
1358
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1359
|
+
// this method should never leak to prod
|
|
1360
|
+
throw new ReferenceError();
|
|
1219
1361
|
}
|
|
1220
1362
|
|
|
1221
|
-
|
|
1222
|
-
|
|
1363
|
+
isDomMutationAllowed = true;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function lockDomMutation() {
|
|
1367
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1368
|
+
// this method should never leak to prod
|
|
1369
|
+
throw new ReferenceError();
|
|
1223
1370
|
}
|
|
1224
1371
|
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
oldAttrs = isUndefined$1(oldAttrs) ? EmptyObject : oldAttrs; // update modified attributes, add new attributes
|
|
1228
|
-
// this routine is only useful for data-* attributes in all kind of elements
|
|
1229
|
-
// and aria-* in standard elements (custom elements will use props for these)
|
|
1372
|
+
isDomMutationAllowed = false;
|
|
1373
|
+
}
|
|
1230
1374
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1375
|
+
function logMissingPortalError(name, type) {
|
|
1376
|
+
return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
|
|
1377
|
+
}
|
|
1234
1378
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1379
|
+
function patchElementWithRestrictions(elm, options) {
|
|
1380
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1381
|
+
// this method should never leak to prod
|
|
1382
|
+
throw new ReferenceError();
|
|
1383
|
+
}
|
|
1237
1384
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
setAttribute$1(elm, key, cur);
|
|
1385
|
+
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1386
|
+
const descriptors = {
|
|
1387
|
+
outerHTML: generateAccessorDescriptor({
|
|
1388
|
+
get() {
|
|
1389
|
+
return originalOuterHTMLDescriptor.get.call(this);
|
|
1390
|
+
},
|
|
1391
|
+
|
|
1392
|
+
set(_value) {
|
|
1393
|
+
throw new TypeError(`Invalid attempt to set outerHTML on Element.`);
|
|
1248
1394
|
}
|
|
1249
1395
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1396
|
+
})
|
|
1397
|
+
}; // Apply extra restriction related to DOM manipulation if the element is not a portal.
|
|
1254
1398
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
};
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1399
|
+
if (!options.isLight && !options.isPortal) {
|
|
1400
|
+
const {
|
|
1401
|
+
appendChild,
|
|
1402
|
+
insertBefore,
|
|
1403
|
+
removeChild,
|
|
1404
|
+
replaceChild
|
|
1405
|
+
} = elm;
|
|
1406
|
+
const originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
|
|
1407
|
+
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
1408
|
+
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
|
1409
|
+
assign(descriptors, {
|
|
1410
|
+
appendChild: generateDataDescriptor({
|
|
1411
|
+
value(aChild) {
|
|
1412
|
+
logMissingPortalError('appendChild', 'method');
|
|
1413
|
+
return appendChild.call(this, aChild);
|
|
1414
|
+
}
|
|
1268
1415
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1416
|
+
}),
|
|
1417
|
+
insertBefore: generateDataDescriptor({
|
|
1418
|
+
value(newNode, referenceNode) {
|
|
1419
|
+
if (!isDomMutationAllowed) {
|
|
1420
|
+
logMissingPortalError('insertBefore', 'method');
|
|
1421
|
+
}
|
|
1274
1422
|
|
|
1275
|
-
|
|
1276
|
-
|
|
1423
|
+
return insertBefore.call(this, newNode, referenceNode);
|
|
1424
|
+
}
|
|
1277
1425
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1426
|
+
}),
|
|
1427
|
+
removeChild: generateDataDescriptor({
|
|
1428
|
+
value(aChild) {
|
|
1429
|
+
if (!isDomMutationAllowed) {
|
|
1430
|
+
logMissingPortalError('removeChild', 'method');
|
|
1431
|
+
}
|
|
1281
1432
|
|
|
1282
|
-
|
|
1433
|
+
return removeChild.call(this, aChild);
|
|
1434
|
+
}
|
|
1283
1435
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1436
|
+
}),
|
|
1437
|
+
replaceChild: generateDataDescriptor({
|
|
1438
|
+
value(newChild, oldChild) {
|
|
1439
|
+
logMissingPortalError('replaceChild', 'method');
|
|
1440
|
+
return replaceChild.call(this, newChild, oldChild);
|
|
1441
|
+
}
|
|
1287
1442
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1443
|
+
}),
|
|
1444
|
+
nodeValue: generateAccessorDescriptor({
|
|
1445
|
+
get() {
|
|
1446
|
+
return originalNodeValueDescriptor.get.call(this);
|
|
1447
|
+
},
|
|
1291
1448
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
} = vnode;
|
|
1449
|
+
set(value) {
|
|
1450
|
+
if (!isDomMutationAllowed) {
|
|
1451
|
+
logMissingPortalError('nodeValue', 'property');
|
|
1452
|
+
}
|
|
1297
1453
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1454
|
+
originalNodeValueDescriptor.set.call(this, value);
|
|
1455
|
+
}
|
|
1300
1456
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1457
|
+
}),
|
|
1458
|
+
textContent: generateAccessorDescriptor({
|
|
1459
|
+
get() {
|
|
1460
|
+
return originalTextContentDescriptor.get.call(this);
|
|
1461
|
+
},
|
|
1306
1462
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
create: vnode => update(emptyVNode$2, vnode),
|
|
1312
|
-
update
|
|
1313
|
-
};
|
|
1314
|
-
/*
|
|
1315
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1316
|
-
* All rights reserved.
|
|
1317
|
-
* SPDX-License-Identifier: MIT
|
|
1318
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1319
|
-
*/
|
|
1463
|
+
set(value) {
|
|
1464
|
+
logMissingPortalError('textContent', 'property');
|
|
1465
|
+
originalTextContentDescriptor.set.call(this, value);
|
|
1466
|
+
}
|
|
1320
1467
|
|
|
1321
|
-
|
|
1468
|
+
}),
|
|
1469
|
+
innerHTML: generateAccessorDescriptor({
|
|
1470
|
+
get() {
|
|
1471
|
+
return originalInnerHTMLDescriptor.get.call(this);
|
|
1472
|
+
},
|
|
1322
1473
|
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
} // computed class names must be string
|
|
1474
|
+
set(value) {
|
|
1475
|
+
logMissingPortalError('innerHTML', 'property');
|
|
1476
|
+
return originalInnerHTMLDescriptor.set.call(this, value);
|
|
1477
|
+
}
|
|
1328
1478
|
|
|
1479
|
+
})
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1329
1482
|
|
|
1330
|
-
|
|
1331
|
-
|
|
1483
|
+
defineProperties(elm, descriptors);
|
|
1484
|
+
}
|
|
1332
1485
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1486
|
+
function getShadowRootRestrictionsDescriptors(sr) {
|
|
1487
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1488
|
+
// this method should never leak to prod
|
|
1489
|
+
throw new ReferenceError();
|
|
1490
|
+
} // Disallowing properties in dev mode only to avoid people doing the wrong
|
|
1491
|
+
// thing when using the real shadow root, because if that's the case,
|
|
1492
|
+
// the component will not work when running with synthetic shadow.
|
|
1336
1493
|
|
|
1337
|
-
map = create(null);
|
|
1338
|
-
let start = 0;
|
|
1339
|
-
let o;
|
|
1340
|
-
const len = className.length;
|
|
1341
1494
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1495
|
+
const originalAddEventListener = sr.addEventListener;
|
|
1496
|
+
const originalInnerHTMLDescriptor = getPropertyDescriptor(sr, 'innerHTML');
|
|
1497
|
+
const originalTextContentDescriptor = getPropertyDescriptor(sr, 'textContent');
|
|
1498
|
+
return {
|
|
1499
|
+
innerHTML: generateAccessorDescriptor({
|
|
1500
|
+
get() {
|
|
1501
|
+
return originalInnerHTMLDescriptor.get.call(this);
|
|
1502
|
+
},
|
|
1503
|
+
|
|
1504
|
+
set(_value) {
|
|
1505
|
+
throw new TypeError(`Invalid attempt to set innerHTML on ShadowRoot.`);
|
|
1346
1506
|
}
|
|
1347
1507
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1508
|
+
}),
|
|
1509
|
+
textContent: generateAccessorDescriptor({
|
|
1510
|
+
get() {
|
|
1511
|
+
return originalTextContentDescriptor.get.call(this);
|
|
1512
|
+
},
|
|
1351
1513
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1514
|
+
set(_value) {
|
|
1515
|
+
throw new TypeError(`Invalid attempt to set textContent on ShadowRoot.`);
|
|
1516
|
+
}
|
|
1355
1517
|
|
|
1356
|
-
|
|
1518
|
+
}),
|
|
1519
|
+
addEventListener: generateDataDescriptor({
|
|
1520
|
+
value(type, listener, options) {
|
|
1521
|
+
// TODO [#420]: this is triggered when the component author attempts to add a listener
|
|
1522
|
+
// programmatically into its Component's shadow root
|
|
1523
|
+
if (!isUndefined$1(options)) {
|
|
1524
|
+
logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
|
|
1525
|
+
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1526
|
+
// @ts-ignore type-mismatch
|
|
1357
1527
|
|
|
1358
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1359
|
-
// just to make sure that this object never changes as part of the diffing algo
|
|
1360
|
-
freeze(map);
|
|
1361
|
-
}
|
|
1362
1528
|
|
|
1363
|
-
|
|
1364
|
-
}
|
|
1529
|
+
return originalAddEventListener.apply(this, arguments);
|
|
1530
|
+
}
|
|
1365
1531
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
className: newClass
|
|
1371
|
-
}
|
|
1372
|
-
} = vnode;
|
|
1373
|
-
const {
|
|
1374
|
-
data: {
|
|
1375
|
-
className: oldClass
|
|
1376
|
-
}
|
|
1377
|
-
} = oldVnode;
|
|
1532
|
+
})
|
|
1533
|
+
};
|
|
1534
|
+
} // Custom Elements Restrictions:
|
|
1535
|
+
// -----------------------------
|
|
1378
1536
|
|
|
1379
|
-
|
|
1380
|
-
|
|
1537
|
+
|
|
1538
|
+
function getCustomElementRestrictionsDescriptors(elm) {
|
|
1539
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1540
|
+
// this method should never leak to prod
|
|
1541
|
+
throw new ReferenceError();
|
|
1381
1542
|
}
|
|
1382
1543
|
|
|
1383
|
-
const
|
|
1384
|
-
const
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1544
|
+
const originalAddEventListener = elm.addEventListener;
|
|
1545
|
+
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
1546
|
+
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1547
|
+
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
|
1548
|
+
return {
|
|
1549
|
+
innerHTML: generateAccessorDescriptor({
|
|
1550
|
+
get() {
|
|
1551
|
+
return originalInnerHTMLDescriptor.get.call(this);
|
|
1552
|
+
},
|
|
1387
1553
|
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
classList.remove(name);
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1554
|
+
set(_value) {
|
|
1555
|
+
throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
|
|
1556
|
+
}
|
|
1394
1557
|
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1558
|
+
}),
|
|
1559
|
+
outerHTML: generateAccessorDescriptor({
|
|
1560
|
+
get() {
|
|
1561
|
+
return originalOuterHTMLDescriptor.get.call(this);
|
|
1562
|
+
},
|
|
1401
1563
|
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
}
|
|
1405
|
-
var modComputedClassName = {
|
|
1406
|
-
create: vnode => updateClassAttribute(emptyVNode$1, vnode),
|
|
1407
|
-
update: updateClassAttribute
|
|
1408
|
-
};
|
|
1409
|
-
/*
|
|
1410
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1411
|
-
* All rights reserved.
|
|
1412
|
-
* SPDX-License-Identifier: MIT
|
|
1413
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1414
|
-
*/
|
|
1564
|
+
set(_value) {
|
|
1565
|
+
throw new TypeError(`Invalid attempt to set outerHTML on HTMLElement.`);
|
|
1566
|
+
}
|
|
1415
1567
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
}
|
|
1422
|
-
} = vnode;
|
|
1568
|
+
}),
|
|
1569
|
+
textContent: generateAccessorDescriptor({
|
|
1570
|
+
get() {
|
|
1571
|
+
return originalTextContentDescriptor.get.call(this);
|
|
1572
|
+
},
|
|
1423
1573
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1574
|
+
set(_value) {
|
|
1575
|
+
throw new TypeError(`Invalid attempt to set textContent on HTMLElement.`);
|
|
1576
|
+
}
|
|
1427
1577
|
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1578
|
+
}),
|
|
1579
|
+
addEventListener: generateDataDescriptor({
|
|
1580
|
+
value(type, listener, options) {
|
|
1581
|
+
// TODO [#420]: this is triggered when the component author attempts to add a listener
|
|
1582
|
+
// programmatically into a lighting element node
|
|
1583
|
+
if (!isUndefined$1(options)) {
|
|
1584
|
+
logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
|
|
1585
|
+
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1586
|
+
// @ts-ignore type-mismatch
|
|
1587
|
+
|
|
1588
|
+
|
|
1589
|
+
return originalAddEventListener.apply(this, arguments);
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
})
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
function getComponentRestrictionsDescriptors() {
|
|
1597
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1598
|
+
// this method should never leak to prod
|
|
1599
|
+
throw new ReferenceError();
|
|
1432
1600
|
}
|
|
1601
|
+
|
|
1602
|
+
return {
|
|
1603
|
+
tagName: generateAccessorDescriptor({
|
|
1604
|
+
get() {
|
|
1605
|
+
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.`);
|
|
1606
|
+
},
|
|
1607
|
+
|
|
1608
|
+
configurable: true,
|
|
1609
|
+
enumerable: false // no enumerable properties on component
|
|
1610
|
+
|
|
1611
|
+
})
|
|
1612
|
+
};
|
|
1433
1613
|
}
|
|
1434
1614
|
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
update: updateStyleAttribute
|
|
1441
|
-
};
|
|
1442
|
-
/*
|
|
1443
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1444
|
-
* All rights reserved.
|
|
1445
|
-
* SPDX-License-Identifier: MIT
|
|
1446
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1447
|
-
*/
|
|
1448
|
-
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
1449
|
-
// different classnames properties individually instead of via a string.
|
|
1615
|
+
function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
|
1616
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1617
|
+
// this method should never leak to prod
|
|
1618
|
+
throw new ReferenceError();
|
|
1619
|
+
}
|
|
1450
1620
|
|
|
1451
|
-
|
|
1452
|
-
const {
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1621
|
+
const originalDispatchEvent = proto.dispatchEvent;
|
|
1622
|
+
const descriptors = {
|
|
1623
|
+
dispatchEvent: generateDataDescriptor({
|
|
1624
|
+
value(event) {
|
|
1625
|
+
const vm = getAssociatedVM(this);
|
|
1626
|
+
|
|
1627
|
+
if (!isNull(event) && isObject(event)) {
|
|
1628
|
+
const {
|
|
1629
|
+
type
|
|
1630
|
+
} = event;
|
|
1631
|
+
|
|
1632
|
+
if (!/^[a-z][a-z0-9_]*$/.test(type)) {
|
|
1633
|
+
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);
|
|
1634
|
+
}
|
|
1635
|
+
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1636
|
+
// @ts-ignore type-mismatch
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
return originalDispatchEvent.apply(this, arguments);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
})
|
|
1643
|
+
};
|
|
1644
|
+
forEach.call(getOwnPropertyNames$1(globalHTMLProperties), propName => {
|
|
1645
|
+
if (propName in proto) {
|
|
1646
|
+
return; // no need to redefine something that we are already exposing
|
|
1456
1647
|
}
|
|
1457
|
-
} = vnode;
|
|
1458
1648
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1649
|
+
descriptors[propName] = generateAccessorDescriptor({
|
|
1650
|
+
get() {
|
|
1651
|
+
const {
|
|
1652
|
+
error,
|
|
1653
|
+
attribute
|
|
1654
|
+
} = globalHTMLProperties[propName];
|
|
1655
|
+
const msg = [];
|
|
1656
|
+
msg.push(`Accessing the global HTML property "${propName}" is disabled.`);
|
|
1462
1657
|
|
|
1463
|
-
|
|
1658
|
+
if (error) {
|
|
1659
|
+
msg.push(error);
|
|
1660
|
+
} else if (attribute) {
|
|
1661
|
+
msg.push(`Instead access it via \`this.getAttribute("${attribute}")\`.`);
|
|
1662
|
+
}
|
|
1464
1663
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1664
|
+
logError(msg.join('\n'), getAssociatedVM(this));
|
|
1665
|
+
},
|
|
1666
|
+
|
|
1667
|
+
set() {
|
|
1668
|
+
const {
|
|
1669
|
+
readOnly
|
|
1670
|
+
} = globalHTMLProperties[propName];
|
|
1671
|
+
|
|
1672
|
+
if (readOnly) {
|
|
1673
|
+
logError(`The global HTML property \`${propName}\` is read-only.`, getAssociatedVM(this));
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
});
|
|
1678
|
+
});
|
|
1679
|
+
return descriptors;
|
|
1680
|
+
} // This routine will prevent access to certain properties on a shadow root instance to guarantee
|
|
1681
|
+
// that all components will work fine in IE11 and other browsers without shadow dom support.
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
function patchShadowRootWithRestrictions(sr) {
|
|
1685
|
+
defineProperties(sr, getShadowRootRestrictionsDescriptors(sr));
|
|
1468
1686
|
}
|
|
1469
1687
|
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1688
|
+
function patchCustomElementWithRestrictions(elm) {
|
|
1689
|
+
const restrictionsDescriptors = getCustomElementRestrictionsDescriptors(elm);
|
|
1690
|
+
const elmProto = getPrototypeOf$1(elm);
|
|
1691
|
+
setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
function patchComponentWithRestrictions(cmp) {
|
|
1695
|
+
defineProperties(cmp, getComponentRestrictionsDescriptors());
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
1699
|
+
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
1700
|
+
}
|
|
1473
1701
|
/*
|
|
1474
1702
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1475
1703
|
* All rights reserved.
|
|
1476
1704
|
* SPDX-License-Identifier: MIT
|
|
1477
1705
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1478
1706
|
*/
|
|
1479
|
-
//
|
|
1480
|
-
//
|
|
1481
|
-
|
|
1482
|
-
function createStyleAttribute(vnode) {
|
|
1483
|
-
const {
|
|
1484
|
-
elm,
|
|
1485
|
-
data: {
|
|
1486
|
-
styleDecls
|
|
1487
|
-
}
|
|
1488
|
-
} = vnode;
|
|
1489
|
-
|
|
1490
|
-
if (isUndefined$1(styleDecls)) {
|
|
1491
|
-
return;
|
|
1492
|
-
}
|
|
1707
|
+
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
1708
|
+
// to inject at runtime.
|
|
1493
1709
|
|
|
1494
|
-
for (let i = 0; i < styleDecls.length; i++) {
|
|
1495
|
-
const [prop, value, important] = styleDecls[i];
|
|
1496
|
-
setCSSStyleProperty$1(elm, prop, value, important);
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
1710
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
};
|
|
1711
|
+
const HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
|
1712
|
+
const HTMLElementPrototype = HTMLElementConstructor$1.prototype;
|
|
1503
1713
|
/*
|
|
1504
1714
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1505
1715
|
* All rights reserved.
|
|
@@ -1507,623 +1717,36 @@ var modStaticStyle = {
|
|
|
1507
1717
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1508
1718
|
*/
|
|
1509
1719
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
function isVNode(vnode) {
|
|
1519
|
-
return vnode != null;
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
1523
|
-
const map = {};
|
|
1524
|
-
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
1525
|
-
|
|
1526
|
-
for (j = beginIdx; j <= endIdx; ++j) {
|
|
1527
|
-
ch = children[j];
|
|
1720
|
+
/**
|
|
1721
|
+
* This is a descriptor map that contains
|
|
1722
|
+
* all standard properties that a Custom Element can support (including AOM properties), which
|
|
1723
|
+
* determines what kind of capabilities the Base HTML Element and
|
|
1724
|
+
* Base Lightning Element should support.
|
|
1725
|
+
*/
|
|
1528
1726
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1727
|
+
const HTMLElementOriginalDescriptors = create(null);
|
|
1728
|
+
forEach.call(keys(AriaPropNameToAttrNameMap), propName => {
|
|
1729
|
+
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1730
|
+
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
|
|
1731
|
+
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1531
1732
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1733
|
+
if (!isUndefined$1(descriptor)) {
|
|
1734
|
+
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1536
1735
|
}
|
|
1736
|
+
});
|
|
1737
|
+
forEach.call(defaultDefHTMLPropertyNames, propName => {
|
|
1738
|
+
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
1739
|
+
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
|
|
1740
|
+
// this category, so, better to be sure.
|
|
1741
|
+
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
1537
1742
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
|
1542
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
1543
|
-
const ch = vnodes[startIdx];
|
|
1544
|
-
|
|
1545
|
-
if (isVNode(ch)) {
|
|
1546
|
-
ch.hook.create(ch);
|
|
1547
|
-
ch.hook.insert(ch, parentElm, before);
|
|
1548
|
-
}
|
|
1743
|
+
if (!isUndefined$1(descriptor)) {
|
|
1744
|
+
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
1549
1745
|
}
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
1555
|
-
|
|
1556
|
-
if (isVNode(ch)) {
|
|
1557
|
-
ch.hook.remove(ch, parentElm);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
1563
|
-
let oldStartIdx = 0;
|
|
1564
|
-
let newStartIdx = 0;
|
|
1565
|
-
let oldEndIdx = oldCh.length - 1;
|
|
1566
|
-
let oldStartVnode = oldCh[0];
|
|
1567
|
-
let oldEndVnode = oldCh[oldEndIdx];
|
|
1568
|
-
const newChEnd = newCh.length - 1;
|
|
1569
|
-
let newEndIdx = newChEnd;
|
|
1570
|
-
let newStartVnode = newCh[0];
|
|
1571
|
-
let newEndVnode = newCh[newEndIdx];
|
|
1572
|
-
let oldKeyToIdx;
|
|
1573
|
-
let idxInOld;
|
|
1574
|
-
let elmToMove;
|
|
1575
|
-
let before;
|
|
1576
|
-
|
|
1577
|
-
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
1578
|
-
if (!isVNode(oldStartVnode)) {
|
|
1579
|
-
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
1580
|
-
} else if (!isVNode(oldEndVnode)) {
|
|
1581
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1582
|
-
} else if (!isVNode(newStartVnode)) {
|
|
1583
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1584
|
-
} else if (!isVNode(newEndVnode)) {
|
|
1585
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1586
|
-
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
1587
|
-
patchVnode(oldStartVnode, newStartVnode);
|
|
1588
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1589
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1590
|
-
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
1591
|
-
patchVnode(oldEndVnode, newEndVnode);
|
|
1592
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1593
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1594
|
-
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
1595
|
-
// Vnode moved right
|
|
1596
|
-
patchVnode(oldStartVnode, newEndVnode);
|
|
1597
|
-
newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
|
|
1598
|
-
oldStartVnode = oldCh[++oldStartIdx];
|
|
1599
|
-
newEndVnode = newCh[--newEndIdx];
|
|
1600
|
-
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
1601
|
-
// Vnode moved left
|
|
1602
|
-
patchVnode(oldEndVnode, newStartVnode);
|
|
1603
|
-
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
|
1604
|
-
oldEndVnode = oldCh[--oldEndIdx];
|
|
1605
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1606
|
-
} else {
|
|
1607
|
-
if (oldKeyToIdx === undefined) {
|
|
1608
|
-
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
1612
|
-
|
|
1613
|
-
if (isUndef(idxInOld)) {
|
|
1614
|
-
// New element
|
|
1615
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1616
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1617
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1618
|
-
} else {
|
|
1619
|
-
elmToMove = oldCh[idxInOld];
|
|
1620
|
-
|
|
1621
|
-
if (isVNode(elmToMove)) {
|
|
1622
|
-
if (elmToMove.sel !== newStartVnode.sel) {
|
|
1623
|
-
// New element
|
|
1624
|
-
newStartVnode.hook.create(newStartVnode);
|
|
1625
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
1626
|
-
} else {
|
|
1627
|
-
patchVnode(elmToMove, newStartVnode);
|
|
1628
|
-
oldCh[idxInOld] = undefined;
|
|
1629
|
-
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
|
-
newStartVnode = newCh[++newStartIdx];
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
1639
|
-
if (oldStartIdx > oldEndIdx) {
|
|
1640
|
-
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
1641
|
-
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
1642
|
-
let i = newEndIdx;
|
|
1643
|
-
let n;
|
|
1644
|
-
|
|
1645
|
-
do {
|
|
1646
|
-
n = newCh[++i];
|
|
1647
|
-
} while (!isVNode(n) && i < newChEnd);
|
|
1648
|
-
|
|
1649
|
-
before = isVNode(n) ? n.elm : null;
|
|
1650
|
-
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
|
1651
|
-
} else {
|
|
1652
|
-
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
function updateStaticChildren(parentElm, oldCh, newCh) {
|
|
1658
|
-
const oldChLength = oldCh.length;
|
|
1659
|
-
const newChLength = newCh.length;
|
|
1660
|
-
|
|
1661
|
-
if (oldChLength === 0) {
|
|
1662
|
-
// the old list is empty, we can directly insert anything new
|
|
1663
|
-
addVnodes(parentElm, null, newCh, 0, newChLength);
|
|
1664
|
-
return;
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
|
-
if (newChLength === 0) {
|
|
1668
|
-
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
1669
|
-
// this is the case in which the dynamic children of an if-directive should be removed
|
|
1670
|
-
removeVnodes(parentElm, oldCh, 0, oldChLength);
|
|
1671
|
-
return;
|
|
1672
|
-
} // if the old list is not empty, the new list MUST have the same
|
|
1673
|
-
// amount of nodes, that's why we call this static children
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
let referenceElm = null;
|
|
1677
|
-
|
|
1678
|
-
for (let i = newChLength - 1; i >= 0; i -= 1) {
|
|
1679
|
-
const vnode = newCh[i];
|
|
1680
|
-
const oldVNode = oldCh[i];
|
|
1681
|
-
|
|
1682
|
-
if (vnode !== oldVNode) {
|
|
1683
|
-
if (isVNode(oldVNode)) {
|
|
1684
|
-
if (isVNode(vnode)) {
|
|
1685
|
-
// both vnodes must be equivalent, and se just need to patch them
|
|
1686
|
-
patchVnode(oldVNode, vnode);
|
|
1687
|
-
referenceElm = vnode.elm;
|
|
1688
|
-
} else {
|
|
1689
|
-
// removing the old vnode since the new one is null
|
|
1690
|
-
oldVNode.hook.remove(oldVNode, parentElm);
|
|
1691
|
-
}
|
|
1692
|
-
} else if (isVNode(vnode)) {
|
|
1693
|
-
// this condition is unnecessary
|
|
1694
|
-
vnode.hook.create(vnode); // insert the new node one since the old one is null
|
|
1695
|
-
|
|
1696
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
1697
|
-
referenceElm = vnode.elm;
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
function patchVnode(oldVnode, vnode) {
|
|
1704
|
-
if (oldVnode !== vnode) {
|
|
1705
|
-
vnode.elm = oldVnode.elm;
|
|
1706
|
-
vnode.hook.update(oldVnode, vnode);
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
/*
|
|
1710
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
1711
|
-
* All rights reserved.
|
|
1712
|
-
* SPDX-License-Identifier: MIT
|
|
1713
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1714
|
-
*/
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
function generateDataDescriptor(options) {
|
|
1718
|
-
return assign({
|
|
1719
|
-
configurable: true,
|
|
1720
|
-
enumerable: true,
|
|
1721
|
-
writable: true
|
|
1722
|
-
}, options);
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
function generateAccessorDescriptor(options) {
|
|
1726
|
-
return assign({
|
|
1727
|
-
configurable: true,
|
|
1728
|
-
enumerable: true
|
|
1729
|
-
}, options);
|
|
1730
|
-
}
|
|
1731
|
-
|
|
1732
|
-
let isDomMutationAllowed = false;
|
|
1733
|
-
|
|
1734
|
-
function unlockDomMutation() {
|
|
1735
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1736
|
-
// this method should never leak to prod
|
|
1737
|
-
throw new ReferenceError();
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
isDomMutationAllowed = true;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
function lockDomMutation() {
|
|
1744
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1745
|
-
// this method should never leak to prod
|
|
1746
|
-
throw new ReferenceError();
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
isDomMutationAllowed = false;
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
function logMissingPortalError(name, type) {
|
|
1753
|
-
return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
function patchElementWithRestrictions(elm, options) {
|
|
1757
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1758
|
-
// this method should never leak to prod
|
|
1759
|
-
throw new ReferenceError();
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1763
|
-
const descriptors = {
|
|
1764
|
-
outerHTML: generateAccessorDescriptor({
|
|
1765
|
-
get() {
|
|
1766
|
-
return originalOuterHTMLDescriptor.get.call(this);
|
|
1767
|
-
},
|
|
1768
|
-
|
|
1769
|
-
set(_value) {
|
|
1770
|
-
throw new TypeError(`Invalid attempt to set outerHTML on Element.`);
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
})
|
|
1774
|
-
}; // Apply extra restriction related to DOM manipulation if the element is not a portal.
|
|
1775
|
-
|
|
1776
|
-
if (!options.isLight && !options.isPortal) {
|
|
1777
|
-
const {
|
|
1778
|
-
appendChild,
|
|
1779
|
-
insertBefore,
|
|
1780
|
-
removeChild,
|
|
1781
|
-
replaceChild
|
|
1782
|
-
} = elm;
|
|
1783
|
-
const originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
|
|
1784
|
-
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
1785
|
-
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
|
1786
|
-
assign(descriptors, {
|
|
1787
|
-
appendChild: generateDataDescriptor({
|
|
1788
|
-
value(aChild) {
|
|
1789
|
-
logMissingPortalError('appendChild', 'method');
|
|
1790
|
-
return appendChild.call(this, aChild);
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
}),
|
|
1794
|
-
insertBefore: generateDataDescriptor({
|
|
1795
|
-
value(newNode, referenceNode) {
|
|
1796
|
-
if (!isDomMutationAllowed) {
|
|
1797
|
-
logMissingPortalError('insertBefore', 'method');
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
return insertBefore.call(this, newNode, referenceNode);
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
}),
|
|
1804
|
-
removeChild: generateDataDescriptor({
|
|
1805
|
-
value(aChild) {
|
|
1806
|
-
if (!isDomMutationAllowed) {
|
|
1807
|
-
logMissingPortalError('removeChild', 'method');
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
return removeChild.call(this, aChild);
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
}),
|
|
1814
|
-
replaceChild: generateDataDescriptor({
|
|
1815
|
-
value(newChild, oldChild) {
|
|
1816
|
-
logMissingPortalError('replaceChild', 'method');
|
|
1817
|
-
return replaceChild.call(this, newChild, oldChild);
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
}),
|
|
1821
|
-
nodeValue: generateAccessorDescriptor({
|
|
1822
|
-
get() {
|
|
1823
|
-
return originalNodeValueDescriptor.get.call(this);
|
|
1824
|
-
},
|
|
1825
|
-
|
|
1826
|
-
set(value) {
|
|
1827
|
-
if (!isDomMutationAllowed) {
|
|
1828
|
-
logMissingPortalError('nodeValue', 'property');
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
originalNodeValueDescriptor.set.call(this, value);
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
}),
|
|
1835
|
-
textContent: generateAccessorDescriptor({
|
|
1836
|
-
get() {
|
|
1837
|
-
return originalTextContentDescriptor.get.call(this);
|
|
1838
|
-
},
|
|
1839
|
-
|
|
1840
|
-
set(value) {
|
|
1841
|
-
logMissingPortalError('textContent', 'property');
|
|
1842
|
-
originalTextContentDescriptor.set.call(this, value);
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
|
-
}),
|
|
1846
|
-
innerHTML: generateAccessorDescriptor({
|
|
1847
|
-
get() {
|
|
1848
|
-
return originalInnerHTMLDescriptor.get.call(this);
|
|
1849
|
-
},
|
|
1850
|
-
|
|
1851
|
-
set(value) {
|
|
1852
|
-
logMissingPortalError('innerHTML', 'property');
|
|
1853
|
-
return originalInnerHTMLDescriptor.set.call(this, value);
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
})
|
|
1857
|
-
});
|
|
1858
|
-
}
|
|
1859
|
-
|
|
1860
|
-
defineProperties(elm, descriptors);
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
function getShadowRootRestrictionsDescriptors(sr) {
|
|
1864
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1865
|
-
// this method should never leak to prod
|
|
1866
|
-
throw new ReferenceError();
|
|
1867
|
-
} // Disallowing properties in dev mode only to avoid people doing the wrong
|
|
1868
|
-
// thing when using the real shadow root, because if that's the case,
|
|
1869
|
-
// the component will not work when running with synthetic shadow.
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
const originalAddEventListener = sr.addEventListener;
|
|
1873
|
-
const originalInnerHTMLDescriptor = getPropertyDescriptor(sr, 'innerHTML');
|
|
1874
|
-
const originalTextContentDescriptor = getPropertyDescriptor(sr, 'textContent');
|
|
1875
|
-
return {
|
|
1876
|
-
innerHTML: generateAccessorDescriptor({
|
|
1877
|
-
get() {
|
|
1878
|
-
return originalInnerHTMLDescriptor.get.call(this);
|
|
1879
|
-
},
|
|
1880
|
-
|
|
1881
|
-
set(_value) {
|
|
1882
|
-
throw new TypeError(`Invalid attempt to set innerHTML on ShadowRoot.`);
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
}),
|
|
1886
|
-
textContent: generateAccessorDescriptor({
|
|
1887
|
-
get() {
|
|
1888
|
-
return originalTextContentDescriptor.get.call(this);
|
|
1889
|
-
},
|
|
1890
|
-
|
|
1891
|
-
set(_value) {
|
|
1892
|
-
throw new TypeError(`Invalid attempt to set textContent on ShadowRoot.`);
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
}),
|
|
1896
|
-
addEventListener: generateDataDescriptor({
|
|
1897
|
-
value(type, listener, options) {
|
|
1898
|
-
// TODO [#420]: this is triggered when the component author attempts to add a listener
|
|
1899
|
-
// programmatically into its Component's shadow root
|
|
1900
|
-
if (!isUndefined$1(options)) {
|
|
1901
|
-
logError('The `addEventListener` method on ShadowRoot does not support any options.', getAssociatedVMIfPresent(this));
|
|
1902
|
-
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1903
|
-
// @ts-ignore type-mismatch
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
return originalAddEventListener.apply(this, arguments);
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
})
|
|
1910
|
-
};
|
|
1911
|
-
} // Custom Elements Restrictions:
|
|
1912
|
-
// -----------------------------
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
function getCustomElementRestrictionsDescriptors(elm) {
|
|
1916
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1917
|
-
// this method should never leak to prod
|
|
1918
|
-
throw new ReferenceError();
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
const originalAddEventListener = elm.addEventListener;
|
|
1922
|
-
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
1923
|
-
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
1924
|
-
const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
|
1925
|
-
return {
|
|
1926
|
-
innerHTML: generateAccessorDescriptor({
|
|
1927
|
-
get() {
|
|
1928
|
-
return originalInnerHTMLDescriptor.get.call(this);
|
|
1929
|
-
},
|
|
1930
|
-
|
|
1931
|
-
set(_value) {
|
|
1932
|
-
throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
}),
|
|
1936
|
-
outerHTML: generateAccessorDescriptor({
|
|
1937
|
-
get() {
|
|
1938
|
-
return originalOuterHTMLDescriptor.get.call(this);
|
|
1939
|
-
},
|
|
1940
|
-
|
|
1941
|
-
set(_value) {
|
|
1942
|
-
throw new TypeError(`Invalid attempt to set outerHTML on HTMLElement.`);
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
}),
|
|
1946
|
-
textContent: generateAccessorDescriptor({
|
|
1947
|
-
get() {
|
|
1948
|
-
return originalTextContentDescriptor.get.call(this);
|
|
1949
|
-
},
|
|
1950
|
-
|
|
1951
|
-
set(_value) {
|
|
1952
|
-
throw new TypeError(`Invalid attempt to set textContent on HTMLElement.`);
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
}),
|
|
1956
|
-
addEventListener: generateDataDescriptor({
|
|
1957
|
-
value(type, listener, options) {
|
|
1958
|
-
// TODO [#420]: this is triggered when the component author attempts to add a listener
|
|
1959
|
-
// programmatically into a lighting element node
|
|
1960
|
-
if (!isUndefined$1(options)) {
|
|
1961
|
-
logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
|
|
1962
|
-
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
1963
|
-
// @ts-ignore type-mismatch
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
return originalAddEventListener.apply(this, arguments);
|
|
1967
|
-
}
|
|
1968
|
-
|
|
1969
|
-
})
|
|
1970
|
-
};
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1973
|
-
function getComponentRestrictionsDescriptors() {
|
|
1974
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1975
|
-
// this method should never leak to prod
|
|
1976
|
-
throw new ReferenceError();
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
|
-
return {
|
|
1980
|
-
tagName: generateAccessorDescriptor({
|
|
1981
|
-
get() {
|
|
1982
|
-
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.`);
|
|
1983
|
-
},
|
|
1984
|
-
|
|
1985
|
-
configurable: true,
|
|
1986
|
-
enumerable: false // no enumerable properties on component
|
|
1987
|
-
|
|
1988
|
-
})
|
|
1989
|
-
};
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
|
-
function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
|
1993
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1994
|
-
// this method should never leak to prod
|
|
1995
|
-
throw new ReferenceError();
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
const originalDispatchEvent = proto.dispatchEvent;
|
|
1999
|
-
const descriptors = {
|
|
2000
|
-
dispatchEvent: generateDataDescriptor({
|
|
2001
|
-
value(event) {
|
|
2002
|
-
const vm = getAssociatedVM(this);
|
|
2003
|
-
|
|
2004
|
-
if (!isNull(event) && isObject(event)) {
|
|
2005
|
-
const {
|
|
2006
|
-
type
|
|
2007
|
-
} = event;
|
|
2008
|
-
|
|
2009
|
-
if (!/^[a-z][a-z0-9_]*$/.test(type)) {
|
|
2010
|
-
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);
|
|
2011
|
-
}
|
|
2012
|
-
} // Typescript does not like it when you treat the `arguments` object as an array
|
|
2013
|
-
// @ts-ignore type-mismatch
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
return originalDispatchEvent.apply(this, arguments);
|
|
2017
|
-
}
|
|
2018
|
-
|
|
2019
|
-
})
|
|
2020
|
-
};
|
|
2021
|
-
forEach.call(getOwnPropertyNames$1(globalHTMLProperties), propName => {
|
|
2022
|
-
if (propName in proto) {
|
|
2023
|
-
return; // no need to redefine something that we are already exposing
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
|
-
descriptors[propName] = generateAccessorDescriptor({
|
|
2027
|
-
get() {
|
|
2028
|
-
const {
|
|
2029
|
-
error,
|
|
2030
|
-
attribute
|
|
2031
|
-
} = globalHTMLProperties[propName];
|
|
2032
|
-
const msg = [];
|
|
2033
|
-
msg.push(`Accessing the global HTML property "${propName}" is disabled.`);
|
|
2034
|
-
|
|
2035
|
-
if (error) {
|
|
2036
|
-
msg.push(error);
|
|
2037
|
-
} else if (attribute) {
|
|
2038
|
-
msg.push(`Instead access it via \`this.getAttribute("${attribute}")\`.`);
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
logError(msg.join('\n'), getAssociatedVM(this));
|
|
2042
|
-
},
|
|
2043
|
-
|
|
2044
|
-
set() {
|
|
2045
|
-
const {
|
|
2046
|
-
readOnly
|
|
2047
|
-
} = globalHTMLProperties[propName];
|
|
2048
|
-
|
|
2049
|
-
if (readOnly) {
|
|
2050
|
-
logError(`The global HTML property \`${propName}\` is read-only.`, getAssociatedVM(this));
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
|
|
2054
|
-
});
|
|
2055
|
-
});
|
|
2056
|
-
return descriptors;
|
|
2057
|
-
} // This routine will prevent access to certain properties on a shadow root instance to guarantee
|
|
2058
|
-
// that all components will work fine in IE11 and other browsers without shadow dom support.
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
function patchShadowRootWithRestrictions(sr) {
|
|
2062
|
-
defineProperties(sr, getShadowRootRestrictionsDescriptors(sr));
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
function patchCustomElementWithRestrictions(elm) {
|
|
2066
|
-
const restrictionsDescriptors = getCustomElementRestrictionsDescriptors(elm);
|
|
2067
|
-
const elmProto = getPrototypeOf$1(elm);
|
|
2068
|
-
setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
function patchComponentWithRestrictions(cmp) {
|
|
2072
|
-
defineProperties(cmp, getComponentRestrictionsDescriptors());
|
|
2073
|
-
}
|
|
2074
|
-
|
|
2075
|
-
function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
2076
|
-
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
2077
|
-
}
|
|
2078
|
-
/*
|
|
2079
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
2080
|
-
* All rights reserved.
|
|
2081
|
-
* SPDX-License-Identifier: MIT
|
|
2082
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2083
|
-
*/
|
|
2084
|
-
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
2085
|
-
// to inject at runtime.
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
const HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
|
2089
|
-
const HTMLElementPrototype = HTMLElementConstructor$1.prototype;
|
|
2090
|
-
/*
|
|
2091
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
2092
|
-
* All rights reserved.
|
|
2093
|
-
* SPDX-License-Identifier: MIT
|
|
2094
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2095
|
-
*/
|
|
2096
|
-
|
|
2097
|
-
/**
|
|
2098
|
-
* This is a descriptor map that contains
|
|
2099
|
-
* all standard properties that a Custom Element can support (including AOM properties), which
|
|
2100
|
-
* determines what kind of capabilities the Base HTML Element and
|
|
2101
|
-
* Base Lightning Element should support.
|
|
2102
|
-
*/
|
|
2103
|
-
|
|
2104
|
-
const HTMLElementOriginalDescriptors = create(null);
|
|
2105
|
-
forEach.call(keys(AriaPropNameToAttrNameMap), propName => {
|
|
2106
|
-
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
2107
|
-
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
|
|
2108
|
-
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
2109
|
-
|
|
2110
|
-
if (!isUndefined$1(descriptor)) {
|
|
2111
|
-
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
2112
|
-
}
|
|
2113
|
-
});
|
|
2114
|
-
forEach.call(defaultDefHTMLPropertyNames, propName => {
|
|
2115
|
-
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
|
|
2116
|
-
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
|
|
2117
|
-
// this category, so, better to be sure.
|
|
2118
|
-
const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
|
2119
|
-
|
|
2120
|
-
if (!isUndefined$1(descriptor)) {
|
|
2121
|
-
HTMLElementOriginalDescriptors[propName] = descriptor;
|
|
2122
|
-
}
|
|
2123
|
-
});
|
|
2124
|
-
/**
|
|
2125
|
-
* Copyright (C) 2017 salesforce.com, inc.
|
|
2126
|
-
*/
|
|
1746
|
+
});
|
|
1747
|
+
/**
|
|
1748
|
+
* Copyright (C) 2017 salesforce.com, inc.
|
|
1749
|
+
*/
|
|
2127
1750
|
|
|
2128
1751
|
const {
|
|
2129
1752
|
isArray
|
|
@@ -3303,97 +2926,333 @@ for (const childGetter of childGetters) {
|
|
|
3303
2926
|
warnIfInvokedDuringConstruction(vm, childGetter);
|
|
3304
2927
|
}
|
|
3305
2928
|
|
|
3306
|
-
return getChildGetter(childGetter)(elm);
|
|
3307
|
-
},
|
|
3308
|
-
|
|
3309
|
-
configurable: true,
|
|
3310
|
-
enumerable: true
|
|
3311
|
-
};
|
|
3312
|
-
}
|
|
2929
|
+
return getChildGetter(childGetter)(elm);
|
|
2930
|
+
},
|
|
2931
|
+
|
|
2932
|
+
configurable: true,
|
|
2933
|
+
enumerable: true
|
|
2934
|
+
};
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2937
|
+
const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
|
|
2938
|
+
|
|
2939
|
+
function getQueryMethod(methodName) {
|
|
2940
|
+
switch (methodName) {
|
|
2941
|
+
case 'getElementsByClassName':
|
|
2942
|
+
return getElementsByClassName$1;
|
|
2943
|
+
|
|
2944
|
+
case 'getElementsByTagName':
|
|
2945
|
+
return getElementsByTagName$1;
|
|
2946
|
+
|
|
2947
|
+
case 'querySelector':
|
|
2948
|
+
return querySelector$1;
|
|
2949
|
+
|
|
2950
|
+
case 'querySelectorAll':
|
|
2951
|
+
return querySelectorAll$1;
|
|
2952
|
+
}
|
|
2953
|
+
} // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
for (const queryMethod of queryMethods) {
|
|
2957
|
+
queryAndChildGetterDescriptors[queryMethod] = {
|
|
2958
|
+
value(arg) {
|
|
2959
|
+
const vm = getAssociatedVM(this);
|
|
2960
|
+
const {
|
|
2961
|
+
elm
|
|
2962
|
+
} = vm;
|
|
2963
|
+
|
|
2964
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2965
|
+
warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
return getQueryMethod(queryMethod)(elm, arg);
|
|
2969
|
+
},
|
|
2970
|
+
|
|
2971
|
+
configurable: true,
|
|
2972
|
+
enumerable: true,
|
|
2973
|
+
writable: true
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
|
|
2978
|
+
const lightningBasedDescriptors = create(null);
|
|
2979
|
+
|
|
2980
|
+
for (const propName in HTMLElementOriginalDescriptors) {
|
|
2981
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
2985
|
+
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
2986
|
+
get() {
|
|
2987
|
+
// If required, a runtime-specific implementation must be defined.
|
|
2988
|
+
throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
|
|
2989
|
+
},
|
|
2990
|
+
|
|
2991
|
+
configurable: true
|
|
2992
|
+
});
|
|
2993
|
+
|
|
2994
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2995
|
+
patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
|
|
2996
|
+
}
|
|
2997
|
+
/*
|
|
2998
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2999
|
+
* All rights reserved.
|
|
3000
|
+
* SPDX-License-Identifier: MIT
|
|
3001
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3002
|
+
*/
|
|
3003
|
+
|
|
3004
|
+
/**
|
|
3005
|
+
* @wire decorator to wire fields and methods to a wire adapter in
|
|
3006
|
+
* LWC Components. This function implements the internals of this
|
|
3007
|
+
* decorator.
|
|
3008
|
+
*/
|
|
3009
|
+
|
|
3010
|
+
|
|
3011
|
+
function wire(_adapter, _config) {
|
|
3012
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3013
|
+
assert.fail('@wire(adapter, config?) may only be used as a decorator.');
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
throw new Error();
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
function internalWireFieldDecorator(key) {
|
|
3020
|
+
return {
|
|
3021
|
+
get() {
|
|
3022
|
+
const vm = getAssociatedVM(this);
|
|
3023
|
+
componentValueObserved(vm, key);
|
|
3024
|
+
return vm.cmpFields[key];
|
|
3025
|
+
},
|
|
3026
|
+
|
|
3027
|
+
set(value) {
|
|
3028
|
+
const vm = getAssociatedVM(this);
|
|
3029
|
+
/**
|
|
3030
|
+
* Reactivity for wired fields is provided in wiring.
|
|
3031
|
+
* We intentionally add reactivity here since this is just
|
|
3032
|
+
* letting the author to do the wrong thing, but it will keep our
|
|
3033
|
+
* system to be backward compatible.
|
|
3034
|
+
*/
|
|
3035
|
+
|
|
3036
|
+
if (value !== vm.cmpFields[key]) {
|
|
3037
|
+
vm.cmpFields[key] = value;
|
|
3038
|
+
componentValueMutated(vm, key);
|
|
3039
|
+
}
|
|
3040
|
+
},
|
|
3041
|
+
|
|
3042
|
+
enumerable: true,
|
|
3043
|
+
configurable: true
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
/*
|
|
3047
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3048
|
+
* All rights reserved.
|
|
3049
|
+
* SPDX-License-Identifier: MIT
|
|
3050
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3051
|
+
*/
|
|
3052
|
+
|
|
3053
|
+
|
|
3054
|
+
function track(target) {
|
|
3055
|
+
if (arguments.length === 1) {
|
|
3056
|
+
return reactiveMembrane.getProxy(target);
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3060
|
+
assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
throw new Error();
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
function internalTrackDecorator(key) {
|
|
3067
|
+
return {
|
|
3068
|
+
get() {
|
|
3069
|
+
const vm = getAssociatedVM(this);
|
|
3070
|
+
componentValueObserved(vm, key);
|
|
3071
|
+
return vm.cmpFields[key];
|
|
3072
|
+
},
|
|
3073
|
+
|
|
3074
|
+
set(newValue) {
|
|
3075
|
+
const vm = getAssociatedVM(this);
|
|
3076
|
+
|
|
3077
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3078
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
3079
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3080
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
|
|
3084
|
+
|
|
3085
|
+
if (reactiveOrAnyValue !== vm.cmpFields[key]) {
|
|
3086
|
+
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
3087
|
+
componentValueMutated(vm, key);
|
|
3088
|
+
}
|
|
3089
|
+
},
|
|
3090
|
+
|
|
3091
|
+
enumerable: true,
|
|
3092
|
+
configurable: true
|
|
3093
|
+
};
|
|
3094
|
+
}
|
|
3095
|
+
/*
|
|
3096
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3097
|
+
* All rights reserved.
|
|
3098
|
+
* SPDX-License-Identifier: MIT
|
|
3099
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3100
|
+
*/
|
|
3101
|
+
|
|
3102
|
+
|
|
3103
|
+
function api$1() {
|
|
3104
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3105
|
+
assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
throw new Error();
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
function createPublicPropertyDescriptor(key) {
|
|
3112
|
+
return {
|
|
3113
|
+
get() {
|
|
3114
|
+
const vm = getAssociatedVM(this);
|
|
3115
|
+
|
|
3116
|
+
if (isBeingConstructed(vm)) {
|
|
3117
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3118
|
+
logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
return;
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
componentValueObserved(vm, key);
|
|
3125
|
+
return vm.cmpProps[key];
|
|
3126
|
+
},
|
|
3127
|
+
|
|
3128
|
+
set(newValue) {
|
|
3129
|
+
const vm = getAssociatedVM(this);
|
|
3130
|
+
|
|
3131
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3132
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
3133
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3134
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
vm.cmpProps[key] = newValue;
|
|
3138
|
+
componentValueMutated(vm, key);
|
|
3139
|
+
},
|
|
3140
|
+
|
|
3141
|
+
enumerable: true,
|
|
3142
|
+
configurable: true
|
|
3143
|
+
};
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
class AccessorReactiveObserver extends ReactiveObserver {
|
|
3147
|
+
constructor(vm, set) {
|
|
3148
|
+
super(() => {
|
|
3149
|
+
if (isFalse(this.debouncing)) {
|
|
3150
|
+
this.debouncing = true;
|
|
3151
|
+
addCallbackToNextTick(() => {
|
|
3152
|
+
if (isTrue(this.debouncing)) {
|
|
3153
|
+
const {
|
|
3154
|
+
value
|
|
3155
|
+
} = this;
|
|
3156
|
+
const {
|
|
3157
|
+
isDirty: dirtyStateBeforeSetterCall,
|
|
3158
|
+
component,
|
|
3159
|
+
idx
|
|
3160
|
+
} = vm;
|
|
3161
|
+
set.call(component, value); // de-bouncing after the call to the original setter to prevent
|
|
3162
|
+
// infinity loop if the setter itself is mutating things that
|
|
3163
|
+
// were accessed during the previous invocation.
|
|
3164
|
+
|
|
3165
|
+
this.debouncing = false;
|
|
3166
|
+
|
|
3167
|
+
if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
3168
|
+
// immediate rehydration due to a setter driven mutation, otherwise
|
|
3169
|
+
// the component will get rendered on the second tick, which it is not
|
|
3170
|
+
// desirable.
|
|
3171
|
+
rerenderVM(vm);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
this.debouncing = false;
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
reset(value) {
|
|
3181
|
+
super.reset();
|
|
3182
|
+
this.debouncing = false;
|
|
3313
3183
|
|
|
3314
|
-
|
|
3184
|
+
if (arguments.length > 0) {
|
|
3185
|
+
this.value = value;
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3315
3188
|
|
|
3316
|
-
|
|
3317
|
-
switch (methodName) {
|
|
3318
|
-
case 'getElementsByClassName':
|
|
3319
|
-
return getElementsByClassName$1;
|
|
3189
|
+
}
|
|
3320
3190
|
|
|
3321
|
-
|
|
3322
|
-
|
|
3191
|
+
function createPublicAccessorDescriptor(key, descriptor) {
|
|
3192
|
+
const {
|
|
3193
|
+
get,
|
|
3194
|
+
set,
|
|
3195
|
+
enumerable,
|
|
3196
|
+
configurable
|
|
3197
|
+
} = descriptor;
|
|
3323
3198
|
|
|
3324
|
-
|
|
3325
|
-
|
|
3199
|
+
if (!isFunction$1(get)) {
|
|
3200
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3201
|
+
assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
|
3202
|
+
}
|
|
3326
3203
|
|
|
3327
|
-
|
|
3328
|
-
return querySelectorAll$1;
|
|
3204
|
+
throw new Error();
|
|
3329
3205
|
}
|
|
3330
|
-
} // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
for (const queryMethod of queryMethods) {
|
|
3334
|
-
queryAndChildGetterDescriptors[queryMethod] = {
|
|
3335
|
-
value(arg) {
|
|
3336
|
-
const vm = getAssociatedVM(this);
|
|
3337
|
-
const {
|
|
3338
|
-
elm
|
|
3339
|
-
} = vm;
|
|
3340
3206
|
|
|
3207
|
+
return {
|
|
3208
|
+
get() {
|
|
3341
3209
|
if (process.env.NODE_ENV !== 'production') {
|
|
3342
|
-
|
|
3210
|
+
// Assert that the this value is an actual Component with an associated VM.
|
|
3211
|
+
getAssociatedVM(this);
|
|
3343
3212
|
}
|
|
3344
3213
|
|
|
3345
|
-
return
|
|
3214
|
+
return get.call(this);
|
|
3346
3215
|
},
|
|
3347
3216
|
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
writable: true
|
|
3351
|
-
};
|
|
3352
|
-
}
|
|
3353
|
-
|
|
3354
|
-
defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
|
|
3355
|
-
const lightningBasedDescriptors = create(null);
|
|
3356
|
-
|
|
3357
|
-
for (const propName in HTMLElementOriginalDescriptors) {
|
|
3358
|
-
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
3359
|
-
}
|
|
3360
|
-
|
|
3361
|
-
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
3362
|
-
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
3363
|
-
get() {
|
|
3364
|
-
// If required, a runtime-specific implementation must be defined.
|
|
3365
|
-
throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
|
|
3366
|
-
},
|
|
3217
|
+
set(newValue) {
|
|
3218
|
+
const vm = getAssociatedVM(this);
|
|
3367
3219
|
|
|
3368
|
-
|
|
3369
|
-
|
|
3220
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3221
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
3222
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3223
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3224
|
+
}
|
|
3370
3225
|
|
|
3371
|
-
if (
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
/*
|
|
3375
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
3376
|
-
* All rights reserved.
|
|
3377
|
-
* SPDX-License-Identifier: MIT
|
|
3378
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3379
|
-
*/
|
|
3226
|
+
if (set) {
|
|
3227
|
+
if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
3228
|
+
let ro = vm.oar[key];
|
|
3380
3229
|
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3230
|
+
if (isUndefined$1(ro)) {
|
|
3231
|
+
ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
|
|
3232
|
+
} // every time we invoke this setter from outside (through this wrapper setter)
|
|
3233
|
+
// we should reset the value and then debounce just in case there is a pending
|
|
3234
|
+
// invocation the next tick that is not longer relevant since the value is changing
|
|
3235
|
+
// from outside.
|
|
3386
3236
|
|
|
3387
3237
|
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3238
|
+
ro.reset(newValue);
|
|
3239
|
+
ro.observe(() => {
|
|
3240
|
+
set.call(this, newValue);
|
|
3241
|
+
});
|
|
3242
|
+
} else {
|
|
3243
|
+
set.call(this, newValue);
|
|
3244
|
+
}
|
|
3245
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
3246
|
+
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
3247
|
+
}
|
|
3248
|
+
},
|
|
3392
3249
|
|
|
3393
|
-
|
|
3250
|
+
enumerable,
|
|
3251
|
+
configurable
|
|
3252
|
+
};
|
|
3394
3253
|
}
|
|
3395
3254
|
|
|
3396
|
-
function
|
|
3255
|
+
function createObservedFieldPropertyDescriptor(key) {
|
|
3397
3256
|
return {
|
|
3398
3257
|
get() {
|
|
3399
3258
|
const vm = getAssociatedVM(this);
|
|
@@ -3401,17 +3260,11 @@ function internalWireFieldDecorator(key) {
|
|
|
3401
3260
|
return vm.cmpFields[key];
|
|
3402
3261
|
},
|
|
3403
3262
|
|
|
3404
|
-
set(
|
|
3263
|
+
set(newValue) {
|
|
3405
3264
|
const vm = getAssociatedVM(this);
|
|
3406
|
-
/**
|
|
3407
|
-
* Reactivity for wired fields is provided in wiring.
|
|
3408
|
-
* We intentionally add reactivity here since this is just
|
|
3409
|
-
* letting the author to do the wrong thing, but it will keep our
|
|
3410
|
-
* system to be backward compatible.
|
|
3411
|
-
*/
|
|
3412
3265
|
|
|
3413
|
-
if (
|
|
3414
|
-
vm.cmpFields[key] =
|
|
3266
|
+
if (newValue !== vm.cmpFields[key]) {
|
|
3267
|
+
vm.cmpFields[key] = newValue;
|
|
3415
3268
|
componentValueMutated(vm, key);
|
|
3416
3269
|
}
|
|
3417
3270
|
},
|
|
@@ -3428,227 +3281,299 @@ function internalWireFieldDecorator(key) {
|
|
|
3428
3281
|
*/
|
|
3429
3282
|
|
|
3430
3283
|
|
|
3431
|
-
function
|
|
3432
|
-
if (
|
|
3433
|
-
return
|
|
3434
|
-
|
|
3284
|
+
function getClassDescriptorType(descriptor) {
|
|
3285
|
+
if (isFunction$1(descriptor.value)) {
|
|
3286
|
+
return "method"
|
|
3287
|
+
/* Method */
|
|
3288
|
+
;
|
|
3289
|
+
} else if (isFunction$1(descriptor.set) || isFunction$1(descriptor.get)) {
|
|
3290
|
+
return "accessor"
|
|
3291
|
+
/* Accessor */
|
|
3292
|
+
;
|
|
3293
|
+
} else {
|
|
3294
|
+
return "field"
|
|
3295
|
+
/* Field */
|
|
3296
|
+
;
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
function validateObservedField(Ctor, fieldName, descriptor) {
|
|
3301
|
+
if (!isUndefined$1(descriptor)) {
|
|
3302
|
+
const type = getClassDescriptorType(descriptor);
|
|
3303
|
+
const message = `Invalid observed ${fieldName} field. Found a duplicate ${type} with the same name.`; // [W-9927596] Ideally we always throw an error when detecting duplicate observed field.
|
|
3304
|
+
// This branch is only here for backward compatibility reasons.
|
|
3305
|
+
|
|
3306
|
+
if (type === "accessor"
|
|
3307
|
+
/* Accessor */
|
|
3308
|
+
) {
|
|
3309
|
+
logError(message);
|
|
3310
|
+
} else {
|
|
3311
|
+
assert.fail(message);
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
function validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor) {
|
|
3317
|
+
if (!isUndefined$1(descriptor)) {
|
|
3318
|
+
const type = getClassDescriptorType(descriptor);
|
|
3319
|
+
assert.fail(`Invalid @track ${fieldName} field. Found a duplicate ${type} with the same name.`);
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
function validateFieldDecoratedWithWire(Ctor, fieldName, descriptor) {
|
|
3324
|
+
if (!isUndefined$1(descriptor)) {
|
|
3325
|
+
const type = getClassDescriptorType(descriptor);
|
|
3326
|
+
assert.fail(`Invalid @wire ${fieldName} field. Found a duplicate ${type} with the same name.`);
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
function validateMethodDecoratedWithWire(Ctor, methodName, descriptor) {
|
|
3331
|
+
if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse(descriptor.writable)) {
|
|
3332
|
+
assert.fail(`Invalid @wire ${methodName} method.`);
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
|
+
function validateFieldDecoratedWithApi(Ctor, fieldName, descriptor) {
|
|
3337
|
+
if (!isUndefined$1(descriptor)) {
|
|
3338
|
+
const type = getClassDescriptorType(descriptor);
|
|
3339
|
+
const message = `Invalid @api ${fieldName} field. Found a duplicate ${type} with the same name.`; // [W-9927596] Ideally we always throw an error when detecting duplicate public properties.
|
|
3340
|
+
// This branch is only here for backward compatibility reasons.
|
|
3341
|
+
|
|
3342
|
+
if (type === "accessor"
|
|
3343
|
+
/* Accessor */
|
|
3344
|
+
) {
|
|
3345
|
+
logError(message);
|
|
3346
|
+
} else {
|
|
3347
|
+
assert.fail(message);
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
function validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor) {
|
|
3353
|
+
if (isUndefined$1(descriptor)) {
|
|
3354
|
+
assert.fail(`Invalid @api get ${fieldName} accessor.`);
|
|
3355
|
+
} else if (isFunction$1(descriptor.set)) {
|
|
3356
|
+
assert.isTrue(isFunction$1(descriptor.get), `Missing getter for property ${fieldName} decorated with @api in ${Ctor}. You cannot have a setter without the corresponding getter.`);
|
|
3357
|
+
} else if (!isFunction$1(descriptor.get)) {
|
|
3358
|
+
assert.fail(`Missing @api get ${fieldName} accessor.`);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3362
|
+
function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
|
|
3363
|
+
if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse(descriptor.writable)) {
|
|
3364
|
+
assert.fail(`Invalid @api ${methodName} method.`);
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
/**
|
|
3368
|
+
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
3369
|
+
* will prevent this function from being imported by user-land code.
|
|
3370
|
+
*/
|
|
3371
|
+
|
|
3372
|
+
|
|
3373
|
+
function registerDecorators(Ctor, meta) {
|
|
3374
|
+
const proto = Ctor.prototype;
|
|
3375
|
+
const {
|
|
3376
|
+
publicProps,
|
|
3377
|
+
publicMethods,
|
|
3378
|
+
wire,
|
|
3379
|
+
track,
|
|
3380
|
+
fields
|
|
3381
|
+
} = meta;
|
|
3382
|
+
const apiMethods = create(null);
|
|
3383
|
+
const apiFields = create(null);
|
|
3384
|
+
const wiredMethods = create(null);
|
|
3385
|
+
const wiredFields = create(null);
|
|
3386
|
+
const observedFields = create(null);
|
|
3387
|
+
const apiFieldsConfig = create(null);
|
|
3388
|
+
let descriptor;
|
|
3389
|
+
|
|
3390
|
+
if (!isUndefined$1(publicProps)) {
|
|
3391
|
+
for (const fieldName in publicProps) {
|
|
3392
|
+
const propConfig = publicProps[fieldName];
|
|
3393
|
+
apiFieldsConfig[fieldName] = propConfig.config;
|
|
3394
|
+
descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
|
3395
|
+
|
|
3396
|
+
if (propConfig.config > 0) {
|
|
3397
|
+
// accessor declaration
|
|
3398
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3399
|
+
validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor);
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
if (isUndefined$1(descriptor)) {
|
|
3403
|
+
throw new Error();
|
|
3404
|
+
}
|
|
3435
3405
|
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3406
|
+
descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
|
|
3407
|
+
} else {
|
|
3408
|
+
// field declaration
|
|
3409
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3410
|
+
validateFieldDecoratedWithApi(Ctor, fieldName, descriptor);
|
|
3411
|
+
} // [W-9927596] If a component has both a public property and a private setter/getter
|
|
3412
|
+
// with the same name, the property is defined as a public accessor. This branch is
|
|
3413
|
+
// only here for backward compatibility reasons.
|
|
3439
3414
|
|
|
3440
|
-
throw new Error();
|
|
3441
|
-
}
|
|
3442
3415
|
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
},
|
|
3416
|
+
if (!isUndefined$1(descriptor) && !isUndefined$1(descriptor.get)) {
|
|
3417
|
+
descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
|
|
3418
|
+
} else {
|
|
3419
|
+
descriptor = createPublicPropertyDescriptor(fieldName);
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3450
3422
|
|
|
3451
|
-
|
|
3452
|
-
|
|
3423
|
+
apiFields[fieldName] = descriptor;
|
|
3424
|
+
defineProperty(proto, fieldName, descriptor);
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
|
|
3428
|
+
if (!isUndefined$1(publicMethods)) {
|
|
3429
|
+
forEach.call(publicMethods, methodName => {
|
|
3430
|
+
descriptor = getOwnPropertyDescriptor$1(proto, methodName);
|
|
3453
3431
|
|
|
3454
3432
|
if (process.env.NODE_ENV !== 'production') {
|
|
3455
|
-
|
|
3456
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3457
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3433
|
+
validateMethodDecoratedWithApi(Ctor, methodName, descriptor);
|
|
3458
3434
|
}
|
|
3459
3435
|
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
if (reactiveOrAnyValue !== vm.cmpFields[key]) {
|
|
3463
|
-
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
3464
|
-
componentValueMutated(vm, key);
|
|
3436
|
+
if (isUndefined$1(descriptor)) {
|
|
3437
|
+
throw new Error();
|
|
3465
3438
|
}
|
|
3466
|
-
},
|
|
3467
|
-
|
|
3468
|
-
enumerable: true,
|
|
3469
|
-
configurable: true
|
|
3470
|
-
};
|
|
3471
|
-
}
|
|
3472
|
-
/*
|
|
3473
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
3474
|
-
* All rights reserved.
|
|
3475
|
-
* SPDX-License-Identifier: MIT
|
|
3476
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3477
|
-
*/
|
|
3478
3439
|
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3482
|
-
assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
3440
|
+
apiMethods[methodName] = descriptor;
|
|
3441
|
+
});
|
|
3483
3442
|
}
|
|
3484
3443
|
|
|
3485
|
-
|
|
3486
|
-
|
|
3444
|
+
if (!isUndefined$1(wire)) {
|
|
3445
|
+
for (const fieldOrMethodName in wire) {
|
|
3446
|
+
const {
|
|
3447
|
+
adapter,
|
|
3448
|
+
method,
|
|
3449
|
+
config: configCallback,
|
|
3450
|
+
dynamic = []
|
|
3451
|
+
} = wire[fieldOrMethodName];
|
|
3452
|
+
descriptor = getOwnPropertyDescriptor$1(proto, fieldOrMethodName);
|
|
3487
3453
|
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3454
|
+
if (method === 1) {
|
|
3455
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3456
|
+
assert.isTrue(adapter, `@wire on method "${fieldOrMethodName}": adapter id must be truthy.`);
|
|
3457
|
+
validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
|
|
3458
|
+
}
|
|
3492
3459
|
|
|
3493
|
-
|
|
3460
|
+
if (isUndefined$1(descriptor)) {
|
|
3461
|
+
throw new Error();
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
wiredMethods[fieldOrMethodName] = descriptor;
|
|
3465
|
+
storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
|
|
3466
|
+
} else {
|
|
3494
3467
|
if (process.env.NODE_ENV !== 'production') {
|
|
3495
|
-
|
|
3468
|
+
assert.isTrue(adapter, `@wire on field "${fieldOrMethodName}": adapter id must be truthy.`);
|
|
3469
|
+
validateFieldDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
|
|
3496
3470
|
}
|
|
3497
3471
|
|
|
3498
|
-
|
|
3472
|
+
descriptor = internalWireFieldDecorator(fieldOrMethodName);
|
|
3473
|
+
wiredFields[fieldOrMethodName] = descriptor;
|
|
3474
|
+
storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic);
|
|
3475
|
+
defineProperty(proto, fieldOrMethodName, descriptor);
|
|
3499
3476
|
}
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3500
3479
|
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
set(newValue) {
|
|
3506
|
-
const vm = getAssociatedVM(this);
|
|
3480
|
+
if (!isUndefined$1(track)) {
|
|
3481
|
+
for (const fieldName in track) {
|
|
3482
|
+
descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
|
3507
3483
|
|
|
3508
3484
|
if (process.env.NODE_ENV !== 'production') {
|
|
3509
|
-
|
|
3510
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3511
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
3485
|
+
validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor);
|
|
3512
3486
|
}
|
|
3513
3487
|
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
}
|
|
3517
|
-
|
|
3518
|
-
enumerable: true,
|
|
3519
|
-
configurable: true
|
|
3520
|
-
};
|
|
3521
|
-
}
|
|
3522
|
-
|
|
3523
|
-
class AccessorReactiveObserver extends ReactiveObserver {
|
|
3524
|
-
constructor(vm, set) {
|
|
3525
|
-
super(() => {
|
|
3526
|
-
if (isFalse(this.debouncing)) {
|
|
3527
|
-
this.debouncing = true;
|
|
3528
|
-
addCallbackToNextTick(() => {
|
|
3529
|
-
if (isTrue(this.debouncing)) {
|
|
3530
|
-
const {
|
|
3531
|
-
value
|
|
3532
|
-
} = this;
|
|
3533
|
-
const {
|
|
3534
|
-
isDirty: dirtyStateBeforeSetterCall,
|
|
3535
|
-
component,
|
|
3536
|
-
idx
|
|
3537
|
-
} = vm;
|
|
3538
|
-
set.call(component, value); // de-bouncing after the call to the original setter to prevent
|
|
3539
|
-
// infinity loop if the setter itself is mutating things that
|
|
3540
|
-
// were accessed during the previous invocation.
|
|
3541
|
-
|
|
3542
|
-
this.debouncing = false;
|
|
3543
|
-
|
|
3544
|
-
if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
3545
|
-
// immediate rehydration due to a setter driven mutation, otherwise
|
|
3546
|
-
// the component will get rendered on the second tick, which it is not
|
|
3547
|
-
// desirable.
|
|
3548
|
-
rerenderVM(vm);
|
|
3549
|
-
}
|
|
3550
|
-
}
|
|
3551
|
-
});
|
|
3552
|
-
}
|
|
3553
|
-
});
|
|
3554
|
-
this.debouncing = false;
|
|
3488
|
+
descriptor = internalTrackDecorator(fieldName);
|
|
3489
|
+
defineProperty(proto, fieldName, descriptor);
|
|
3490
|
+
}
|
|
3555
3491
|
}
|
|
3556
3492
|
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3493
|
+
if (!isUndefined$1(fields)) {
|
|
3494
|
+
for (let i = 0, n = fields.length; i < n; i++) {
|
|
3495
|
+
const fieldName = fields[i];
|
|
3496
|
+
descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
|
3560
3497
|
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3498
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3499
|
+
validateObservedField(Ctor, fieldName, descriptor);
|
|
3500
|
+
} // [W-9927596] Only mark a field as observed whenever it isn't a duplicated public nor
|
|
3501
|
+
// tracked property. This is only here for backward compatibility purposes.
|
|
3565
3502
|
|
|
3566
|
-
}
|
|
3567
3503
|
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
get,
|
|
3571
|
-
set,
|
|
3572
|
-
enumerable,
|
|
3573
|
-
configurable
|
|
3574
|
-
} = descriptor;
|
|
3504
|
+
const isDuplicatePublicProp = !isUndefined$1(publicProps) && fieldName in publicProps;
|
|
3505
|
+
const isDuplicateTrackedProp = !isUndefined$1(track) && fieldName in track;
|
|
3575
3506
|
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3507
|
+
if (!isDuplicatePublicProp && !isDuplicateTrackedProp) {
|
|
3508
|
+
observedFields[fieldName] = createObservedFieldPropertyDescriptor(fieldName);
|
|
3509
|
+
}
|
|
3579
3510
|
}
|
|
3580
|
-
|
|
3581
|
-
throw new Error();
|
|
3582
3511
|
}
|
|
3583
3512
|
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3513
|
+
setDecoratorsMeta(Ctor, {
|
|
3514
|
+
apiMethods,
|
|
3515
|
+
apiFields,
|
|
3516
|
+
apiFieldsConfig,
|
|
3517
|
+
wiredMethods,
|
|
3518
|
+
wiredFields,
|
|
3519
|
+
observedFields
|
|
3520
|
+
});
|
|
3521
|
+
return Ctor;
|
|
3522
|
+
}
|
|
3590
3523
|
|
|
3591
|
-
|
|
3592
|
-
},
|
|
3524
|
+
const signedDecoratorToMetaMap = new Map();
|
|
3593
3525
|
|
|
3594
|
-
|
|
3595
|
-
|
|
3526
|
+
function setDecoratorsMeta(Ctor, meta) {
|
|
3527
|
+
signedDecoratorToMetaMap.set(Ctor, meta);
|
|
3528
|
+
}
|
|
3596
3529
|
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3530
|
+
const defaultMeta = {
|
|
3531
|
+
apiMethods: EmptyObject,
|
|
3532
|
+
apiFields: EmptyObject,
|
|
3533
|
+
apiFieldsConfig: EmptyObject,
|
|
3534
|
+
wiredMethods: EmptyObject,
|
|
3535
|
+
wiredFields: EmptyObject,
|
|
3536
|
+
observedFields: EmptyObject
|
|
3537
|
+
};
|
|
3602
3538
|
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3539
|
+
function getDecoratorsMeta(Ctor) {
|
|
3540
|
+
const meta = signedDecoratorToMetaMap.get(Ctor);
|
|
3541
|
+
return isUndefined$1(meta) ? defaultMeta : meta;
|
|
3542
|
+
}
|
|
3606
3543
|
|
|
3607
|
-
|
|
3608
|
-
ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
|
|
3609
|
-
} // every time we invoke this setter from outside (through this wrapper setter)
|
|
3610
|
-
// we should reset the value and then debounce just in case there is a pending
|
|
3611
|
-
// invocation the next tick that is not longer relevant since the value is changing
|
|
3612
|
-
// from outside.
|
|
3544
|
+
const signedTemplateSet = new Set();
|
|
3613
3545
|
|
|
3546
|
+
function defaultEmptyTemplate() {
|
|
3547
|
+
return [];
|
|
3548
|
+
}
|
|
3614
3549
|
|
|
3615
|
-
|
|
3616
|
-
ro.observe(() => {
|
|
3617
|
-
set.call(this, newValue);
|
|
3618
|
-
});
|
|
3619
|
-
} else {
|
|
3620
|
-
set.call(this, newValue);
|
|
3621
|
-
}
|
|
3622
|
-
} else if (process.env.NODE_ENV !== 'production') {
|
|
3623
|
-
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
3624
|
-
}
|
|
3625
|
-
},
|
|
3550
|
+
signedTemplateSet.add(defaultEmptyTemplate);
|
|
3626
3551
|
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
};
|
|
3552
|
+
function isTemplateRegistered(tpl) {
|
|
3553
|
+
return signedTemplateSet.has(tpl);
|
|
3630
3554
|
}
|
|
3555
|
+
/**
|
|
3556
|
+
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
3557
|
+
* will prevent this function from being imported by userland code.
|
|
3558
|
+
*/
|
|
3631
3559
|
|
|
3632
|
-
function createObservedFieldPropertyDescriptor(key) {
|
|
3633
|
-
return {
|
|
3634
|
-
get() {
|
|
3635
|
-
const vm = getAssociatedVM(this);
|
|
3636
|
-
componentValueObserved(vm, key);
|
|
3637
|
-
return vm.cmpFields[key];
|
|
3638
|
-
},
|
|
3639
3560
|
|
|
3640
|
-
|
|
3641
|
-
|
|
3561
|
+
function registerTemplate(tpl) {
|
|
3562
|
+
signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
|
|
3563
|
+
// assignment of templates easily, without too much transformation
|
|
3642
3564
|
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3565
|
+
return tpl;
|
|
3566
|
+
}
|
|
3567
|
+
/**
|
|
3568
|
+
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
3569
|
+
* libraries to sanitize vulnerable attributes.
|
|
3570
|
+
*/
|
|
3648
3571
|
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3572
|
+
|
|
3573
|
+
function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
3574
|
+
// locker-service patches this function during runtime to sanitize vulnerable attributes. When
|
|
3575
|
+
// ran off-core this function becomes a noop and returns the user authored value.
|
|
3576
|
+
return attrValue;
|
|
3652
3577
|
}
|
|
3653
3578
|
/*
|
|
3654
3579
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3656,798 +3581,861 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
3656
3581
|
* SPDX-License-Identifier: MIT
|
|
3657
3582
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3658
3583
|
*/
|
|
3584
|
+
// from the element instance, and get the value or set a new value on the component.
|
|
3585
|
+
// This means that across different elements, similar names can get the exact same
|
|
3586
|
+
// descriptor, so we can cache them:
|
|
3659
3587
|
|
|
3660
3588
|
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
return "method"
|
|
3664
|
-
/* Method */
|
|
3665
|
-
;
|
|
3666
|
-
} else if (isFunction$1(descriptor.set) || isFunction$1(descriptor.get)) {
|
|
3667
|
-
return "accessor"
|
|
3668
|
-
/* Accessor */
|
|
3669
|
-
;
|
|
3670
|
-
} else {
|
|
3671
|
-
return "field"
|
|
3672
|
-
/* Field */
|
|
3673
|
-
;
|
|
3674
|
-
}
|
|
3675
|
-
}
|
|
3589
|
+
const cachedGetterByKey = create(null);
|
|
3590
|
+
const cachedSetterByKey = create(null);
|
|
3676
3591
|
|
|
3677
|
-
function
|
|
3678
|
-
|
|
3679
|
-
const type = getClassDescriptorType(descriptor);
|
|
3680
|
-
const message = `Invalid observed ${fieldName} field. Found a duplicate ${type} with the same name.`; // [W-9927596] Ideally we always throw an error when detecting duplicate observed field.
|
|
3681
|
-
// This branch is only here for backward compatibility reasons.
|
|
3592
|
+
function createGetter(key) {
|
|
3593
|
+
let fn = cachedGetterByKey[key];
|
|
3682
3594
|
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3595
|
+
if (isUndefined$1(fn)) {
|
|
3596
|
+
fn = cachedGetterByKey[key] = function () {
|
|
3597
|
+
const vm = getAssociatedVM(this);
|
|
3598
|
+
const {
|
|
3599
|
+
getHook
|
|
3600
|
+
} = vm;
|
|
3601
|
+
return getHook(vm.component, key);
|
|
3602
|
+
};
|
|
3690
3603
|
}
|
|
3691
|
-
}
|
|
3692
3604
|
|
|
3693
|
-
|
|
3694
|
-
if (!isUndefined$1(descriptor)) {
|
|
3695
|
-
const type = getClassDescriptorType(descriptor);
|
|
3696
|
-
assert.fail(`Invalid @track ${fieldName} field. Found a duplicate ${type} with the same name.`);
|
|
3697
|
-
}
|
|
3605
|
+
return fn;
|
|
3698
3606
|
}
|
|
3699
3607
|
|
|
3700
|
-
function
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3608
|
+
function createSetter(key) {
|
|
3609
|
+
let fn = cachedSetterByKey[key];
|
|
3610
|
+
|
|
3611
|
+
if (isUndefined$1(fn)) {
|
|
3612
|
+
fn = cachedSetterByKey[key] = function (newValue) {
|
|
3613
|
+
const vm = getAssociatedVM(this);
|
|
3614
|
+
const {
|
|
3615
|
+
setHook
|
|
3616
|
+
} = vm;
|
|
3617
|
+
newValue = reactiveMembrane.getReadOnlyProxy(newValue);
|
|
3618
|
+
setHook(vm.component, key, newValue);
|
|
3619
|
+
};
|
|
3704
3620
|
}
|
|
3621
|
+
|
|
3622
|
+
return fn;
|
|
3705
3623
|
}
|
|
3706
3624
|
|
|
3707
|
-
function
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3625
|
+
function createMethodCaller(methodName) {
|
|
3626
|
+
return function () {
|
|
3627
|
+
const vm = getAssociatedVM(this);
|
|
3628
|
+
const {
|
|
3629
|
+
callHook,
|
|
3630
|
+
component
|
|
3631
|
+
} = vm;
|
|
3632
|
+
const fn = component[methodName];
|
|
3633
|
+
return callHook(vm.component, fn, ArraySlice.call(arguments));
|
|
3634
|
+
};
|
|
3711
3635
|
}
|
|
3712
3636
|
|
|
3713
|
-
function
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3637
|
+
function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
|
|
3638
|
+
return function attributeChangedCallback(attrName, oldValue, newValue) {
|
|
3639
|
+
if (oldValue === newValue) {
|
|
3640
|
+
// Ignore same values.
|
|
3641
|
+
return;
|
|
3642
|
+
}
|
|
3718
3643
|
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
) {
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3644
|
+
const propName = attributeToPropMap[attrName];
|
|
3645
|
+
|
|
3646
|
+
if (isUndefined$1(propName)) {
|
|
3647
|
+
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
3648
|
+
// delegate unknown attributes to the super.
|
|
3649
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
3650
|
+
// @ts-ignore type-mismatch
|
|
3651
|
+
superAttributeChangedCallback.apply(this, arguments);
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3654
|
+
return;
|
|
3725
3655
|
}
|
|
3726
|
-
|
|
3656
|
+
|
|
3657
|
+
if (!isAttributeLocked(this, attrName)) {
|
|
3658
|
+
// Ignore changes triggered by the engine itself during:
|
|
3659
|
+
// * diffing when public props are attempting to reflect to the DOM
|
|
3660
|
+
// * component via `this.setAttribute()`, should never update the prop
|
|
3661
|
+
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
3662
|
+
// attribute to be changed
|
|
3663
|
+
return;
|
|
3664
|
+
} // Reflect attribute change to the corresponding property when changed from outside.
|
|
3665
|
+
|
|
3666
|
+
|
|
3667
|
+
this[propName] = newValue;
|
|
3668
|
+
};
|
|
3727
3669
|
}
|
|
3728
3670
|
|
|
3729
|
-
function
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3671
|
+
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
3672
|
+
let HTMLBridgeElement;
|
|
3673
|
+
/**
|
|
3674
|
+
* Modern browsers will have all Native Constructors as regular Classes
|
|
3675
|
+
* and must be instantiated with the new keyword. In older browsers,
|
|
3676
|
+
* specifically IE11, those are objects with a prototype property defined,
|
|
3677
|
+
* since they are not supposed to be extended or instantiated with the
|
|
3678
|
+
* new keyword. This forking logic supports both cases, specifically because
|
|
3679
|
+
* wc.ts relies on the construction path of the bridges to create new
|
|
3680
|
+
* fully qualifying web components.
|
|
3681
|
+
*/
|
|
3682
|
+
|
|
3683
|
+
if (isFunction$1(SuperClass)) {
|
|
3684
|
+
HTMLBridgeElement = class extends SuperClass {};
|
|
3685
|
+
} else {
|
|
3686
|
+
HTMLBridgeElement = function () {
|
|
3687
|
+
// Bridge classes are not supposed to be instantiated directly in
|
|
3688
|
+
// browsers that do not support web components.
|
|
3689
|
+
throw new TypeError('Illegal constructor');
|
|
3690
|
+
}; // prototype inheritance dance
|
|
3691
|
+
|
|
3692
|
+
|
|
3693
|
+
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
3694
|
+
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
3695
|
+
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
3696
|
+
writable: true,
|
|
3697
|
+
configurable: true,
|
|
3698
|
+
value: HTMLBridgeElement
|
|
3699
|
+
});
|
|
3700
|
+
} // generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
|
3701
|
+
// and false positives in case of inheritance.
|
|
3702
|
+
|
|
3703
|
+
|
|
3704
|
+
const attributeToPropMap = create(null);
|
|
3705
|
+
const {
|
|
3706
|
+
attributeChangedCallback: superAttributeChangedCallback
|
|
3707
|
+
} = SuperClass.prototype;
|
|
3708
|
+
const {
|
|
3709
|
+
observedAttributes: superObservedAttributes = []
|
|
3710
|
+
} = SuperClass;
|
|
3711
|
+
const descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
|
|
3712
|
+
|
|
3713
|
+
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
3714
|
+
const propName = props[i];
|
|
3715
|
+
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
3716
|
+
descriptors[propName] = {
|
|
3717
|
+
get: createGetter(propName),
|
|
3718
|
+
set: createSetter(propName),
|
|
3719
|
+
enumerable: true,
|
|
3720
|
+
configurable: true
|
|
3721
|
+
};
|
|
3722
|
+
} // expose public methods as props on the new Element Bridge
|
|
3723
|
+
|
|
3724
|
+
|
|
3725
|
+
for (let i = 0, len = methods.length; i < len; i += 1) {
|
|
3726
|
+
const methodName = methods[i];
|
|
3727
|
+
descriptors[methodName] = {
|
|
3728
|
+
value: createMethodCaller(methodName),
|
|
3729
|
+
writable: true,
|
|
3730
|
+
configurable: true
|
|
3731
|
+
};
|
|
3732
|
+
} // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
3733
|
+
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
3734
|
+
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
3735
|
+
// to preserve this definition.
|
|
3736
|
+
|
|
3737
|
+
|
|
3738
|
+
descriptors.attributeChangedCallback = {
|
|
3739
|
+
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
|
|
3740
|
+
}; // Specify attributes for which we want to reflect changes back to their corresponding
|
|
3741
|
+
// properties via attributeChangedCallback.
|
|
3742
|
+
|
|
3743
|
+
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
3744
|
+
get() {
|
|
3745
|
+
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
});
|
|
3749
|
+
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
3750
|
+
return HTMLBridgeElement;
|
|
3737
3751
|
}
|
|
3738
3752
|
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
*
|
|
3746
|
-
*
|
|
3753
|
+
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor$1, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
3754
|
+
freeze(BaseBridgeElement);
|
|
3755
|
+
seal(BaseBridgeElement.prototype);
|
|
3756
|
+
/*
|
|
3757
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
3758
|
+
* All rights reserved.
|
|
3759
|
+
* SPDX-License-Identifier: MIT
|
|
3760
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3747
3761
|
*/
|
|
3748
3762
|
|
|
3763
|
+
function resolveCircularModuleDependency(fn) {
|
|
3764
|
+
const module = fn();
|
|
3765
|
+
return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
|
|
3766
|
+
}
|
|
3749
3767
|
|
|
3750
|
-
function
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
const apiMethods = create(null);
|
|
3760
|
-
const apiFields = create(null);
|
|
3761
|
-
const wiredMethods = create(null);
|
|
3762
|
-
const wiredFields = create(null);
|
|
3763
|
-
const observedFields = create(null);
|
|
3764
|
-
const apiFieldsConfig = create(null);
|
|
3765
|
-
let descriptor;
|
|
3766
|
-
|
|
3767
|
-
if (!isUndefined$1(publicProps)) {
|
|
3768
|
-
for (const fieldName in publicProps) {
|
|
3769
|
-
const propConfig = publicProps[fieldName];
|
|
3770
|
-
apiFieldsConfig[fieldName] = propConfig.config;
|
|
3771
|
-
descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
|
3772
|
-
|
|
3773
|
-
if (propConfig.config > 0) {
|
|
3774
|
-
// accessor declaration
|
|
3775
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3776
|
-
validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor);
|
|
3777
|
-
}
|
|
3768
|
+
function isCircularModuleDependency(obj) {
|
|
3769
|
+
return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
|
|
3770
|
+
}
|
|
3771
|
+
/*
|
|
3772
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
3773
|
+
* All rights reserved.
|
|
3774
|
+
* SPDX-License-Identifier: MIT
|
|
3775
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3776
|
+
*/
|
|
3778
3777
|
|
|
3779
|
-
if (isUndefined$1(descriptor)) {
|
|
3780
|
-
throw new Error();
|
|
3781
|
-
}
|
|
3782
3778
|
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
// with the same name, the property is defined as a public accessor. This branch is
|
|
3790
|
-
// only here for backward compatibility reasons.
|
|
3779
|
+
const swappedTemplateMap = new WeakMap();
|
|
3780
|
+
const swappedComponentMap = new WeakMap();
|
|
3781
|
+
const swappedStyleMap = new WeakMap();
|
|
3782
|
+
const activeTemplates = new WeakMap();
|
|
3783
|
+
const activeComponents = new WeakMap();
|
|
3784
|
+
const activeStyles = new WeakMap();
|
|
3791
3785
|
|
|
3786
|
+
function rehydrateHotTemplate(tpl) {
|
|
3787
|
+
const list = activeTemplates.get(tpl);
|
|
3792
3788
|
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3789
|
+
if (!isUndefined$1(list)) {
|
|
3790
|
+
list.forEach(vm => {
|
|
3791
|
+
if (isFalse(vm.isDirty)) {
|
|
3792
|
+
// forcing the vm to rehydrate in the micro-task:
|
|
3793
|
+
markComponentAsDirty(vm);
|
|
3794
|
+
scheduleRehydration(vm);
|
|
3798
3795
|
}
|
|
3796
|
+
}); // resetting the Set to release the memory of those vm references
|
|
3797
|
+
// since they are not longer related to this template, instead
|
|
3798
|
+
// they will get re-associated once these instances are rehydrated.
|
|
3799
3799
|
|
|
3800
|
-
|
|
3801
|
-
defineProperty(proto, fieldName, descriptor);
|
|
3802
|
-
}
|
|
3800
|
+
list.clear();
|
|
3803
3801
|
}
|
|
3804
3802
|
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
descriptor = getOwnPropertyDescriptor$1(proto, methodName);
|
|
3803
|
+
return true;
|
|
3804
|
+
}
|
|
3808
3805
|
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
}
|
|
3806
|
+
function rehydrateHotStyle(style) {
|
|
3807
|
+
const list = activeStyles.get(style);
|
|
3812
3808
|
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3809
|
+
if (!isUndefined$1(list)) {
|
|
3810
|
+
list.forEach(vm => {
|
|
3811
|
+
// if a style definition is swapped, we must reset
|
|
3812
|
+
// vm's template content in the next micro-task:
|
|
3813
|
+
forceRehydration(vm);
|
|
3814
|
+
}); // resetting the Set to release the memory of those vm references
|
|
3815
|
+
// since they are not longer related to this style, instead
|
|
3816
|
+
// they will get re-associated once these instances are rehydrated.
|
|
3816
3817
|
|
|
3817
|
-
|
|
3818
|
-
});
|
|
3818
|
+
list.clear();
|
|
3819
3819
|
}
|
|
3820
3820
|
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
const {
|
|
3824
|
-
adapter,
|
|
3825
|
-
method,
|
|
3826
|
-
config: configCallback,
|
|
3827
|
-
dynamic = []
|
|
3828
|
-
} = wire[fieldOrMethodName];
|
|
3829
|
-
descriptor = getOwnPropertyDescriptor$1(proto, fieldOrMethodName);
|
|
3821
|
+
return true;
|
|
3822
|
+
}
|
|
3830
3823
|
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
|
|
3835
|
-
}
|
|
3824
|
+
function rehydrateHotComponent(Ctor) {
|
|
3825
|
+
const list = activeComponents.get(Ctor);
|
|
3826
|
+
let canRefreshAllInstances = true;
|
|
3836
3827
|
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3828
|
+
if (!isUndefined$1(list)) {
|
|
3829
|
+
list.forEach(vm => {
|
|
3830
|
+
const {
|
|
3831
|
+
owner
|
|
3832
|
+
} = vm;
|
|
3840
3833
|
|
|
3841
|
-
|
|
3842
|
-
|
|
3834
|
+
if (!isNull(owner)) {
|
|
3835
|
+
// if a component class definition is swapped, we must reset
|
|
3836
|
+
// owner's template content in the next micro-task:
|
|
3837
|
+
forceRehydration(owner);
|
|
3843
3838
|
} else {
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic);
|
|
3852
|
-
defineProperty(proto, fieldOrMethodName, descriptor);
|
|
3853
|
-
}
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
|
|
3857
|
-
if (!isUndefined$1(track)) {
|
|
3858
|
-
for (const fieldName in track) {
|
|
3859
|
-
descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
|
3860
|
-
|
|
3861
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3862
|
-
validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor);
|
|
3839
|
+
// the hot swapping for components only work for instances of components
|
|
3840
|
+
// created from a template, root elements can't be swapped because we
|
|
3841
|
+
// don't have a way to force the creation of the element with the same state
|
|
3842
|
+
// of the current element.
|
|
3843
|
+
// Instead, we can report the problem to the caller so it can take action,
|
|
3844
|
+
// for example: reload the entire page.
|
|
3845
|
+
canRefreshAllInstances = false;
|
|
3863
3846
|
}
|
|
3847
|
+
}); // resetting the Set to release the memory of those vm references
|
|
3848
|
+
// since they are not longer related to this constructor, instead
|
|
3849
|
+
// they will get re-associated once these instances are rehydrated.
|
|
3864
3850
|
|
|
3865
|
-
|
|
3866
|
-
defineProperty(proto, fieldName, descriptor);
|
|
3867
|
-
}
|
|
3851
|
+
list.clear();
|
|
3868
3852
|
}
|
|
3869
3853
|
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
const fieldName = fields[i];
|
|
3873
|
-
descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
|
3874
|
-
|
|
3875
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3876
|
-
validateObservedField(Ctor, fieldName, descriptor);
|
|
3877
|
-
} // [W-9927596] Only mark a field as observed whenever it isn't a duplicated public nor
|
|
3878
|
-
// tracked property. This is only here for backward compatibility purposes.
|
|
3879
|
-
|
|
3854
|
+
return canRefreshAllInstances;
|
|
3855
|
+
}
|
|
3880
3856
|
|
|
3881
|
-
|
|
3882
|
-
|
|
3857
|
+
function flattenStylesheets(stylesheets) {
|
|
3858
|
+
const list = [];
|
|
3883
3859
|
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3860
|
+
for (const stylesheet of stylesheets) {
|
|
3861
|
+
if (!Array.isArray(stylesheet)) {
|
|
3862
|
+
list.push(stylesheet);
|
|
3863
|
+
} else {
|
|
3864
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
3887
3865
|
}
|
|
3888
3866
|
}
|
|
3889
3867
|
|
|
3890
|
-
|
|
3891
|
-
apiMethods,
|
|
3892
|
-
apiFields,
|
|
3893
|
-
apiFieldsConfig,
|
|
3894
|
-
wiredMethods,
|
|
3895
|
-
wiredFields,
|
|
3896
|
-
observedFields
|
|
3897
|
-
});
|
|
3898
|
-
return Ctor;
|
|
3868
|
+
return list;
|
|
3899
3869
|
}
|
|
3900
3870
|
|
|
3901
|
-
|
|
3871
|
+
function getTemplateOrSwappedTemplate(tpl) {
|
|
3872
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3873
|
+
// this method should never leak to prod
|
|
3874
|
+
throw new ReferenceError();
|
|
3875
|
+
}
|
|
3902
3876
|
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
}
|
|
3877
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3878
|
+
const visited = new Set();
|
|
3906
3879
|
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
wiredFields: EmptyObject,
|
|
3913
|
-
observedFields: EmptyObject
|
|
3914
|
-
};
|
|
3880
|
+
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
3881
|
+
visited.add(tpl);
|
|
3882
|
+
tpl = swappedTemplateMap.get(tpl);
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3915
3885
|
|
|
3916
|
-
|
|
3917
|
-
const meta = signedDecoratorToMetaMap.get(Ctor);
|
|
3918
|
-
return isUndefined$1(meta) ? defaultMeta : meta;
|
|
3886
|
+
return tpl;
|
|
3919
3887
|
}
|
|
3920
3888
|
|
|
3921
|
-
|
|
3889
|
+
function getComponentOrSwappedComponent(Ctor) {
|
|
3890
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3891
|
+
// this method should never leak to prod
|
|
3892
|
+
throw new ReferenceError();
|
|
3893
|
+
}
|
|
3922
3894
|
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
}
|
|
3895
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3896
|
+
const visited = new Set();
|
|
3926
3897
|
|
|
3927
|
-
|
|
3898
|
+
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
3899
|
+
visited.add(Ctor);
|
|
3900
|
+
Ctor = swappedComponentMap.get(Ctor);
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3928
3903
|
|
|
3929
|
-
|
|
3930
|
-
return signedTemplateSet.has(tpl);
|
|
3904
|
+
return Ctor;
|
|
3931
3905
|
}
|
|
3932
|
-
/**
|
|
3933
|
-
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
3934
|
-
* will prevent this function from being imported by userland code.
|
|
3935
|
-
*/
|
|
3936
3906
|
|
|
3907
|
+
function getStyleOrSwappedStyle(style) {
|
|
3908
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3909
|
+
// this method should never leak to prod
|
|
3910
|
+
throw new ReferenceError();
|
|
3911
|
+
}
|
|
3937
3912
|
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
// assignment of templates easily, without too much transformation
|
|
3913
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3914
|
+
const visited = new Set();
|
|
3941
3915
|
|
|
3942
|
-
|
|
3916
|
+
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
3917
|
+
visited.add(style);
|
|
3918
|
+
style = swappedStyleMap.get(style);
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
return style;
|
|
3943
3923
|
}
|
|
3944
|
-
/**
|
|
3945
|
-
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
3946
|
-
* libraries to sanitize vulnerable attributes.
|
|
3947
|
-
*/
|
|
3948
3924
|
|
|
3925
|
+
function setActiveVM(vm) {
|
|
3926
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3927
|
+
// this method should never leak to prod
|
|
3928
|
+
throw new ReferenceError();
|
|
3929
|
+
}
|
|
3949
3930
|
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
}
|
|
3955
|
-
/*
|
|
3956
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
3957
|
-
* All rights reserved.
|
|
3958
|
-
* SPDX-License-Identifier: MIT
|
|
3959
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3960
|
-
*/
|
|
3961
|
-
// from the element instance, and get the value or set a new value on the component.
|
|
3962
|
-
// This means that across different elements, similar names can get the exact same
|
|
3963
|
-
// descriptor, so we can cache them:
|
|
3931
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3932
|
+
// tracking active component
|
|
3933
|
+
const Ctor = vm.def.ctor;
|
|
3934
|
+
let componentVMs = activeComponents.get(Ctor);
|
|
3964
3935
|
|
|
3936
|
+
if (isUndefined$1(componentVMs)) {
|
|
3937
|
+
componentVMs = new Set();
|
|
3938
|
+
activeComponents.set(Ctor, componentVMs);
|
|
3939
|
+
} // this will allow us to keep track of the hot components
|
|
3965
3940
|
|
|
3966
|
-
const cachedGetterByKey = create(null);
|
|
3967
|
-
const cachedSetterByKey = create(null);
|
|
3968
3941
|
|
|
3969
|
-
|
|
3970
|
-
let fn = cachedGetterByKey[key];
|
|
3942
|
+
componentVMs.add(vm); // tracking active template
|
|
3971
3943
|
|
|
3972
|
-
|
|
3973
|
-
fn = cachedGetterByKey[key] = function () {
|
|
3974
|
-
const vm = getAssociatedVM(this);
|
|
3975
|
-
const {
|
|
3976
|
-
getHook
|
|
3977
|
-
} = vm;
|
|
3978
|
-
return getHook(vm.component, key);
|
|
3979
|
-
};
|
|
3980
|
-
}
|
|
3944
|
+
const tpl = vm.cmpTemplate;
|
|
3981
3945
|
|
|
3982
|
-
|
|
3983
|
-
|
|
3946
|
+
if (tpl) {
|
|
3947
|
+
let templateVMs = activeTemplates.get(tpl);
|
|
3984
3948
|
|
|
3985
|
-
|
|
3986
|
-
|
|
3949
|
+
if (isUndefined$1(templateVMs)) {
|
|
3950
|
+
templateVMs = new Set();
|
|
3951
|
+
activeTemplates.set(tpl, templateVMs);
|
|
3952
|
+
} // this will allow us to keep track of the templates that are
|
|
3953
|
+
// being used by a hot component
|
|
3987
3954
|
|
|
3988
|
-
if (isUndefined$1(fn)) {
|
|
3989
|
-
fn = cachedSetterByKey[key] = function (newValue) {
|
|
3990
|
-
const vm = getAssociatedVM(this);
|
|
3991
|
-
const {
|
|
3992
|
-
setHook
|
|
3993
|
-
} = vm;
|
|
3994
|
-
newValue = reactiveMembrane.getReadOnlyProxy(newValue);
|
|
3995
|
-
setHook(vm.component, key, newValue);
|
|
3996
|
-
};
|
|
3997
|
-
}
|
|
3998
3955
|
|
|
3999
|
-
|
|
4000
|
-
}
|
|
3956
|
+
templateVMs.add(vm); // tracking active styles associated to template
|
|
4001
3957
|
|
|
4002
|
-
|
|
4003
|
-
return function () {
|
|
4004
|
-
const vm = getAssociatedVM(this);
|
|
4005
|
-
const {
|
|
4006
|
-
callHook,
|
|
4007
|
-
component
|
|
4008
|
-
} = vm;
|
|
4009
|
-
const fn = component[methodName];
|
|
4010
|
-
return callHook(vm.component, fn, ArraySlice.call(arguments));
|
|
4011
|
-
};
|
|
4012
|
-
}
|
|
3958
|
+
const stylesheets = tpl.stylesheets;
|
|
4013
3959
|
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
3960
|
+
if (!isUndefined$1(stylesheets)) {
|
|
3961
|
+
flattenStylesheets(stylesheets).forEach(stylesheet => {
|
|
3962
|
+
// this is necessary because we don't hold the list of styles
|
|
3963
|
+
// in the vm, we only hold the selected (already swapped template)
|
|
3964
|
+
// but the styles attached to the template might not be the actual
|
|
3965
|
+
// active ones, but the swapped versions of those.
|
|
3966
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3967
|
+
let stylesheetVMs = activeStyles.get(stylesheet);
|
|
4020
3968
|
|
|
4021
|
-
|
|
3969
|
+
if (isUndefined$1(stylesheetVMs)) {
|
|
3970
|
+
stylesheetVMs = new Set();
|
|
3971
|
+
activeStyles.set(stylesheet, stylesheetVMs);
|
|
3972
|
+
} // this will allow us to keep track of the stylesheet that are
|
|
3973
|
+
// being used by a hot component
|
|
4022
3974
|
|
|
4023
|
-
if (isUndefined$1(propName)) {
|
|
4024
|
-
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
4025
|
-
// delegate unknown attributes to the super.
|
|
4026
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
|
4027
|
-
// @ts-ignore type-mismatch
|
|
4028
|
-
superAttributeChangedCallback.apply(this, arguments);
|
|
4029
|
-
}
|
|
4030
3975
|
|
|
4031
|
-
|
|
3976
|
+
stylesheetVMs.add(vm);
|
|
3977
|
+
});
|
|
3978
|
+
}
|
|
4032
3979
|
}
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
4033
3982
|
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
// attribute to be changed
|
|
4040
|
-
return;
|
|
4041
|
-
} // Reflect attribute change to the corresponding property when changed from outside.
|
|
4042
|
-
|
|
3983
|
+
function removeActiveVM(vm) {
|
|
3984
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3985
|
+
// this method should never leak to prod
|
|
3986
|
+
throw new ReferenceError();
|
|
3987
|
+
}
|
|
4043
3988
|
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
3989
|
+
if (runtimeFlags.ENABLE_HMR) {
|
|
3990
|
+
// tracking inactive component
|
|
3991
|
+
const Ctor = vm.def.ctor;
|
|
3992
|
+
let list = activeComponents.get(Ctor);
|
|
4047
3993
|
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
* and must be instantiated with the new keyword. In older browsers,
|
|
4053
|
-
* specifically IE11, those are objects with a prototype property defined,
|
|
4054
|
-
* since they are not supposed to be extended or instantiated with the
|
|
4055
|
-
* new keyword. This forking logic supports both cases, specifically because
|
|
4056
|
-
* wc.ts relies on the construction path of the bridges to create new
|
|
4057
|
-
* fully qualifying web components.
|
|
4058
|
-
*/
|
|
3994
|
+
if (!isUndefined$1(list)) {
|
|
3995
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3996
|
+
list.delete(vm);
|
|
3997
|
+
} // removing inactive template
|
|
4059
3998
|
|
|
4060
|
-
if (isFunction$1(SuperClass)) {
|
|
4061
|
-
HTMLBridgeElement = class extends SuperClass {};
|
|
4062
|
-
} else {
|
|
4063
|
-
HTMLBridgeElement = function () {
|
|
4064
|
-
// Bridge classes are not supposed to be instantiated directly in
|
|
4065
|
-
// browsers that do not support web components.
|
|
4066
|
-
throw new TypeError('Illegal constructor');
|
|
4067
|
-
}; // prototype inheritance dance
|
|
4068
3999
|
|
|
4000
|
+
const tpl = vm.cmpTemplate;
|
|
4069
4001
|
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
4073
|
-
writable: true,
|
|
4074
|
-
configurable: true,
|
|
4075
|
-
value: HTMLBridgeElement
|
|
4076
|
-
});
|
|
4077
|
-
} // generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
|
4078
|
-
// and false positives in case of inheritance.
|
|
4002
|
+
if (tpl) {
|
|
4003
|
+
list = activeTemplates.get(tpl);
|
|
4079
4004
|
|
|
4005
|
+
if (!isUndefined$1(list)) {
|
|
4006
|
+
// deleting the vm from the set to avoid leaking memory
|
|
4007
|
+
list.delete(vm);
|
|
4008
|
+
} // removing active styles associated to template
|
|
4080
4009
|
|
|
4081
|
-
const attributeToPropMap = create(null);
|
|
4082
|
-
const {
|
|
4083
|
-
attributeChangedCallback: superAttributeChangedCallback
|
|
4084
|
-
} = SuperClass.prototype;
|
|
4085
|
-
const {
|
|
4086
|
-
observedAttributes: superObservedAttributes = []
|
|
4087
|
-
} = SuperClass;
|
|
4088
|
-
const descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
|
|
4089
4010
|
|
|
4090
|
-
|
|
4091
|
-
const propName = props[i];
|
|
4092
|
-
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
4093
|
-
descriptors[propName] = {
|
|
4094
|
-
get: createGetter(propName),
|
|
4095
|
-
set: createSetter(propName),
|
|
4096
|
-
enumerable: true,
|
|
4097
|
-
configurable: true
|
|
4098
|
-
};
|
|
4099
|
-
} // expose public methods as props on the new Element Bridge
|
|
4011
|
+
const styles = tpl.stylesheets;
|
|
4100
4012
|
|
|
4013
|
+
if (!isUndefined$1(styles)) {
|
|
4014
|
+
flattenStylesheets(styles).forEach(style => {
|
|
4015
|
+
list = activeStyles.get(style);
|
|
4101
4016
|
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
}
|
|
4109
|
-
}
|
|
4110
|
-
|
|
4111
|
-
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
4112
|
-
// to preserve this definition.
|
|
4017
|
+
if (!isUndefined$1(list)) {
|
|
4018
|
+
// deleting the vm from the set to avoid leaking memory
|
|
4019
|
+
list.delete(vm);
|
|
4020
|
+
}
|
|
4021
|
+
});
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4113
4026
|
|
|
4027
|
+
function swapTemplate(oldTpl, newTpl) {
|
|
4028
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4029
|
+
if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
|
|
4030
|
+
swappedTemplateMap.set(oldTpl, newTpl);
|
|
4031
|
+
return rehydrateHotTemplate(oldTpl);
|
|
4032
|
+
} else {
|
|
4033
|
+
throw new TypeError(`Invalid Template`);
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4114
4036
|
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
}
|
|
4118
|
-
// properties via attributeChangedCallback.
|
|
4037
|
+
if (!runtimeFlags.ENABLE_HMR) {
|
|
4038
|
+
throw new Error('HMR is not enabled');
|
|
4039
|
+
}
|
|
4119
4040
|
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4041
|
+
return false;
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
function swapComponent(oldComponent, newComponent) {
|
|
4045
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4046
|
+
if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
|
|
4047
|
+
swappedComponentMap.set(oldComponent, newComponent);
|
|
4048
|
+
return rehydrateHotComponent(oldComponent);
|
|
4049
|
+
} else {
|
|
4050
|
+
throw new TypeError(`Invalid Component`);
|
|
4123
4051
|
}
|
|
4052
|
+
}
|
|
4124
4053
|
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4054
|
+
if (!runtimeFlags.ENABLE_HMR) {
|
|
4055
|
+
throw new Error('HMR is not enabled');
|
|
4056
|
+
}
|
|
4057
|
+
|
|
4058
|
+
return false;
|
|
4128
4059
|
}
|
|
4129
4060
|
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4138
|
-
*/
|
|
4061
|
+
function swapStyle(oldStyle, newStyle) {
|
|
4062
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4063
|
+
// TODO [#1887]: once the support for registering styles is implemented
|
|
4064
|
+
// we can add the validation of both styles around this block.
|
|
4065
|
+
swappedStyleMap.set(oldStyle, newStyle);
|
|
4066
|
+
return rehydrateHotStyle(oldStyle);
|
|
4067
|
+
}
|
|
4139
4068
|
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
}
|
|
4069
|
+
if (!runtimeFlags.ENABLE_HMR) {
|
|
4070
|
+
throw new Error('HMR is not enabled');
|
|
4071
|
+
}
|
|
4144
4072
|
|
|
4145
|
-
|
|
4146
|
-
return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
|
|
4073
|
+
return false;
|
|
4147
4074
|
}
|
|
4148
4075
|
/*
|
|
4149
|
-
* Copyright (c)
|
|
4076
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4150
4077
|
* All rights reserved.
|
|
4151
4078
|
* SPDX-License-Identifier: MIT
|
|
4152
4079
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4153
4080
|
*/
|
|
4154
4081
|
|
|
4155
4082
|
|
|
4156
|
-
const
|
|
4157
|
-
const swappedComponentMap = new WeakMap();
|
|
4158
|
-
const swappedStyleMap = new WeakMap();
|
|
4159
|
-
const activeTemplates = new WeakMap();
|
|
4160
|
-
const activeComponents = new WeakMap();
|
|
4161
|
-
const activeStyles = new WeakMap();
|
|
4083
|
+
const CtorToDefMap = new WeakMap();
|
|
4162
4084
|
|
|
4163
|
-
function
|
|
4164
|
-
|
|
4085
|
+
function getCtorProto(Ctor) {
|
|
4086
|
+
let proto = getPrototypeOf$1(Ctor);
|
|
4165
4087
|
|
|
4166
|
-
if (
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
// forcing the vm to rehydrate in the micro-task:
|
|
4170
|
-
markComponentAsDirty(vm);
|
|
4171
|
-
scheduleRehydration(vm);
|
|
4172
|
-
}
|
|
4173
|
-
}); // resetting the Set to release the memory of those vm references
|
|
4174
|
-
// since they are not longer related to this template, instead
|
|
4175
|
-
// they will get re-associated once these instances are rehydrated.
|
|
4088
|
+
if (isNull(proto)) {
|
|
4089
|
+
throw new ReferenceError(`Invalid prototype chain for ${Ctor.name}, you must extend LightningElement.`);
|
|
4090
|
+
} // covering the cases where the ref is circular in AMD
|
|
4176
4091
|
|
|
4177
|
-
list.clear();
|
|
4178
|
-
}
|
|
4179
4092
|
|
|
4180
|
-
|
|
4181
|
-
|
|
4093
|
+
if (isCircularModuleDependency(proto)) {
|
|
4094
|
+
const p = resolveCircularModuleDependency(proto);
|
|
4182
4095
|
|
|
4183
|
-
|
|
4184
|
-
|
|
4096
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4097
|
+
if (isNull(p)) {
|
|
4098
|
+
throw new ReferenceError(`Circular module dependency for ${Ctor.name}, must resolve to a constructor that extends LightningElement.`);
|
|
4099
|
+
}
|
|
4100
|
+
} // escape hatch for Locker and other abstractions to provide their own base class instead
|
|
4101
|
+
// of our Base class without having to leak it to user-land. If the circular function returns
|
|
4102
|
+
// itself, that's the signal that we have hit the end of the proto chain, which must always
|
|
4103
|
+
// be base.
|
|
4185
4104
|
|
|
4186
|
-
if (!isUndefined$1(list)) {
|
|
4187
|
-
list.forEach(vm => {
|
|
4188
|
-
// if a style definition is swapped, we must reset
|
|
4189
|
-
// vm's template content in the next micro-task:
|
|
4190
|
-
forceRehydration(vm);
|
|
4191
|
-
}); // resetting the Set to release the memory of those vm references
|
|
4192
|
-
// since they are not longer related to this style, instead
|
|
4193
|
-
// they will get re-associated once these instances are rehydrated.
|
|
4194
4105
|
|
|
4195
|
-
|
|
4106
|
+
proto = p === proto ? LightningElement : p;
|
|
4196
4107
|
}
|
|
4197
4108
|
|
|
4198
|
-
return
|
|
4109
|
+
return proto;
|
|
4199
4110
|
}
|
|
4200
4111
|
|
|
4201
|
-
function
|
|
4202
|
-
const
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
list.forEach(vm => {
|
|
4207
|
-
const {
|
|
4208
|
-
owner
|
|
4209
|
-
} = vm;
|
|
4210
|
-
|
|
4211
|
-
if (!isNull(owner)) {
|
|
4212
|
-
// if a component class definition is swapped, we must reset
|
|
4213
|
-
// owner's template content in the next micro-task:
|
|
4214
|
-
forceRehydration(owner);
|
|
4215
|
-
} else {
|
|
4216
|
-
// the hot swapping for components only work for instances of components
|
|
4217
|
-
// created from a template, root elements can't be swapped because we
|
|
4218
|
-
// don't have a way to force the creation of the element with the same state
|
|
4219
|
-
// of the current element.
|
|
4220
|
-
// Instead, we can report the problem to the caller so it can take action,
|
|
4221
|
-
// for example: reload the entire page.
|
|
4222
|
-
canRefreshAllInstances = false;
|
|
4223
|
-
}
|
|
4224
|
-
}); // resetting the Set to release the memory of those vm references
|
|
4225
|
-
// since they are not longer related to this constructor, instead
|
|
4226
|
-
// they will get re-associated once these instances are rehydrated.
|
|
4112
|
+
function createComponentDef(Ctor) {
|
|
4113
|
+
const {
|
|
4114
|
+
shadowSupportMode: ctorShadowSupportMode,
|
|
4115
|
+
renderMode: ctorRenderMode
|
|
4116
|
+
} = Ctor;
|
|
4227
4117
|
|
|
4228
|
-
|
|
4229
|
-
|
|
4118
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4119
|
+
const ctorName = Ctor.name; // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
|
|
4120
|
+
// assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
|
|
4230
4121
|
|
|
4231
|
-
|
|
4232
|
-
}
|
|
4122
|
+
assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
|
|
4233
4123
|
|
|
4234
|
-
|
|
4235
|
-
|
|
4124
|
+
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
4125
|
+
assert.invariant(ctorShadowSupportMode === "any"
|
|
4126
|
+
/* Any */
|
|
4127
|
+
|| ctorShadowSupportMode === "reset"
|
|
4128
|
+
/* Default */
|
|
4129
|
+
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
4130
|
+
}
|
|
4236
4131
|
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
list.push(stylesheet);
|
|
4240
|
-
} else {
|
|
4241
|
-
list.push(...flattenStylesheets(stylesheet));
|
|
4132
|
+
if (!isUndefined$1(ctorRenderMode)) {
|
|
4133
|
+
assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', `Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
|
|
4242
4134
|
}
|
|
4243
4135
|
}
|
|
4244
4136
|
|
|
4245
|
-
|
|
4246
|
-
|
|
4137
|
+
const decoratorsMeta = getDecoratorsMeta(Ctor);
|
|
4138
|
+
const {
|
|
4139
|
+
apiFields,
|
|
4140
|
+
apiFieldsConfig,
|
|
4141
|
+
apiMethods,
|
|
4142
|
+
wiredFields,
|
|
4143
|
+
wiredMethods,
|
|
4144
|
+
observedFields
|
|
4145
|
+
} = decoratorsMeta;
|
|
4146
|
+
const proto = Ctor.prototype;
|
|
4147
|
+
let {
|
|
4148
|
+
connectedCallback,
|
|
4149
|
+
disconnectedCallback,
|
|
4150
|
+
renderedCallback,
|
|
4151
|
+
errorCallback,
|
|
4152
|
+
render
|
|
4153
|
+
} = proto;
|
|
4154
|
+
const superProto = getCtorProto(Ctor);
|
|
4155
|
+
const superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
|
|
4156
|
+
const bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
|
|
4157
|
+
const props = assign(create(null), superDef.props, apiFields);
|
|
4158
|
+
const propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
|
|
4159
|
+
const methods = assign(create(null), superDef.methods, apiMethods);
|
|
4160
|
+
const wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
|
|
4161
|
+
connectedCallback = connectedCallback || superDef.connectedCallback;
|
|
4162
|
+
disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
|
|
4163
|
+
renderedCallback = renderedCallback || superDef.renderedCallback;
|
|
4164
|
+
errorCallback = errorCallback || superDef.errorCallback;
|
|
4165
|
+
render = render || superDef.render;
|
|
4166
|
+
let shadowSupportMode = superDef.shadowSupportMode;
|
|
4247
4167
|
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
// this method should never leak to prod
|
|
4251
|
-
throw new ReferenceError();
|
|
4168
|
+
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
4169
|
+
shadowSupportMode = ctorShadowSupportMode;
|
|
4252
4170
|
}
|
|
4253
4171
|
|
|
4254
|
-
|
|
4255
|
-
const visited = new Set();
|
|
4172
|
+
let renderMode = superDef.renderMode;
|
|
4256
4173
|
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4174
|
+
if (!isUndefined$1(ctorRenderMode)) {
|
|
4175
|
+
renderMode = ctorRenderMode === 'light' ? 0
|
|
4176
|
+
/* Light */
|
|
4177
|
+
: 1
|
|
4178
|
+
/* Shadow */
|
|
4179
|
+
;
|
|
4261
4180
|
}
|
|
4262
4181
|
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
function getComponentOrSwappedComponent(Ctor) {
|
|
4267
|
-
if (process.env.NODE_ENV === 'production') {
|
|
4268
|
-
// this method should never leak to prod
|
|
4269
|
-
throw new ReferenceError();
|
|
4270
|
-
}
|
|
4182
|
+
const template = getComponentRegisteredTemplate(Ctor) || superDef.template;
|
|
4183
|
+
const name = Ctor.name || superDef.name; // installing observed fields into the prototype.
|
|
4271
4184
|
|
|
4272
|
-
|
|
4273
|
-
|
|
4185
|
+
defineProperties(proto, observedFields);
|
|
4186
|
+
const def = {
|
|
4187
|
+
ctor: Ctor,
|
|
4188
|
+
name,
|
|
4189
|
+
wire,
|
|
4190
|
+
props,
|
|
4191
|
+
propsConfig,
|
|
4192
|
+
methods,
|
|
4193
|
+
bridge,
|
|
4194
|
+
template,
|
|
4195
|
+
renderMode,
|
|
4196
|
+
shadowSupportMode,
|
|
4197
|
+
connectedCallback,
|
|
4198
|
+
disconnectedCallback,
|
|
4199
|
+
renderedCallback,
|
|
4200
|
+
errorCallback,
|
|
4201
|
+
render
|
|
4202
|
+
};
|
|
4274
4203
|
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
Ctor = swappedComponentMap.get(Ctor);
|
|
4278
|
-
}
|
|
4204
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4205
|
+
freeze(Ctor.prototype);
|
|
4279
4206
|
}
|
|
4280
4207
|
|
|
4281
|
-
return
|
|
4208
|
+
return def;
|
|
4282
4209
|
}
|
|
4210
|
+
/**
|
|
4211
|
+
* EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
|
|
4212
|
+
* subject to change or being removed.
|
|
4213
|
+
*/
|
|
4283
4214
|
|
|
4284
|
-
function getStyleOrSwappedStyle(style) {
|
|
4285
|
-
if (process.env.NODE_ENV === 'production') {
|
|
4286
|
-
// this method should never leak to prod
|
|
4287
|
-
throw new ReferenceError();
|
|
4288
|
-
}
|
|
4289
|
-
|
|
4290
|
-
if (runtimeFlags.ENABLE_HMR) {
|
|
4291
|
-
const visited = new Set();
|
|
4292
|
-
|
|
4293
|
-
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
4294
|
-
visited.add(style);
|
|
4295
|
-
style = swappedStyleMap.get(style);
|
|
4296
|
-
}
|
|
4297
|
-
}
|
|
4298
4215
|
|
|
4299
|
-
|
|
4300
|
-
|
|
4216
|
+
function isComponentConstructor(ctor) {
|
|
4217
|
+
if (!isFunction$1(ctor)) {
|
|
4218
|
+
return false;
|
|
4219
|
+
} // Fast path: LightningElement is part of the prototype chain of the constructor.
|
|
4301
4220
|
|
|
4302
|
-
function setActiveVM(vm) {
|
|
4303
|
-
if (process.env.NODE_ENV === 'production') {
|
|
4304
|
-
// this method should never leak to prod
|
|
4305
|
-
throw new ReferenceError();
|
|
4306
|
-
}
|
|
4307
4221
|
|
|
4308
|
-
if (
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4222
|
+
if (ctor.prototype instanceof LightningElement) {
|
|
4223
|
+
return true;
|
|
4224
|
+
} // Slow path: LightningElement is not part of the prototype chain of the constructor, we need
|
|
4225
|
+
// climb up the constructor prototype chain to check in case there are circular dependencies
|
|
4226
|
+
// to resolve.
|
|
4312
4227
|
|
|
4313
|
-
if (isUndefined$1(componentVMs)) {
|
|
4314
|
-
componentVMs = new Set();
|
|
4315
|
-
activeComponents.set(Ctor, componentVMs);
|
|
4316
|
-
} // this will allow us to keep track of the hot components
|
|
4317
4228
|
|
|
4229
|
+
let current = ctor;
|
|
4318
4230
|
|
|
4319
|
-
|
|
4231
|
+
do {
|
|
4232
|
+
if (isCircularModuleDependency(current)) {
|
|
4233
|
+
const circularResolved = resolveCircularModuleDependency(current); // If the circular function returns itself, that's the signal that we have hit the end
|
|
4234
|
+
// of the proto chain, which must always be a valid base constructor.
|
|
4320
4235
|
|
|
4321
|
-
|
|
4236
|
+
if (circularResolved === current) {
|
|
4237
|
+
return true;
|
|
4238
|
+
}
|
|
4322
4239
|
|
|
4323
|
-
|
|
4324
|
-
|
|
4240
|
+
current = circularResolved;
|
|
4241
|
+
}
|
|
4325
4242
|
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
// being used by a hot component
|
|
4243
|
+
if (current === LightningElement) {
|
|
4244
|
+
return true;
|
|
4245
|
+
}
|
|
4246
|
+
} while (!isNull(current) && (current = getPrototypeOf$1(current))); // Finally return false if the LightningElement is not part of the prototype chain.
|
|
4331
4247
|
|
|
4332
4248
|
|
|
4333
|
-
|
|
4249
|
+
return false;
|
|
4250
|
+
}
|
|
4334
4251
|
|
|
4335
|
-
|
|
4252
|
+
function getComponentInternalDef(Ctor) {
|
|
4253
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4254
|
+
Ctor = getComponentOrSwappedComponent(Ctor);
|
|
4255
|
+
}
|
|
4336
4256
|
|
|
4337
|
-
|
|
4338
|
-
flattenStylesheets(stylesheets).forEach(stylesheet => {
|
|
4339
|
-
// this is necessary because we don't hold the list of styles
|
|
4340
|
-
// in the vm, we only hold the selected (already swapped template)
|
|
4341
|
-
// but the styles attached to the template might not be the actual
|
|
4342
|
-
// active ones, but the swapped versions of those.
|
|
4343
|
-
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
4344
|
-
let stylesheetVMs = activeStyles.get(stylesheet);
|
|
4257
|
+
let def = CtorToDefMap.get(Ctor);
|
|
4345
4258
|
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4259
|
+
if (isUndefined$1(def)) {
|
|
4260
|
+
if (isCircularModuleDependency(Ctor)) {
|
|
4261
|
+
const resolvedCtor = resolveCircularModuleDependency(Ctor);
|
|
4262
|
+
def = getComponentInternalDef(resolvedCtor); // Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
|
|
4263
|
+
// look up the definition in cache instead of re-resolving and recreating the def.
|
|
4351
4264
|
|
|
4265
|
+
CtorToDefMap.set(Ctor, def);
|
|
4266
|
+
return def;
|
|
4267
|
+
}
|
|
4352
4268
|
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
}
|
|
4269
|
+
if (!isComponentConstructor(Ctor)) {
|
|
4270
|
+
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.`);
|
|
4356
4271
|
}
|
|
4272
|
+
|
|
4273
|
+
def = createComponentDef(Ctor);
|
|
4274
|
+
CtorToDefMap.set(Ctor, def);
|
|
4357
4275
|
}
|
|
4276
|
+
|
|
4277
|
+
return def;
|
|
4358
4278
|
}
|
|
4359
4279
|
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4280
|
+
const lightingElementDef = {
|
|
4281
|
+
ctor: LightningElement,
|
|
4282
|
+
name: LightningElement.name,
|
|
4283
|
+
props: lightningBasedDescriptors,
|
|
4284
|
+
propsConfig: EmptyObject,
|
|
4285
|
+
methods: EmptyObject,
|
|
4286
|
+
renderMode: 1
|
|
4287
|
+
/* Shadow */
|
|
4288
|
+
,
|
|
4289
|
+
shadowSupportMode: "reset"
|
|
4290
|
+
/* Default */
|
|
4291
|
+
,
|
|
4292
|
+
wire: EmptyObject,
|
|
4293
|
+
bridge: BaseBridgeElement,
|
|
4294
|
+
template: defaultEmptyTemplate,
|
|
4295
|
+
render: LightningElement.prototype.render
|
|
4296
|
+
};
|
|
4297
|
+
/**
|
|
4298
|
+
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
|
4299
|
+
* subject to change or being removed.
|
|
4300
|
+
*/
|
|
4365
4301
|
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4302
|
+
function getComponentDef(Ctor) {
|
|
4303
|
+
const def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
|
|
4304
|
+
// for some external services, e.g.: Locker Service, usually, all they care
|
|
4305
|
+
// is about the shape of the constructor, the internals of it are not relevant
|
|
4306
|
+
// because they don't have a way to mess with that.
|
|
4370
4307
|
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4308
|
+
const {
|
|
4309
|
+
ctor,
|
|
4310
|
+
name,
|
|
4311
|
+
props,
|
|
4312
|
+
propsConfig,
|
|
4313
|
+
methods
|
|
4314
|
+
} = def;
|
|
4315
|
+
const publicProps = {};
|
|
4375
4316
|
|
|
4317
|
+
for (const key in props) {
|
|
4318
|
+
// avoid leaking the reference to the public props descriptors
|
|
4319
|
+
publicProps[key] = {
|
|
4320
|
+
config: propsConfig[key] || 0,
|
|
4321
|
+
type: "any"
|
|
4322
|
+
/* any */
|
|
4323
|
+
,
|
|
4324
|
+
attr: htmlPropertyToAttribute(key)
|
|
4325
|
+
};
|
|
4326
|
+
}
|
|
4376
4327
|
|
|
4377
|
-
|
|
4328
|
+
const publicMethods = {};
|
|
4378
4329
|
|
|
4379
|
-
|
|
4380
|
-
|
|
4330
|
+
for (const key in methods) {
|
|
4331
|
+
// avoid leaking the reference to the public method descriptors
|
|
4332
|
+
publicMethods[key] = methods[key].value;
|
|
4333
|
+
}
|
|
4381
4334
|
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4335
|
+
return {
|
|
4336
|
+
ctor,
|
|
4337
|
+
name,
|
|
4338
|
+
props: publicProps,
|
|
4339
|
+
methods: publicMethods
|
|
4340
|
+
};
|
|
4341
|
+
}
|
|
4342
|
+
/*
|
|
4343
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4344
|
+
* All rights reserved.
|
|
4345
|
+
* SPDX-License-Identifier: MIT
|
|
4346
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4347
|
+
*/
|
|
4386
4348
|
|
|
4387
4349
|
|
|
4388
|
-
|
|
4350
|
+
const xlinkNS = 'http://www.w3.org/1999/xlink';
|
|
4351
|
+
const xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
|
4352
|
+
const ColonCharCode = 58;
|
|
4389
4353
|
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4354
|
+
function patchAttributes(oldVnode, vnode) {
|
|
4355
|
+
const {
|
|
4356
|
+
attrs
|
|
4357
|
+
} = vnode.data;
|
|
4393
4358
|
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
list.delete(vm);
|
|
4397
|
-
}
|
|
4398
|
-
});
|
|
4399
|
-
}
|
|
4400
|
-
}
|
|
4359
|
+
if (isUndefined$1(attrs)) {
|
|
4360
|
+
return;
|
|
4401
4361
|
}
|
|
4402
|
-
}
|
|
4403
4362
|
|
|
4404
|
-
|
|
4405
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4406
|
-
if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
|
|
4407
|
-
swappedTemplateMap.set(oldTpl, newTpl);
|
|
4408
|
-
return rehydrateHotTemplate(oldTpl);
|
|
4409
|
-
} else {
|
|
4410
|
-
throw new TypeError(`Invalid Template`);
|
|
4411
|
-
}
|
|
4412
|
-
}
|
|
4363
|
+
const oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
|
|
4413
4364
|
|
|
4414
|
-
if (
|
|
4415
|
-
|
|
4365
|
+
if (oldAttrs === attrs) {
|
|
4366
|
+
return;
|
|
4416
4367
|
}
|
|
4417
4368
|
|
|
4418
|
-
|
|
4419
|
-
|
|
4369
|
+
const {
|
|
4370
|
+
elm
|
|
4371
|
+
} = vnode;
|
|
4420
4372
|
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4373
|
+
for (const key in attrs) {
|
|
4374
|
+
const cur = attrs[key];
|
|
4375
|
+
const old = oldAttrs[key];
|
|
4376
|
+
|
|
4377
|
+
if (old !== cur) {
|
|
4378
|
+
unlockAttribute(elm, key);
|
|
4379
|
+
|
|
4380
|
+
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
|
|
4381
|
+
// Assume xml namespace
|
|
4382
|
+
setAttribute$1(elm, key, cur, xmlNS);
|
|
4383
|
+
} else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
|
|
4384
|
+
// Assume xlink namespace
|
|
4385
|
+
setAttribute$1(elm, key, cur, xlinkNS);
|
|
4386
|
+
} else if (isNull(cur) || isUndefined$1(cur)) {
|
|
4387
|
+
removeAttribute$1(elm, key);
|
|
4388
|
+
} else {
|
|
4389
|
+
setAttribute$1(elm, key, cur);
|
|
4390
|
+
}
|
|
4391
|
+
|
|
4392
|
+
lockAttribute();
|
|
4428
4393
|
}
|
|
4429
4394
|
}
|
|
4395
|
+
}
|
|
4396
|
+
/*
|
|
4397
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4398
|
+
* All rights reserved.
|
|
4399
|
+
* SPDX-License-Identifier: MIT
|
|
4400
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4401
|
+
*/
|
|
4430
4402
|
|
|
4431
|
-
if (!runtimeFlags.ENABLE_HMR) {
|
|
4432
|
-
throw new Error('HMR is not enabled');
|
|
4433
|
-
}
|
|
4434
4403
|
|
|
4435
|
-
|
|
4404
|
+
function isLiveBindingProp(sel, key) {
|
|
4405
|
+
// For properties with live bindings, we read values from the DOM element
|
|
4406
|
+
// instead of relying on internally tracked values.
|
|
4407
|
+
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
4436
4408
|
}
|
|
4437
4409
|
|
|
4438
|
-
function
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4410
|
+
function patchProps(oldVnode, vnode) {
|
|
4411
|
+
const {
|
|
4412
|
+
props
|
|
4413
|
+
} = vnode.data;
|
|
4414
|
+
|
|
4415
|
+
if (isUndefined$1(props)) {
|
|
4416
|
+
return;
|
|
4444
4417
|
}
|
|
4445
4418
|
|
|
4446
|
-
|
|
4447
|
-
|
|
4419
|
+
const oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
|
|
4420
|
+
|
|
4421
|
+
if (oldProps === props) {
|
|
4422
|
+
return;
|
|
4448
4423
|
}
|
|
4449
4424
|
|
|
4450
|
-
|
|
4425
|
+
const isFirstPatch = isNull(oldVnode);
|
|
4426
|
+
const {
|
|
4427
|
+
elm,
|
|
4428
|
+
sel
|
|
4429
|
+
} = vnode;
|
|
4430
|
+
|
|
4431
|
+
for (const key in props) {
|
|
4432
|
+
const cur = props[key]; // Set the property if it's the first time is is patched or if the previous property is
|
|
4433
|
+
// different than the one previously set.
|
|
4434
|
+
|
|
4435
|
+
if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
|
|
4436
|
+
setProperty$1(elm, key, cur);
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4451
4439
|
}
|
|
4452
4440
|
/*
|
|
4453
4441
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -4457,264 +4445,188 @@ function swapStyle(oldStyle, newStyle) {
|
|
|
4457
4445
|
*/
|
|
4458
4446
|
|
|
4459
4447
|
|
|
4460
|
-
const
|
|
4448
|
+
const classNameToClassMap = create(null);
|
|
4461
4449
|
|
|
4462
|
-
function
|
|
4463
|
-
|
|
4450
|
+
function getMapFromClassName(className) {
|
|
4451
|
+
// Intentionally using == to match undefined and null values from computed style attribute
|
|
4452
|
+
if (className == null) {
|
|
4453
|
+
return EmptyObject;
|
|
4454
|
+
} // computed class names must be string
|
|
4464
4455
|
|
|
4465
|
-
if (isNull(proto)) {
|
|
4466
|
-
throw new ReferenceError(`Invalid prototype chain for ${Ctor.name}, you must extend LightningElement.`);
|
|
4467
|
-
} // covering the cases where the ref is circular in AMD
|
|
4468
4456
|
|
|
4457
|
+
className = isString(className) ? className : className + '';
|
|
4458
|
+
let map = classNameToClassMap[className];
|
|
4469
4459
|
|
|
4470
|
-
if (
|
|
4471
|
-
|
|
4460
|
+
if (map) {
|
|
4461
|
+
return map;
|
|
4462
|
+
}
|
|
4472
4463
|
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
} // escape hatch for Locker and other abstractions to provide their own base class instead
|
|
4478
|
-
// of our Base class without having to leak it to user-land. If the circular function returns
|
|
4479
|
-
// itself, that's the signal that we have hit the end of the proto chain, which must always
|
|
4480
|
-
// be base.
|
|
4464
|
+
map = create(null);
|
|
4465
|
+
let start = 0;
|
|
4466
|
+
let o;
|
|
4467
|
+
const len = className.length;
|
|
4481
4468
|
|
|
4469
|
+
for (o = 0; o < len; o++) {
|
|
4470
|
+
if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
|
|
4471
|
+
if (o > start) {
|
|
4472
|
+
map[StringSlice.call(className, start, o)] = true;
|
|
4473
|
+
}
|
|
4482
4474
|
|
|
4483
|
-
|
|
4475
|
+
start = o + 1;
|
|
4476
|
+
}
|
|
4484
4477
|
}
|
|
4485
4478
|
|
|
4486
|
-
|
|
4487
|
-
|
|
4479
|
+
if (o > start) {
|
|
4480
|
+
map[StringSlice.call(className, start, o)] = true;
|
|
4481
|
+
}
|
|
4488
4482
|
|
|
4489
|
-
|
|
4490
|
-
const {
|
|
4491
|
-
shadowSupportMode: ctorShadowSupportMode,
|
|
4492
|
-
renderMode: ctorRenderMode
|
|
4493
|
-
} = Ctor;
|
|
4483
|
+
classNameToClassMap[className] = map;
|
|
4494
4484
|
|
|
4495
4485
|
if (process.env.NODE_ENV !== 'production') {
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
|
|
4500
|
-
|
|
4501
|
-
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
4502
|
-
assert.invariant(ctorShadowSupportMode === "any"
|
|
4503
|
-
/* Any */
|
|
4504
|
-
|| ctorShadowSupportMode === "reset"
|
|
4505
|
-
/* Default */
|
|
4506
|
-
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
4507
|
-
}
|
|
4508
|
-
|
|
4509
|
-
if (!isUndefined$1(ctorRenderMode)) {
|
|
4510
|
-
assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', `Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
|
|
4511
|
-
}
|
|
4486
|
+
// just to make sure that this object never changes as part of the diffing algo
|
|
4487
|
+
freeze(map);
|
|
4512
4488
|
}
|
|
4513
4489
|
|
|
4514
|
-
|
|
4490
|
+
return map;
|
|
4491
|
+
}
|
|
4492
|
+
|
|
4493
|
+
function patchClassAttribute(oldVnode, vnode) {
|
|
4515
4494
|
const {
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
} = decoratorsMeta;
|
|
4523
|
-
const proto = Ctor.prototype;
|
|
4524
|
-
let {
|
|
4525
|
-
connectedCallback,
|
|
4526
|
-
disconnectedCallback,
|
|
4527
|
-
renderedCallback,
|
|
4528
|
-
errorCallback,
|
|
4529
|
-
render
|
|
4530
|
-
} = proto;
|
|
4531
|
-
const superProto = getCtorProto(Ctor);
|
|
4532
|
-
const superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
|
|
4533
|
-
const bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
|
|
4534
|
-
const props = assign(create(null), superDef.props, apiFields);
|
|
4535
|
-
const propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
|
|
4536
|
-
const methods = assign(create(null), superDef.methods, apiMethods);
|
|
4537
|
-
const wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
|
|
4538
|
-
connectedCallback = connectedCallback || superDef.connectedCallback;
|
|
4539
|
-
disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
|
|
4540
|
-
renderedCallback = renderedCallback || superDef.renderedCallback;
|
|
4541
|
-
errorCallback = errorCallback || superDef.errorCallback;
|
|
4542
|
-
render = render || superDef.render;
|
|
4543
|
-
let shadowSupportMode = superDef.shadowSupportMode;
|
|
4495
|
+
elm,
|
|
4496
|
+
data: {
|
|
4497
|
+
className: newClass
|
|
4498
|
+
}
|
|
4499
|
+
} = vnode;
|
|
4500
|
+
const oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
|
|
4544
4501
|
|
|
4545
|
-
if (
|
|
4546
|
-
|
|
4502
|
+
if (oldClass === newClass) {
|
|
4503
|
+
return;
|
|
4547
4504
|
}
|
|
4548
4505
|
|
|
4549
|
-
|
|
4506
|
+
const classList = getClassList$1(elm);
|
|
4507
|
+
const newClassMap = getMapFromClassName(newClass);
|
|
4508
|
+
const oldClassMap = getMapFromClassName(oldClass);
|
|
4509
|
+
let name;
|
|
4550
4510
|
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
;
|
|
4511
|
+
for (name in oldClassMap) {
|
|
4512
|
+
// remove only if it is not in the new class collection and it is not set from within the instance
|
|
4513
|
+
if (isUndefined$1(newClassMap[name])) {
|
|
4514
|
+
classList.remove(name);
|
|
4515
|
+
}
|
|
4557
4516
|
}
|
|
4558
4517
|
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
const def = {
|
|
4564
|
-
ctor: Ctor,
|
|
4565
|
-
name,
|
|
4566
|
-
wire,
|
|
4567
|
-
props,
|
|
4568
|
-
propsConfig,
|
|
4569
|
-
methods,
|
|
4570
|
-
bridge,
|
|
4571
|
-
template,
|
|
4572
|
-
renderMode,
|
|
4573
|
-
shadowSupportMode,
|
|
4574
|
-
connectedCallback,
|
|
4575
|
-
disconnectedCallback,
|
|
4576
|
-
renderedCallback,
|
|
4577
|
-
errorCallback,
|
|
4578
|
-
render
|
|
4579
|
-
};
|
|
4580
|
-
|
|
4581
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4582
|
-
freeze(Ctor.prototype);
|
|
4518
|
+
for (name in newClassMap) {
|
|
4519
|
+
if (isUndefined$1(oldClassMap[name])) {
|
|
4520
|
+
classList.add(name);
|
|
4521
|
+
}
|
|
4583
4522
|
}
|
|
4584
|
-
|
|
4585
|
-
return def;
|
|
4586
4523
|
}
|
|
4587
|
-
|
|
4588
|
-
*
|
|
4589
|
-
*
|
|
4524
|
+
/*
|
|
4525
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4526
|
+
* All rights reserved.
|
|
4527
|
+
* SPDX-License-Identifier: MIT
|
|
4528
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4590
4529
|
*/
|
|
4591
4530
|
|
|
4592
4531
|
|
|
4593
|
-
function
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
if (ctor.prototype instanceof LightningElement) {
|
|
4600
|
-
return true;
|
|
4601
|
-
} // Slow path: LightningElement is not part of the prototype chain of the constructor, we need
|
|
4602
|
-
// climb up the constructor prototype chain to check in case there are circular dependencies
|
|
4603
|
-
// to resolve.
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
let current = ctor;
|
|
4607
|
-
|
|
4608
|
-
do {
|
|
4609
|
-
if (isCircularModuleDependency(current)) {
|
|
4610
|
-
const circularResolved = resolveCircularModuleDependency(current); // If the circular function returns itself, that's the signal that we have hit the end
|
|
4611
|
-
// of the proto chain, which must always be a valid base constructor.
|
|
4612
|
-
|
|
4613
|
-
if (circularResolved === current) {
|
|
4614
|
-
return true;
|
|
4615
|
-
}
|
|
4616
|
-
|
|
4617
|
-
current = circularResolved;
|
|
4532
|
+
function patchStyleAttribute(oldVnode, vnode) {
|
|
4533
|
+
const {
|
|
4534
|
+
elm,
|
|
4535
|
+
data: {
|
|
4536
|
+
style: newStyle
|
|
4618
4537
|
}
|
|
4538
|
+
} = vnode;
|
|
4539
|
+
const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
|
|
4619
4540
|
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4541
|
+
if (oldStyle === newStyle) {
|
|
4542
|
+
return;
|
|
4543
|
+
}
|
|
4544
|
+
|
|
4545
|
+
if (!isString(newStyle) || newStyle === '') {
|
|
4546
|
+
removeAttribute$1(elm, 'style');
|
|
4547
|
+
} else {
|
|
4548
|
+
setAttribute$1(elm, 'style', newStyle);
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
/*
|
|
4552
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4553
|
+
* All rights reserved.
|
|
4554
|
+
* SPDX-License-Identifier: MIT
|
|
4555
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4556
|
+
*/
|
|
4624
4557
|
|
|
4625
4558
|
|
|
4626
|
-
|
|
4627
|
-
|
|
4559
|
+
function applyEventListeners(vnode) {
|
|
4560
|
+
const {
|
|
4561
|
+
elm,
|
|
4562
|
+
data: {
|
|
4563
|
+
on
|
|
4564
|
+
}
|
|
4565
|
+
} = vnode;
|
|
4628
4566
|
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
Ctor = getComponentOrSwappedComponent(Ctor);
|
|
4567
|
+
if (isUndefined$1(on)) {
|
|
4568
|
+
return;
|
|
4632
4569
|
}
|
|
4633
4570
|
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4571
|
+
for (const name in on) {
|
|
4572
|
+
const handler = on[name];
|
|
4573
|
+
addEventListener$1(elm, name, handler);
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
/*
|
|
4577
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4578
|
+
* All rights reserved.
|
|
4579
|
+
* SPDX-License-Identifier: MIT
|
|
4580
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4581
|
+
*/
|
|
4582
|
+
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
|
|
4583
|
+
// different classnames properties individually instead of via a string.
|
|
4641
4584
|
|
|
4642
|
-
CtorToDefMap.set(Ctor, def);
|
|
4643
|
-
return def;
|
|
4644
|
-
}
|
|
4645
4585
|
|
|
4646
|
-
|
|
4647
|
-
|
|
4586
|
+
function applyStaticClassAttribute(vnode) {
|
|
4587
|
+
const {
|
|
4588
|
+
elm,
|
|
4589
|
+
data: {
|
|
4590
|
+
classMap
|
|
4648
4591
|
}
|
|
4592
|
+
} = vnode;
|
|
4649
4593
|
|
|
4650
|
-
|
|
4651
|
-
|
|
4594
|
+
if (isUndefined$1(classMap)) {
|
|
4595
|
+
return;
|
|
4652
4596
|
}
|
|
4653
4597
|
|
|
4654
|
-
|
|
4655
|
-
}
|
|
4598
|
+
const classList = getClassList$1(elm);
|
|
4656
4599
|
|
|
4657
|
-
const
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
shadowSupportMode: "reset"
|
|
4667
|
-
/* Default */
|
|
4668
|
-
,
|
|
4669
|
-
wire: EmptyObject,
|
|
4670
|
-
bridge: BaseBridgeElement,
|
|
4671
|
-
template: defaultEmptyTemplate,
|
|
4672
|
-
render: LightningElement.prototype.render
|
|
4673
|
-
};
|
|
4674
|
-
/**
|
|
4675
|
-
* EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
|
|
4676
|
-
* subject to change or being removed.
|
|
4600
|
+
for (const name in classMap) {
|
|
4601
|
+
classList.add(name);
|
|
4602
|
+
}
|
|
4603
|
+
}
|
|
4604
|
+
/*
|
|
4605
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
4606
|
+
* All rights reserved.
|
|
4607
|
+
* SPDX-License-Identifier: MIT
|
|
4608
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4677
4609
|
*/
|
|
4610
|
+
// The compiler takes care of transforming the inline style into an object. It's faster to set the
|
|
4611
|
+
// different style properties individually instead of via a string.
|
|
4678
4612
|
|
|
4679
|
-
function getComponentDef(Ctor) {
|
|
4680
|
-
const def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
|
|
4681
|
-
// for some external services, e.g.: Locker Service, usually, all they care
|
|
4682
|
-
// is about the shape of the constructor, the internals of it are not relevant
|
|
4683
|
-
// because they don't have a way to mess with that.
|
|
4684
4613
|
|
|
4614
|
+
function applyStaticStyleAttribute(vnode) {
|
|
4685
4615
|
const {
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
} = def;
|
|
4692
|
-
const publicProps = {};
|
|
4616
|
+
elm,
|
|
4617
|
+
data: {
|
|
4618
|
+
styleDecls
|
|
4619
|
+
}
|
|
4620
|
+
} = vnode;
|
|
4693
4621
|
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
publicProps[key] = {
|
|
4697
|
-
config: propsConfig[key] || 0,
|
|
4698
|
-
type: "any"
|
|
4699
|
-
/* any */
|
|
4700
|
-
,
|
|
4701
|
-
attr: htmlPropertyToAttribute(key)
|
|
4702
|
-
};
|
|
4622
|
+
if (isUndefined$1(styleDecls)) {
|
|
4623
|
+
return;
|
|
4703
4624
|
}
|
|
4704
4625
|
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
// avoid leaking the reference to the public method descriptors
|
|
4709
|
-
publicMethods[key] = methods[key].value;
|
|
4626
|
+
for (let i = 0; i < styleDecls.length; i++) {
|
|
4627
|
+
const [prop, value, important] = styleDecls[i];
|
|
4628
|
+
setCSSStyleProperty$1(elm, prop, value, important);
|
|
4710
4629
|
}
|
|
4711
|
-
|
|
4712
|
-
return {
|
|
4713
|
-
ctor,
|
|
4714
|
-
name,
|
|
4715
|
-
props: publicProps,
|
|
4716
|
-
methods: publicMethods
|
|
4717
|
-
};
|
|
4718
4630
|
}
|
|
4719
4631
|
/*
|
|
4720
4632
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -4788,28 +4700,24 @@ function removeNodeHook(vnode, parentNode) {
|
|
|
4788
4700
|
}
|
|
4789
4701
|
}
|
|
4790
4702
|
|
|
4791
|
-
function
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4703
|
+
function patchElementPropsAndAttrs(oldVnode, vnode) {
|
|
4704
|
+
if (isNull(oldVnode)) {
|
|
4705
|
+
applyEventListeners(vnode);
|
|
4706
|
+
applyStaticClassAttribute(vnode);
|
|
4707
|
+
applyStaticStyleAttribute(vnode);
|
|
4708
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4709
|
+
// value is set before type=radio.
|
|
4795
4710
|
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
modComputedStyle.create(vnode);
|
|
4711
|
+
|
|
4712
|
+
patchClassAttribute(oldVnode, vnode);
|
|
4713
|
+
patchStyleAttribute(oldVnode, vnode);
|
|
4714
|
+
patchAttributes(oldVnode, vnode);
|
|
4715
|
+
patchProps(oldVnode, vnode);
|
|
4802
4716
|
}
|
|
4803
4717
|
|
|
4804
4718
|
function hydrateElmHook(vnode) {
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
modProps.create(vnode); // Already set.
|
|
4809
|
-
// modStaticClassName.create(vnode);
|
|
4810
|
-
// modStaticStyle.create(vnode);
|
|
4811
|
-
// modComputedClassName.create(vnode);
|
|
4812
|
-
// modComputedStyle.create(vnode);
|
|
4719
|
+
applyEventListeners(vnode);
|
|
4720
|
+
patchProps(null, vnode);
|
|
4813
4721
|
}
|
|
4814
4722
|
|
|
4815
4723
|
function fallbackElmHook(elm, vnode) {
|
|
@@ -4861,26 +4769,11 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4861
4769
|
}
|
|
4862
4770
|
}
|
|
4863
4771
|
|
|
4864
|
-
function
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
// is set before type=radio.
|
|
4868
|
-
modAttrs.update(oldVnode, vnode);
|
|
4869
|
-
modProps.update(oldVnode, vnode);
|
|
4870
|
-
modComputedClassName.update(oldVnode, vnode);
|
|
4871
|
-
modComputedStyle.update(oldVnode, vnode);
|
|
4872
|
-
}
|
|
4873
|
-
|
|
4874
|
-
function updateChildrenHook(oldVnode, vnode) {
|
|
4875
|
-
const {
|
|
4876
|
-
elm,
|
|
4877
|
-
children
|
|
4878
|
-
} = vnode;
|
|
4879
|
-
|
|
4880
|
-
if (hasDynamicChildren(children)) {
|
|
4881
|
-
updateDynamicChildren(elm, oldVnode.children, children);
|
|
4772
|
+
function patchChildren(parent, oldCh, newCh) {
|
|
4773
|
+
if (hasDynamicChildren(newCh)) {
|
|
4774
|
+
updateDynamicChildren(parent, oldCh, newCh);
|
|
4882
4775
|
} else {
|
|
4883
|
-
updateStaticChildren(
|
|
4776
|
+
updateStaticChildren(parent, oldCh, newCh);
|
|
4884
4777
|
}
|
|
4885
4778
|
}
|
|
4886
4779
|
|
|
@@ -4955,19 +4848,6 @@ function createViewModelHook(elm, vnode) {
|
|
|
4955
4848
|
}
|
|
4956
4849
|
}
|
|
4957
4850
|
|
|
4958
|
-
function createCustomElmHook(vnode) {
|
|
4959
|
-
modEvents.create(vnode); // Attrs need to be applied to element before props
|
|
4960
|
-
// IE11 will wipe out value on radio inputs if value
|
|
4961
|
-
// is set before type=radio.
|
|
4962
|
-
|
|
4963
|
-
modAttrs.create(vnode);
|
|
4964
|
-
modProps.create(vnode);
|
|
4965
|
-
modStaticClassName.create(vnode);
|
|
4966
|
-
modStaticStyle.create(vnode);
|
|
4967
|
-
modComputedClassName.create(vnode);
|
|
4968
|
-
modComputedStyle.create(vnode);
|
|
4969
|
-
}
|
|
4970
|
-
|
|
4971
4851
|
function createChildrenHook(vnode) {
|
|
4972
4852
|
const {
|
|
4973
4853
|
elm,
|
|
@@ -5148,16 +5028,6 @@ function hydrateChildrenHook(elmChildren, children, vm) {
|
|
|
5148
5028
|
}
|
|
5149
5029
|
}
|
|
5150
5030
|
|
|
5151
|
-
function updateCustomElmHook(oldVnode, vnode) {
|
|
5152
|
-
// Attrs need to be applied to element before props
|
|
5153
|
-
// IE11 will wipe out value on radio inputs if value
|
|
5154
|
-
// is set before type=radio.
|
|
5155
|
-
modAttrs.update(oldVnode, vnode);
|
|
5156
|
-
modProps.update(oldVnode, vnode);
|
|
5157
|
-
modComputedClassName.update(oldVnode, vnode);
|
|
5158
|
-
modComputedStyle.update(oldVnode, vnode);
|
|
5159
|
-
}
|
|
5160
|
-
|
|
5161
5031
|
function removeElmHook(vnode) {
|
|
5162
5032
|
// this method only needs to search on child vnodes from template
|
|
5163
5033
|
// to trigger the remove hook just in case some of those children
|
|
@@ -5174,6 +5044,66 @@ function removeElmHook(vnode) {
|
|
|
5174
5044
|
ch.hook.remove(ch, elm);
|
|
5175
5045
|
}
|
|
5176
5046
|
}
|
|
5047
|
+
}
|
|
5048
|
+
|
|
5049
|
+
function allocateInSlot(vm, children) {
|
|
5050
|
+
const {
|
|
5051
|
+
cmpSlots: oldSlots
|
|
5052
|
+
} = vm;
|
|
5053
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
5054
|
+
|
|
5055
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
5056
|
+
const vnode = children[i];
|
|
5057
|
+
|
|
5058
|
+
if (isNull(vnode)) {
|
|
5059
|
+
continue;
|
|
5060
|
+
}
|
|
5061
|
+
|
|
5062
|
+
const {
|
|
5063
|
+
data
|
|
5064
|
+
} = vnode;
|
|
5065
|
+
const slotName = data.attrs && data.attrs.slot || '';
|
|
5066
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
|
|
5067
|
+
// which might have similar keys. Each vnode will always have a key that
|
|
5068
|
+
// starts with a numeric character from compiler. In this case, we add a unique
|
|
5069
|
+
// notation for slotted vnodes keys, e.g.: `@foo:1:1`
|
|
5070
|
+
|
|
5071
|
+
if (!isUndefined$1(vnode.key)) {
|
|
5072
|
+
vnode.key = `@${slotName}:${vnode.key}`;
|
|
5073
|
+
}
|
|
5074
|
+
|
|
5075
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
5076
|
+
}
|
|
5077
|
+
|
|
5078
|
+
if (isFalse(vm.isDirty)) {
|
|
5079
|
+
// We need to determine if the old allocation is really different from the new one
|
|
5080
|
+
// and mark the vm as dirty
|
|
5081
|
+
const oldKeys = keys(oldSlots);
|
|
5082
|
+
|
|
5083
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
5084
|
+
markComponentAsDirty(vm);
|
|
5085
|
+
return;
|
|
5086
|
+
}
|
|
5087
|
+
|
|
5088
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
5089
|
+
const key = oldKeys[i];
|
|
5090
|
+
|
|
5091
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
5092
|
+
markComponentAsDirty(vm);
|
|
5093
|
+
return;
|
|
5094
|
+
}
|
|
5095
|
+
|
|
5096
|
+
const oldVNodes = oldSlots[key];
|
|
5097
|
+
const vnodes = cmpSlots[key];
|
|
5098
|
+
|
|
5099
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
5100
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
5101
|
+
markComponentAsDirty(vm);
|
|
5102
|
+
return;
|
|
5103
|
+
}
|
|
5104
|
+
}
|
|
5105
|
+
}
|
|
5106
|
+
}
|
|
5177
5107
|
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
5178
5108
|
|
|
5179
5109
|
|
|
@@ -5320,11 +5250,11 @@ const ElementHook = {
|
|
|
5320
5250
|
linkNodeToShadow(elm, owner);
|
|
5321
5251
|
fallbackElmHook(elm, vnode);
|
|
5322
5252
|
vnode.elm = elm;
|
|
5323
|
-
|
|
5253
|
+
patchElementPropsAndAttrs(null, vnode);
|
|
5324
5254
|
},
|
|
5325
5255
|
update: (oldVnode, vnode) => {
|
|
5326
|
-
|
|
5327
|
-
|
|
5256
|
+
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
5257
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
5328
5258
|
},
|
|
5329
5259
|
insert: (vnode, parentNode, referenceNode) => {
|
|
5330
5260
|
insertNodeHook(vnode, parentNode, referenceNode);
|
|
@@ -5398,10 +5328,10 @@ const CustomElementHook = {
|
|
|
5398
5328
|
throw new TypeError(`Incorrect Component Constructor`);
|
|
5399
5329
|
}
|
|
5400
5330
|
|
|
5401
|
-
|
|
5331
|
+
patchElementPropsAndAttrs(null, vnode);
|
|
5402
5332
|
},
|
|
5403
5333
|
update: (oldVnode, vnode) => {
|
|
5404
|
-
|
|
5334
|
+
patchElementPropsAndAttrs(oldVnode, vnode);
|
|
5405
5335
|
const vm = getAssociatedVMIfPresent(vnode.elm);
|
|
5406
5336
|
|
|
5407
5337
|
if (vm) {
|
|
@@ -5412,7 +5342,7 @@ const CustomElementHook = {
|
|
|
5412
5342
|
// will happen, but in native, it does allocate the light dom
|
|
5413
5343
|
|
|
5414
5344
|
|
|
5415
|
-
|
|
5345
|
+
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
5416
5346
|
|
|
5417
5347
|
if (vm) {
|
|
5418
5348
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -7112,7 +7042,6 @@ function patchShadowRoot(vm, newCh) {
|
|
|
7112
7042
|
// patch function mutates vnodes by adding the element reference,
|
|
7113
7043
|
// however, if patching fails it contains partial changes.
|
|
7114
7044
|
if (oldCh !== newCh) {
|
|
7115
|
-
const fn = hasDynamicChildren(newCh) ? updateDynamicChildren : updateStaticChildren;
|
|
7116
7045
|
runWithBoundaryProtection(vm, vm, () => {
|
|
7117
7046
|
// pre
|
|
7118
7047
|
logOperationStart(2
|
|
@@ -7120,8 +7049,8 @@ function patchShadowRoot(vm, newCh) {
|
|
|
7120
7049
|
, vm);
|
|
7121
7050
|
}, () => {
|
|
7122
7051
|
// job
|
|
7123
|
-
const
|
|
7124
|
-
|
|
7052
|
+
const renderRoot = getRenderRoot(vm);
|
|
7053
|
+
patchChildren(renderRoot, oldCh, newCh);
|
|
7125
7054
|
}, () => {
|
|
7126
7055
|
// post
|
|
7127
7056
|
logOperationEnd(2
|
|
@@ -7416,69 +7345,6 @@ function getErrorBoundaryVM(vm) {
|
|
|
7416
7345
|
|
|
7417
7346
|
currentVm = currentVm.owner;
|
|
7418
7347
|
}
|
|
7419
|
-
} // slow path routine
|
|
7420
|
-
// NOTE: we should probably more this routine to the synthetic shadow folder
|
|
7421
|
-
// and get the allocation to be cached by in the elm instead of in the VM
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
function allocateInSlot(vm, children) {
|
|
7425
|
-
const {
|
|
7426
|
-
cmpSlots: oldSlots
|
|
7427
|
-
} = vm;
|
|
7428
|
-
const cmpSlots = vm.cmpSlots = create(null);
|
|
7429
|
-
|
|
7430
|
-
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
7431
|
-
const vnode = children[i];
|
|
7432
|
-
|
|
7433
|
-
if (isNull(vnode)) {
|
|
7434
|
-
continue;
|
|
7435
|
-
}
|
|
7436
|
-
|
|
7437
|
-
const {
|
|
7438
|
-
data
|
|
7439
|
-
} = vnode;
|
|
7440
|
-
const slotName = data.attrs && data.attrs.slot || '';
|
|
7441
|
-
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
|
|
7442
|
-
// which might have similar keys. Each vnode will always have a key that
|
|
7443
|
-
// starts with a numeric character from compiler. In this case, we add a unique
|
|
7444
|
-
// notation for slotted vnodes keys, e.g.: `@foo:1:1`
|
|
7445
|
-
|
|
7446
|
-
if (!isUndefined$1(vnode.key)) {
|
|
7447
|
-
vnode.key = `@${slotName}:${vnode.key}`;
|
|
7448
|
-
}
|
|
7449
|
-
|
|
7450
|
-
ArrayPush$1.call(vnodes, vnode);
|
|
7451
|
-
}
|
|
7452
|
-
|
|
7453
|
-
if (isFalse(vm.isDirty)) {
|
|
7454
|
-
// We need to determine if the old allocation is really different from the new one
|
|
7455
|
-
// and mark the vm as dirty
|
|
7456
|
-
const oldKeys = keys(oldSlots);
|
|
7457
|
-
|
|
7458
|
-
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
7459
|
-
markComponentAsDirty(vm);
|
|
7460
|
-
return;
|
|
7461
|
-
}
|
|
7462
|
-
|
|
7463
|
-
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
7464
|
-
const key = oldKeys[i];
|
|
7465
|
-
|
|
7466
|
-
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
7467
|
-
markComponentAsDirty(vm);
|
|
7468
|
-
return;
|
|
7469
|
-
}
|
|
7470
|
-
|
|
7471
|
-
const oldVNodes = oldSlots[key];
|
|
7472
|
-
const vnodes = cmpSlots[key];
|
|
7473
|
-
|
|
7474
|
-
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
7475
|
-
if (oldVNodes[j] !== vnodes[j]) {
|
|
7476
|
-
markComponentAsDirty(vm);
|
|
7477
|
-
return;
|
|
7478
|
-
}
|
|
7479
|
-
}
|
|
7480
|
-
}
|
|
7481
|
-
}
|
|
7482
7348
|
}
|
|
7483
7349
|
|
|
7484
7350
|
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
@@ -7929,7 +7795,7 @@ function setHooks(hooks) {
|
|
|
7929
7795
|
hooksAreSet = true;
|
|
7930
7796
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7931
7797
|
}
|
|
7932
|
-
/* version: 2.7.
|
|
7798
|
+
/* version: 2.7.3 */
|
|
7933
7799
|
|
|
7934
7800
|
/*
|
|
7935
7801
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8631,6 +8497,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
8631
8497
|
});
|
|
8632
8498
|
freeze(LightningElement);
|
|
8633
8499
|
seal(LightningElement.prototype);
|
|
8634
|
-
/* version: 2.7.
|
|
8500
|
+
/* version: 2.7.3 */
|
|
8635
8501
|
|
|
8636
8502
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|