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