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
@@ -348,7 +348,7 @@ var LWC = (function (exports) {
348
348
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
349
349
  return attributeName;
350
350
  }
351
- /** version: 2.7.2 */
351
+ /** version: 2.7.3 */
352
352
 
353
353
  /*
354
354
  * Copyright (c) 2018, salesforce.com, inc.
@@ -526,7 +526,7 @@ var LWC = (function (exports) {
526
526
  setFeatureFlag(name, value);
527
527
  }
528
528
  }
529
- /** version: 2.7.2 */
529
+ /** version: 2.7.3 */
530
530
 
531
531
  /* proxy-compat-disable */
532
532
 
@@ -1081,52 +1081,205 @@ var LWC = (function (exports) {
1081
1081
  */
1082
1082
 
1083
1083
 
1084
- function handleEvent(event, vnode) {
1085
- var type = event.type;
1086
- var on = vnode.data.on;
1087
- var handler = on && on[type]; // call event handler if exists
1084
+ function isUndef(s) {
1085
+ return s === undefined;
1086
+ }
1087
+
1088
+ function sameVnode(vnode1, vnode2) {
1089
+ return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
1090
+ }
1091
+
1092
+ function isVNode(vnode) {
1093
+ return vnode != null;
1094
+ }
1095
+
1096
+ function createKeyToOldIdx(children, beginIdx, endIdx) {
1097
+ var map = {};
1098
+ var j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
1099
+
1100
+ for (j = beginIdx; j <= endIdx; ++j) {
1101
+ ch = children[j];
1102
+
1103
+ if (isVNode(ch)) {
1104
+ key = ch.key;
1088
1105
 
1089
- if (handler) {
1090
- handler.call(undefined, event);
1106
+ if (key !== undefined) {
1107
+ map[key] = j;
1108
+ }
1109
+ }
1091
1110
  }
1111
+
1112
+ return map;
1092
1113
  }
1093
1114
 
1094
- function createListener() {
1095
- return function handler(event) {
1096
- handleEvent(event, handler.vnode);
1097
- };
1115
+ function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
1116
+ for (; startIdx <= endIdx; ++startIdx) {
1117
+ var ch = vnodes[startIdx];
1118
+
1119
+ if (isVNode(ch)) {
1120
+ ch.hook.create(ch);
1121
+ ch.hook.insert(ch, parentElm, before);
1122
+ }
1123
+ }
1098
1124
  }
1099
1125
 
1100
- function updateAllEventListeners(oldVnode, vnode) {
1101
- if (isUndefined$1(oldVnode.listener)) {
1102
- createAllEventListeners(vnode);
1103
- } else {
1104
- vnode.listener = oldVnode.listener;
1105
- vnode.listener.vnode = vnode;
1126
+ function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
1127
+ for (; startIdx <= endIdx; ++startIdx) {
1128
+ var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
1129
+
1130
+ if (isVNode(ch)) {
1131
+ ch.hook.remove(ch, parentElm);
1132
+ }
1106
1133
  }
1107
1134
  }
1108
1135
 
1109
- function createAllEventListeners(vnode) {
1110
- var elm = vnode.elm,
1111
- on = vnode.data.on;
1136
+ function updateDynamicChildren(parentElm, oldCh, newCh) {
1137
+ var oldStartIdx = 0;
1138
+ var newStartIdx = 0;
1139
+ var oldEndIdx = oldCh.length - 1;
1140
+ var oldStartVnode = oldCh[0];
1141
+ var oldEndVnode = oldCh[oldEndIdx];
1142
+ var newChEnd = newCh.length - 1;
1143
+ var newEndIdx = newChEnd;
1144
+ var newStartVnode = newCh[0];
1145
+ var newEndVnode = newCh[newEndIdx];
1146
+ var oldKeyToIdx;
1147
+ var idxInOld;
1148
+ var elmToMove;
1149
+ var before;
1112
1150
 
1113
- if (isUndefined$1(on)) {
1151
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1152
+ if (!isVNode(oldStartVnode)) {
1153
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
1154
+ } else if (!isVNode(oldEndVnode)) {
1155
+ oldEndVnode = oldCh[--oldEndIdx];
1156
+ } else if (!isVNode(newStartVnode)) {
1157
+ newStartVnode = newCh[++newStartIdx];
1158
+ } else if (!isVNode(newEndVnode)) {
1159
+ newEndVnode = newCh[--newEndIdx];
1160
+ } else if (sameVnode(oldStartVnode, newStartVnode)) {
1161
+ patchVnode(oldStartVnode, newStartVnode);
1162
+ oldStartVnode = oldCh[++oldStartIdx];
1163
+ newStartVnode = newCh[++newStartIdx];
1164
+ } else if (sameVnode(oldEndVnode, newEndVnode)) {
1165
+ patchVnode(oldEndVnode, newEndVnode);
1166
+ oldEndVnode = oldCh[--oldEndIdx];
1167
+ newEndVnode = newCh[--newEndIdx];
1168
+ } else if (sameVnode(oldStartVnode, newEndVnode)) {
1169
+ // Vnode moved right
1170
+ patchVnode(oldStartVnode, newEndVnode);
1171
+ newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
1172
+ oldStartVnode = oldCh[++oldStartIdx];
1173
+ newEndVnode = newCh[--newEndIdx];
1174
+ } else if (sameVnode(oldEndVnode, newStartVnode)) {
1175
+ // Vnode moved left
1176
+ patchVnode(oldEndVnode, newStartVnode);
1177
+ newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
1178
+ oldEndVnode = oldCh[--oldEndIdx];
1179
+ newStartVnode = newCh[++newStartIdx];
1180
+ } else {
1181
+ if (oldKeyToIdx === undefined) {
1182
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
1183
+ }
1184
+
1185
+ idxInOld = oldKeyToIdx[newStartVnode.key];
1186
+
1187
+ if (isUndef(idxInOld)) {
1188
+ // New element
1189
+ newStartVnode.hook.create(newStartVnode);
1190
+ newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1191
+ newStartVnode = newCh[++newStartIdx];
1192
+ } else {
1193
+ elmToMove = oldCh[idxInOld];
1194
+
1195
+ if (isVNode(elmToMove)) {
1196
+ if (elmToMove.sel !== newStartVnode.sel) {
1197
+ // New element
1198
+ newStartVnode.hook.create(newStartVnode);
1199
+ newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1200
+ } else {
1201
+ patchVnode(elmToMove, newStartVnode);
1202
+ oldCh[idxInOld] = undefined;
1203
+ newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
1204
+ }
1205
+ }
1206
+
1207
+ newStartVnode = newCh[++newStartIdx];
1208
+ }
1209
+ }
1210
+ }
1211
+
1212
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
1213
+ if (oldStartIdx > oldEndIdx) {
1214
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
1215
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
1216
+ var _i6 = newEndIdx;
1217
+ var n;
1218
+
1219
+ do {
1220
+ n = newCh[++_i6];
1221
+ } while (!isVNode(n) && _i6 < newChEnd);
1222
+
1223
+ before = isVNode(n) ? n.elm : null;
1224
+ addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
1225
+ } else {
1226
+ removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
1227
+ }
1228
+ }
1229
+ }
1230
+
1231
+ function updateStaticChildren(parentElm, oldCh, newCh) {
1232
+ var oldChLength = oldCh.length;
1233
+ var newChLength = newCh.length;
1234
+
1235
+ if (oldChLength === 0) {
1236
+ // the old list is empty, we can directly insert anything new
1237
+ addVnodes(parentElm, null, newCh, 0, newChLength);
1114
1238
  return;
1115
1239
  }
1116
1240
 
1117
- var listener = vnode.listener = createListener();
1118
- listener.vnode = vnode;
1119
- var name;
1241
+ if (newChLength === 0) {
1242
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
1243
+ // this is the case in which the dynamic children of an if-directive should be removed
1244
+ removeVnodes(parentElm, oldCh, 0, oldChLength);
1245
+ return;
1246
+ } // if the old list is not empty, the new list MUST have the same
1247
+ // amount of nodes, that's why we call this static children
1248
+
1249
+
1250
+ var referenceElm = null;
1251
+
1252
+ for (var _i7 = newChLength - 1; _i7 >= 0; _i7 -= 1) {
1253
+ var vnode = newCh[_i7];
1254
+ var oldVNode = oldCh[_i7];
1255
+
1256
+ if (vnode !== oldVNode) {
1257
+ if (isVNode(oldVNode)) {
1258
+ if (isVNode(vnode)) {
1259
+ // both vnodes must be equivalent, and se just need to patch them
1260
+ patchVnode(oldVNode, vnode);
1261
+ referenceElm = vnode.elm;
1262
+ } else {
1263
+ // removing the old vnode since the new one is null
1264
+ oldVNode.hook.remove(oldVNode, parentElm);
1265
+ }
1266
+ } else if (isVNode(vnode)) {
1267
+ // this condition is unnecessary
1268
+ vnode.hook.create(vnode); // insert the new node one since the old one is null
1120
1269
 
1121
- for (name in on) {
1122
- addEventListener$1(elm, name, listener);
1270
+ vnode.hook.insert(vnode, parentElm, referenceElm);
1271
+ referenceElm = vnode.elm;
1272
+ }
1273
+ }
1123
1274
  }
1124
1275
  }
1125
1276
 
1126
- var modEvents = {
1127
- update: updateAllEventListeners,
1128
- create: createAllEventListeners
1129
- };
1277
+ function patchVnode(oldVnode, vnode) {
1278
+ if (oldVnode !== vnode) {
1279
+ vnode.elm = oldVnode.elm;
1280
+ vnode.hook.update(oldVnode, vnode);
1281
+ }
1282
+ }
1130
1283
  /*
1131
1284
  * Copyright (c) 2018, salesforce.com, inc.
1132
1285
  * All rights reserved.
@@ -1134,6 +1287,7 @@ var LWC = (function (exports) {
1134
1287
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1135
1288
  */
1136
1289
 
1290
+
1137
1291
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1138
1292
 
1139
1293
  function offsetPropertyErrorMessage(name) {
@@ -1253,565 +1407,62 @@ var LWC = (function (exports) {
1253
1407
  */
1254
1408
 
1255
1409
 
1256
- var xlinkNS = 'http://www.w3.org/1999/xlink';
1257
- var xmlNS = 'http://www.w3.org/XML/1998/namespace';
1258
- var ColonCharCode = 58;
1259
-
1260
- function updateAttrs(oldVnode, vnode) {
1261
- var attrs = vnode.data.attrs;
1410
+ function generateDataDescriptor(options) {
1411
+ return assign({
1412
+ configurable: true,
1413
+ enumerable: true,
1414
+ writable: true
1415
+ }, options);
1416
+ }
1262
1417
 
1263
- if (isUndefined$1(attrs)) {
1264
- return;
1265
- }
1418
+ function generateAccessorDescriptor(options) {
1419
+ return assign({
1420
+ configurable: true,
1421
+ enumerable: true
1422
+ }, options);
1423
+ }
1266
1424
 
1267
- var oldAttrs = oldVnode.data.attrs;
1425
+ var isDomMutationAllowed = false;
1268
1426
 
1269
- if (oldAttrs === attrs) {
1270
- return;
1427
+ function unlockDomMutation() {
1428
+ if (process.env.NODE_ENV === 'production') {
1429
+ // this method should never leak to prod
1430
+ throw new ReferenceError();
1271
1431
  }
1272
1432
 
1273
- if (process.env.NODE_ENV !== 'production') {
1274
- assert.invariant(isUndefined$1(oldAttrs) || keys(oldAttrs).join(',') === keys(attrs).join(','), "vnode.data.attrs cannot change shape.");
1433
+ isDomMutationAllowed = true;
1434
+ }
1435
+
1436
+ function lockDomMutation() {
1437
+ if (process.env.NODE_ENV === 'production') {
1438
+ // this method should never leak to prod
1439
+ throw new ReferenceError();
1275
1440
  }
1276
1441
 
1277
- var elm = vnode.elm;
1278
- var key;
1279
- oldAttrs = isUndefined$1(oldAttrs) ? EmptyObject : oldAttrs; // update modified attributes, add new attributes
1280
- // this routine is only useful for data-* attributes in all kind of elements
1281
- // and aria-* in standard elements (custom elements will use props for these)
1442
+ isDomMutationAllowed = false;
1443
+ }
1282
1444
 
1283
- for (key in attrs) {
1284
- var cur = attrs[key];
1285
- var old = oldAttrs[key];
1445
+ function logMissingPortalError(name, type) {
1446
+ return logError("The `".concat(name, "` ").concat(type, " is available only on elements that use the `lwc:dom=\"manual\"` directive."));
1447
+ }
1286
1448
 
1287
- if (old !== cur) {
1288
- unlockAttribute(elm, key);
1449
+ function patchElementWithRestrictions(elm, options) {
1450
+ if (process.env.NODE_ENV === 'production') {
1451
+ // this method should never leak to prod
1452
+ throw new ReferenceError();
1453
+ }
1289
1454
 
1290
- if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
1291
- // Assume xml namespace
1292
- setAttribute$1(elm, key, cur, xmlNS);
1293
- } else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
1294
- // Assume xlink namespace
1295
- setAttribute$1(elm, key, cur, xlinkNS);
1296
- } else if (isNull(cur) || isUndefined$1(cur)) {
1297
- removeAttribute$1(elm, key);
1298
- } else {
1299
- setAttribute$1(elm, key, cur);
1455
+ var originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
1456
+ var descriptors = {
1457
+ outerHTML: generateAccessorDescriptor({
1458
+ get: function get() {
1459
+ return originalOuterHTMLDescriptor.get.call(this);
1460
+ },
1461
+ set: function set(_value) {
1462
+ throw new TypeError("Invalid attempt to set outerHTML on Element.");
1300
1463
  }
1301
-
1302
- lockAttribute();
1303
- }
1304
- }
1305
- }
1306
-
1307
- var emptyVNode$3 = {
1308
- data: {}
1309
- };
1310
- var modAttrs = {
1311
- create: function create(vnode) {
1312
- return updateAttrs(emptyVNode$3, vnode);
1313
- },
1314
- update: updateAttrs
1315
- };
1316
- /*
1317
- * Copyright (c) 2018, salesforce.com, inc.
1318
- * All rights reserved.
1319
- * SPDX-License-Identifier: MIT
1320
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1321
- */
1322
-
1323
- function isLiveBindingProp(sel, key) {
1324
- // For properties with live bindings, we read values from the DOM element
1325
- // instead of relying on internally tracked values.
1326
- return sel === 'input' && (key === 'value' || key === 'checked');
1327
- }
1328
-
1329
- function update(oldVnode, vnode) {
1330
- var props = vnode.data.props;
1331
-
1332
- if (isUndefined$1(props)) {
1333
- return;
1334
- }
1335
-
1336
- var oldProps = oldVnode.data.props;
1337
-
1338
- if (oldProps === props) {
1339
- return;
1340
- }
1341
-
1342
- if (process.env.NODE_ENV !== 'production') {
1343
- assert.invariant(isUndefined$1(oldProps) || keys(oldProps).join(',') === keys(props).join(','), 'vnode.data.props cannot change shape.');
1344
- }
1345
-
1346
- var isFirstPatch = isUndefined$1(oldProps);
1347
- var elm = vnode.elm,
1348
- sel = vnode.sel;
1349
-
1350
- for (var key in props) {
1351
- var cur = props[key]; // if it is the first time this element is patched, or the current value is different to the previous value...
1352
-
1353
- if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
1354
- setProperty$1(elm, key, cur);
1355
- }
1356
- }
1357
- }
1358
-
1359
- var emptyVNode$2 = {
1360
- data: {}
1361
- };
1362
- var modProps = {
1363
- create: function create(vnode) {
1364
- return update(emptyVNode$2, vnode);
1365
- },
1366
- update: update
1367
- };
1368
- /*
1369
- * Copyright (c) 2018, salesforce.com, inc.
1370
- * All rights reserved.
1371
- * SPDX-License-Identifier: MIT
1372
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1373
- */
1374
-
1375
- var classNameToClassMap = create(null);
1376
-
1377
- function getMapFromClassName(className) {
1378
- // Intentionally using == to match undefined and null values from computed style attribute
1379
- if (className == null) {
1380
- return EmptyObject;
1381
- } // computed class names must be string
1382
-
1383
-
1384
- className = isString(className) ? className : className + '';
1385
- var map = classNameToClassMap[className];
1386
-
1387
- if (map) {
1388
- return map;
1389
- }
1390
-
1391
- map = create(null);
1392
- var start = 0;
1393
- var o;
1394
- var len = className.length;
1395
-
1396
- for (o = 0; o < len; o++) {
1397
- if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
1398
- if (o > start) {
1399
- map[StringSlice.call(className, start, o)] = true;
1400
- }
1401
-
1402
- start = o + 1;
1403
- }
1404
- }
1405
-
1406
- if (o > start) {
1407
- map[StringSlice.call(className, start, o)] = true;
1408
- }
1409
-
1410
- classNameToClassMap[className] = map;
1411
-
1412
- if (process.env.NODE_ENV !== 'production') {
1413
- // just to make sure that this object never changes as part of the diffing algo
1414
- freeze(map);
1415
- }
1416
-
1417
- return map;
1418
- }
1419
-
1420
- function updateClassAttribute(oldVnode, vnode) {
1421
- var elm = vnode.elm,
1422
- newClass = vnode.data.className;
1423
- var oldClass = oldVnode.data.className;
1424
-
1425
- if (oldClass === newClass) {
1426
- return;
1427
- }
1428
-
1429
- var classList = getClassList$1(elm);
1430
- var newClassMap = getMapFromClassName(newClass);
1431
- var oldClassMap = getMapFromClassName(oldClass);
1432
- var name;
1433
-
1434
- for (name in oldClassMap) {
1435
- // remove only if it is not in the new class collection and it is not set from within the instance
1436
- if (isUndefined$1(newClassMap[name])) {
1437
- classList.remove(name);
1438
- }
1439
- }
1440
-
1441
- for (name in newClassMap) {
1442
- if (isUndefined$1(oldClassMap[name])) {
1443
- classList.add(name);
1444
- }
1445
- }
1446
- }
1447
-
1448
- var emptyVNode$1 = {
1449
- data: {}
1450
- };
1451
- var modComputedClassName = {
1452
- create: function create(vnode) {
1453
- return updateClassAttribute(emptyVNode$1, vnode);
1454
- },
1455
- update: updateClassAttribute
1456
- };
1457
- /*
1458
- * Copyright (c) 2018, salesforce.com, inc.
1459
- * All rights reserved.
1460
- * SPDX-License-Identifier: MIT
1461
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1462
- */
1463
-
1464
- function updateStyleAttribute(oldVnode, vnode) {
1465
- var elm = vnode.elm,
1466
- newStyle = vnode.data.style;
1467
-
1468
- if (oldVnode.data.style === newStyle) {
1469
- return;
1470
- }
1471
-
1472
- if (!isString(newStyle) || newStyle === '') {
1473
- removeAttribute$1(elm, 'style');
1474
- } else {
1475
- setAttribute$1(elm, 'style', newStyle);
1476
- }
1477
- }
1478
-
1479
- var emptyVNode = {
1480
- data: {}
1481
- };
1482
- var modComputedStyle = {
1483
- create: function create(vnode) {
1484
- return updateStyleAttribute(emptyVNode, vnode);
1485
- },
1486
- update: updateStyleAttribute
1487
- };
1488
- /*
1489
- * Copyright (c) 2018, salesforce.com, inc.
1490
- * All rights reserved.
1491
- * SPDX-License-Identifier: MIT
1492
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1493
- */
1494
- // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
1495
- // different classnames properties individually instead of via a string.
1496
-
1497
- function createClassAttribute(vnode) {
1498
- var elm = vnode.elm,
1499
- classMap = vnode.data.classMap;
1500
-
1501
- if (isUndefined$1(classMap)) {
1502
- return;
1503
- }
1504
-
1505
- var classList = getClassList$1(elm);
1506
-
1507
- for (var name in classMap) {
1508
- classList.add(name);
1509
- }
1510
- }
1511
-
1512
- var modStaticClassName = {
1513
- create: createClassAttribute
1514
- };
1515
- /*
1516
- * Copyright (c) 2018, salesforce.com, inc.
1517
- * All rights reserved.
1518
- * SPDX-License-Identifier: MIT
1519
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1520
- */
1521
- // The compiler takes care of transforming the inline style into an object. It's faster to set the
1522
- // different style properties individually instead of via a string.
1523
-
1524
- function createStyleAttribute(vnode) {
1525
- var elm = vnode.elm,
1526
- styleDecls = vnode.data.styleDecls;
1527
-
1528
- if (isUndefined$1(styleDecls)) {
1529
- return;
1530
- }
1531
-
1532
- for (var _i6 = 0; _i6 < styleDecls.length; _i6++) {
1533
- var _styleDecls$_i = _slicedToArray(styleDecls[_i6], 3),
1534
- prop = _styleDecls$_i[0],
1535
- value = _styleDecls$_i[1],
1536
- important = _styleDecls$_i[2];
1537
-
1538
- setCSSStyleProperty$1(elm, prop, value, important);
1539
- }
1540
- }
1541
-
1542
- var modStaticStyle = {
1543
- create: createStyleAttribute
1544
- };
1545
- /*
1546
- * Copyright (c) 2018, salesforce.com, inc.
1547
- * All rights reserved.
1548
- * SPDX-License-Identifier: MIT
1549
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1550
- */
1551
-
1552
- function isUndef(s) {
1553
- return s === undefined;
1554
- }
1555
-
1556
- function sameVnode(vnode1, vnode2) {
1557
- return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
1558
- }
1559
-
1560
- function isVNode(vnode) {
1561
- return vnode != null;
1562
- }
1563
-
1564
- function createKeyToOldIdx(children, beginIdx, endIdx) {
1565
- var map = {};
1566
- var j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
1567
-
1568
- for (j = beginIdx; j <= endIdx; ++j) {
1569
- ch = children[j];
1570
-
1571
- if (isVNode(ch)) {
1572
- key = ch.key;
1573
-
1574
- if (key !== undefined) {
1575
- map[key] = j;
1576
- }
1577
- }
1578
- }
1579
-
1580
- return map;
1581
- }
1582
-
1583
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
1584
- for (; startIdx <= endIdx; ++startIdx) {
1585
- var ch = vnodes[startIdx];
1586
-
1587
- if (isVNode(ch)) {
1588
- ch.hook.create(ch);
1589
- ch.hook.insert(ch, parentElm, before);
1590
- }
1591
- }
1592
- }
1593
-
1594
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
1595
- for (; startIdx <= endIdx; ++startIdx) {
1596
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
1597
-
1598
- if (isVNode(ch)) {
1599
- ch.hook.remove(ch, parentElm);
1600
- }
1601
- }
1602
- }
1603
-
1604
- function updateDynamicChildren(parentElm, oldCh, newCh) {
1605
- var oldStartIdx = 0;
1606
- var newStartIdx = 0;
1607
- var oldEndIdx = oldCh.length - 1;
1608
- var oldStartVnode = oldCh[0];
1609
- var oldEndVnode = oldCh[oldEndIdx];
1610
- var newChEnd = newCh.length - 1;
1611
- var newEndIdx = newChEnd;
1612
- var newStartVnode = newCh[0];
1613
- var newEndVnode = newCh[newEndIdx];
1614
- var oldKeyToIdx;
1615
- var idxInOld;
1616
- var elmToMove;
1617
- var before;
1618
-
1619
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1620
- if (!isVNode(oldStartVnode)) {
1621
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
1622
- } else if (!isVNode(oldEndVnode)) {
1623
- oldEndVnode = oldCh[--oldEndIdx];
1624
- } else if (!isVNode(newStartVnode)) {
1625
- newStartVnode = newCh[++newStartIdx];
1626
- } else if (!isVNode(newEndVnode)) {
1627
- newEndVnode = newCh[--newEndIdx];
1628
- } else if (sameVnode(oldStartVnode, newStartVnode)) {
1629
- patchVnode(oldStartVnode, newStartVnode);
1630
- oldStartVnode = oldCh[++oldStartIdx];
1631
- newStartVnode = newCh[++newStartIdx];
1632
- } else if (sameVnode(oldEndVnode, newEndVnode)) {
1633
- patchVnode(oldEndVnode, newEndVnode);
1634
- oldEndVnode = oldCh[--oldEndIdx];
1635
- newEndVnode = newCh[--newEndIdx];
1636
- } else if (sameVnode(oldStartVnode, newEndVnode)) {
1637
- // Vnode moved right
1638
- patchVnode(oldStartVnode, newEndVnode);
1639
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
1640
- oldStartVnode = oldCh[++oldStartIdx];
1641
- newEndVnode = newCh[--newEndIdx];
1642
- } else if (sameVnode(oldEndVnode, newStartVnode)) {
1643
- // Vnode moved left
1644
- patchVnode(oldEndVnode, newStartVnode);
1645
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
1646
- oldEndVnode = oldCh[--oldEndIdx];
1647
- newStartVnode = newCh[++newStartIdx];
1648
- } else {
1649
- if (oldKeyToIdx === undefined) {
1650
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
1651
- }
1652
-
1653
- idxInOld = oldKeyToIdx[newStartVnode.key];
1654
-
1655
- if (isUndef(idxInOld)) {
1656
- // New element
1657
- newStartVnode.hook.create(newStartVnode);
1658
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1659
- newStartVnode = newCh[++newStartIdx];
1660
- } else {
1661
- elmToMove = oldCh[idxInOld];
1662
-
1663
- if (isVNode(elmToMove)) {
1664
- if (elmToMove.sel !== newStartVnode.sel) {
1665
- // New element
1666
- newStartVnode.hook.create(newStartVnode);
1667
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1668
- } else {
1669
- patchVnode(elmToMove, newStartVnode);
1670
- oldCh[idxInOld] = undefined;
1671
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
1672
- }
1673
- }
1674
-
1675
- newStartVnode = newCh[++newStartIdx];
1676
- }
1677
- }
1678
- }
1679
-
1680
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
1681
- if (oldStartIdx > oldEndIdx) {
1682
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
1683
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
1684
- var _i7 = newEndIdx;
1685
- var n;
1686
-
1687
- do {
1688
- n = newCh[++_i7];
1689
- } while (!isVNode(n) && _i7 < newChEnd);
1690
-
1691
- before = isVNode(n) ? n.elm : null;
1692
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
1693
- } else {
1694
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
1695
- }
1696
- }
1697
- }
1698
-
1699
- function updateStaticChildren(parentElm, oldCh, newCh) {
1700
- var oldChLength = oldCh.length;
1701
- var newChLength = newCh.length;
1702
-
1703
- if (oldChLength === 0) {
1704
- // the old list is empty, we can directly insert anything new
1705
- addVnodes(parentElm, null, newCh, 0, newChLength);
1706
- return;
1707
- }
1708
-
1709
- if (newChLength === 0) {
1710
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
1711
- // this is the case in which the dynamic children of an if-directive should be removed
1712
- removeVnodes(parentElm, oldCh, 0, oldChLength);
1713
- return;
1714
- } // if the old list is not empty, the new list MUST have the same
1715
- // amount of nodes, that's why we call this static children
1716
-
1717
-
1718
- var referenceElm = null;
1719
-
1720
- for (var _i8 = newChLength - 1; _i8 >= 0; _i8 -= 1) {
1721
- var vnode = newCh[_i8];
1722
- var oldVNode = oldCh[_i8];
1723
-
1724
- if (vnode !== oldVNode) {
1725
- if (isVNode(oldVNode)) {
1726
- if (isVNode(vnode)) {
1727
- // both vnodes must be equivalent, and se just need to patch them
1728
- patchVnode(oldVNode, vnode);
1729
- referenceElm = vnode.elm;
1730
- } else {
1731
- // removing the old vnode since the new one is null
1732
- oldVNode.hook.remove(oldVNode, parentElm);
1733
- }
1734
- } else if (isVNode(vnode)) {
1735
- // this condition is unnecessary
1736
- vnode.hook.create(vnode); // insert the new node one since the old one is null
1737
-
1738
- vnode.hook.insert(vnode, parentElm, referenceElm);
1739
- referenceElm = vnode.elm;
1740
- }
1741
- }
1742
- }
1743
- }
1744
-
1745
- function patchVnode(oldVnode, vnode) {
1746
- if (oldVnode !== vnode) {
1747
- vnode.elm = oldVnode.elm;
1748
- vnode.hook.update(oldVnode, vnode);
1749
- }
1750
- }
1751
- /*
1752
- * Copyright (c) 2018, salesforce.com, inc.
1753
- * All rights reserved.
1754
- * SPDX-License-Identifier: MIT
1755
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1756
- */
1757
-
1758
-
1759
- function generateDataDescriptor(options) {
1760
- return assign({
1761
- configurable: true,
1762
- enumerable: true,
1763
- writable: true
1764
- }, options);
1765
- }
1766
-
1767
- function generateAccessorDescriptor(options) {
1768
- return assign({
1769
- configurable: true,
1770
- enumerable: true
1771
- }, options);
1772
- }
1773
-
1774
- var isDomMutationAllowed = false;
1775
-
1776
- function unlockDomMutation() {
1777
- if (process.env.NODE_ENV === 'production') {
1778
- // this method should never leak to prod
1779
- throw new ReferenceError();
1780
- }
1781
-
1782
- isDomMutationAllowed = true;
1783
- }
1784
-
1785
- function lockDomMutation() {
1786
- if (process.env.NODE_ENV === 'production') {
1787
- // this method should never leak to prod
1788
- throw new ReferenceError();
1789
- }
1790
-
1791
- isDomMutationAllowed = false;
1792
- }
1793
-
1794
- function logMissingPortalError(name, type) {
1795
- return logError("The `".concat(name, "` ").concat(type, " is available only on elements that use the `lwc:dom=\"manual\"` directive."));
1796
- }
1797
-
1798
- function patchElementWithRestrictions(elm, options) {
1799
- if (process.env.NODE_ENV === 'production') {
1800
- // this method should never leak to prod
1801
- throw new ReferenceError();
1802
- }
1803
-
1804
- var originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
1805
- var descriptors = {
1806
- outerHTML: generateAccessorDescriptor({
1807
- get: function get() {
1808
- return originalOuterHTMLDescriptor.get.call(this);
1809
- },
1810
- set: function set(_value) {
1811
- throw new TypeError("Invalid attempt to set outerHTML on Element.");
1812
- }
1813
- })
1814
- }; // Apply extra restriction related to DOM manipulation if the element is not a portal.
1464
+ })
1465
+ }; // Apply extra restriction related to DOM manipulation if the element is not a portal.
1815
1466
 
1816
1467
  if (!options.isLight && !options.isPortal) {
1817
1468
  var _appendChild = elm.appendChild,
@@ -3273,132 +2924,369 @@ var LWC = (function (exports) {
3273
2924
  case 'lastElementChild':
3274
2925
  return getLastElementChild$1;
3275
2926
  }
3276
- } // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
2927
+ } // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
2928
+
2929
+
2930
+ var _loop = function _loop() {
2931
+ var childGetter = _childGetters[_i8];
2932
+ queryAndChildGetterDescriptors[childGetter] = {
2933
+ get: function get() {
2934
+ var vm = getAssociatedVM(this);
2935
+ var elm = vm.elm;
2936
+
2937
+ if (process.env.NODE_ENV !== 'production') {
2938
+ warnIfInvokedDuringConstruction(vm, childGetter);
2939
+ }
2940
+
2941
+ return getChildGetter(childGetter)(elm);
2942
+ },
2943
+ configurable: true,
2944
+ enumerable: true
2945
+ };
2946
+ };
2947
+
2948
+ for (var _i8 = 0, _childGetters = childGetters; _i8 < _childGetters.length; _i8++) {
2949
+ _loop();
2950
+ }
2951
+
2952
+ var queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
2953
+
2954
+ function getQueryMethod(methodName) {
2955
+ switch (methodName) {
2956
+ case 'getElementsByClassName':
2957
+ return getElementsByClassName$1;
2958
+
2959
+ case 'getElementsByTagName':
2960
+ return getElementsByTagName$1;
2961
+
2962
+ case 'querySelector':
2963
+ return querySelector$1;
2964
+
2965
+ case 'querySelectorAll':
2966
+ return querySelectorAll$1;
2967
+ }
2968
+ } // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
2969
+
2970
+
2971
+ var _loop2 = function _loop2() {
2972
+ var queryMethod = _queryMethods[_i9];
2973
+ queryAndChildGetterDescriptors[queryMethod] = {
2974
+ value: function value(arg) {
2975
+ var vm = getAssociatedVM(this);
2976
+ var elm = vm.elm;
2977
+
2978
+ if (process.env.NODE_ENV !== 'production') {
2979
+ warnIfInvokedDuringConstruction(vm, "".concat(queryMethod, "()"));
2980
+ }
2981
+
2982
+ return getQueryMethod(queryMethod)(elm, arg);
2983
+ },
2984
+ configurable: true,
2985
+ enumerable: true,
2986
+ writable: true
2987
+ };
2988
+ };
2989
+
2990
+ for (var _i9 = 0, _queryMethods = queryMethods; _i9 < _queryMethods.length; _i9++) {
2991
+ _loop2();
2992
+ }
2993
+
2994
+ defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
2995
+ var lightningBasedDescriptors = create(null);
2996
+
2997
+ for (var _propName in HTMLElementOriginalDescriptors) {
2998
+ lightningBasedDescriptors[_propName] = createBridgeToElementDescriptor(_propName, HTMLElementOriginalDescriptors[_propName]);
2999
+ }
3000
+
3001
+ defineProperties(LightningElement.prototype, lightningBasedDescriptors);
3002
+ defineProperty(LightningElement, 'CustomElementConstructor', {
3003
+ get: function get() {
3004
+ // If required, a runtime-specific implementation must be defined.
3005
+ throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
3006
+ },
3007
+ configurable: true
3008
+ });
3009
+
3010
+ if (process.env.NODE_ENV !== 'production') {
3011
+ patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
3012
+ }
3013
+ /*
3014
+ * Copyright (c) 2018, salesforce.com, inc.
3015
+ * All rights reserved.
3016
+ * SPDX-License-Identifier: MIT
3017
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3018
+ */
3019
+
3020
+ /**
3021
+ * @wire decorator to wire fields and methods to a wire adapter in
3022
+ * LWC Components. This function implements the internals of this
3023
+ * decorator.
3024
+ */
3025
+
3026
+
3027
+ function wire(_adapter, _config) {
3028
+ if (process.env.NODE_ENV !== 'production') {
3029
+ assert.fail('@wire(adapter, config?) may only be used as a decorator.');
3030
+ }
3031
+
3032
+ throw new Error();
3033
+ }
3034
+
3035
+ function internalWireFieldDecorator(key) {
3036
+ return {
3037
+ get: function get() {
3038
+ var vm = getAssociatedVM(this);
3039
+ componentValueObserved(vm, key);
3040
+ return vm.cmpFields[key];
3041
+ },
3042
+ set: function set(value) {
3043
+ var vm = getAssociatedVM(this);
3044
+ /**
3045
+ * Reactivity for wired fields is provided in wiring.
3046
+ * We intentionally add reactivity here since this is just
3047
+ * letting the author to do the wrong thing, but it will keep our
3048
+ * system to be backward compatible.
3049
+ */
3050
+
3051
+ if (value !== vm.cmpFields[key]) {
3052
+ vm.cmpFields[key] = value;
3053
+ componentValueMutated(vm, key);
3054
+ }
3055
+ },
3056
+ enumerable: true,
3057
+ configurable: true
3058
+ };
3059
+ }
3060
+ /*
3061
+ * Copyright (c) 2018, salesforce.com, inc.
3062
+ * All rights reserved.
3063
+ * SPDX-License-Identifier: MIT
3064
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3065
+ */
3066
+
3067
+
3068
+ function track(target) {
3069
+ if (arguments.length === 1) {
3070
+ return reactiveMembrane.getProxy(target);
3071
+ }
3072
+
3073
+ if (process.env.NODE_ENV !== 'production') {
3074
+ assert.fail("@track decorator can only be used with one argument to return a trackable object, or as a decorator function.");
3075
+ }
3076
+
3077
+ throw new Error();
3078
+ }
3079
+
3080
+ function internalTrackDecorator(key) {
3081
+ return {
3082
+ get: function get() {
3083
+ var vm = getAssociatedVM(this);
3084
+ componentValueObserved(vm, key);
3085
+ return vm.cmpFields[key];
3086
+ },
3087
+ set: function set(newValue) {
3088
+ var vm = getAssociatedVM(this);
3089
+
3090
+ if (process.env.NODE_ENV !== 'production') {
3091
+ var _vmBeingRendered3 = getVMBeingRendered();
3092
+
3093
+ assert.invariant(!isInvokingRender, "".concat(_vmBeingRendered3, ".render() method has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3094
+ assert.invariant(!isUpdatingTemplate, "Updating the template of ".concat(_vmBeingRendered3, " has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3095
+ }
3096
+
3097
+ var reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
3098
+
3099
+ if (reactiveOrAnyValue !== vm.cmpFields[key]) {
3100
+ vm.cmpFields[key] = reactiveOrAnyValue;
3101
+ componentValueMutated(vm, key);
3102
+ }
3103
+ },
3104
+ enumerable: true,
3105
+ configurable: true
3106
+ };
3107
+ }
3108
+ /*
3109
+ * Copyright (c) 2018, salesforce.com, inc.
3110
+ * All rights reserved.
3111
+ * SPDX-License-Identifier: MIT
3112
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3113
+ */
3114
+
3115
+
3116
+ function api$1() {
3117
+ if (process.env.NODE_ENV !== 'production') {
3118
+ assert.fail("@api decorator can only be used as a decorator function.");
3119
+ }
3277
3120
 
3121
+ throw new Error();
3122
+ }
3278
3123
 
3279
- var _loop = function _loop() {
3280
- var childGetter = _childGetters[_i9];
3281
- queryAndChildGetterDescriptors[childGetter] = {
3124
+ function createPublicPropertyDescriptor(key) {
3125
+ return {
3282
3126
  get: function get() {
3283
3127
  var vm = getAssociatedVM(this);
3284
- var elm = vm.elm;
3128
+
3129
+ if (isBeingConstructed(vm)) {
3130
+ if (process.env.NODE_ENV !== 'production') {
3131
+ logError("Can\u2019t read the value of property `".concat(toString$1(key), "` from the constructor because the owner component hasn\u2019t set the value yet. Instead, use the constructor to set a default value for the property."), vm);
3132
+ }
3133
+
3134
+ return;
3135
+ }
3136
+
3137
+ componentValueObserved(vm, key);
3138
+ return vm.cmpProps[key];
3139
+ },
3140
+ set: function set(newValue) {
3141
+ var vm = getAssociatedVM(this);
3285
3142
 
3286
3143
  if (process.env.NODE_ENV !== 'production') {
3287
- warnIfInvokedDuringConstruction(vm, childGetter);
3144
+ var _vmBeingRendered4 = getVMBeingRendered();
3145
+
3146
+ assert.invariant(!isInvokingRender, "".concat(_vmBeingRendered4, ".render() method has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3147
+ assert.invariant(!isUpdatingTemplate, "Updating the template of ".concat(_vmBeingRendered4, " has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3288
3148
  }
3289
3149
 
3290
- return getChildGetter(childGetter)(elm);
3150
+ vm.cmpProps[key] = newValue;
3151
+ componentValueMutated(vm, key);
3291
3152
  },
3292
- configurable: true,
3293
- enumerable: true
3153
+ enumerable: true,
3154
+ configurable: true
3294
3155
  };
3295
- };
3296
-
3297
- for (var _i9 = 0, _childGetters = childGetters; _i9 < _childGetters.length; _i9++) {
3298
- _loop();
3299
3156
  }
3300
3157
 
3301
- var queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
3158
+ var AccessorReactiveObserver = /*#__PURE__*/function (_ReactiveObserver) {
3159
+ _inherits(AccessorReactiveObserver, _ReactiveObserver);
3302
3160
 
3303
- function getQueryMethod(methodName) {
3304
- switch (methodName) {
3305
- case 'getElementsByClassName':
3306
- return getElementsByClassName$1;
3161
+ var _super3 = _createSuper(AccessorReactiveObserver);
3307
3162
 
3308
- case 'getElementsByTagName':
3309
- return getElementsByTagName$1;
3163
+ function AccessorReactiveObserver(vm, set) {
3164
+ var _this2;
3310
3165
 
3311
- case 'querySelector':
3312
- return querySelector$1;
3166
+ _classCallCheck(this, AccessorReactiveObserver);
3313
3167
 
3314
- case 'querySelectorAll':
3315
- return querySelectorAll$1;
3168
+ _this2 = _super3.call(this, function () {
3169
+ if (isFalse(_this2.debouncing)) {
3170
+ _this2.debouncing = true;
3171
+ addCallbackToNextTick(function () {
3172
+ if (isTrue(_this2.debouncing)) {
3173
+ var _assertThisInitialize = _assertThisInitialized(_this2),
3174
+ value = _assertThisInitialize.value;
3175
+
3176
+ var dirtyStateBeforeSetterCall = vm.isDirty,
3177
+ component = vm.component,
3178
+ _idx = vm.idx;
3179
+ set.call(component, value); // de-bouncing after the call to the original setter to prevent
3180
+ // infinity loop if the setter itself is mutating things that
3181
+ // were accessed during the previous invocation.
3182
+
3183
+ _this2.debouncing = false;
3184
+
3185
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && _idx > 0) {
3186
+ // immediate rehydration due to a setter driven mutation, otherwise
3187
+ // the component will get rendered on the second tick, which it is not
3188
+ // desirable.
3189
+ rerenderVM(vm);
3190
+ }
3191
+ }
3192
+ });
3193
+ }
3194
+ });
3195
+ _this2.debouncing = false;
3196
+ return _this2;
3316
3197
  }
3317
- } // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
3318
3198
 
3199
+ _createClass(AccessorReactiveObserver, [{
3200
+ key: "reset",
3201
+ value: function reset(value) {
3202
+ _get2(_getPrototypeOf2(AccessorReactiveObserver.prototype), "reset", this).call(this);
3319
3203
 
3320
- var _loop2 = function _loop2() {
3321
- var queryMethod = _queryMethods[_i10];
3322
- queryAndChildGetterDescriptors[queryMethod] = {
3323
- value: function value(arg) {
3324
- var vm = getAssociatedVM(this);
3325
- var elm = vm.elm;
3204
+ this.debouncing = false;
3326
3205
 
3327
- if (process.env.NODE_ENV !== 'production') {
3328
- warnIfInvokedDuringConstruction(vm, "".concat(queryMethod, "()"));
3206
+ if (arguments.length > 0) {
3207
+ this.value = value;
3329
3208
  }
3209
+ }
3210
+ }]);
3330
3211
 
3331
- return getQueryMethod(queryMethod)(elm, arg);
3332
- },
3333
- configurable: true,
3334
- enumerable: true,
3335
- writable: true
3336
- };
3337
- };
3212
+ return AccessorReactiveObserver;
3213
+ }(ReactiveObserver);
3338
3214
 
3339
- for (var _i10 = 0, _queryMethods = queryMethods; _i10 < _queryMethods.length; _i10++) {
3340
- _loop2();
3341
- }
3215
+ function createPublicAccessorDescriptor(key, descriptor) {
3216
+ var _get3 = descriptor.get,
3217
+ _set2 = descriptor.set,
3218
+ enumerable = descriptor.enumerable,
3219
+ configurable = descriptor.configurable;
3342
3220
 
3343
- defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
3344
- var lightningBasedDescriptors = create(null);
3221
+ if (!isFunction$1(_get3)) {
3222
+ if (process.env.NODE_ENV !== 'production') {
3223
+ assert.invariant(isFunction$1(_get3), "Invalid compiler output for public accessor ".concat(toString$1(key), " decorated with @api"));
3224
+ }
3345
3225
 
3346
- for (var _propName in HTMLElementOriginalDescriptors) {
3347
- lightningBasedDescriptors[_propName] = createBridgeToElementDescriptor(_propName, HTMLElementOriginalDescriptors[_propName]);
3348
- }
3226
+ throw new Error();
3227
+ }
3349
3228
 
3350
- defineProperties(LightningElement.prototype, lightningBasedDescriptors);
3351
- defineProperty(LightningElement, 'CustomElementConstructor', {
3352
- get: function get() {
3353
- // If required, a runtime-specific implementation must be defined.
3354
- throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
3355
- },
3356
- configurable: true
3357
- });
3229
+ return {
3230
+ get: function get() {
3231
+ if (process.env.NODE_ENV !== 'production') {
3232
+ // Assert that the this value is an actual Component with an associated VM.
3233
+ getAssociatedVM(this);
3234
+ }
3358
3235
 
3359
- if (process.env.NODE_ENV !== 'production') {
3360
- patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
3361
- }
3362
- /*
3363
- * Copyright (c) 2018, salesforce.com, inc.
3364
- * All rights reserved.
3365
- * SPDX-License-Identifier: MIT
3366
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3367
- */
3236
+ return _get3.call(this);
3237
+ },
3238
+ set: function set(newValue) {
3239
+ var _this3 = this;
3368
3240
 
3369
- /**
3370
- * @wire decorator to wire fields and methods to a wire adapter in
3371
- * LWC Components. This function implements the internals of this
3372
- * decorator.
3373
- */
3241
+ var vm = getAssociatedVM(this);
3374
3242
 
3243
+ if (process.env.NODE_ENV !== 'production') {
3244
+ var _vmBeingRendered5 = getVMBeingRendered();
3375
3245
 
3376
- function wire(_adapter, _config) {
3377
- if (process.env.NODE_ENV !== 'production') {
3378
- assert.fail('@wire(adapter, config?) may only be used as a decorator.');
3379
- }
3246
+ assert.invariant(!isInvokingRender, "".concat(_vmBeingRendered5, ".render() method has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3247
+ assert.invariant(!isUpdatingTemplate, "Updating the template of ".concat(_vmBeingRendered5, " has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3248
+ }
3380
3249
 
3381
- throw new Error();
3250
+ if (_set2) {
3251
+ if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
3252
+ var ro = vm.oar[key];
3253
+
3254
+ if (isUndefined$1(ro)) {
3255
+ ro = vm.oar[key] = new AccessorReactiveObserver(vm, _set2);
3256
+ } // every time we invoke this setter from outside (through this wrapper setter)
3257
+ // we should reset the value and then debounce just in case there is a pending
3258
+ // invocation the next tick that is not longer relevant since the value is changing
3259
+ // from outside.
3260
+
3261
+
3262
+ ro.reset(newValue);
3263
+ ro.observe(function () {
3264
+ _set2.call(_this3, newValue);
3265
+ });
3266
+ } else {
3267
+ _set2.call(this, newValue);
3268
+ }
3269
+ } else if (process.env.NODE_ENV !== 'production') {
3270
+ assert.fail("Invalid attempt to set a new value for property ".concat(toString$1(key), " of ").concat(vm, " that does not has a setter decorated with @api."));
3271
+ }
3272
+ },
3273
+ enumerable: enumerable,
3274
+ configurable: configurable
3275
+ };
3382
3276
  }
3383
3277
 
3384
- function internalWireFieldDecorator(key) {
3278
+ function createObservedFieldPropertyDescriptor(key) {
3385
3279
  return {
3386
3280
  get: function get() {
3387
3281
  var vm = getAssociatedVM(this);
3388
3282
  componentValueObserved(vm, key);
3389
3283
  return vm.cmpFields[key];
3390
3284
  },
3391
- set: function set(value) {
3285
+ set: function set(newValue) {
3392
3286
  var vm = getAssociatedVM(this);
3393
- /**
3394
- * Reactivity for wired fields is provided in wiring.
3395
- * We intentionally add reactivity here since this is just
3396
- * letting the author to do the wrong thing, but it will keep our
3397
- * system to be backward compatible.
3398
- */
3399
3287
 
3400
- if (value !== vm.cmpFields[key]) {
3401
- vm.cmpFields[key] = value;
3288
+ if (newValue !== vm.cmpFields[key]) {
3289
+ vm.cmpFields[key] = newValue;
3402
3290
  componentValueMutated(vm, key);
3403
3291
  }
3404
3292
  },
@@ -3414,234 +3302,297 @@ var LWC = (function (exports) {
3414
3302
  */
3415
3303
 
3416
3304
 
3417
- function track(target) {
3418
- if (arguments.length === 1) {
3419
- return reactiveMembrane.getProxy(target);
3305
+ function getClassDescriptorType(descriptor) {
3306
+ if (isFunction$1(descriptor.value)) {
3307
+ return "method"
3308
+ /* Method */
3309
+ ;
3310
+ } else if (isFunction$1(descriptor.set) || isFunction$1(descriptor.get)) {
3311
+ return "accessor"
3312
+ /* Accessor */
3313
+ ;
3314
+ } else {
3315
+ return "field"
3316
+ /* Field */
3317
+ ;
3318
+ }
3319
+ }
3320
+
3321
+ function validateObservedField(Ctor, fieldName, descriptor) {
3322
+ if (!isUndefined$1(descriptor)) {
3323
+ var type = getClassDescriptorType(descriptor);
3324
+ var message = "Invalid observed ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."); // [W-9927596] Ideally we always throw an error when detecting duplicate observed field.
3325
+ // This branch is only here for backward compatibility reasons.
3326
+
3327
+ if (type === "accessor"
3328
+ /* Accessor */
3329
+ ) {
3330
+ logError(message);
3331
+ } else {
3332
+ assert.fail(message);
3333
+ }
3334
+ }
3335
+ }
3336
+
3337
+ function validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor) {
3338
+ if (!isUndefined$1(descriptor)) {
3339
+ var type = getClassDescriptorType(descriptor);
3340
+ assert.fail("Invalid @track ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."));
3341
+ }
3342
+ }
3343
+
3344
+ function validateFieldDecoratedWithWire(Ctor, fieldName, descriptor) {
3345
+ if (!isUndefined$1(descriptor)) {
3346
+ var type = getClassDescriptorType(descriptor);
3347
+ assert.fail("Invalid @wire ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."));
3420
3348
  }
3349
+ }
3421
3350
 
3422
- if (process.env.NODE_ENV !== 'production') {
3423
- assert.fail("@track decorator can only be used with one argument to return a trackable object, or as a decorator function.");
3351
+ function validateMethodDecoratedWithWire(Ctor, methodName, descriptor) {
3352
+ if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse(descriptor.writable)) {
3353
+ assert.fail("Invalid @wire ".concat(methodName, " method."));
3424
3354
  }
3425
-
3426
- throw new Error();
3427
3355
  }
3428
3356
 
3429
- function internalTrackDecorator(key) {
3430
- return {
3431
- get: function get() {
3432
- var vm = getAssociatedVM(this);
3433
- componentValueObserved(vm, key);
3434
- return vm.cmpFields[key];
3435
- },
3436
- set: function set(newValue) {
3437
- var vm = getAssociatedVM(this);
3438
-
3439
- if (process.env.NODE_ENV !== 'production') {
3440
- var _vmBeingRendered3 = getVMBeingRendered();
3357
+ function validateFieldDecoratedWithApi(Ctor, fieldName, descriptor) {
3358
+ if (!isUndefined$1(descriptor)) {
3359
+ var type = getClassDescriptorType(descriptor);
3360
+ var message = "Invalid @api ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."); // [W-9927596] Ideally we always throw an error when detecting duplicate public properties.
3361
+ // This branch is only here for backward compatibility reasons.
3441
3362
 
3442
- assert.invariant(!isInvokingRender, "".concat(_vmBeingRendered3, ".render() method has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3443
- assert.invariant(!isUpdatingTemplate, "Updating the template of ".concat(_vmBeingRendered3, " has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3444
- }
3363
+ if (type === "accessor"
3364
+ /* Accessor */
3365
+ ) {
3366
+ logError(message);
3367
+ } else {
3368
+ assert.fail(message);
3369
+ }
3370
+ }
3371
+ }
3445
3372
 
3446
- var reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
3373
+ function validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor) {
3374
+ if (isUndefined$1(descriptor)) {
3375
+ assert.fail("Invalid @api get ".concat(fieldName, " accessor."));
3376
+ } else if (isFunction$1(descriptor.set)) {
3377
+ assert.isTrue(isFunction$1(descriptor.get), "Missing getter for property ".concat(fieldName, " decorated with @api in ").concat(Ctor, ". You cannot have a setter without the corresponding getter."));
3378
+ } else if (!isFunction$1(descriptor.get)) {
3379
+ assert.fail("Missing @api get ".concat(fieldName, " accessor."));
3380
+ }
3381
+ }
3447
3382
 
3448
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
3449
- vm.cmpFields[key] = reactiveOrAnyValue;
3450
- componentValueMutated(vm, key);
3451
- }
3452
- },
3453
- enumerable: true,
3454
- configurable: true
3455
- };
3383
+ function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
3384
+ if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse(descriptor.writable)) {
3385
+ assert.fail("Invalid @api ".concat(methodName, " method."));
3386
+ }
3456
3387
  }
3457
- /*
3458
- * Copyright (c) 2018, salesforce.com, inc.
3459
- * All rights reserved.
3460
- * SPDX-License-Identifier: MIT
3461
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3388
+ /**
3389
+ * INTERNAL: This function can only be invoked by compiled code. The compiler
3390
+ * will prevent this function from being imported by user-land code.
3462
3391
  */
3463
3392
 
3464
3393
 
3465
- function api$1() {
3466
- if (process.env.NODE_ENV !== 'production') {
3467
- assert.fail("@api decorator can only be used as a decorator function.");
3468
- }
3469
-
3470
- throw new Error();
3471
- }
3394
+ function registerDecorators(Ctor, meta) {
3395
+ var proto = Ctor.prototype;
3396
+ var publicProps = meta.publicProps,
3397
+ publicMethods = meta.publicMethods,
3398
+ wire = meta.wire,
3399
+ track = meta.track,
3400
+ fields = meta.fields;
3401
+ var apiMethods = create(null);
3402
+ var apiFields = create(null);
3403
+ var wiredMethods = create(null);
3404
+ var wiredFields = create(null);
3405
+ var observedFields = create(null);
3406
+ var apiFieldsConfig = create(null);
3407
+ var descriptor;
3472
3408
 
3473
- function createPublicPropertyDescriptor(key) {
3474
- return {
3475
- get: function get() {
3476
- var vm = getAssociatedVM(this);
3409
+ if (!isUndefined$1(publicProps)) {
3410
+ for (var fieldName in publicProps) {
3411
+ var propConfig = publicProps[fieldName];
3412
+ apiFieldsConfig[fieldName] = propConfig.config;
3413
+ descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
3477
3414
 
3478
- if (isBeingConstructed(vm)) {
3415
+ if (propConfig.config > 0) {
3416
+ // accessor declaration
3479
3417
  if (process.env.NODE_ENV !== 'production') {
3480
- logError("Can\u2019t read the value of property `".concat(toString$1(key), "` from the constructor because the owner component hasn\u2019t set the value yet. Instead, use the constructor to set a default value for the property."), vm);
3418
+ validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor);
3481
3419
  }
3482
3420
 
3483
- return;
3421
+ if (isUndefined$1(descriptor)) {
3422
+ throw new Error();
3423
+ }
3424
+
3425
+ descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
3426
+ } else {
3427
+ // field declaration
3428
+ if (process.env.NODE_ENV !== 'production') {
3429
+ validateFieldDecoratedWithApi(Ctor, fieldName, descriptor);
3430
+ } // [W-9927596] If a component has both a public property and a private setter/getter
3431
+ // with the same name, the property is defined as a public accessor. This branch is
3432
+ // only here for backward compatibility reasons.
3433
+
3434
+
3435
+ if (!isUndefined$1(descriptor) && !isUndefined$1(descriptor.get)) {
3436
+ descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
3437
+ } else {
3438
+ descriptor = createPublicPropertyDescriptor(fieldName);
3439
+ }
3484
3440
  }
3485
3441
 
3486
- componentValueObserved(vm, key);
3487
- return vm.cmpProps[key];
3488
- },
3489
- set: function set(newValue) {
3490
- var vm = getAssociatedVM(this);
3442
+ apiFields[fieldName] = descriptor;
3443
+ defineProperty(proto, fieldName, descriptor);
3444
+ }
3445
+ }
3491
3446
 
3492
- if (process.env.NODE_ENV !== 'production') {
3493
- var _vmBeingRendered4 = getVMBeingRendered();
3447
+ if (!isUndefined$1(publicMethods)) {
3448
+ forEach.call(publicMethods, function (methodName) {
3449
+ descriptor = getOwnPropertyDescriptor$1(proto, methodName);
3494
3450
 
3495
- assert.invariant(!isInvokingRender, "".concat(_vmBeingRendered4, ".render() method has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3496
- assert.invariant(!isUpdatingTemplate, "Updating the template of ".concat(_vmBeingRendered4, " has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3451
+ if (process.env.NODE_ENV !== 'production') {
3452
+ validateMethodDecoratedWithApi(Ctor, methodName, descriptor);
3497
3453
  }
3498
3454
 
3499
- vm.cmpProps[key] = newValue;
3500
- componentValueMutated(vm, key);
3501
- },
3502
- enumerable: true,
3503
- configurable: true
3504
- };
3505
- }
3455
+ if (isUndefined$1(descriptor)) {
3456
+ throw new Error();
3457
+ }
3506
3458
 
3507
- var AccessorReactiveObserver = /*#__PURE__*/function (_ReactiveObserver) {
3508
- _inherits(AccessorReactiveObserver, _ReactiveObserver);
3459
+ apiMethods[methodName] = descriptor;
3460
+ });
3461
+ }
3509
3462
 
3510
- var _super3 = _createSuper(AccessorReactiveObserver);
3463
+ if (!isUndefined$1(wire)) {
3464
+ for (var fieldOrMethodName in wire) {
3465
+ var _wire$fieldOrMethodNa = wire[fieldOrMethodName],
3466
+ adapter = _wire$fieldOrMethodNa.adapter,
3467
+ method = _wire$fieldOrMethodNa.method,
3468
+ configCallback = _wire$fieldOrMethodNa.config,
3469
+ _wire$fieldOrMethodNa2 = _wire$fieldOrMethodNa.dynamic,
3470
+ dynamic = _wire$fieldOrMethodNa2 === void 0 ? [] : _wire$fieldOrMethodNa2;
3471
+ descriptor = getOwnPropertyDescriptor$1(proto, fieldOrMethodName);
3511
3472
 
3512
- function AccessorReactiveObserver(vm, set) {
3513
- var _this2;
3473
+ if (method === 1) {
3474
+ if (process.env.NODE_ENV !== 'production') {
3475
+ assert.isTrue(adapter, "@wire on method \"".concat(fieldOrMethodName, "\": adapter id must be truthy."));
3476
+ validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
3477
+ }
3514
3478
 
3515
- _classCallCheck(this, AccessorReactiveObserver);
3479
+ if (isUndefined$1(descriptor)) {
3480
+ throw new Error();
3481
+ }
3516
3482
 
3517
- _this2 = _super3.call(this, function () {
3518
- if (isFalse(_this2.debouncing)) {
3519
- _this2.debouncing = true;
3520
- addCallbackToNextTick(function () {
3521
- if (isTrue(_this2.debouncing)) {
3522
- var _assertThisInitialize = _assertThisInitialized(_this2),
3523
- value = _assertThisInitialize.value;
3483
+ wiredMethods[fieldOrMethodName] = descriptor;
3484
+ storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
3485
+ } else {
3486
+ if (process.env.NODE_ENV !== 'production') {
3487
+ assert.isTrue(adapter, "@wire on field \"".concat(fieldOrMethodName, "\": adapter id must be truthy."));
3488
+ validateFieldDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
3489
+ }
3524
3490
 
3525
- var dirtyStateBeforeSetterCall = vm.isDirty,
3526
- component = vm.component,
3527
- _idx = vm.idx;
3528
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
3529
- // infinity loop if the setter itself is mutating things that
3530
- // were accessed during the previous invocation.
3491
+ descriptor = internalWireFieldDecorator(fieldOrMethodName);
3492
+ wiredFields[fieldOrMethodName] = descriptor;
3493
+ storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic);
3494
+ defineProperty(proto, fieldOrMethodName, descriptor);
3495
+ }
3496
+ }
3497
+ }
3531
3498
 
3532
- _this2.debouncing = false;
3499
+ if (!isUndefined$1(track)) {
3500
+ for (var _fieldName in track) {
3501
+ descriptor = getOwnPropertyDescriptor$1(proto, _fieldName);
3533
3502
 
3534
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && _idx > 0) {
3535
- // immediate rehydration due to a setter driven mutation, otherwise
3536
- // the component will get rendered on the second tick, which it is not
3537
- // desirable.
3538
- rerenderVM(vm);
3539
- }
3540
- }
3541
- });
3503
+ if (process.env.NODE_ENV !== 'production') {
3504
+ validateFieldDecoratedWithTrack(Ctor, _fieldName, descriptor);
3542
3505
  }
3543
- });
3544
- _this2.debouncing = false;
3545
- return _this2;
3506
+
3507
+ descriptor = internalTrackDecorator(_fieldName);
3508
+ defineProperty(proto, _fieldName, descriptor);
3509
+ }
3546
3510
  }
3547
3511
 
3548
- _createClass(AccessorReactiveObserver, [{
3549
- key: "reset",
3550
- value: function reset(value) {
3551
- _get2(_getPrototypeOf2(AccessorReactiveObserver.prototype), "reset", this).call(this);
3512
+ if (!isUndefined$1(fields)) {
3513
+ for (var _i10 = 0, n = fields.length; _i10 < n; _i10++) {
3514
+ var _fieldName2 = fields[_i10];
3515
+ descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
3552
3516
 
3553
- this.debouncing = false;
3517
+ if (process.env.NODE_ENV !== 'production') {
3518
+ validateObservedField(Ctor, _fieldName2, descriptor);
3519
+ } // [W-9927596] Only mark a field as observed whenever it isn't a duplicated public nor
3520
+ // tracked property. This is only here for backward compatibility purposes.
3554
3521
 
3555
- if (arguments.length > 0) {
3556
- this.value = value;
3522
+
3523
+ var isDuplicatePublicProp = !isUndefined$1(publicProps) && _fieldName2 in publicProps;
3524
+ var isDuplicateTrackedProp = !isUndefined$1(track) && _fieldName2 in track;
3525
+
3526
+ if (!isDuplicatePublicProp && !isDuplicateTrackedProp) {
3527
+ observedFields[_fieldName2] = createObservedFieldPropertyDescriptor(_fieldName2);
3557
3528
  }
3558
3529
  }
3559
- }]);
3560
-
3561
- return AccessorReactiveObserver;
3562
- }(ReactiveObserver);
3530
+ }
3563
3531
 
3564
- function createPublicAccessorDescriptor(key, descriptor) {
3565
- var _get3 = descriptor.get,
3566
- _set2 = descriptor.set,
3567
- enumerable = descriptor.enumerable,
3568
- configurable = descriptor.configurable;
3532
+ setDecoratorsMeta(Ctor, {
3533
+ apiMethods: apiMethods,
3534
+ apiFields: apiFields,
3535
+ apiFieldsConfig: apiFieldsConfig,
3536
+ wiredMethods: wiredMethods,
3537
+ wiredFields: wiredFields,
3538
+ observedFields: observedFields
3539
+ });
3540
+ return Ctor;
3541
+ }
3569
3542
 
3570
- if (!isFunction$1(_get3)) {
3571
- if (process.env.NODE_ENV !== 'production') {
3572
- assert.invariant(isFunction$1(_get3), "Invalid compiler output for public accessor ".concat(toString$1(key), " decorated with @api"));
3573
- }
3543
+ var signedDecoratorToMetaMap = new Map();
3574
3544
 
3575
- throw new Error();
3576
- }
3545
+ function setDecoratorsMeta(Ctor, meta) {
3546
+ signedDecoratorToMetaMap.set(Ctor, meta);
3547
+ }
3577
3548
 
3578
- return {
3579
- get: function get() {
3580
- if (process.env.NODE_ENV !== 'production') {
3581
- // Assert that the this value is an actual Component with an associated VM.
3582
- getAssociatedVM(this);
3583
- }
3549
+ var defaultMeta = {
3550
+ apiMethods: EmptyObject,
3551
+ apiFields: EmptyObject,
3552
+ apiFieldsConfig: EmptyObject,
3553
+ wiredMethods: EmptyObject,
3554
+ wiredFields: EmptyObject,
3555
+ observedFields: EmptyObject
3556
+ };
3584
3557
 
3585
- return _get3.call(this);
3586
- },
3587
- set: function set(newValue) {
3588
- var _this3 = this;
3558
+ function getDecoratorsMeta(Ctor) {
3559
+ var meta = signedDecoratorToMetaMap.get(Ctor);
3560
+ return isUndefined$1(meta) ? defaultMeta : meta;
3561
+ }
3589
3562
 
3590
- var vm = getAssociatedVM(this);
3563
+ var signedTemplateSet = new Set();
3591
3564
 
3592
- if (process.env.NODE_ENV !== 'production') {
3593
- var _vmBeingRendered5 = getVMBeingRendered();
3565
+ function defaultEmptyTemplate() {
3566
+ return [];
3567
+ }
3594
3568
 
3595
- assert.invariant(!isInvokingRender, "".concat(_vmBeingRendered5, ".render() method has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3596
- assert.invariant(!isUpdatingTemplate, "Updating the template of ".concat(_vmBeingRendered5, " has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
3597
- }
3569
+ signedTemplateSet.add(defaultEmptyTemplate);
3598
3570
 
3599
- if (_set2) {
3600
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
3601
- var ro = vm.oar[key];
3571
+ function isTemplateRegistered(tpl) {
3572
+ return signedTemplateSet.has(tpl);
3573
+ }
3574
+ /**
3575
+ * INTERNAL: This function can only be invoked by compiled code. The compiler
3576
+ * will prevent this function from being imported by userland code.
3577
+ */
3602
3578
 
3603
- if (isUndefined$1(ro)) {
3604
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, _set2);
3605
- } // every time we invoke this setter from outside (through this wrapper setter)
3606
- // we should reset the value and then debounce just in case there is a pending
3607
- // invocation the next tick that is not longer relevant since the value is changing
3608
- // from outside.
3609
3579
 
3580
+ function registerTemplate(tpl) {
3581
+ signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3582
+ // assignment of templates easily, without too much transformation
3610
3583
 
3611
- ro.reset(newValue);
3612
- ro.observe(function () {
3613
- _set2.call(_this3, newValue);
3614
- });
3615
- } else {
3616
- _set2.call(this, newValue);
3617
- }
3618
- } else if (process.env.NODE_ENV !== 'production') {
3619
- assert.fail("Invalid attempt to set a new value for property ".concat(toString$1(key), " of ").concat(vm, " that does not has a setter decorated with @api."));
3620
- }
3621
- },
3622
- enumerable: enumerable,
3623
- configurable: configurable
3624
- };
3584
+ return tpl;
3625
3585
  }
3586
+ /**
3587
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3588
+ * libraries to sanitize vulnerable attributes.
3589
+ */
3626
3590
 
3627
- function createObservedFieldPropertyDescriptor(key) {
3628
- return {
3629
- get: function get() {
3630
- var vm = getAssociatedVM(this);
3631
- componentValueObserved(vm, key);
3632
- return vm.cmpFields[key];
3633
- },
3634
- set: function set(newValue) {
3635
- var vm = getAssociatedVM(this);
3636
3591
 
3637
- if (newValue !== vm.cmpFields[key]) {
3638
- vm.cmpFields[key] = newValue;
3639
- componentValueMutated(vm, key);
3640
- }
3641
- },
3642
- enumerable: true,
3643
- configurable: true
3644
- };
3592
+ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3593
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3594
+ // ran off-core this function becomes a noop and returns the user authored value.
3595
+ return attrValue;
3645
3596
  }
3646
3597
  /*
3647
3598
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3649,807 +3600,816 @@ var LWC = (function (exports) {
3649
3600
  * SPDX-License-Identifier: MIT
3650
3601
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3651
3602
  */
3603
+ // from the element instance, and get the value or set a new value on the component.
3604
+ // This means that across different elements, similar names can get the exact same
3605
+ // descriptor, so we can cache them:
3652
3606
 
3653
3607
 
3654
- function getClassDescriptorType(descriptor) {
3655
- if (isFunction$1(descriptor.value)) {
3656
- return "method"
3657
- /* Method */
3658
- ;
3659
- } else if (isFunction$1(descriptor.set) || isFunction$1(descriptor.get)) {
3660
- return "accessor"
3661
- /* Accessor */
3662
- ;
3663
- } else {
3664
- return "field"
3665
- /* Field */
3666
- ;
3667
- }
3668
- }
3608
+ var cachedGetterByKey = create(null);
3609
+ var cachedSetterByKey = create(null);
3669
3610
 
3670
- function validateObservedField(Ctor, fieldName, descriptor) {
3671
- if (!isUndefined$1(descriptor)) {
3672
- var type = getClassDescriptorType(descriptor);
3673
- var message = "Invalid observed ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."); // [W-9927596] Ideally we always throw an error when detecting duplicate observed field.
3674
- // This branch is only here for backward compatibility reasons.
3611
+ function createGetter(key) {
3612
+ var fn = cachedGetterByKey[key];
3675
3613
 
3676
- if (type === "accessor"
3677
- /* Accessor */
3678
- ) {
3679
- logError(message);
3680
- } else {
3681
- assert.fail(message);
3682
- }
3614
+ if (isUndefined$1(fn)) {
3615
+ fn = cachedGetterByKey[key] = function () {
3616
+ var vm = getAssociatedVM(this);
3617
+ var getHook = vm.getHook;
3618
+ return getHook(vm.component, key);
3619
+ };
3683
3620
  }
3684
- }
3685
3621
 
3686
- function validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor) {
3687
- if (!isUndefined$1(descriptor)) {
3688
- var type = getClassDescriptorType(descriptor);
3689
- assert.fail("Invalid @track ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."));
3690
- }
3622
+ return fn;
3691
3623
  }
3692
3624
 
3693
- function validateFieldDecoratedWithWire(Ctor, fieldName, descriptor) {
3694
- if (!isUndefined$1(descriptor)) {
3695
- var type = getClassDescriptorType(descriptor);
3696
- assert.fail("Invalid @wire ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."));
3625
+ function createSetter(key) {
3626
+ var fn = cachedSetterByKey[key];
3627
+
3628
+ if (isUndefined$1(fn)) {
3629
+ fn = cachedSetterByKey[key] = function (newValue) {
3630
+ var vm = getAssociatedVM(this);
3631
+ var setHook = vm.setHook;
3632
+ newValue = reactiveMembrane.getReadOnlyProxy(newValue);
3633
+ setHook(vm.component, key, newValue);
3634
+ };
3697
3635
  }
3636
+
3637
+ return fn;
3698
3638
  }
3699
3639
 
3700
- function validateMethodDecoratedWithWire(Ctor, methodName, descriptor) {
3701
- if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse(descriptor.writable)) {
3702
- assert.fail("Invalid @wire ".concat(methodName, " method."));
3703
- }
3640
+ function createMethodCaller(methodName) {
3641
+ return function () {
3642
+ var vm = getAssociatedVM(this);
3643
+ var callHook = vm.callHook,
3644
+ component = vm.component;
3645
+ var fn = component[methodName];
3646
+ return callHook(vm.component, fn, ArraySlice.call(arguments));
3647
+ };
3704
3648
  }
3705
3649
 
3706
- function validateFieldDecoratedWithApi(Ctor, fieldName, descriptor) {
3707
- if (!isUndefined$1(descriptor)) {
3708
- var type = getClassDescriptorType(descriptor);
3709
- var message = "Invalid @api ".concat(fieldName, " field. Found a duplicate ").concat(type, " with the same name."); // [W-9927596] Ideally we always throw an error when detecting duplicate public properties.
3710
- // This branch is only here for backward compatibility reasons.
3650
+ function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
3651
+ return function attributeChangedCallback(attrName, oldValue, newValue) {
3652
+ if (oldValue === newValue) {
3653
+ // Ignore same values.
3654
+ return;
3655
+ }
3711
3656
 
3712
- if (type === "accessor"
3713
- /* Accessor */
3714
- ) {
3715
- logError(message);
3716
- } else {
3717
- assert.fail(message);
3657
+ var propName = attributeToPropMap[attrName];
3658
+
3659
+ if (isUndefined$1(propName)) {
3660
+ if (!isUndefined$1(superAttributeChangedCallback)) {
3661
+ // delegate unknown attributes to the super.
3662
+ // Typescript does not like it when you treat the `arguments` object as an array
3663
+ // @ts-ignore type-mismatch
3664
+ superAttributeChangedCallback.apply(this, arguments);
3665
+ }
3666
+
3667
+ return;
3718
3668
  }
3719
- }
3720
- }
3721
3669
 
3722
- function validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor) {
3723
- if (isUndefined$1(descriptor)) {
3724
- assert.fail("Invalid @api get ".concat(fieldName, " accessor."));
3725
- } else if (isFunction$1(descriptor.set)) {
3726
- assert.isTrue(isFunction$1(descriptor.get), "Missing getter for property ".concat(fieldName, " decorated with @api in ").concat(Ctor, ". You cannot have a setter without the corresponding getter."));
3727
- } else if (!isFunction$1(descriptor.get)) {
3728
- assert.fail("Missing @api get ".concat(fieldName, " accessor."));
3729
- }
3730
- }
3670
+ if (!isAttributeLocked(this, attrName)) {
3671
+ // Ignore changes triggered by the engine itself during:
3672
+ // * diffing when public props are attempting to reflect to the DOM
3673
+ // * component via `this.setAttribute()`, should never update the prop
3674
+ // Both cases, the setAttribute call is always wrapped by the unlocking of the
3675
+ // attribute to be changed
3676
+ return;
3677
+ } // Reflect attribute change to the corresponding property when changed from outside.
3731
3678
 
3732
- function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
3733
- if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse(descriptor.writable)) {
3734
- assert.fail("Invalid @api ".concat(methodName, " method."));
3735
- }
3679
+
3680
+ this[propName] = newValue;
3681
+ };
3736
3682
  }
3737
- /**
3738
- * INTERNAL: This function can only be invoked by compiled code. The compiler
3739
- * will prevent this function from being imported by user-land code.
3740
- */
3741
3683
 
3684
+ function HTMLBridgeElementFactory(SuperClass, props, methods) {
3685
+ var HTMLBridgeElement;
3686
+ /**
3687
+ * Modern browsers will have all Native Constructors as regular Classes
3688
+ * and must be instantiated with the new keyword. In older browsers,
3689
+ * specifically IE11, those are objects with a prototype property defined,
3690
+ * since they are not supposed to be extended or instantiated with the
3691
+ * new keyword. This forking logic supports both cases, specifically because
3692
+ * wc.ts relies on the construction path of the bridges to create new
3693
+ * fully qualifying web components.
3694
+ */
3695
+
3696
+ if (isFunction$1(SuperClass)) {
3697
+ HTMLBridgeElement = /*#__PURE__*/function (_SuperClass) {
3698
+ _inherits(HTMLBridgeElement, _SuperClass);
3699
+
3700
+ var _super4 = _createSuper(HTMLBridgeElement);
3742
3701
 
3743
- function registerDecorators(Ctor, meta) {
3744
- var proto = Ctor.prototype;
3745
- var publicProps = meta.publicProps,
3746
- publicMethods = meta.publicMethods,
3747
- wire = meta.wire,
3748
- track = meta.track,
3749
- fields = meta.fields;
3750
- var apiMethods = create(null);
3751
- var apiFields = create(null);
3752
- var wiredMethods = create(null);
3753
- var wiredFields = create(null);
3754
- var observedFields = create(null);
3755
- var apiFieldsConfig = create(null);
3756
- var descriptor;
3702
+ function HTMLBridgeElement() {
3703
+ _classCallCheck(this, HTMLBridgeElement);
3757
3704
 
3758
- if (!isUndefined$1(publicProps)) {
3759
- for (var fieldName in publicProps) {
3760
- var propConfig = publicProps[fieldName];
3761
- apiFieldsConfig[fieldName] = propConfig.config;
3762
- descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
3705
+ return _super4.apply(this, arguments);
3706
+ }
3763
3707
 
3764
- if (propConfig.config > 0) {
3765
- // accessor declaration
3766
- if (process.env.NODE_ENV !== 'production') {
3767
- validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor);
3768
- }
3708
+ return _createClass(HTMLBridgeElement);
3709
+ }(SuperClass);
3710
+ } else {
3711
+ HTMLBridgeElement = function HTMLBridgeElement() {
3712
+ // Bridge classes are not supposed to be instantiated directly in
3713
+ // browsers that do not support web components.
3714
+ throw new TypeError('Illegal constructor');
3715
+ }; // prototype inheritance dance
3769
3716
 
3770
- if (isUndefined$1(descriptor)) {
3771
- throw new Error();
3772
- }
3773
3717
 
3774
- descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
3775
- } else {
3776
- // field declaration
3777
- if (process.env.NODE_ENV !== 'production') {
3778
- validateFieldDecoratedWithApi(Ctor, fieldName, descriptor);
3779
- } // [W-9927596] If a component has both a public property and a private setter/getter
3780
- // with the same name, the property is defined as a public accessor. This branch is
3781
- // only here for backward compatibility reasons.
3718
+ setPrototypeOf(HTMLBridgeElement, SuperClass);
3719
+ setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
3720
+ defineProperty(HTMLBridgeElement.prototype, 'constructor', {
3721
+ writable: true,
3722
+ configurable: true,
3723
+ value: HTMLBridgeElement
3724
+ });
3725
+ } // generating the hash table for attributes to avoid duplicate fields and facilitate validation
3726
+ // and false positives in case of inheritance.
3782
3727
 
3783
3728
 
3784
- if (!isUndefined$1(descriptor) && !isUndefined$1(descriptor.get)) {
3785
- descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
3786
- } else {
3787
- descriptor = createPublicPropertyDescriptor(fieldName);
3788
- }
3789
- }
3729
+ var attributeToPropMap = create(null);
3730
+ var superAttributeChangedCallback = SuperClass.prototype.attributeChangedCallback;
3731
+ var _SuperClass$observedA = SuperClass.observedAttributes,
3732
+ superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
3733
+ var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
3790
3734
 
3791
- apiFields[fieldName] = descriptor;
3792
- defineProperty(proto, fieldName, descriptor);
3793
- }
3794
- }
3735
+ for (var _i11 = 0, _len3 = props.length; _i11 < _len3; _i11 += 1) {
3736
+ var _propName2 = props[_i11];
3737
+ attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
3738
+ descriptors[_propName2] = {
3739
+ get: createGetter(_propName2),
3740
+ set: createSetter(_propName2),
3741
+ enumerable: true,
3742
+ configurable: true
3743
+ };
3744
+ } // expose public methods as props on the new Element Bridge
3795
3745
 
3796
- if (!isUndefined$1(publicMethods)) {
3797
- forEach.call(publicMethods, function (methodName) {
3798
- descriptor = getOwnPropertyDescriptor$1(proto, methodName);
3799
3746
 
3800
- if (process.env.NODE_ENV !== 'production') {
3801
- validateMethodDecoratedWithApi(Ctor, methodName, descriptor);
3802
- }
3747
+ for (var _i12 = 0, _len4 = methods.length; _i12 < _len4; _i12 += 1) {
3748
+ var methodName = methods[_i12];
3749
+ descriptors[methodName] = {
3750
+ value: createMethodCaller(methodName),
3751
+ writable: true,
3752
+ configurable: true
3753
+ };
3754
+ } // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
3755
+ // map of attributes to props. We do this after all other props and methods to avoid the possibility
3756
+ // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
3757
+ // to preserve this definition.
3803
3758
 
3804
- if (isUndefined$1(descriptor)) {
3805
- throw new Error();
3806
- }
3807
3759
 
3808
- apiMethods[methodName] = descriptor;
3809
- });
3810
- }
3760
+ descriptors.attributeChangedCallback = {
3761
+ value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
3762
+ }; // Specify attributes for which we want to reflect changes back to their corresponding
3763
+ // properties via attributeChangedCallback.
3811
3764
 
3812
- if (!isUndefined$1(wire)) {
3813
- for (var fieldOrMethodName in wire) {
3814
- var _wire$fieldOrMethodNa = wire[fieldOrMethodName],
3815
- adapter = _wire$fieldOrMethodNa.adapter,
3816
- method = _wire$fieldOrMethodNa.method,
3817
- configCallback = _wire$fieldOrMethodNa.config,
3818
- _wire$fieldOrMethodNa2 = _wire$fieldOrMethodNa.dynamic,
3819
- dynamic = _wire$fieldOrMethodNa2 === void 0 ? [] : _wire$fieldOrMethodNa2;
3820
- descriptor = getOwnPropertyDescriptor$1(proto, fieldOrMethodName);
3765
+ defineProperty(HTMLBridgeElement, 'observedAttributes', {
3766
+ get: function get() {
3767
+ return [].concat(_toConsumableArray(superObservedAttributes), _toConsumableArray(keys(attributeToPropMap)));
3768
+ }
3769
+ });
3770
+ defineProperties(HTMLBridgeElement.prototype, descriptors);
3771
+ return HTMLBridgeElement;
3772
+ }
3821
3773
 
3822
- if (method === 1) {
3823
- if (process.env.NODE_ENV !== 'production') {
3824
- assert.isTrue(adapter, "@wire on method \"".concat(fieldOrMethodName, "\": adapter id must be truthy."));
3825
- validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
3826
- }
3774
+ var BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor$1, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
3775
+ freeze(BaseBridgeElement);
3776
+ seal(BaseBridgeElement.prototype);
3777
+ /*
3778
+ * Copyright (c) 2020, salesforce.com, inc.
3779
+ * All rights reserved.
3780
+ * SPDX-License-Identifier: MIT
3781
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3782
+ */
3827
3783
 
3828
- if (isUndefined$1(descriptor)) {
3829
- throw new Error();
3830
- }
3784
+ function resolveCircularModuleDependency(fn) {
3785
+ var module = fn();
3786
+ return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
3787
+ }
3831
3788
 
3832
- wiredMethods[fieldOrMethodName] = descriptor;
3833
- storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
3834
- } else {
3835
- if (process.env.NODE_ENV !== 'production') {
3836
- assert.isTrue(adapter, "@wire on field \"".concat(fieldOrMethodName, "\": adapter id must be truthy."));
3837
- validateFieldDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
3838
- }
3789
+ function isCircularModuleDependency(obj) {
3790
+ return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
3791
+ }
3792
+ /*
3793
+ * Copyright (c) 2020, salesforce.com, inc.
3794
+ * All rights reserved.
3795
+ * SPDX-License-Identifier: MIT
3796
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3797
+ */
3839
3798
 
3840
- descriptor = internalWireFieldDecorator(fieldOrMethodName);
3841
- wiredFields[fieldOrMethodName] = descriptor;
3842
- storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic);
3843
- defineProperty(proto, fieldOrMethodName, descriptor);
3844
- }
3845
- }
3846
- }
3847
3799
 
3848
- if (!isUndefined$1(track)) {
3849
- for (var _fieldName in track) {
3850
- descriptor = getOwnPropertyDescriptor$1(proto, _fieldName);
3800
+ var swappedTemplateMap = new WeakMap();
3801
+ var swappedComponentMap = new WeakMap();
3802
+ var swappedStyleMap = new WeakMap();
3803
+ var activeTemplates = new WeakMap();
3804
+ var activeComponents = new WeakMap();
3805
+ var activeStyles = new WeakMap();
3851
3806
 
3852
- if (process.env.NODE_ENV !== 'production') {
3853
- validateFieldDecoratedWithTrack(Ctor, _fieldName, descriptor);
3807
+ function rehydrateHotTemplate(tpl) {
3808
+ var list = activeTemplates.get(tpl);
3809
+
3810
+ if (!isUndefined$1(list)) {
3811
+ list.forEach(function (vm) {
3812
+ if (isFalse(vm.isDirty)) {
3813
+ // forcing the vm to rehydrate in the micro-task:
3814
+ markComponentAsDirty(vm);
3815
+ scheduleRehydration(vm);
3854
3816
  }
3817
+ }); // resetting the Set to release the memory of those vm references
3818
+ // since they are not longer related to this template, instead
3819
+ // they will get re-associated once these instances are rehydrated.
3855
3820
 
3856
- descriptor = internalTrackDecorator(_fieldName);
3857
- defineProperty(proto, _fieldName, descriptor);
3858
- }
3821
+ list.clear();
3859
3822
  }
3860
3823
 
3861
- if (!isUndefined$1(fields)) {
3862
- for (var _i11 = 0, n = fields.length; _i11 < n; _i11++) {
3863
- var _fieldName2 = fields[_i11];
3864
- descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
3865
-
3866
- if (process.env.NODE_ENV !== 'production') {
3867
- validateObservedField(Ctor, _fieldName2, descriptor);
3868
- } // [W-9927596] Only mark a field as observed whenever it isn't a duplicated public nor
3869
- // tracked property. This is only here for backward compatibility purposes.
3824
+ return true;
3825
+ }
3870
3826
 
3827
+ function rehydrateHotStyle(style) {
3828
+ var list = activeStyles.get(style);
3871
3829
 
3872
- var isDuplicatePublicProp = !isUndefined$1(publicProps) && _fieldName2 in publicProps;
3873
- var isDuplicateTrackedProp = !isUndefined$1(track) && _fieldName2 in track;
3830
+ if (!isUndefined$1(list)) {
3831
+ list.forEach(function (vm) {
3832
+ // if a style definition is swapped, we must reset
3833
+ // vm's template content in the next micro-task:
3834
+ forceRehydration(vm);
3835
+ }); // resetting the Set to release the memory of those vm references
3836
+ // since they are not longer related to this style, instead
3837
+ // they will get re-associated once these instances are rehydrated.
3874
3838
 
3875
- if (!isDuplicatePublicProp && !isDuplicateTrackedProp) {
3876
- observedFields[_fieldName2] = createObservedFieldPropertyDescriptor(_fieldName2);
3877
- }
3878
- }
3839
+ list.clear();
3879
3840
  }
3880
3841
 
3881
- setDecoratorsMeta(Ctor, {
3882
- apiMethods: apiMethods,
3883
- apiFields: apiFields,
3884
- apiFieldsConfig: apiFieldsConfig,
3885
- wiredMethods: wiredMethods,
3886
- wiredFields: wiredFields,
3887
- observedFields: observedFields
3888
- });
3889
- return Ctor;
3842
+ return true;
3890
3843
  }
3891
3844
 
3892
- var signedDecoratorToMetaMap = new Map();
3845
+ function rehydrateHotComponent(Ctor) {
3846
+ var list = activeComponents.get(Ctor);
3847
+ var canRefreshAllInstances = true;
3848
+
3849
+ if (!isUndefined$1(list)) {
3850
+ list.forEach(function (vm) {
3851
+ var owner = vm.owner;
3852
+
3853
+ if (!isNull(owner)) {
3854
+ // if a component class definition is swapped, we must reset
3855
+ // owner's template content in the next micro-task:
3856
+ forceRehydration(owner);
3857
+ } else {
3858
+ // the hot swapping for components only work for instances of components
3859
+ // created from a template, root elements can't be swapped because we
3860
+ // don't have a way to force the creation of the element with the same state
3861
+ // of the current element.
3862
+ // Instead, we can report the problem to the caller so it can take action,
3863
+ // for example: reload the entire page.
3864
+ canRefreshAllInstances = false;
3865
+ }
3866
+ }); // resetting the Set to release the memory of those vm references
3867
+ // since they are not longer related to this constructor, instead
3868
+ // they will get re-associated once these instances are rehydrated.
3869
+
3870
+ list.clear();
3871
+ }
3893
3872
 
3894
- function setDecoratorsMeta(Ctor, meta) {
3895
- signedDecoratorToMetaMap.set(Ctor, meta);
3873
+ return canRefreshAllInstances;
3896
3874
  }
3897
3875
 
3898
- var defaultMeta = {
3899
- apiMethods: EmptyObject,
3900
- apiFields: EmptyObject,
3901
- apiFieldsConfig: EmptyObject,
3902
- wiredMethods: EmptyObject,
3903
- wiredFields: EmptyObject,
3904
- observedFields: EmptyObject
3905
- };
3906
-
3907
- function getDecoratorsMeta(Ctor) {
3908
- var meta = signedDecoratorToMetaMap.get(Ctor);
3909
- return isUndefined$1(meta) ? defaultMeta : meta;
3910
- }
3876
+ function flattenStylesheets(stylesheets) {
3877
+ var list = [];
3911
3878
 
3912
- var signedTemplateSet = new Set();
3879
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
3880
+ _step2;
3913
3881
 
3914
- function defaultEmptyTemplate() {
3915
- return [];
3916
- }
3882
+ try {
3883
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3884
+ var stylesheet = _step2.value;
3917
3885
 
3918
- signedTemplateSet.add(defaultEmptyTemplate);
3886
+ if (!Array.isArray(stylesheet)) {
3887
+ list.push(stylesheet);
3888
+ } else {
3889
+ list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
3890
+ }
3891
+ }
3892
+ } catch (err) {
3893
+ _iterator2.e(err);
3894
+ } finally {
3895
+ _iterator2.f();
3896
+ }
3919
3897
 
3920
- function isTemplateRegistered(tpl) {
3921
- return signedTemplateSet.has(tpl);
3898
+ return list;
3922
3899
  }
3923
- /**
3924
- * INTERNAL: This function can only be invoked by compiled code. The compiler
3925
- * will prevent this function from being imported by userland code.
3926
- */
3927
3900
 
3901
+ function getTemplateOrSwappedTemplate(tpl) {
3902
+ if (process.env.NODE_ENV === 'production') {
3903
+ // this method should never leak to prod
3904
+ throw new ReferenceError();
3905
+ }
3928
3906
 
3929
- function registerTemplate(tpl) {
3930
- signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3931
- // assignment of templates easily, without too much transformation
3907
+ if (runtimeFlags.ENABLE_HMR) {
3908
+ var visited = new Set();
3909
+
3910
+ while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
3911
+ visited.add(tpl);
3912
+ tpl = swappedTemplateMap.get(tpl);
3913
+ }
3914
+ }
3932
3915
 
3933
3916
  return tpl;
3934
3917
  }
3935
- /**
3936
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3937
- * libraries to sanitize vulnerable attributes.
3938
- */
3939
3918
 
3919
+ function getComponentOrSwappedComponent(Ctor) {
3920
+ if (process.env.NODE_ENV === 'production') {
3921
+ // this method should never leak to prod
3922
+ throw new ReferenceError();
3923
+ }
3940
3924
 
3941
- function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3942
- // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3943
- // ran off-core this function becomes a noop and returns the user authored value.
3944
- return attrValue;
3945
- }
3946
- /*
3947
- * Copyright (c) 2018, salesforce.com, inc.
3948
- * All rights reserved.
3949
- * SPDX-License-Identifier: MIT
3950
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3951
- */
3952
- // from the element instance, and get the value or set a new value on the component.
3953
- // This means that across different elements, similar names can get the exact same
3954
- // descriptor, so we can cache them:
3925
+ if (runtimeFlags.ENABLE_HMR) {
3926
+ var visited = new Set();
3927
+
3928
+ while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
3929
+ visited.add(Ctor);
3930
+ Ctor = swappedComponentMap.get(Ctor);
3931
+ }
3932
+ }
3955
3933
 
3934
+ return Ctor;
3935
+ }
3956
3936
 
3957
- var cachedGetterByKey = create(null);
3958
- var cachedSetterByKey = create(null);
3937
+ function getStyleOrSwappedStyle(style) {
3938
+ if (process.env.NODE_ENV === 'production') {
3939
+ // this method should never leak to prod
3940
+ throw new ReferenceError();
3941
+ }
3959
3942
 
3960
- function createGetter(key) {
3961
- var fn = cachedGetterByKey[key];
3943
+ if (runtimeFlags.ENABLE_HMR) {
3944
+ var visited = new Set();
3962
3945
 
3963
- if (isUndefined$1(fn)) {
3964
- fn = cachedGetterByKey[key] = function () {
3965
- var vm = getAssociatedVM(this);
3966
- var getHook = vm.getHook;
3967
- return getHook(vm.component, key);
3968
- };
3946
+ while (swappedStyleMap.has(style) && !visited.has(style)) {
3947
+ visited.add(style);
3948
+ style = swappedStyleMap.get(style);
3949
+ }
3969
3950
  }
3970
3951
 
3971
- return fn;
3952
+ return style;
3972
3953
  }
3973
3954
 
3974
- function createSetter(key) {
3975
- var fn = cachedSetterByKey[key];
3976
-
3977
- if (isUndefined$1(fn)) {
3978
- fn = cachedSetterByKey[key] = function (newValue) {
3979
- var vm = getAssociatedVM(this);
3980
- var setHook = vm.setHook;
3981
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
3982
- setHook(vm.component, key, newValue);
3983
- };
3955
+ function setActiveVM(vm) {
3956
+ if (process.env.NODE_ENV === 'production') {
3957
+ // this method should never leak to prod
3958
+ throw new ReferenceError();
3984
3959
  }
3985
3960
 
3986
- return fn;
3987
- }
3961
+ if (runtimeFlags.ENABLE_HMR) {
3962
+ // tracking active component
3963
+ var Ctor = vm.def.ctor;
3964
+ var componentVMs = activeComponents.get(Ctor);
3988
3965
 
3989
- function createMethodCaller(methodName) {
3990
- return function () {
3991
- var vm = getAssociatedVM(this);
3992
- var callHook = vm.callHook,
3993
- component = vm.component;
3994
- var fn = component[methodName];
3995
- return callHook(vm.component, fn, ArraySlice.call(arguments));
3996
- };
3997
- }
3966
+ if (isUndefined$1(componentVMs)) {
3967
+ componentVMs = new Set();
3968
+ activeComponents.set(Ctor, componentVMs);
3969
+ } // this will allow us to keep track of the hot components
3998
3970
 
3999
- function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
4000
- return function attributeChangedCallback(attrName, oldValue, newValue) {
4001
- if (oldValue === newValue) {
4002
- // Ignore same values.
4003
- return;
4004
- }
4005
3971
 
4006
- var propName = attributeToPropMap[attrName];
3972
+ componentVMs.add(vm); // tracking active template
4007
3973
 
4008
- if (isUndefined$1(propName)) {
4009
- if (!isUndefined$1(superAttributeChangedCallback)) {
4010
- // delegate unknown attributes to the super.
4011
- // Typescript does not like it when you treat the `arguments` object as an array
4012
- // @ts-ignore type-mismatch
4013
- superAttributeChangedCallback.apply(this, arguments);
4014
- }
3974
+ var tpl = vm.cmpTemplate;
4015
3975
 
4016
- return;
4017
- }
3976
+ if (tpl) {
3977
+ var templateVMs = activeTemplates.get(tpl);
4018
3978
 
4019
- if (!isAttributeLocked(this, attrName)) {
4020
- // Ignore changes triggered by the engine itself during:
4021
- // * diffing when public props are attempting to reflect to the DOM
4022
- // * component via `this.setAttribute()`, should never update the prop
4023
- // Both cases, the setAttribute call is always wrapped by the unlocking of the
4024
- // attribute to be changed
4025
- return;
4026
- } // Reflect attribute change to the corresponding property when changed from outside.
3979
+ if (isUndefined$1(templateVMs)) {
3980
+ templateVMs = new Set();
3981
+ activeTemplates.set(tpl, templateVMs);
3982
+ } // this will allow us to keep track of the templates that are
3983
+ // being used by a hot component
4027
3984
 
4028
3985
 
4029
- this[propName] = newValue;
4030
- };
4031
- }
3986
+ templateVMs.add(vm); // tracking active styles associated to template
4032
3987
 
4033
- function HTMLBridgeElementFactory(SuperClass, props, methods) {
4034
- var HTMLBridgeElement;
4035
- /**
4036
- * Modern browsers will have all Native Constructors as regular Classes
4037
- * and must be instantiated with the new keyword. In older browsers,
4038
- * specifically IE11, those are objects with a prototype property defined,
4039
- * since they are not supposed to be extended or instantiated with the
4040
- * new keyword. This forking logic supports both cases, specifically because
4041
- * wc.ts relies on the construction path of the bridges to create new
4042
- * fully qualifying web components.
4043
- */
3988
+ var stylesheets = tpl.stylesheets;
4044
3989
 
4045
- if (isFunction$1(SuperClass)) {
4046
- HTMLBridgeElement = /*#__PURE__*/function (_SuperClass) {
4047
- _inherits(HTMLBridgeElement, _SuperClass);
3990
+ if (!isUndefined$1(stylesheets)) {
3991
+ flattenStylesheets(stylesheets).forEach(function (stylesheet) {
3992
+ // this is necessary because we don't hold the list of styles
3993
+ // in the vm, we only hold the selected (already swapped template)
3994
+ // but the styles attached to the template might not be the actual
3995
+ // active ones, but the swapped versions of those.
3996
+ stylesheet = getStyleOrSwappedStyle(stylesheet);
3997
+ var stylesheetVMs = activeStyles.get(stylesheet);
4048
3998
 
4049
- var _super4 = _createSuper(HTMLBridgeElement);
3999
+ if (isUndefined$1(stylesheetVMs)) {
4000
+ stylesheetVMs = new Set();
4001
+ activeStyles.set(stylesheet, stylesheetVMs);
4002
+ } // this will allow us to keep track of the stylesheet that are
4003
+ // being used by a hot component
4050
4004
 
4051
- function HTMLBridgeElement() {
4052
- _classCallCheck(this, HTMLBridgeElement);
4053
4005
 
4054
- return _super4.apply(this, arguments);
4006
+ stylesheetVMs.add(vm);
4007
+ });
4055
4008
  }
4009
+ }
4010
+ }
4011
+ }
4056
4012
 
4057
- return _createClass(HTMLBridgeElement);
4058
- }(SuperClass);
4059
- } else {
4060
- HTMLBridgeElement = function HTMLBridgeElement() {
4061
- // Bridge classes are not supposed to be instantiated directly in
4062
- // browsers that do not support web components.
4063
- throw new TypeError('Illegal constructor');
4064
- }; // prototype inheritance dance
4065
-
4013
+ function removeActiveVM(vm) {
4014
+ if (process.env.NODE_ENV === 'production') {
4015
+ // this method should never leak to prod
4016
+ throw new ReferenceError();
4017
+ }
4066
4018
 
4067
- setPrototypeOf(HTMLBridgeElement, SuperClass);
4068
- setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
4069
- defineProperty(HTMLBridgeElement.prototype, 'constructor', {
4070
- writable: true,
4071
- configurable: true,
4072
- value: HTMLBridgeElement
4073
- });
4074
- } // generating the hash table for attributes to avoid duplicate fields and facilitate validation
4075
- // and false positives in case of inheritance.
4019
+ if (runtimeFlags.ENABLE_HMR) {
4020
+ // tracking inactive component
4021
+ var Ctor = vm.def.ctor;
4022
+ var list = activeComponents.get(Ctor);
4076
4023
 
4024
+ if (!isUndefined$1(list)) {
4025
+ // deleting the vm from the set to avoid leaking memory
4026
+ list.delete(vm);
4027
+ } // removing inactive template
4077
4028
 
4078
- var attributeToPropMap = create(null);
4079
- var superAttributeChangedCallback = SuperClass.prototype.attributeChangedCallback;
4080
- var _SuperClass$observedA = SuperClass.observedAttributes,
4081
- superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
4082
- var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
4083
4029
 
4084
- for (var _i12 = 0, _len3 = props.length; _i12 < _len3; _i12 += 1) {
4085
- var _propName2 = props[_i12];
4086
- attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
4087
- descriptors[_propName2] = {
4088
- get: createGetter(_propName2),
4089
- set: createSetter(_propName2),
4090
- enumerable: true,
4091
- configurable: true
4092
- };
4093
- } // expose public methods as props on the new Element Bridge
4030
+ var tpl = vm.cmpTemplate;
4094
4031
 
4032
+ if (tpl) {
4033
+ list = activeTemplates.get(tpl);
4095
4034
 
4096
- for (var _i13 = 0, _len4 = methods.length; _i13 < _len4; _i13 += 1) {
4097
- var methodName = methods[_i13];
4098
- descriptors[methodName] = {
4099
- value: createMethodCaller(methodName),
4100
- writable: true,
4101
- configurable: true
4102
- };
4103
- } // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
4104
- // map of attributes to props. We do this after all other props and methods to avoid the possibility
4105
- // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
4106
- // to preserve this definition.
4035
+ if (!isUndefined$1(list)) {
4036
+ // deleting the vm from the set to avoid leaking memory
4037
+ list.delete(vm);
4038
+ } // removing active styles associated to template
4107
4039
 
4108
4040
 
4109
- descriptors.attributeChangedCallback = {
4110
- value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
4111
- }; // Specify attributes for which we want to reflect changes back to their corresponding
4112
- // properties via attributeChangedCallback.
4041
+ var styles = tpl.stylesheets;
4113
4042
 
4114
- defineProperty(HTMLBridgeElement, 'observedAttributes', {
4115
- get: function get() {
4116
- return [].concat(_toConsumableArray(superObservedAttributes), _toConsumableArray(keys(attributeToPropMap)));
4043
+ if (!isUndefined$1(styles)) {
4044
+ flattenStylesheets(styles).forEach(function (style) {
4045
+ list = activeStyles.get(style);
4046
+
4047
+ if (!isUndefined$1(list)) {
4048
+ // deleting the vm from the set to avoid leaking memory
4049
+ list.delete(vm);
4050
+ }
4051
+ });
4052
+ }
4117
4053
  }
4118
- });
4119
- defineProperties(HTMLBridgeElement.prototype, descriptors);
4120
- return HTMLBridgeElement;
4054
+ }
4121
4055
  }
4122
4056
 
4123
- var BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor$1, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
4124
- freeze(BaseBridgeElement);
4125
- seal(BaseBridgeElement.prototype);
4126
- /*
4127
- * Copyright (c) 2020, salesforce.com, inc.
4128
- * All rights reserved.
4129
- * SPDX-License-Identifier: MIT
4130
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4131
- */
4057
+ function swapTemplate(oldTpl, newTpl) {
4058
+ if (process.env.NODE_ENV !== 'production') {
4059
+ if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
4060
+ swappedTemplateMap.set(oldTpl, newTpl);
4061
+ return rehydrateHotTemplate(oldTpl);
4062
+ } else {
4063
+ throw new TypeError("Invalid Template");
4064
+ }
4065
+ }
4132
4066
 
4133
- function resolveCircularModuleDependency(fn) {
4134
- var module = fn();
4135
- return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
4136
- }
4067
+ if (!runtimeFlags.ENABLE_HMR) {
4068
+ throw new Error('HMR is not enabled');
4069
+ }
4137
4070
 
4138
- function isCircularModuleDependency(obj) {
4139
- return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
4071
+ return false;
4140
4072
  }
4141
- /*
4142
- * Copyright (c) 2020, salesforce.com, inc.
4143
- * All rights reserved.
4144
- * SPDX-License-Identifier: MIT
4145
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4146
- */
4147
4073
 
4074
+ function swapComponent(oldComponent, newComponent) {
4075
+ if (process.env.NODE_ENV !== 'production') {
4076
+ if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
4077
+ swappedComponentMap.set(oldComponent, newComponent);
4078
+ return rehydrateHotComponent(oldComponent);
4079
+ } else {
4080
+ throw new TypeError("Invalid Component");
4081
+ }
4082
+ }
4148
4083
 
4149
- var swappedTemplateMap = new WeakMap();
4150
- var swappedComponentMap = new WeakMap();
4151
- var swappedStyleMap = new WeakMap();
4152
- var activeTemplates = new WeakMap();
4153
- var activeComponents = new WeakMap();
4154
- var activeStyles = new WeakMap();
4084
+ if (!runtimeFlags.ENABLE_HMR) {
4085
+ throw new Error('HMR is not enabled');
4086
+ }
4155
4087
 
4156
- function rehydrateHotTemplate(tpl) {
4157
- var list = activeTemplates.get(tpl);
4088
+ return false;
4089
+ }
4158
4090
 
4159
- if (!isUndefined$1(list)) {
4160
- list.forEach(function (vm) {
4161
- if (isFalse(vm.isDirty)) {
4162
- // forcing the vm to rehydrate in the micro-task:
4163
- markComponentAsDirty(vm);
4164
- scheduleRehydration(vm);
4165
- }
4166
- }); // resetting the Set to release the memory of those vm references
4167
- // since they are not longer related to this template, instead
4168
- // they will get re-associated once these instances are rehydrated.
4091
+ function swapStyle(oldStyle, newStyle) {
4092
+ if (process.env.NODE_ENV !== 'production') {
4093
+ // TODO [#1887]: once the support for registering styles is implemented
4094
+ // we can add the validation of both styles around this block.
4095
+ swappedStyleMap.set(oldStyle, newStyle);
4096
+ return rehydrateHotStyle(oldStyle);
4097
+ }
4169
4098
 
4170
- list.clear();
4099
+ if (!runtimeFlags.ENABLE_HMR) {
4100
+ throw new Error('HMR is not enabled');
4171
4101
  }
4172
4102
 
4173
- return true;
4103
+ return false;
4174
4104
  }
4105
+ /*
4106
+ * Copyright (c) 2018, salesforce.com, inc.
4107
+ * All rights reserved.
4108
+ * SPDX-License-Identifier: MIT
4109
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4110
+ */
4175
4111
 
4176
- function rehydrateHotStyle(style) {
4177
- var list = activeStyles.get(style);
4178
4112
 
4179
- if (!isUndefined$1(list)) {
4180
- list.forEach(function (vm) {
4181
- // if a style definition is swapped, we must reset
4182
- // vm's template content in the next micro-task:
4183
- forceRehydration(vm);
4184
- }); // resetting the Set to release the memory of those vm references
4185
- // since they are not longer related to this style, instead
4186
- // they will get re-associated once these instances are rehydrated.
4113
+ var CtorToDefMap = new WeakMap();
4187
4114
 
4188
- list.clear();
4189
- }
4115
+ function getCtorProto(Ctor) {
4116
+ var proto = getPrototypeOf$1(Ctor);
4190
4117
 
4191
- return true;
4192
- }
4118
+ if (isNull(proto)) {
4119
+ throw new ReferenceError("Invalid prototype chain for ".concat(Ctor.name, ", you must extend LightningElement."));
4120
+ } // covering the cases where the ref is circular in AMD
4193
4121
 
4194
- function rehydrateHotComponent(Ctor) {
4195
- var list = activeComponents.get(Ctor);
4196
- var canRefreshAllInstances = true;
4197
4122
 
4198
- if (!isUndefined$1(list)) {
4199
- list.forEach(function (vm) {
4200
- var owner = vm.owner;
4123
+ if (isCircularModuleDependency(proto)) {
4124
+ var p = resolveCircularModuleDependency(proto);
4201
4125
 
4202
- if (!isNull(owner)) {
4203
- // if a component class definition is swapped, we must reset
4204
- // owner's template content in the next micro-task:
4205
- forceRehydration(owner);
4206
- } else {
4207
- // the hot swapping for components only work for instances of components
4208
- // created from a template, root elements can't be swapped because we
4209
- // don't have a way to force the creation of the element with the same state
4210
- // of the current element.
4211
- // Instead, we can report the problem to the caller so it can take action,
4212
- // for example: reload the entire page.
4213
- canRefreshAllInstances = false;
4126
+ if (process.env.NODE_ENV !== 'production') {
4127
+ if (isNull(p)) {
4128
+ throw new ReferenceError("Circular module dependency for ".concat(Ctor.name, ", must resolve to a constructor that extends LightningElement."));
4214
4129
  }
4215
- }); // resetting the Set to release the memory of those vm references
4216
- // since they are not longer related to this constructor, instead
4217
- // they will get re-associated once these instances are rehydrated.
4130
+ } // escape hatch for Locker and other abstractions to provide their own base class instead
4131
+ // of our Base class without having to leak it to user-land. If the circular function returns
4132
+ // itself, that's the signal that we have hit the end of the proto chain, which must always
4133
+ // be base.
4218
4134
 
4219
- list.clear();
4135
+
4136
+ proto = p === proto ? LightningElement : p;
4220
4137
  }
4221
4138
 
4222
- return canRefreshAllInstances;
4139
+ return proto;
4223
4140
  }
4224
4141
 
4225
- function flattenStylesheets(stylesheets) {
4226
- var list = [];
4142
+ function createComponentDef(Ctor) {
4143
+ var ctorShadowSupportMode = Ctor.shadowSupportMode,
4144
+ ctorRenderMode = Ctor.renderMode;
4227
4145
 
4228
- var _iterator2 = _createForOfIteratorHelper(stylesheets),
4229
- _step2;
4146
+ if (process.env.NODE_ENV !== 'production') {
4147
+ var ctorName = Ctor.name; // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
4148
+ // assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
4230
4149
 
4231
- try {
4232
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4233
- var stylesheet = _step2.value;
4150
+ assert.isTrue(Ctor.constructor, "Missing ".concat(ctorName, ".constructor, ").concat(ctorName, " should have a \"constructor\" property."));
4234
4151
 
4235
- if (!Array.isArray(stylesheet)) {
4236
- list.push(stylesheet);
4237
- } else {
4238
- list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
4239
- }
4152
+ if (!isUndefined$1(ctorShadowSupportMode)) {
4153
+ assert.invariant(ctorShadowSupportMode === "any"
4154
+ /* Any */
4155
+ || ctorShadowSupportMode === "reset"
4156
+ /* Default */
4157
+ , "Invalid value for static property shadowSupportMode: '".concat(ctorShadowSupportMode, "'"));
4240
4158
  }
4241
- } catch (err) {
4242
- _iterator2.e(err);
4243
- } finally {
4244
- _iterator2.f();
4245
- }
4246
4159
 
4247
- return list;
4248
- }
4249
-
4250
- function getTemplateOrSwappedTemplate(tpl) {
4251
- if (process.env.NODE_ENV === 'production') {
4252
- // this method should never leak to prod
4253
- throw new ReferenceError();
4160
+ if (!isUndefined$1(ctorRenderMode)) {
4161
+ assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', "Invalid value for static property renderMode: '".concat(ctorRenderMode, "'. renderMode must be either 'light' or 'shadow'."));
4162
+ }
4254
4163
  }
4255
4164
 
4256
- if (runtimeFlags.ENABLE_HMR) {
4257
- var visited = new Set();
4165
+ var decoratorsMeta = getDecoratorsMeta(Ctor);
4166
+ var apiFields = decoratorsMeta.apiFields,
4167
+ apiFieldsConfig = decoratorsMeta.apiFieldsConfig,
4168
+ apiMethods = decoratorsMeta.apiMethods,
4169
+ wiredFields = decoratorsMeta.wiredFields,
4170
+ wiredMethods = decoratorsMeta.wiredMethods,
4171
+ observedFields = decoratorsMeta.observedFields;
4172
+ var proto = Ctor.prototype;
4173
+ var connectedCallback = proto.connectedCallback,
4174
+ disconnectedCallback = proto.disconnectedCallback,
4175
+ renderedCallback = proto.renderedCallback,
4176
+ errorCallback = proto.errorCallback,
4177
+ render = proto.render;
4178
+ var superProto = getCtorProto(Ctor);
4179
+ var superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
4180
+ var bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
4181
+ var props = assign(create(null), superDef.props, apiFields);
4182
+ var propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
4183
+ var methods = assign(create(null), superDef.methods, apiMethods);
4184
+ var wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
4185
+ connectedCallback = connectedCallback || superDef.connectedCallback;
4186
+ disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
4187
+ renderedCallback = renderedCallback || superDef.renderedCallback;
4188
+ errorCallback = errorCallback || superDef.errorCallback;
4189
+ render = render || superDef.render;
4190
+ var shadowSupportMode = superDef.shadowSupportMode;
4258
4191
 
4259
- while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
4260
- visited.add(tpl);
4261
- tpl = swappedTemplateMap.get(tpl);
4262
- }
4192
+ if (!isUndefined$1(ctorShadowSupportMode)) {
4193
+ shadowSupportMode = ctorShadowSupportMode;
4263
4194
  }
4264
4195
 
4265
- return tpl;
4266
- }
4196
+ var renderMode = superDef.renderMode;
4267
4197
 
4268
- function getComponentOrSwappedComponent(Ctor) {
4269
- if (process.env.NODE_ENV === 'production') {
4270
- // this method should never leak to prod
4271
- throw new ReferenceError();
4198
+ if (!isUndefined$1(ctorRenderMode)) {
4199
+ renderMode = ctorRenderMode === 'light' ? 0
4200
+ /* Light */
4201
+ : 1
4202
+ /* Shadow */
4203
+ ;
4272
4204
  }
4273
4205
 
4274
- if (runtimeFlags.ENABLE_HMR) {
4275
- var visited = new Set();
4276
-
4277
- while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
4278
- visited.add(Ctor);
4279
- Ctor = swappedComponentMap.get(Ctor);
4280
- }
4281
- }
4206
+ var template = getComponentRegisteredTemplate(Ctor) || superDef.template;
4207
+ var name = Ctor.name || superDef.name; // installing observed fields into the prototype.
4282
4208
 
4283
- return Ctor;
4284
- }
4209
+ defineProperties(proto, observedFields);
4210
+ var def = {
4211
+ ctor: Ctor,
4212
+ name: name,
4213
+ wire: wire,
4214
+ props: props,
4215
+ propsConfig: propsConfig,
4216
+ methods: methods,
4217
+ bridge: bridge,
4218
+ template: template,
4219
+ renderMode: renderMode,
4220
+ shadowSupportMode: shadowSupportMode,
4221
+ connectedCallback: connectedCallback,
4222
+ disconnectedCallback: disconnectedCallback,
4223
+ renderedCallback: renderedCallback,
4224
+ errorCallback: errorCallback,
4225
+ render: render
4226
+ };
4285
4227
 
4286
- function getStyleOrSwappedStyle(style) {
4287
- if (process.env.NODE_ENV === 'production') {
4288
- // this method should never leak to prod
4289
- throw new ReferenceError();
4228
+ if (process.env.NODE_ENV !== 'production') {
4229
+ freeze(Ctor.prototype);
4290
4230
  }
4291
4231
 
4292
- if (runtimeFlags.ENABLE_HMR) {
4293
- var visited = new Set();
4232
+ return def;
4233
+ }
4234
+ /**
4235
+ * EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
4236
+ * subject to change or being removed.
4237
+ */
4294
4238
 
4295
- while (swappedStyleMap.has(style) && !visited.has(style)) {
4296
- visited.add(style);
4297
- style = swappedStyleMap.get(style);
4298
- }
4299
- }
4300
4239
 
4301
- return style;
4302
- }
4240
+ function isComponentConstructor(ctor) {
4241
+ if (!isFunction$1(ctor)) {
4242
+ return false;
4243
+ } // Fast path: LightningElement is part of the prototype chain of the constructor.
4303
4244
 
4304
- function setActiveVM(vm) {
4305
- if (process.env.NODE_ENV === 'production') {
4306
- // this method should never leak to prod
4307
- throw new ReferenceError();
4308
- }
4309
4245
 
4310
- if (runtimeFlags.ENABLE_HMR) {
4311
- // tracking active component
4312
- var Ctor = vm.def.ctor;
4313
- var componentVMs = activeComponents.get(Ctor);
4246
+ if (ctor.prototype instanceof LightningElement) {
4247
+ return true;
4248
+ } // Slow path: LightningElement is not part of the prototype chain of the constructor, we need
4249
+ // climb up the constructor prototype chain to check in case there are circular dependencies
4250
+ // to resolve.
4314
4251
 
4315
- if (isUndefined$1(componentVMs)) {
4316
- componentVMs = new Set();
4317
- activeComponents.set(Ctor, componentVMs);
4318
- } // this will allow us to keep track of the hot components
4319
4252
 
4253
+ var current = ctor;
4320
4254
 
4321
- componentVMs.add(vm); // tracking active template
4255
+ do {
4256
+ if (isCircularModuleDependency(current)) {
4257
+ var circularResolved = resolveCircularModuleDependency(current); // If the circular function returns itself, that's the signal that we have hit the end
4258
+ // of the proto chain, which must always be a valid base constructor.
4322
4259
 
4323
- var tpl = vm.cmpTemplate;
4260
+ if (circularResolved === current) {
4261
+ return true;
4262
+ }
4324
4263
 
4325
- if (tpl) {
4326
- var templateVMs = activeTemplates.get(tpl);
4264
+ current = circularResolved;
4265
+ }
4327
4266
 
4328
- if (isUndefined$1(templateVMs)) {
4329
- templateVMs = new Set();
4330
- activeTemplates.set(tpl, templateVMs);
4331
- } // this will allow us to keep track of the templates that are
4332
- // being used by a hot component
4267
+ if (current === LightningElement) {
4268
+ return true;
4269
+ }
4270
+ } while (!isNull(current) && (current = getPrototypeOf$1(current))); // Finally return false if the LightningElement is not part of the prototype chain.
4333
4271
 
4334
4272
 
4335
- templateVMs.add(vm); // tracking active styles associated to template
4273
+ return false;
4274
+ }
4336
4275
 
4337
- var stylesheets = tpl.stylesheets;
4276
+ function getComponentInternalDef(Ctor) {
4277
+ if (process.env.NODE_ENV !== 'production') {
4278
+ Ctor = getComponentOrSwappedComponent(Ctor);
4279
+ }
4338
4280
 
4339
- if (!isUndefined$1(stylesheets)) {
4340
- flattenStylesheets(stylesheets).forEach(function (stylesheet) {
4341
- // this is necessary because we don't hold the list of styles
4342
- // in the vm, we only hold the selected (already swapped template)
4343
- // but the styles attached to the template might not be the actual
4344
- // active ones, but the swapped versions of those.
4345
- stylesheet = getStyleOrSwappedStyle(stylesheet);
4346
- var stylesheetVMs = activeStyles.get(stylesheet);
4281
+ var def = CtorToDefMap.get(Ctor);
4347
4282
 
4348
- if (isUndefined$1(stylesheetVMs)) {
4349
- stylesheetVMs = new Set();
4350
- activeStyles.set(stylesheet, stylesheetVMs);
4351
- } // this will allow us to keep track of the stylesheet that are
4352
- // being used by a hot component
4283
+ if (isUndefined$1(def)) {
4284
+ if (isCircularModuleDependency(Ctor)) {
4285
+ var resolvedCtor = resolveCircularModuleDependency(Ctor);
4286
+ def = getComponentInternalDef(resolvedCtor); // Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
4287
+ // look up the definition in cache instead of re-resolving and recreating the def.
4353
4288
 
4289
+ CtorToDefMap.set(Ctor, def);
4290
+ return def;
4291
+ }
4354
4292
 
4355
- stylesheetVMs.add(vm);
4356
- });
4357
- }
4293
+ if (!isComponentConstructor(Ctor)) {
4294
+ throw new TypeError("".concat(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."));
4358
4295
  }
4359
- }
4360
- }
4361
4296
 
4362
- function removeActiveVM(vm) {
4363
- if (process.env.NODE_ENV === 'production') {
4364
- // this method should never leak to prod
4365
- throw new ReferenceError();
4297
+ def = createComponentDef(Ctor);
4298
+ CtorToDefMap.set(Ctor, def);
4366
4299
  }
4367
4300
 
4368
- if (runtimeFlags.ENABLE_HMR) {
4369
- // tracking inactive component
4370
- var Ctor = vm.def.ctor;
4371
- var list = activeComponents.get(Ctor);
4301
+ return def;
4302
+ }
4372
4303
 
4373
- if (!isUndefined$1(list)) {
4374
- // deleting the vm from the set to avoid leaking memory
4375
- list.delete(vm);
4376
- } // removing inactive template
4304
+ var lightingElementDef = {
4305
+ ctor: LightningElement,
4306
+ name: LightningElement.name,
4307
+ props: lightningBasedDescriptors,
4308
+ propsConfig: EmptyObject,
4309
+ methods: EmptyObject,
4310
+ renderMode: 1
4311
+ /* Shadow */
4312
+ ,
4313
+ shadowSupportMode: "reset"
4314
+ /* Default */
4315
+ ,
4316
+ wire: EmptyObject,
4317
+ bridge: BaseBridgeElement,
4318
+ template: defaultEmptyTemplate,
4319
+ render: LightningElement.prototype.render
4320
+ };
4321
+ /**
4322
+ * EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
4323
+ * subject to change or being removed.
4324
+ */
4377
4325
 
4326
+ function getComponentDef(Ctor) {
4327
+ var def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
4328
+ // for some external services, e.g.: Locker Service, usually, all they care
4329
+ // is about the shape of the constructor, the internals of it are not relevant
4330
+ // because they don't have a way to mess with that.
4378
4331
 
4379
- var tpl = vm.cmpTemplate;
4332
+ var ctor = def.ctor,
4333
+ name = def.name,
4334
+ props = def.props,
4335
+ propsConfig = def.propsConfig,
4336
+ methods = def.methods;
4337
+ var publicProps = {};
4380
4338
 
4381
- if (tpl) {
4382
- list = activeTemplates.get(tpl);
4339
+ for (var key in props) {
4340
+ // avoid leaking the reference to the public props descriptors
4341
+ publicProps[key] = {
4342
+ config: propsConfig[key] || 0,
4343
+ type: "any"
4344
+ /* any */
4345
+ ,
4346
+ attr: htmlPropertyToAttribute(key)
4347
+ };
4348
+ }
4383
4349
 
4384
- if (!isUndefined$1(list)) {
4385
- // deleting the vm from the set to avoid leaking memory
4386
- list.delete(vm);
4387
- } // removing active styles associated to template
4350
+ var publicMethods = {};
4388
4351
 
4352
+ for (var _key2 in methods) {
4353
+ // avoid leaking the reference to the public method descriptors
4354
+ publicMethods[_key2] = methods[_key2].value;
4355
+ }
4389
4356
 
4390
- var styles = tpl.stylesheets;
4357
+ return {
4358
+ ctor: ctor,
4359
+ name: name,
4360
+ props: publicProps,
4361
+ methods: publicMethods
4362
+ };
4363
+ }
4364
+ /*
4365
+ * Copyright (c) 2018, salesforce.com, inc.
4366
+ * All rights reserved.
4367
+ * SPDX-License-Identifier: MIT
4368
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4369
+ */
4391
4370
 
4392
- if (!isUndefined$1(styles)) {
4393
- flattenStylesheets(styles).forEach(function (style) {
4394
- list = activeStyles.get(style);
4395
4371
 
4396
- if (!isUndefined$1(list)) {
4397
- // deleting the vm from the set to avoid leaking memory
4398
- list.delete(vm);
4399
- }
4400
- });
4401
- }
4402
- }
4403
- }
4404
- }
4372
+ var xlinkNS = 'http://www.w3.org/1999/xlink';
4373
+ var xmlNS = 'http://www.w3.org/XML/1998/namespace';
4374
+ var ColonCharCode = 58;
4405
4375
 
4406
- function swapTemplate(oldTpl, newTpl) {
4407
- if (process.env.NODE_ENV !== 'production') {
4408
- if (isTemplateRegistered(oldTpl) && isTemplateRegistered(newTpl)) {
4409
- swappedTemplateMap.set(oldTpl, newTpl);
4410
- return rehydrateHotTemplate(oldTpl);
4411
- } else {
4412
- throw new TypeError("Invalid Template");
4413
- }
4414
- }
4376
+ function patchAttributes(oldVnode, vnode) {
4377
+ var attrs = vnode.data.attrs;
4415
4378
 
4416
- if (!runtimeFlags.ENABLE_HMR) {
4417
- throw new Error('HMR is not enabled');
4379
+ if (isUndefined$1(attrs)) {
4380
+ return;
4418
4381
  }
4419
4382
 
4420
- return false;
4421
- }
4383
+ var oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
4422
4384
 
4423
- function swapComponent(oldComponent, newComponent) {
4424
- if (process.env.NODE_ENV !== 'production') {
4425
- if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
4426
- swappedComponentMap.set(oldComponent, newComponent);
4427
- return rehydrateHotComponent(oldComponent);
4428
- } else {
4429
- throw new TypeError("Invalid Component");
4430
- }
4385
+ if (oldAttrs === attrs) {
4386
+ return;
4431
4387
  }
4432
4388
 
4433
- if (!runtimeFlags.ENABLE_HMR) {
4434
- throw new Error('HMR is not enabled');
4435
- }
4389
+ var elm = vnode.elm;
4436
4390
 
4437
- return false;
4438
- }
4391
+ for (var key in attrs) {
4392
+ var cur = attrs[key];
4393
+ var old = oldAttrs[key];
4439
4394
 
4440
- function swapStyle(oldStyle, newStyle) {
4441
- if (process.env.NODE_ENV !== 'production') {
4442
- // TODO [#1887]: once the support for registering styles is implemented
4443
- // we can add the validation of both styles around this block.
4444
- swappedStyleMap.set(oldStyle, newStyle);
4445
- return rehydrateHotStyle(oldStyle);
4446
- }
4395
+ if (old !== cur) {
4396
+ unlockAttribute(elm, key);
4447
4397
 
4448
- if (!runtimeFlags.ENABLE_HMR) {
4449
- throw new Error('HMR is not enabled');
4450
- }
4398
+ if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
4399
+ // Assume xml namespace
4400
+ setAttribute$1(elm, key, cur, xmlNS);
4401
+ } else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
4402
+ // Assume xlink namespace
4403
+ setAttribute$1(elm, key, cur, xlinkNS);
4404
+ } else if (isNull(cur) || isUndefined$1(cur)) {
4405
+ removeAttribute$1(elm, key);
4406
+ } else {
4407
+ setAttribute$1(elm, key, cur);
4408
+ }
4451
4409
 
4452
- return false;
4410
+ lockAttribute();
4411
+ }
4412
+ }
4453
4413
  }
4454
4414
  /*
4455
4415
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4459,256 +4419,212 @@ var LWC = (function (exports) {
4459
4419
  */
4460
4420
 
4461
4421
 
4462
- var CtorToDefMap = new WeakMap();
4422
+ function isLiveBindingProp(sel, key) {
4423
+ // For properties with live bindings, we read values from the DOM element
4424
+ // instead of relying on internally tracked values.
4425
+ return sel === 'input' && (key === 'value' || key === 'checked');
4426
+ }
4463
4427
 
4464
- function getCtorProto(Ctor) {
4465
- var proto = getPrototypeOf$1(Ctor);
4428
+ function patchProps(oldVnode, vnode) {
4429
+ var props = vnode.data.props;
4466
4430
 
4467
- if (isNull(proto)) {
4468
- throw new ReferenceError("Invalid prototype chain for ".concat(Ctor.name, ", you must extend LightningElement."));
4469
- } // covering the cases where the ref is circular in AMD
4431
+ if (isUndefined$1(props)) {
4432
+ return;
4433
+ }
4470
4434
 
4435
+ var oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
4471
4436
 
4472
- if (isCircularModuleDependency(proto)) {
4473
- var p = resolveCircularModuleDependency(proto);
4437
+ if (oldProps === props) {
4438
+ return;
4439
+ }
4474
4440
 
4475
- if (process.env.NODE_ENV !== 'production') {
4476
- if (isNull(p)) {
4477
- throw new ReferenceError("Circular module dependency for ".concat(Ctor.name, ", must resolve to a constructor that extends LightningElement."));
4478
- }
4479
- } // escape hatch for Locker and other abstractions to provide their own base class instead
4480
- // of our Base class without having to leak it to user-land. If the circular function returns
4481
- // itself, that's the signal that we have hit the end of the proto chain, which must always
4482
- // be base.
4441
+ var isFirstPatch = isNull(oldVnode);
4442
+ var elm = vnode.elm,
4443
+ sel = vnode.sel;
4483
4444
 
4445
+ for (var key in props) {
4446
+ var cur = props[key]; // Set the property if it's the first time is is patched or if the previous property is
4447
+ // different than the one previously set.
4484
4448
 
4485
- proto = p === proto ? LightningElement : p;
4449
+ if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
4450
+ setProperty$1(elm, key, cur);
4451
+ }
4486
4452
  }
4487
-
4488
- return proto;
4489
4453
  }
4454
+ /*
4455
+ * Copyright (c) 2018, salesforce.com, inc.
4456
+ * All rights reserved.
4457
+ * SPDX-License-Identifier: MIT
4458
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4459
+ */
4490
4460
 
4491
- function createComponentDef(Ctor) {
4492
- var ctorShadowSupportMode = Ctor.shadowSupportMode,
4493
- ctorRenderMode = Ctor.renderMode;
4494
-
4495
- if (process.env.NODE_ENV !== 'production') {
4496
- var ctorName = Ctor.name; // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
4497
- // assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
4498
4461
 
4499
- assert.isTrue(Ctor.constructor, "Missing ".concat(ctorName, ".constructor, ").concat(ctorName, " should have a \"constructor\" property."));
4462
+ var classNameToClassMap = create(null);
4500
4463
 
4501
- if (!isUndefined$1(ctorShadowSupportMode)) {
4502
- assert.invariant(ctorShadowSupportMode === "any"
4503
- /* Any */
4504
- || ctorShadowSupportMode === "reset"
4505
- /* Default */
4506
- , "Invalid value for static property shadowSupportMode: '".concat(ctorShadowSupportMode, "'"));
4507
- }
4464
+ function getMapFromClassName(className) {
4465
+ // Intentionally using == to match undefined and null values from computed style attribute
4466
+ if (className == null) {
4467
+ return EmptyObject;
4468
+ } // computed class names must be string
4508
4469
 
4509
- if (!isUndefined$1(ctorRenderMode)) {
4510
- assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', "Invalid value for static property renderMode: '".concat(ctorRenderMode, "'. renderMode must be either 'light' or 'shadow'."));
4511
- }
4512
- }
4513
4470
 
4514
- var decoratorsMeta = getDecoratorsMeta(Ctor);
4515
- var apiFields = decoratorsMeta.apiFields,
4516
- apiFieldsConfig = decoratorsMeta.apiFieldsConfig,
4517
- apiMethods = decoratorsMeta.apiMethods,
4518
- wiredFields = decoratorsMeta.wiredFields,
4519
- wiredMethods = decoratorsMeta.wiredMethods,
4520
- observedFields = decoratorsMeta.observedFields;
4521
- var proto = Ctor.prototype;
4522
- var connectedCallback = proto.connectedCallback,
4523
- disconnectedCallback = proto.disconnectedCallback,
4524
- renderedCallback = proto.renderedCallback,
4525
- errorCallback = proto.errorCallback,
4526
- render = proto.render;
4527
- var superProto = getCtorProto(Ctor);
4528
- var superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
4529
- var bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
4530
- var props = assign(create(null), superDef.props, apiFields);
4531
- var propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
4532
- var methods = assign(create(null), superDef.methods, apiMethods);
4533
- var wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
4534
- connectedCallback = connectedCallback || superDef.connectedCallback;
4535
- disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
4536
- renderedCallback = renderedCallback || superDef.renderedCallback;
4537
- errorCallback = errorCallback || superDef.errorCallback;
4538
- render = render || superDef.render;
4539
- var shadowSupportMode = superDef.shadowSupportMode;
4471
+ className = isString(className) ? className : className + '';
4472
+ var map = classNameToClassMap[className];
4540
4473
 
4541
- if (!isUndefined$1(ctorShadowSupportMode)) {
4542
- shadowSupportMode = ctorShadowSupportMode;
4474
+ if (map) {
4475
+ return map;
4543
4476
  }
4544
4477
 
4545
- var renderMode = superDef.renderMode;
4478
+ map = create(null);
4479
+ var start = 0;
4480
+ var o;
4481
+ var len = className.length;
4546
4482
 
4547
- if (!isUndefined$1(ctorRenderMode)) {
4548
- renderMode = ctorRenderMode === 'light' ? 0
4549
- /* Light */
4550
- : 1
4551
- /* Shadow */
4552
- ;
4483
+ for (o = 0; o < len; o++) {
4484
+ if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
4485
+ if (o > start) {
4486
+ map[StringSlice.call(className, start, o)] = true;
4487
+ }
4488
+
4489
+ start = o + 1;
4490
+ }
4553
4491
  }
4554
4492
 
4555
- var template = getComponentRegisteredTemplate(Ctor) || superDef.template;
4556
- var name = Ctor.name || superDef.name; // installing observed fields into the prototype.
4493
+ if (o > start) {
4494
+ map[StringSlice.call(className, start, o)] = true;
4495
+ }
4557
4496
 
4558
- defineProperties(proto, observedFields);
4559
- var def = {
4560
- ctor: Ctor,
4561
- name: name,
4562
- wire: wire,
4563
- props: props,
4564
- propsConfig: propsConfig,
4565
- methods: methods,
4566
- bridge: bridge,
4567
- template: template,
4568
- renderMode: renderMode,
4569
- shadowSupportMode: shadowSupportMode,
4570
- connectedCallback: connectedCallback,
4571
- disconnectedCallback: disconnectedCallback,
4572
- renderedCallback: renderedCallback,
4573
- errorCallback: errorCallback,
4574
- render: render
4575
- };
4497
+ classNameToClassMap[className] = map;
4576
4498
 
4577
4499
  if (process.env.NODE_ENV !== 'production') {
4578
- freeze(Ctor.prototype);
4500
+ // just to make sure that this object never changes as part of the diffing algo
4501
+ freeze(map);
4579
4502
  }
4580
4503
 
4581
- return def;
4504
+ return map;
4582
4505
  }
4583
- /**
4584
- * EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
4585
- * subject to change or being removed.
4586
- */
4587
-
4588
-
4589
- function isComponentConstructor(ctor) {
4590
- if (!isFunction$1(ctor)) {
4591
- return false;
4592
- } // Fast path: LightningElement is part of the prototype chain of the constructor.
4593
4506
 
4507
+ function patchClassAttribute(oldVnode, vnode) {
4508
+ var elm = vnode.elm,
4509
+ newClass = vnode.data.className;
4510
+ var oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
4594
4511
 
4595
- if (ctor.prototype instanceof LightningElement) {
4596
- return true;
4597
- } // Slow path: LightningElement is not part of the prototype chain of the constructor, we need
4598
- // climb up the constructor prototype chain to check in case there are circular dependencies
4599
- // to resolve.
4600
-
4512
+ if (oldClass === newClass) {
4513
+ return;
4514
+ }
4601
4515
 
4602
- var current = ctor;
4516
+ var classList = getClassList$1(elm);
4517
+ var newClassMap = getMapFromClassName(newClass);
4518
+ var oldClassMap = getMapFromClassName(oldClass);
4519
+ var name;
4603
4520
 
4604
- do {
4605
- if (isCircularModuleDependency(current)) {
4606
- var circularResolved = resolveCircularModuleDependency(current); // If the circular function returns itself, that's the signal that we have hit the end
4607
- // of the proto chain, which must always be a valid base constructor.
4521
+ for (name in oldClassMap) {
4522
+ // remove only if it is not in the new class collection and it is not set from within the instance
4523
+ if (isUndefined$1(newClassMap[name])) {
4524
+ classList.remove(name);
4525
+ }
4526
+ }
4608
4527
 
4609
- if (circularResolved === current) {
4610
- return true;
4611
- }
4528
+ for (name in newClassMap) {
4529
+ if (isUndefined$1(oldClassMap[name])) {
4530
+ classList.add(name);
4531
+ }
4532
+ }
4533
+ }
4534
+ /*
4535
+ * Copyright (c) 2018, salesforce.com, inc.
4536
+ * All rights reserved.
4537
+ * SPDX-License-Identifier: MIT
4538
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4539
+ */
4612
4540
 
4613
- current = circularResolved;
4614
- }
4615
4541
 
4616
- if (current === LightningElement) {
4617
- return true;
4618
- }
4619
- } while (!isNull(current) && (current = getPrototypeOf$1(current))); // Finally return false if the LightningElement is not part of the prototype chain.
4542
+ function patchStyleAttribute(oldVnode, vnode) {
4543
+ var elm = vnode.elm,
4544
+ newStyle = vnode.data.style;
4545
+ var oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
4620
4546
 
4547
+ if (oldStyle === newStyle) {
4548
+ return;
4549
+ }
4621
4550
 
4622
- return false;
4551
+ if (!isString(newStyle) || newStyle === '') {
4552
+ removeAttribute$1(elm, 'style');
4553
+ } else {
4554
+ setAttribute$1(elm, 'style', newStyle);
4555
+ }
4623
4556
  }
4557
+ /*
4558
+ * Copyright (c) 2018, salesforce.com, inc.
4559
+ * All rights reserved.
4560
+ * SPDX-License-Identifier: MIT
4561
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4562
+ */
4624
4563
 
4625
- function getComponentInternalDef(Ctor) {
4626
- if (process.env.NODE_ENV !== 'production') {
4627
- Ctor = getComponentOrSwappedComponent(Ctor);
4628
- }
4629
4564
 
4630
- var def = CtorToDefMap.get(Ctor);
4565
+ function applyEventListeners(vnode) {
4566
+ var elm = vnode.elm,
4567
+ on = vnode.data.on;
4631
4568
 
4632
- if (isUndefined$1(def)) {
4633
- if (isCircularModuleDependency(Ctor)) {
4634
- var resolvedCtor = resolveCircularModuleDependency(Ctor);
4635
- def = getComponentInternalDef(resolvedCtor); // Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
4636
- // look up the definition in cache instead of re-resolving and recreating the def.
4569
+ if (isUndefined$1(on)) {
4570
+ return;
4571
+ }
4637
4572
 
4638
- CtorToDefMap.set(Ctor, def);
4639
- return def;
4640
- }
4573
+ for (var name in on) {
4574
+ var handler = on[name];
4575
+ addEventListener$1(elm, name, handler);
4576
+ }
4577
+ }
4578
+ /*
4579
+ * Copyright (c) 2018, salesforce.com, inc.
4580
+ * All rights reserved.
4581
+ * SPDX-License-Identifier: MIT
4582
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4583
+ */
4584
+ // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
4585
+ // different classnames properties individually instead of via a string.
4641
4586
 
4642
- if (!isComponentConstructor(Ctor)) {
4643
- throw new TypeError("".concat(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."));
4644
- }
4645
4587
 
4646
- def = createComponentDef(Ctor);
4647
- CtorToDefMap.set(Ctor, def);
4588
+ function applyStaticClassAttribute(vnode) {
4589
+ var elm = vnode.elm,
4590
+ classMap = vnode.data.classMap;
4591
+
4592
+ if (isUndefined$1(classMap)) {
4593
+ return;
4648
4594
  }
4649
4595
 
4650
- return def;
4651
- }
4596
+ var classList = getClassList$1(elm);
4652
4597
 
4653
- var lightingElementDef = {
4654
- ctor: LightningElement,
4655
- name: LightningElement.name,
4656
- props: lightningBasedDescriptors,
4657
- propsConfig: EmptyObject,
4658
- methods: EmptyObject,
4659
- renderMode: 1
4660
- /* Shadow */
4661
- ,
4662
- shadowSupportMode: "reset"
4663
- /* Default */
4664
- ,
4665
- wire: EmptyObject,
4666
- bridge: BaseBridgeElement,
4667
- template: defaultEmptyTemplate,
4668
- render: LightningElement.prototype.render
4669
- };
4670
- /**
4671
- * EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
4672
- * subject to change or being removed.
4598
+ for (var name in classMap) {
4599
+ classList.add(name);
4600
+ }
4601
+ }
4602
+ /*
4603
+ * Copyright (c) 2018, salesforce.com, inc.
4604
+ * All rights reserved.
4605
+ * SPDX-License-Identifier: MIT
4606
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4673
4607
  */
4608
+ // The compiler takes care of transforming the inline style into an object. It's faster to set the
4609
+ // different style properties individually instead of via a string.
4674
4610
 
4675
- function getComponentDef(Ctor) {
4676
- var def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
4677
- // for some external services, e.g.: Locker Service, usually, all they care
4678
- // is about the shape of the constructor, the internals of it are not relevant
4679
- // because they don't have a way to mess with that.
4680
4611
 
4681
- var ctor = def.ctor,
4682
- name = def.name,
4683
- props = def.props,
4684
- propsConfig = def.propsConfig,
4685
- methods = def.methods;
4686
- var publicProps = {};
4612
+ function applyStaticStyleAttribute(vnode) {
4613
+ var elm = vnode.elm,
4614
+ styleDecls = vnode.data.styleDecls;
4687
4615
 
4688
- for (var key in props) {
4689
- // avoid leaking the reference to the public props descriptors
4690
- publicProps[key] = {
4691
- config: propsConfig[key] || 0,
4692
- type: "any"
4693
- /* any */
4694
- ,
4695
- attr: htmlPropertyToAttribute(key)
4696
- };
4616
+ if (isUndefined$1(styleDecls)) {
4617
+ return;
4697
4618
  }
4698
4619
 
4699
- var publicMethods = {};
4620
+ for (var _i13 = 0; _i13 < styleDecls.length; _i13++) {
4621
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i13], 3),
4622
+ prop = _styleDecls$_i[0],
4623
+ value = _styleDecls$_i[1],
4624
+ important = _styleDecls$_i[2];
4700
4625
 
4701
- for (var _key2 in methods) {
4702
- // avoid leaking the reference to the public method descriptors
4703
- publicMethods[_key2] = methods[_key2].value;
4626
+ setCSSStyleProperty$1(elm, prop, value, important);
4704
4627
  }
4705
-
4706
- return {
4707
- ctor: ctor,
4708
- name: name,
4709
- props: publicProps,
4710
- methods: publicMethods
4711
- };
4712
4628
  }
4713
4629
  /*
4714
4630
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4778,28 +4694,24 @@ var LWC = (function (exports) {
4778
4694
  }
4779
4695
  }
4780
4696
 
4781
- function createElmHook(vnode) {
4782
- modEvents.create(vnode); // Attrs need to be applied to element before props
4783
- // IE11 will wipe out value on radio inputs if value
4784
- // is set before type=radio.
4697
+ function patchElementPropsAndAttrs(oldVnode, vnode) {
4698
+ if (isNull(oldVnode)) {
4699
+ applyEventListeners(vnode);
4700
+ applyStaticClassAttribute(vnode);
4701
+ applyStaticStyleAttribute(vnode);
4702
+ } // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
4703
+ // value is set before type=radio.
4785
4704
 
4786
- modAttrs.create(vnode);
4787
- modProps.create(vnode);
4788
- modStaticClassName.create(vnode);
4789
- modStaticStyle.create(vnode);
4790
- modComputedClassName.create(vnode);
4791
- modComputedStyle.create(vnode);
4705
+
4706
+ patchClassAttribute(oldVnode, vnode);
4707
+ patchStyleAttribute(oldVnode, vnode);
4708
+ patchAttributes(oldVnode, vnode);
4709
+ patchProps(oldVnode, vnode);
4792
4710
  }
4793
4711
 
4794
4712
  function hydrateElmHook(vnode) {
4795
- modEvents.create(vnode); // Attrs are already on the element.
4796
- // modAttrs.create(vnode);
4797
-
4798
- modProps.create(vnode); // Already set.
4799
- // modStaticClassName.create(vnode);
4800
- // modStaticStyle.create(vnode);
4801
- // modComputedClassName.create(vnode);
4802
- // modComputedStyle.create(vnode);
4713
+ applyEventListeners(vnode);
4714
+ patchProps(null, vnode);
4803
4715
  }
4804
4716
 
4805
4717
  function fallbackElmHook(elm, vnode) {
@@ -4839,24 +4751,11 @@ var LWC = (function (exports) {
4839
4751
  }
4840
4752
  }
4841
4753
 
4842
- function updateElmHook(oldVnode, vnode) {
4843
- // Attrs need to be applied to element before props
4844
- // IE11 will wipe out value on radio inputs if value
4845
- // is set before type=radio.
4846
- modAttrs.update(oldVnode, vnode);
4847
- modProps.update(oldVnode, vnode);
4848
- modComputedClassName.update(oldVnode, vnode);
4849
- modComputedStyle.update(oldVnode, vnode);
4850
- }
4851
-
4852
- function updateChildrenHook(oldVnode, vnode) {
4853
- var elm = vnode.elm,
4854
- children = vnode.children;
4855
-
4856
- if (hasDynamicChildren(children)) {
4857
- updateDynamicChildren(elm, oldVnode.children, children);
4754
+ function patchChildren(parent, oldCh, newCh) {
4755
+ if (hasDynamicChildren(newCh)) {
4756
+ updateDynamicChildren(parent, oldCh, newCh);
4858
4757
  } else {
4859
- updateStaticChildren(elm, oldVnode.children, children);
4758
+ updateStaticChildren(parent, oldCh, newCh);
4860
4759
  }
4861
4760
  }
4862
4761
 
@@ -4925,19 +4824,6 @@ var LWC = (function (exports) {
4925
4824
  }
4926
4825
  }
4927
4826
 
4928
- function createCustomElmHook(vnode) {
4929
- modEvents.create(vnode); // Attrs need to be applied to element before props
4930
- // IE11 will wipe out value on radio inputs if value
4931
- // is set before type=radio.
4932
-
4933
- modAttrs.create(vnode);
4934
- modProps.create(vnode);
4935
- modStaticClassName.create(vnode);
4936
- modStaticStyle.create(vnode);
4937
- modComputedClassName.create(vnode);
4938
- modComputedStyle.create(vnode);
4939
- }
4940
-
4941
4827
  function createChildrenHook(vnode) {
4942
4828
  var elm = vnode.elm,
4943
4829
  children = vnode.children;
@@ -5117,16 +5003,6 @@ var LWC = (function (exports) {
5117
5003
  }
5118
5004
  }
5119
5005
 
5120
- function updateCustomElmHook(oldVnode, vnode) {
5121
- // Attrs need to be applied to element before props
5122
- // IE11 will wipe out value on radio inputs if value
5123
- // is set before type=radio.
5124
- modAttrs.update(oldVnode, vnode);
5125
- modProps.update(oldVnode, vnode);
5126
- modComputedClassName.update(oldVnode, vnode);
5127
- modComputedStyle.update(oldVnode, vnode);
5128
- }
5129
-
5130
5006
  function removeElmHook(vnode) {
5131
5007
  // this method only needs to search on child vnodes from template
5132
5008
  // to trigger the remove hook just in case some of those children
@@ -5141,6 +5017,62 @@ var LWC = (function (exports) {
5141
5017
  ch.hook.remove(ch, elm);
5142
5018
  }
5143
5019
  }
5020
+ }
5021
+
5022
+ function allocateInSlot(vm, children) {
5023
+ var oldSlots = vm.cmpSlots;
5024
+ var cmpSlots = vm.cmpSlots = create(null);
5025
+
5026
+ for (var _i16 = 0, _len6 = children.length; _i16 < _len6; _i16 += 1) {
5027
+ var vnode = children[_i16];
5028
+
5029
+ if (isNull(vnode)) {
5030
+ continue;
5031
+ }
5032
+
5033
+ var data = vnode.data;
5034
+ var slotName = data.attrs && data.attrs.slot || '';
5035
+ var vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
5036
+ // which might have similar keys. Each vnode will always have a key that
5037
+ // starts with a numeric character from compiler. In this case, we add a unique
5038
+ // notation for slotted vnodes keys, e.g.: `@foo:1:1`
5039
+
5040
+ if (!isUndefined$1(vnode.key)) {
5041
+ vnode.key = "@".concat(slotName, ":").concat(vnode.key);
5042
+ }
5043
+
5044
+ ArrayPush$1.call(vnodes, vnode);
5045
+ }
5046
+
5047
+ if (isFalse(vm.isDirty)) {
5048
+ // We need to determine if the old allocation is really different from the new one
5049
+ // and mark the vm as dirty
5050
+ var oldKeys = keys(oldSlots);
5051
+
5052
+ if (oldKeys.length !== keys(cmpSlots).length) {
5053
+ markComponentAsDirty(vm);
5054
+ return;
5055
+ }
5056
+
5057
+ for (var _i17 = 0, _len7 = oldKeys.length; _i17 < _len7; _i17 += 1) {
5058
+ var key = oldKeys[_i17];
5059
+
5060
+ if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5061
+ markComponentAsDirty(vm);
5062
+ return;
5063
+ }
5064
+
5065
+ var oldVNodes = oldSlots[key];
5066
+ var _vnodes = cmpSlots[key];
5067
+
5068
+ for (var j = 0, a = cmpSlots[key].length; j < a; j += 1) {
5069
+ if (oldVNodes[j] !== _vnodes[j]) {
5070
+ markComponentAsDirty(vm);
5071
+ return;
5072
+ }
5073
+ }
5074
+ }
5075
+ }
5144
5076
  } // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
5145
5077
 
5146
5078
 
@@ -5291,11 +5223,11 @@ var LWC = (function (exports) {
5291
5223
  linkNodeToShadow(elm, owner);
5292
5224
  fallbackElmHook(elm, vnode);
5293
5225
  vnode.elm = elm;
5294
- createElmHook(vnode);
5226
+ patchElementPropsAndAttrs(null, vnode);
5295
5227
  },
5296
5228
  update: function update(oldVnode, vnode) {
5297
- updateElmHook(oldVnode, vnode);
5298
- updateChildrenHook(oldVnode, vnode);
5229
+ patchElementPropsAndAttrs(oldVnode, vnode);
5230
+ patchChildren(vnode.elm, oldVnode.children, vnode.children);
5299
5231
  },
5300
5232
  insert: function insert(vnode, parentNode, referenceNode) {
5301
5233
  insertNodeHook(vnode, parentNode, referenceNode);
@@ -5363,10 +5295,10 @@ var LWC = (function (exports) {
5363
5295
  throw new TypeError("Incorrect Component Constructor");
5364
5296
  }
5365
5297
 
5366
- createCustomElmHook(vnode);
5298
+ patchElementPropsAndAttrs(null, vnode);
5367
5299
  },
5368
5300
  update: function update(oldVnode, vnode) {
5369
- updateCustomElmHook(oldVnode, vnode);
5301
+ patchElementPropsAndAttrs(oldVnode, vnode);
5370
5302
  var vm = getAssociatedVMIfPresent(vnode.elm);
5371
5303
 
5372
5304
  if (vm) {
@@ -5377,7 +5309,7 @@ var LWC = (function (exports) {
5377
5309
  // will happen, but in native, it does allocate the light dom
5378
5310
 
5379
5311
 
5380
- updateChildrenHook(oldVnode, vnode);
5312
+ patchChildren(vnode.elm, oldVnode.children, vnode.children);
5381
5313
 
5382
5314
  if (vm) {
5383
5315
  if (process.env.NODE_ENV !== 'production') {
@@ -6039,8 +5971,8 @@ var LWC = (function (exports) {
6039
5971
  var content = [];
6040
5972
  var root;
6041
5973
 
6042
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
6043
- var stylesheet = stylesheets[_i16];
5974
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
5975
+ var stylesheet = stylesheets[_i18];
6044
5976
 
6045
5977
  if (isArray$1(stylesheet)) {
6046
5978
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -6150,8 +6082,8 @@ var LWC = (function (exports) {
6150
6082
  && shadowMode === 1
6151
6083
  /* Synthetic */
6152
6084
  ) {
6153
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
6154
- insertGlobalStylesheet$1(stylesheets[_i17]);
6085
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6086
+ insertGlobalStylesheet$1(stylesheets[_i19]);
6155
6087
  }
6156
6088
  } else if (ssr$1 || isHydrating$1()) {
6157
6089
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -6165,12 +6097,12 @@ var LWC = (function (exports) {
6165
6097
  var root = getNearestNativeShadowComponent(vm);
6166
6098
  var isGlobal = isNull(root);
6167
6099
 
6168
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
6100
+ for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
6169
6101
  if (isGlobal) {
6170
- insertGlobalStylesheet$1(stylesheets[_i18]);
6102
+ insertGlobalStylesheet$1(stylesheets[_i20]);
6171
6103
  } else {
6172
6104
  // local level
6173
- insertStylesheet$1(stylesheets[_i18], root.cmpRoot);
6105
+ insertStylesheet$1(stylesheets[_i20], root.cmpRoot);
6174
6106
  }
6175
6107
  }
6176
6108
  }
@@ -6447,8 +6379,8 @@ var LWC = (function (exports) {
6447
6379
  var stylesheets = template.stylesheets;
6448
6380
 
6449
6381
  if (!isUndefined$1(stylesheets)) {
6450
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6451
- if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
6382
+ for (var _i21 = 0; _i21 < stylesheets.length; _i21++) {
6383
+ if (isTrue(stylesheets[_i21][KEY__SCOPED_CSS])) {
6452
6384
  return true;
6453
6385
  }
6454
6386
  }
@@ -6678,8 +6610,8 @@ var LWC = (function (exports) {
6678
6610
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6679
6611
  }
6680
6612
 
6681
- for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6682
- var hookName = hooks[_i20];
6613
+ for (var _i22 = 0; _i22 < hooks.length; ++_i22) {
6614
+ var hookName = hooks[_i22];
6683
6615
 
6684
6616
  if (hookName in service) {
6685
6617
  var l = Services[hookName];
@@ -6702,8 +6634,8 @@ var LWC = (function (exports) {
6702
6634
  def = vm.def,
6703
6635
  context = vm.context;
6704
6636
 
6705
- for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
6706
- cbs[_i21].call(undefined, component, {}, def, context);
6637
+ for (var _i23 = 0, _len8 = cbs.length; _i23 < _len8; ++_i23) {
6638
+ cbs[_i23].call(undefined, component, {}, def, context);
6707
6639
  }
6708
6640
  }
6709
6641
  /*
@@ -7016,7 +6948,6 @@ var LWC = (function (exports) {
7016
6948
  // patch function mutates vnodes by adding the element reference,
7017
6949
  // however, if patching fails it contains partial changes.
7018
6950
  if (oldCh !== newCh) {
7019
- var fn = hasDynamicChildren(newCh) ? updateDynamicChildren : updateStaticChildren;
7020
6951
  runWithBoundaryProtection(vm, vm, function () {
7021
6952
  // pre
7022
6953
  logOperationStart(2
@@ -7024,8 +6955,8 @@ var LWC = (function (exports) {
7024
6955
  , vm);
7025
6956
  }, function () {
7026
6957
  // job
7027
- var elementToRenderTo = getRenderRoot(vm);
7028
- fn(elementToRenderTo, oldCh, newCh);
6958
+ var renderRoot = getRenderRoot(vm);
6959
+ patchChildren(renderRoot, oldCh, newCh);
7029
6960
  }, function () {
7030
6961
  // post
7031
6962
  logOperationEnd(2
@@ -7086,19 +7017,19 @@ var LWC = (function (exports) {
7086
7017
  });
7087
7018
  rehydrateQueue = []; // reset to a new queue
7088
7019
 
7089
- for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
7090
- var vm = vms[_i22];
7020
+ for (var _i24 = 0, _len9 = vms.length; _i24 < _len9; _i24 += 1) {
7021
+ var vm = vms[_i24];
7091
7022
 
7092
7023
  try {
7093
7024
  rehydrate(vm);
7094
7025
  } catch (error) {
7095
- if (_i22 + 1 < _len7) {
7026
+ if (_i24 + 1 < _len9) {
7096
7027
  // pieces of the queue are still pending to be rehydrated, those should have priority
7097
7028
  if (rehydrateQueue.length === 0) {
7098
7029
  addCallbackToNextTick(flushRehydrationQueue);
7099
7030
  }
7100
7031
 
7101
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
7032
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i24 + 1));
7102
7033
  } // we need to end the measure before throwing.
7103
7034
 
7104
7035
 
@@ -7202,8 +7133,8 @@ var LWC = (function (exports) {
7202
7133
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
7203
7134
  // inserted in reserved order.
7204
7135
 
7205
- for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
7206
- var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
7136
+ for (var _i25 = vCustomElementCollection.length - 1; _i25 >= 0; _i25 -= 1) {
7137
+ var elm = vCustomElementCollection[_i25].elm; // There are two cases where the element could be undefined:
7207
7138
  // * when there is an error during the construction phase, and an error
7208
7139
  // boundary picks it, there is a possibility that the VCustomElement
7209
7140
  // is not properly initialized, and therefore is should be ignored.
@@ -7237,8 +7168,8 @@ var LWC = (function (exports) {
7237
7168
 
7238
7169
 
7239
7170
  function recursivelyDisconnectChildren(vnodes) {
7240
- for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
7241
- var vnode = vnodes[_i24];
7171
+ for (var _i26 = 0, _len10 = vnodes.length; _i26 < _len10; _i26 += 1) {
7172
+ var vnode = vnodes[_i26];
7242
7173
 
7243
7174
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
7244
7175
  // vnode is a VElement with children
@@ -7261,8 +7192,8 @@ var LWC = (function (exports) {
7261
7192
  var children = vm.children;
7262
7193
  var rootNode = getRenderRoot(vm);
7263
7194
 
7264
- for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
7265
- var child = children[_i25];
7195
+ for (var _i27 = 0, _len11 = children.length; _i27 < _len11; _i27++) {
7196
+ var child = children[_i27];
7266
7197
 
7267
7198
  if (!isNull(child) && !isUndefined$1(child.elm)) {
7268
7199
  remove$1(child.elm, rootNode);
@@ -7298,65 +7229,6 @@ var LWC = (function (exports) {
7298
7229
 
7299
7230
  currentVm = currentVm.owner;
7300
7231
  }
7301
- } // slow path routine
7302
- // NOTE: we should probably more this routine to the synthetic shadow folder
7303
- // and get the allocation to be cached by in the elm instead of in the VM
7304
-
7305
-
7306
- function allocateInSlot(vm, children) {
7307
- var oldSlots = vm.cmpSlots;
7308
- var cmpSlots = vm.cmpSlots = create(null);
7309
-
7310
- for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
7311
- var vnode = children[_i26];
7312
-
7313
- if (isNull(vnode)) {
7314
- continue;
7315
- }
7316
-
7317
- var data = vnode.data;
7318
- var slotName = data.attrs && data.attrs.slot || '';
7319
- var vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
7320
- // which might have similar keys. Each vnode will always have a key that
7321
- // starts with a numeric character from compiler. In this case, we add a unique
7322
- // notation for slotted vnodes keys, e.g.: `@foo:1:1`
7323
-
7324
- if (!isUndefined$1(vnode.key)) {
7325
- vnode.key = "@".concat(slotName, ":").concat(vnode.key);
7326
- }
7327
-
7328
- ArrayPush$1.call(vnodes, vnode);
7329
- }
7330
-
7331
- if (isFalse(vm.isDirty)) {
7332
- // We need to determine if the old allocation is really different from the new one
7333
- // and mark the vm as dirty
7334
- var oldKeys = keys(oldSlots);
7335
-
7336
- if (oldKeys.length !== keys(cmpSlots).length) {
7337
- markComponentAsDirty(vm);
7338
- return;
7339
- }
7340
-
7341
- for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
7342
- var key = oldKeys[_i27];
7343
-
7344
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
7345
- markComponentAsDirty(vm);
7346
- return;
7347
- }
7348
-
7349
- var oldVNodes = oldSlots[key];
7350
- var _vnodes = cmpSlots[key];
7351
-
7352
- for (var j = 0, a = cmpSlots[key].length; j < a; j += 1) {
7353
- if (oldVNodes[j] !== _vnodes[j]) {
7354
- markComponentAsDirty(vm);
7355
- return;
7356
- }
7357
- }
7358
- }
7359
- }
7360
7232
  }
7361
7233
 
7362
7234
  function runWithBoundaryProtection(vm, owner, pre, job, post) {
@@ -7801,7 +7673,7 @@ var LWC = (function (exports) {
7801
7673
  hooksAreSet = true;
7802
7674
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7803
7675
  }
7804
- /* version: 2.7.2 */
7676
+ /* version: 2.7.3 */
7805
7677
 
7806
7678
  /*
7807
7679
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8536,7 +8408,7 @@ var LWC = (function (exports) {
8536
8408
  });
8537
8409
  freeze(LightningElement);
8538
8410
  seal(LightningElement.prototype);
8539
- /* version: 2.7.2 */
8411
+ /* version: 2.7.3 */
8540
8412
 
8541
8413
  exports.LightningElement = LightningElement;
8542
8414
  exports.__unstable__ProfilerControl = profilerControl;