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
@@ -344,7 +344,7 @@
344
344
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
345
345
  return attributeName;
346
346
  }
347
- /** version: 2.7.2 */
347
+ /** version: 2.7.3 */
348
348
 
349
349
  /*
350
350
  * Copyright (c) 2018, salesforce.com, inc.
@@ -514,7 +514,7 @@
514
514
 
515
515
  function setFeatureFlagForTest(name, value) {
516
516
  }
517
- /** version: 2.7.2 */
517
+ /** version: 2.7.3 */
518
518
 
519
519
  /* proxy-compat-disable */
520
520
 
@@ -1007,52 +1007,205 @@
1007
1007
  */
1008
1008
 
1009
1009
 
1010
- function handleEvent(event, vnode) {
1011
- var type = event.type;
1012
- var on = vnode.data.on;
1013
- var handler = on && on[type]; // call event handler if exists
1010
+ function isUndef(s) {
1011
+ return s === undefined;
1012
+ }
1013
+
1014
+ function sameVnode(vnode1, vnode2) {
1015
+ return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
1016
+ }
1017
+
1018
+ function isVNode(vnode) {
1019
+ return vnode != null;
1020
+ }
1021
+
1022
+ function createKeyToOldIdx(children, beginIdx, endIdx) {
1023
+ var map = {};
1024
+ var j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
1025
+
1026
+ for (j = beginIdx; j <= endIdx; ++j) {
1027
+ ch = children[j];
1028
+
1029
+ if (isVNode(ch)) {
1030
+ key = ch.key;
1014
1031
 
1015
- if (handler) {
1016
- handler.call(undefined, event);
1032
+ if (key !== undefined) {
1033
+ map[key] = j;
1034
+ }
1035
+ }
1017
1036
  }
1037
+
1038
+ return map;
1018
1039
  }
1019
1040
 
1020
- function createListener() {
1021
- return function handler(event) {
1022
- handleEvent(event, handler.vnode);
1023
- };
1041
+ function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
1042
+ for (; startIdx <= endIdx; ++startIdx) {
1043
+ var ch = vnodes[startIdx];
1044
+
1045
+ if (isVNode(ch)) {
1046
+ ch.hook.create(ch);
1047
+ ch.hook.insert(ch, parentElm, before);
1048
+ }
1049
+ }
1024
1050
  }
1025
1051
 
1026
- function updateAllEventListeners(oldVnode, vnode) {
1027
- if (isUndefined$1(oldVnode.listener)) {
1028
- createAllEventListeners(vnode);
1029
- } else {
1030
- vnode.listener = oldVnode.listener;
1031
- vnode.listener.vnode = vnode;
1052
+ function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
1053
+ for (; startIdx <= endIdx; ++startIdx) {
1054
+ var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
1055
+
1056
+ if (isVNode(ch)) {
1057
+ ch.hook.remove(ch, parentElm);
1058
+ }
1032
1059
  }
1033
1060
  }
1034
1061
 
1035
- function createAllEventListeners(vnode) {
1036
- var elm = vnode.elm,
1037
- on = vnode.data.on;
1062
+ function updateDynamicChildren(parentElm, oldCh, newCh) {
1063
+ var oldStartIdx = 0;
1064
+ var newStartIdx = 0;
1065
+ var oldEndIdx = oldCh.length - 1;
1066
+ var oldStartVnode = oldCh[0];
1067
+ var oldEndVnode = oldCh[oldEndIdx];
1068
+ var newChEnd = newCh.length - 1;
1069
+ var newEndIdx = newChEnd;
1070
+ var newStartVnode = newCh[0];
1071
+ var newEndVnode = newCh[newEndIdx];
1072
+ var oldKeyToIdx;
1073
+ var idxInOld;
1074
+ var elmToMove;
1075
+ var before;
1038
1076
 
1039
- if (isUndefined$1(on)) {
1077
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1078
+ if (!isVNode(oldStartVnode)) {
1079
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
1080
+ } else if (!isVNode(oldEndVnode)) {
1081
+ oldEndVnode = oldCh[--oldEndIdx];
1082
+ } else if (!isVNode(newStartVnode)) {
1083
+ newStartVnode = newCh[++newStartIdx];
1084
+ } else if (!isVNode(newEndVnode)) {
1085
+ newEndVnode = newCh[--newEndIdx];
1086
+ } else if (sameVnode(oldStartVnode, newStartVnode)) {
1087
+ patchVnode(oldStartVnode, newStartVnode);
1088
+ oldStartVnode = oldCh[++oldStartIdx];
1089
+ newStartVnode = newCh[++newStartIdx];
1090
+ } else if (sameVnode(oldEndVnode, newEndVnode)) {
1091
+ patchVnode(oldEndVnode, newEndVnode);
1092
+ oldEndVnode = oldCh[--oldEndIdx];
1093
+ newEndVnode = newCh[--newEndIdx];
1094
+ } else if (sameVnode(oldStartVnode, newEndVnode)) {
1095
+ // Vnode moved right
1096
+ patchVnode(oldStartVnode, newEndVnode);
1097
+ newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
1098
+ oldStartVnode = oldCh[++oldStartIdx];
1099
+ newEndVnode = newCh[--newEndIdx];
1100
+ } else if (sameVnode(oldEndVnode, newStartVnode)) {
1101
+ // Vnode moved left
1102
+ patchVnode(oldEndVnode, newStartVnode);
1103
+ newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
1104
+ oldEndVnode = oldCh[--oldEndIdx];
1105
+ newStartVnode = newCh[++newStartIdx];
1106
+ } else {
1107
+ if (oldKeyToIdx === undefined) {
1108
+ oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
1109
+ }
1110
+
1111
+ idxInOld = oldKeyToIdx[newStartVnode.key];
1112
+
1113
+ if (isUndef(idxInOld)) {
1114
+ // New element
1115
+ newStartVnode.hook.create(newStartVnode);
1116
+ newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1117
+ newStartVnode = newCh[++newStartIdx];
1118
+ } else {
1119
+ elmToMove = oldCh[idxInOld];
1120
+
1121
+ if (isVNode(elmToMove)) {
1122
+ if (elmToMove.sel !== newStartVnode.sel) {
1123
+ // New element
1124
+ newStartVnode.hook.create(newStartVnode);
1125
+ newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1126
+ } else {
1127
+ patchVnode(elmToMove, newStartVnode);
1128
+ oldCh[idxInOld] = undefined;
1129
+ newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
1130
+ }
1131
+ }
1132
+
1133
+ newStartVnode = newCh[++newStartIdx];
1134
+ }
1135
+ }
1136
+ }
1137
+
1138
+ if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
1139
+ if (oldStartIdx > oldEndIdx) {
1140
+ // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
1141
+ // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
1142
+ var _i6 = newEndIdx;
1143
+ var n;
1144
+
1145
+ do {
1146
+ n = newCh[++_i6];
1147
+ } while (!isVNode(n) && _i6 < newChEnd);
1148
+
1149
+ before = isVNode(n) ? n.elm : null;
1150
+ addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
1151
+ } else {
1152
+ removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
1153
+ }
1154
+ }
1155
+ }
1156
+
1157
+ function updateStaticChildren(parentElm, oldCh, newCh) {
1158
+ var oldChLength = oldCh.length;
1159
+ var newChLength = newCh.length;
1160
+
1161
+ if (oldChLength === 0) {
1162
+ // the old list is empty, we can directly insert anything new
1163
+ addVnodes(parentElm, null, newCh, 0, newChLength);
1040
1164
  return;
1041
1165
  }
1042
1166
 
1043
- var listener = vnode.listener = createListener();
1044
- listener.vnode = vnode;
1045
- var name;
1167
+ if (newChLength === 0) {
1168
+ // the old list is nonempty and the new list is empty so we can directly remove all old nodes
1169
+ // this is the case in which the dynamic children of an if-directive should be removed
1170
+ removeVnodes(parentElm, oldCh, 0, oldChLength);
1171
+ return;
1172
+ } // if the old list is not empty, the new list MUST have the same
1173
+ // amount of nodes, that's why we call this static children
1174
+
1175
+
1176
+ var referenceElm = null;
1177
+
1178
+ for (var _i7 = newChLength - 1; _i7 >= 0; _i7 -= 1) {
1179
+ var vnode = newCh[_i7];
1180
+ var oldVNode = oldCh[_i7];
1181
+
1182
+ if (vnode !== oldVNode) {
1183
+ if (isVNode(oldVNode)) {
1184
+ if (isVNode(vnode)) {
1185
+ // both vnodes must be equivalent, and se just need to patch them
1186
+ patchVnode(oldVNode, vnode);
1187
+ referenceElm = vnode.elm;
1188
+ } else {
1189
+ // removing the old vnode since the new one is null
1190
+ oldVNode.hook.remove(oldVNode, parentElm);
1191
+ }
1192
+ } else if (isVNode(vnode)) {
1193
+ // this condition is unnecessary
1194
+ vnode.hook.create(vnode); // insert the new node one since the old one is null
1046
1195
 
1047
- for (name in on) {
1048
- addEventListener$1(elm, name, listener);
1196
+ vnode.hook.insert(vnode, parentElm, referenceElm);
1197
+ referenceElm = vnode.elm;
1198
+ }
1199
+ }
1049
1200
  }
1050
1201
  }
1051
1202
 
1052
- var modEvents = {
1053
- update: updateAllEventListeners,
1054
- create: createAllEventListeners
1055
- };
1203
+ function patchVnode(oldVnode, vnode) {
1204
+ if (oldVnode !== vnode) {
1205
+ vnode.elm = oldVnode.elm;
1206
+ vnode.hook.update(oldVnode, vnode);
1207
+ }
1208
+ }
1056
1209
  /*
1057
1210
  * Copyright (c) 2018, salesforce.com, inc.
1058
1211
  * All rights reserved.
@@ -1060,6 +1213,7 @@
1060
1213
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1061
1214
  */
1062
1215
 
1216
+
1063
1217
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1064
1218
 
1065
1219
  function offsetPropertyErrorMessage(name) {
@@ -1177,64 +1331,12 @@
1177
1331
  * SPDX-License-Identifier: MIT
1178
1332
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1179
1333
  */
1334
+ // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
1335
+ // to inject at runtime.
1180
1336
 
1181
1337
 
1182
- var xlinkNS = 'http://www.w3.org/1999/xlink';
1183
- var xmlNS = 'http://www.w3.org/XML/1998/namespace';
1184
- var ColonCharCode = 58;
1185
-
1186
- function updateAttrs(oldVnode, vnode) {
1187
- var attrs = vnode.data.attrs;
1188
-
1189
- if (isUndefined$1(attrs)) {
1190
- return;
1191
- }
1192
-
1193
- var oldAttrs = oldVnode.data.attrs;
1194
-
1195
- if (oldAttrs === attrs) {
1196
- return;
1197
- }
1198
-
1199
- var elm = vnode.elm;
1200
- var key;
1201
- oldAttrs = isUndefined$1(oldAttrs) ? EmptyObject : oldAttrs; // update modified attributes, add new attributes
1202
- // this routine is only useful for data-* attributes in all kind of elements
1203
- // and aria-* in standard elements (custom elements will use props for these)
1204
-
1205
- for (key in attrs) {
1206
- var cur = attrs[key];
1207
- var old = oldAttrs[key];
1208
-
1209
- if (old !== cur) {
1210
- unlockAttribute(elm, key);
1211
-
1212
- if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
1213
- // Assume xml namespace
1214
- setAttribute$1(elm, key, cur, xmlNS);
1215
- } else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
1216
- // Assume xlink namespace
1217
- setAttribute$1(elm, key, cur, xlinkNS);
1218
- } else if (isNull(cur) || isUndefined$1(cur)) {
1219
- removeAttribute$1(elm, key);
1220
- } else {
1221
- setAttribute$1(elm, key, cur);
1222
- }
1223
-
1224
- lockAttribute();
1225
- }
1226
- }
1227
- }
1228
-
1229
- var emptyVNode$3 = {
1230
- data: {}
1231
- };
1232
- var modAttrs = {
1233
- create: function create(vnode) {
1234
- return updateAttrs(emptyVNode$3, vnode);
1235
- },
1236
- update: updateAttrs
1237
- };
1338
+ var HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
1339
+ var HTMLElementPrototype = HTMLElementConstructor$1.prototype;
1238
1340
  /*
1239
1341
  * Copyright (c) 2018, salesforce.com, inc.
1240
1342
  * All rights reserved.
@@ -1242,1109 +1344,1077 @@
1242
1344
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1243
1345
  */
1244
1346
 
1245
- function isLiveBindingProp(sel, key) {
1246
- // For properties with live bindings, we read values from the DOM element
1247
- // instead of relying on internally tracked values.
1248
- return sel === 'input' && (key === 'value' || key === 'checked');
1249
- }
1347
+ /**
1348
+ * This is a descriptor map that contains
1349
+ * all standard properties that a Custom Element can support (including AOM properties), which
1350
+ * determines what kind of capabilities the Base HTML Element and
1351
+ * Base Lightning Element should support.
1352
+ */
1250
1353
 
1251
- function update(oldVnode, vnode) {
1252
- var props = vnode.data.props;
1354
+ var HTMLElementOriginalDescriptors = create(null);
1355
+ forEach.call(keys(AriaPropNameToAttrNameMap), function (propName) {
1356
+ // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1357
+ // in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
1358
+ var descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
1253
1359
 
1254
- if (isUndefined$1(props)) {
1255
- return;
1360
+ if (!isUndefined$1(descriptor)) {
1361
+ HTMLElementOriginalDescriptors[propName] = descriptor;
1256
1362
  }
1257
-
1258
- var oldProps = oldVnode.data.props;
1259
-
1260
- if (oldProps === props) {
1261
- return;
1363
+ });
1364
+ forEach.call(defaultDefHTMLPropertyNames, function (propName) {
1365
+ // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1366
+ // in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
1367
+ // this category, so, better to be sure.
1368
+ var descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
1369
+
1370
+ if (!isUndefined$1(descriptor)) {
1371
+ HTMLElementOriginalDescriptors[propName] = descriptor;
1262
1372
  }
1373
+ });
1374
+ /**
1375
+ * Copyright (C) 2017 salesforce.com, inc.
1376
+ */
1263
1377
 
1264
- var isFirstPatch = isUndefined$1(oldProps);
1265
- var elm = vnode.elm,
1266
- sel = vnode.sel;
1378
+ var isArray = Array.isArray;
1379
+ var ObjectDotPrototype = Object.prototype,
1380
+ _getPrototypeOf = Object.getPrototypeOf,
1381
+ ObjectCreate = Object.create,
1382
+ ObjectDefineProperty = Object.defineProperty,
1383
+ _isExtensible = Object.isExtensible,
1384
+ _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor,
1385
+ getOwnPropertyNames = Object.getOwnPropertyNames,
1386
+ getOwnPropertySymbols = Object.getOwnPropertySymbols,
1387
+ _preventExtensions = Object.preventExtensions,
1388
+ hasOwnProperty = Object.hasOwnProperty;
1389
+ var _Array$prototype2 = Array.prototype,
1390
+ ArrayPush = _Array$prototype2.push,
1391
+ ArrayConcat = _Array$prototype2.concat;
1267
1392
 
1268
- for (var key in props) {
1269
- var cur = props[key]; // if it is the first time this element is patched, or the current value is different to the previous value...
1393
+ function isUndefined(obj) {
1394
+ return obj === undefined;
1395
+ }
1270
1396
 
1271
- if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
1272
- setProperty$1(elm, key, cur);
1273
- }
1274
- }
1397
+ function isFunction(obj) {
1398
+ return typeof obj === 'function';
1275
1399
  }
1276
1400
 
1277
- var emptyVNode$2 = {
1278
- data: {}
1279
- };
1280
- var modProps = {
1281
- create: function create(vnode) {
1282
- return update(emptyVNode$2, vnode);
1283
- },
1284
- update: update
1285
- };
1286
- /*
1287
- * Copyright (c) 2018, salesforce.com, inc.
1288
- * All rights reserved.
1289
- * SPDX-License-Identifier: MIT
1290
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1291
- */
1401
+ var proxyToValueMap = new WeakMap();
1292
1402
 
1293
- var classNameToClassMap = create(null);
1403
+ function registerProxy(proxy, value) {
1404
+ proxyToValueMap.set(proxy, value);
1405
+ }
1294
1406
 
1295
- function getMapFromClassName(className) {
1296
- // Intentionally using == to match undefined and null values from computed style attribute
1297
- if (className == null) {
1298
- return EmptyObject;
1299
- } // computed class names must be string
1407
+ var unwrap$1 = function unwrap$1(replicaOrAny) {
1408
+ return proxyToValueMap.get(replicaOrAny) || replicaOrAny;
1409
+ };
1410
+
1411
+ var BaseProxyHandler = /*#__PURE__*/function () {
1412
+ function BaseProxyHandler(membrane, value) {
1413
+ _classCallCheck(this, BaseProxyHandler);
1300
1414
 
1415
+ this.originalTarget = value;
1416
+ this.membrane = membrane;
1417
+ } // Shared utility methods
1301
1418
 
1302
- className = isString(className) ? className : className + '';
1303
- var map = classNameToClassMap[className];
1304
1419
 
1305
- if (map) {
1306
- return map;
1307
- }
1420
+ _createClass(BaseProxyHandler, [{
1421
+ key: "wrapDescriptor",
1422
+ value: function wrapDescriptor(descriptor) {
1423
+ if (hasOwnProperty.call(descriptor, 'value')) {
1424
+ descriptor.value = this.wrapValue(descriptor.value);
1425
+ } else {
1426
+ var originalSet = descriptor.set,
1427
+ originalGet = descriptor.get;
1308
1428
 
1309
- map = create(null);
1310
- var start = 0;
1311
- var o;
1312
- var len = className.length;
1429
+ if (!isUndefined(originalGet)) {
1430
+ descriptor.get = this.wrapGetter(originalGet);
1431
+ }
1313
1432
 
1314
- for (o = 0; o < len; o++) {
1315
- if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
1316
- if (o > start) {
1317
- map[StringSlice.call(className, start, o)] = true;
1433
+ if (!isUndefined(originalSet)) {
1434
+ descriptor.set = this.wrapSetter(originalSet);
1435
+ }
1318
1436
  }
1319
1437
 
1320
- start = o + 1;
1438
+ return descriptor;
1321
1439
  }
1322
- }
1323
-
1324
- if (o > start) {
1325
- map[StringSlice.call(className, start, o)] = true;
1326
- }
1440
+ }, {
1441
+ key: "copyDescriptorIntoShadowTarget",
1442
+ value: function copyDescriptorIntoShadowTarget(shadowTarget, key) {
1443
+ var originalTarget = this.originalTarget; // Note: a property might get defined multiple times in the shadowTarget
1444
+ // but it will always be compatible with the previous descriptor
1445
+ // to preserve the object invariants, which makes these lines safe.
1327
1446
 
1328
- classNameToClassMap[className] = map;
1447
+ var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1329
1448
 
1330
- return map;
1331
- }
1449
+ /* istanbul ignore else */
1332
1450
 
1333
- function updateClassAttribute(oldVnode, vnode) {
1334
- var elm = vnode.elm,
1335
- newClass = vnode.data.className;
1336
- var oldClass = oldVnode.data.className;
1337
1451
 
1338
- if (oldClass === newClass) {
1339
- return;
1340
- }
1452
+ if (!isUndefined(originalDescriptor)) {
1453
+ var wrappedDesc = this.wrapDescriptor(originalDescriptor);
1454
+ ObjectDefineProperty(shadowTarget, key, wrappedDesc);
1455
+ }
1456
+ }
1457
+ }, {
1458
+ key: "lockShadowTarget",
1459
+ value: function lockShadowTarget(shadowTarget) {
1460
+ var _this = this;
1341
1461
 
1342
- var classList = getClassList$1(elm);
1343
- var newClassMap = getMapFromClassName(newClass);
1344
- var oldClassMap = getMapFromClassName(oldClass);
1345
- var name;
1462
+ var originalTarget = this.originalTarget;
1463
+ var targetKeys = ArrayConcat.call(getOwnPropertyNames(originalTarget), getOwnPropertySymbols(originalTarget));
1464
+ targetKeys.forEach(function (key) {
1465
+ _this.copyDescriptorIntoShadowTarget(shadowTarget, key);
1466
+ });
1467
+ var tagPropertyKey = this.membrane.tagPropertyKey;
1346
1468
 
1347
- for (name in oldClassMap) {
1348
- // remove only if it is not in the new class collection and it is not set from within the instance
1349
- if (isUndefined$1(newClassMap[name])) {
1350
- classList.remove(name);
1351
- }
1352
- }
1469
+ if (!isUndefined(tagPropertyKey) && !hasOwnProperty.call(shadowTarget, tagPropertyKey)) {
1470
+ ObjectDefineProperty(shadowTarget, tagPropertyKey, ObjectCreate(null));
1471
+ }
1353
1472
 
1354
- for (name in newClassMap) {
1355
- if (isUndefined$1(oldClassMap[name])) {
1356
- classList.add(name);
1357
- }
1358
- }
1359
- }
1473
+ _preventExtensions(shadowTarget);
1474
+ } // Shared Traps
1475
+ // TODO: apply() is never called
1360
1476
 
1361
- var emptyVNode$1 = {
1362
- data: {}
1363
- };
1364
- var modComputedClassName = {
1365
- create: function create(vnode) {
1366
- return updateClassAttribute(emptyVNode$1, vnode);
1367
- },
1368
- update: updateClassAttribute
1369
- };
1370
- /*
1371
- * Copyright (c) 2018, salesforce.com, inc.
1372
- * All rights reserved.
1373
- * SPDX-License-Identifier: MIT
1374
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1375
- */
1477
+ /* istanbul ignore next */
1376
1478
 
1377
- function updateStyleAttribute(oldVnode, vnode) {
1378
- var elm = vnode.elm,
1379
- newStyle = vnode.data.style;
1479
+ }, {
1480
+ key: "apply",
1481
+ value: function apply(shadowTarget, thisArg, argArray) {
1482
+ /* No op */
1483
+ } // TODO: construct() is never called
1380
1484
 
1381
- if (oldVnode.data.style === newStyle) {
1382
- return;
1383
- }
1485
+ /* istanbul ignore next */
1384
1486
 
1385
- if (!isString(newStyle) || newStyle === '') {
1386
- removeAttribute$1(elm, 'style');
1387
- } else {
1388
- setAttribute$1(elm, 'style', newStyle);
1389
- }
1390
- }
1487
+ }, {
1488
+ key: "construct",
1489
+ value: function construct(shadowTarget, argArray, newTarget) {
1490
+ /* No op */
1491
+ }
1492
+ }, {
1493
+ key: "get",
1494
+ value: function get(shadowTarget, key) {
1495
+ var originalTarget = this.originalTarget,
1496
+ valueObserved = this.membrane.valueObserved;
1497
+ var value = originalTarget[key];
1498
+ valueObserved(originalTarget, key);
1499
+ return this.wrapValue(value);
1500
+ }
1501
+ }, {
1502
+ key: "has",
1503
+ value: function has(shadowTarget, key) {
1504
+ var originalTarget = this.originalTarget,
1505
+ _this$membrane = this.membrane,
1506
+ tagPropertyKey = _this$membrane.tagPropertyKey,
1507
+ valueObserved = _this$membrane.valueObserved;
1508
+ valueObserved(originalTarget, key); // since key is never going to be undefined, and tagPropertyKey might be undefined
1509
+ // we can simply compare them as the second part of the condition.
1391
1510
 
1392
- var emptyVNode = {
1393
- data: {}
1394
- };
1395
- var modComputedStyle = {
1396
- create: function create(vnode) {
1397
- return updateStyleAttribute(emptyVNode, vnode);
1398
- },
1399
- update: updateStyleAttribute
1400
- };
1401
- /*
1402
- * Copyright (c) 2018, salesforce.com, inc.
1403
- * All rights reserved.
1404
- * SPDX-License-Identifier: MIT
1405
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1406
- */
1407
- // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
1408
- // different classnames properties individually instead of via a string.
1511
+ return key in originalTarget || key === tagPropertyKey;
1512
+ }
1513
+ }, {
1514
+ key: "ownKeys",
1515
+ value: function ownKeys(shadowTarget) {
1516
+ var originalTarget = this.originalTarget,
1517
+ tagPropertyKey = this.membrane.tagPropertyKey; // if the membrane tag key exists and it is not in the original target, we add it to the keys.
1409
1518
 
1410
- function createClassAttribute(vnode) {
1411
- var elm = vnode.elm,
1412
- classMap = vnode.data.classMap;
1519
+ var keys = isUndefined(tagPropertyKey) || hasOwnProperty.call(originalTarget, tagPropertyKey) ? [] : [tagPropertyKey]; // small perf optimization using push instead of concat to avoid creating an extra array
1413
1520
 
1414
- if (isUndefined$1(classMap)) {
1415
- return;
1416
- }
1521
+ ArrayPush.apply(keys, getOwnPropertyNames(originalTarget));
1522
+ ArrayPush.apply(keys, getOwnPropertySymbols(originalTarget));
1523
+ return keys;
1524
+ }
1525
+ }, {
1526
+ key: "isExtensible",
1527
+ value: function isExtensible(shadowTarget) {
1528
+ var originalTarget = this.originalTarget; // optimization to avoid attempting to lock down the shadowTarget multiple times
1417
1529
 
1418
- var classList = getClassList$1(elm);
1530
+ if (!_isExtensible(shadowTarget)) {
1531
+ return false; // was already locked down
1532
+ }
1419
1533
 
1420
- for (var name in classMap) {
1421
- classList.add(name);
1422
- }
1423
- }
1534
+ if (!_isExtensible(originalTarget)) {
1535
+ this.lockShadowTarget(shadowTarget);
1536
+ return false;
1537
+ }
1424
1538
 
1425
- var modStaticClassName = {
1426
- create: createClassAttribute
1427
- };
1428
- /*
1429
- * Copyright (c) 2018, salesforce.com, inc.
1430
- * All rights reserved.
1431
- * SPDX-License-Identifier: MIT
1432
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1433
- */
1434
- // The compiler takes care of transforming the inline style into an object. It's faster to set the
1435
- // different style properties individually instead of via a string.
1539
+ return true;
1540
+ }
1541
+ }, {
1542
+ key: "getPrototypeOf",
1543
+ value: function getPrototypeOf(shadowTarget) {
1544
+ var originalTarget = this.originalTarget;
1545
+ return _getPrototypeOf(originalTarget);
1546
+ }
1547
+ }, {
1548
+ key: "getOwnPropertyDescriptor",
1549
+ value: function getOwnPropertyDescriptor(shadowTarget, key) {
1550
+ var originalTarget = this.originalTarget,
1551
+ _this$membrane2 = this.membrane,
1552
+ valueObserved = _this$membrane2.valueObserved,
1553
+ tagPropertyKey = _this$membrane2.tagPropertyKey; // keys looked up via getOwnPropertyDescriptor need to be reactive
1436
1554
 
1437
- function createStyleAttribute(vnode) {
1438
- var elm = vnode.elm,
1439
- styleDecls = vnode.data.styleDecls;
1555
+ valueObserved(originalTarget, key);
1440
1556
 
1441
- if (isUndefined$1(styleDecls)) {
1442
- return;
1443
- }
1557
+ var desc = _getOwnPropertyDescriptor(originalTarget, key);
1444
1558
 
1445
- for (var _i6 = 0; _i6 < styleDecls.length; _i6++) {
1446
- var _styleDecls$_i = _slicedToArray(styleDecls[_i6], 3),
1447
- prop = _styleDecls$_i[0],
1448
- value = _styleDecls$_i[1],
1449
- important = _styleDecls$_i[2];
1559
+ if (isUndefined(desc)) {
1560
+ if (key !== tagPropertyKey) {
1561
+ return undefined;
1562
+ } // if the key is the membrane tag key, and is not in the original target,
1563
+ // we produce a synthetic descriptor and install it on the shadow target
1450
1564
 
1451
- setCSSStyleProperty$1(elm, prop, value, important);
1452
- }
1453
- }
1454
1565
 
1455
- var modStaticStyle = {
1456
- create: createStyleAttribute
1457
- };
1458
- /*
1459
- * Copyright (c) 2018, salesforce.com, inc.
1460
- * All rights reserved.
1461
- * SPDX-License-Identifier: MIT
1462
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1463
- */
1566
+ desc = {
1567
+ value: undefined,
1568
+ writable: false,
1569
+ configurable: false,
1570
+ enumerable: false
1571
+ };
1572
+ ObjectDefineProperty(shadowTarget, tagPropertyKey, desc);
1573
+ return desc;
1574
+ }
1464
1575
 
1465
- function isUndef(s) {
1466
- return s === undefined;
1467
- }
1576
+ if (desc.configurable === false) {
1577
+ // updating the descriptor to non-configurable on the shadow
1578
+ this.copyDescriptorIntoShadowTarget(shadowTarget, key);
1579
+ } // Note: by accessing the descriptor, the key is marked as observed
1580
+ // but access to the value, setter or getter (if available) cannot observe
1581
+ // mutations, just like regular methods, in which case we just do nothing.
1468
1582
 
1469
- function sameVnode(vnode1, vnode2) {
1470
- return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
1471
- }
1472
1583
 
1473
- function isVNode(vnode) {
1474
- return vnode != null;
1475
- }
1584
+ return this.wrapDescriptor(desc);
1585
+ }
1586
+ }]);
1476
1587
 
1477
- function createKeyToOldIdx(children, beginIdx, endIdx) {
1478
- var map = {};
1479
- var j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
1588
+ return BaseProxyHandler;
1589
+ }();
1480
1590
 
1481
- for (j = beginIdx; j <= endIdx; ++j) {
1482
- ch = children[j];
1591
+ var getterMap$1 = new WeakMap();
1592
+ var setterMap$1 = new WeakMap();
1593
+ var reverseGetterMap = new WeakMap();
1594
+ var reverseSetterMap = new WeakMap();
1483
1595
 
1484
- if (isVNode(ch)) {
1485
- key = ch.key;
1596
+ var ReactiveProxyHandler = /*#__PURE__*/function (_BaseProxyHandler) {
1597
+ _inherits(ReactiveProxyHandler, _BaseProxyHandler);
1486
1598
 
1487
- if (key !== undefined) {
1488
- map[key] = j;
1489
- }
1490
- }
1491
- }
1599
+ var _super = _createSuper(ReactiveProxyHandler);
1492
1600
 
1493
- return map;
1494
- }
1601
+ function ReactiveProxyHandler() {
1602
+ _classCallCheck(this, ReactiveProxyHandler);
1495
1603
 
1496
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
1497
- for (; startIdx <= endIdx; ++startIdx) {
1498
- var ch = vnodes[startIdx];
1604
+ return _super.apply(this, arguments);
1605
+ }
1499
1606
 
1500
- if (isVNode(ch)) {
1501
- ch.hook.create(ch);
1502
- ch.hook.insert(ch, parentElm, before);
1607
+ _createClass(ReactiveProxyHandler, [{
1608
+ key: "wrapValue",
1609
+ value: function wrapValue(value) {
1610
+ return this.membrane.getProxy(value);
1503
1611
  }
1504
- }
1505
- }
1612
+ }, {
1613
+ key: "wrapGetter",
1614
+ value: function wrapGetter(originalGet) {
1615
+ var wrappedGetter = getterMap$1.get(originalGet);
1506
1616
 
1507
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
1508
- for (; startIdx <= endIdx; ++startIdx) {
1509
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
1617
+ if (!isUndefined(wrappedGetter)) {
1618
+ return wrappedGetter;
1619
+ }
1510
1620
 
1511
- if (isVNode(ch)) {
1512
- ch.hook.remove(ch, parentElm);
1513
- }
1514
- }
1515
- }
1621
+ var handler = this;
1516
1622
 
1517
- function updateDynamicChildren(parentElm, oldCh, newCh) {
1518
- var oldStartIdx = 0;
1519
- var newStartIdx = 0;
1520
- var oldEndIdx = oldCh.length - 1;
1521
- var oldStartVnode = oldCh[0];
1522
- var oldEndVnode = oldCh[oldEndIdx];
1523
- var newChEnd = newCh.length - 1;
1524
- var newEndIdx = newChEnd;
1525
- var newStartVnode = newCh[0];
1526
- var newEndVnode = newCh[newEndIdx];
1527
- var oldKeyToIdx;
1528
- var idxInOld;
1529
- var elmToMove;
1530
- var before;
1623
+ var get = function get() {
1624
+ // invoking the original getter with the original target
1625
+ return handler.wrapValue(originalGet.call(unwrap$1(this)));
1626
+ };
1531
1627
 
1532
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1533
- if (!isVNode(oldStartVnode)) {
1534
- oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
1535
- } else if (!isVNode(oldEndVnode)) {
1536
- oldEndVnode = oldCh[--oldEndIdx];
1537
- } else if (!isVNode(newStartVnode)) {
1538
- newStartVnode = newCh[++newStartIdx];
1539
- } else if (!isVNode(newEndVnode)) {
1540
- newEndVnode = newCh[--newEndIdx];
1541
- } else if (sameVnode(oldStartVnode, newStartVnode)) {
1542
- patchVnode(oldStartVnode, newStartVnode);
1543
- oldStartVnode = oldCh[++oldStartIdx];
1544
- newStartVnode = newCh[++newStartIdx];
1545
- } else if (sameVnode(oldEndVnode, newEndVnode)) {
1546
- patchVnode(oldEndVnode, newEndVnode);
1547
- oldEndVnode = oldCh[--oldEndIdx];
1548
- newEndVnode = newCh[--newEndIdx];
1549
- } else if (sameVnode(oldStartVnode, newEndVnode)) {
1550
- // Vnode moved right
1551
- patchVnode(oldStartVnode, newEndVnode);
1552
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
1553
- oldStartVnode = oldCh[++oldStartIdx];
1554
- newEndVnode = newCh[--newEndIdx];
1555
- } else if (sameVnode(oldEndVnode, newStartVnode)) {
1556
- // Vnode moved left
1557
- patchVnode(oldEndVnode, newStartVnode);
1558
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
1559
- oldEndVnode = oldCh[--oldEndIdx];
1560
- newStartVnode = newCh[++newStartIdx];
1561
- } else {
1562
- if (oldKeyToIdx === undefined) {
1563
- oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
1628
+ getterMap$1.set(originalGet, get);
1629
+ reverseGetterMap.set(get, originalGet);
1630
+ return get;
1631
+ }
1632
+ }, {
1633
+ key: "wrapSetter",
1634
+ value: function wrapSetter(originalSet) {
1635
+ var wrappedSetter = setterMap$1.get(originalSet);
1636
+
1637
+ if (!isUndefined(wrappedSetter)) {
1638
+ return wrappedSetter;
1564
1639
  }
1565
1640
 
1566
- idxInOld = oldKeyToIdx[newStartVnode.key];
1641
+ var set = function set(v) {
1642
+ // invoking the original setter with the original target
1643
+ originalSet.call(unwrap$1(this), unwrap$1(v));
1644
+ };
1567
1645
 
1568
- if (isUndef(idxInOld)) {
1569
- // New element
1570
- newStartVnode.hook.create(newStartVnode);
1571
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1572
- newStartVnode = newCh[++newStartIdx];
1646
+ setterMap$1.set(originalSet, set);
1647
+ reverseSetterMap.set(set, originalSet);
1648
+ return set;
1649
+ }
1650
+ }, {
1651
+ key: "unwrapDescriptor",
1652
+ value: function unwrapDescriptor(descriptor) {
1653
+ if (hasOwnProperty.call(descriptor, 'value')) {
1654
+ // dealing with a data descriptor
1655
+ descriptor.value = unwrap$1(descriptor.value);
1573
1656
  } else {
1574
- elmToMove = oldCh[idxInOld];
1657
+ var set = descriptor.set,
1658
+ get = descriptor.get;
1575
1659
 
1576
- if (isVNode(elmToMove)) {
1577
- if (elmToMove.sel !== newStartVnode.sel) {
1578
- // New element
1579
- newStartVnode.hook.create(newStartVnode);
1580
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
1581
- } else {
1582
- patchVnode(elmToMove, newStartVnode);
1583
- oldCh[idxInOld] = undefined;
1584
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
1585
- }
1660
+ if (!isUndefined(get)) {
1661
+ descriptor.get = this.unwrapGetter(get);
1586
1662
  }
1587
1663
 
1588
- newStartVnode = newCh[++newStartIdx];
1664
+ if (!isUndefined(set)) {
1665
+ descriptor.set = this.unwrapSetter(set);
1666
+ }
1589
1667
  }
1668
+
1669
+ return descriptor;
1590
1670
  }
1591
- }
1671
+ }, {
1672
+ key: "unwrapGetter",
1673
+ value: function unwrapGetter(redGet) {
1674
+ var reverseGetter = reverseGetterMap.get(redGet);
1592
1675
 
1593
- if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
1594
- if (oldStartIdx > oldEndIdx) {
1595
- // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
1596
- // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
1597
- var _i7 = newEndIdx;
1598
- var n;
1676
+ if (!isUndefined(reverseGetter)) {
1677
+ return reverseGetter;
1678
+ }
1599
1679
 
1600
- do {
1601
- n = newCh[++_i7];
1602
- } while (!isVNode(n) && _i7 < newChEnd);
1680
+ var handler = this;
1603
1681
 
1604
- before = isVNode(n) ? n.elm : null;
1605
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
1606
- } else {
1607
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
1608
- }
1609
- }
1610
- }
1611
-
1612
- function updateStaticChildren(parentElm, oldCh, newCh) {
1613
- var oldChLength = oldCh.length;
1614
- var newChLength = newCh.length;
1615
-
1616
- if (oldChLength === 0) {
1617
- // the old list is empty, we can directly insert anything new
1618
- addVnodes(parentElm, null, newCh, 0, newChLength);
1619
- return;
1620
- }
1621
-
1622
- if (newChLength === 0) {
1623
- // the old list is nonempty and the new list is empty so we can directly remove all old nodes
1624
- // this is the case in which the dynamic children of an if-directive should be removed
1625
- removeVnodes(parentElm, oldCh, 0, oldChLength);
1626
- return;
1627
- } // if the old list is not empty, the new list MUST have the same
1628
- // amount of nodes, that's why we call this static children
1682
+ var get = function get() {
1683
+ // invoking the red getter with the proxy of this
1684
+ return unwrap$1(redGet.call(handler.wrapValue(this)));
1685
+ };
1629
1686
 
1687
+ getterMap$1.set(get, redGet);
1688
+ reverseGetterMap.set(redGet, get);
1689
+ return get;
1690
+ }
1691
+ }, {
1692
+ key: "unwrapSetter",
1693
+ value: function unwrapSetter(redSet) {
1694
+ var reverseSetter = reverseSetterMap.get(redSet);
1630
1695
 
1631
- var referenceElm = null;
1696
+ if (!isUndefined(reverseSetter)) {
1697
+ return reverseSetter;
1698
+ }
1632
1699
 
1633
- for (var _i8 = newChLength - 1; _i8 >= 0; _i8 -= 1) {
1634
- var vnode = newCh[_i8];
1635
- var oldVNode = oldCh[_i8];
1700
+ var handler = this;
1636
1701
 
1637
- if (vnode !== oldVNode) {
1638
- if (isVNode(oldVNode)) {
1639
- if (isVNode(vnode)) {
1640
- // both vnodes must be equivalent, and se just need to patch them
1641
- patchVnode(oldVNode, vnode);
1642
- referenceElm = vnode.elm;
1643
- } else {
1644
- // removing the old vnode since the new one is null
1645
- oldVNode.hook.remove(oldVNode, parentElm);
1646
- }
1647
- } else if (isVNode(vnode)) {
1648
- // this condition is unnecessary
1649
- vnode.hook.create(vnode); // insert the new node one since the old one is null
1702
+ var set = function set(v) {
1703
+ // invoking the red setter with the proxy of this
1704
+ redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1705
+ };
1650
1706
 
1651
- vnode.hook.insert(vnode, parentElm, referenceElm);
1652
- referenceElm = vnode.elm;
1653
- }
1707
+ setterMap$1.set(set, redSet);
1708
+ reverseSetterMap.set(redSet, set);
1709
+ return set;
1654
1710
  }
1655
- }
1656
- }
1657
-
1658
- function patchVnode(oldVnode, vnode) {
1659
- if (oldVnode !== vnode) {
1660
- vnode.elm = oldVnode.elm;
1661
- vnode.hook.update(oldVnode, vnode);
1662
- }
1663
- }
1664
- /*
1665
- * Copyright (c) 2018, salesforce.com, inc.
1666
- * All rights reserved.
1667
- * SPDX-License-Identifier: MIT
1668
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1669
- */
1670
- // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
1671
- // to inject at runtime.
1711
+ }, {
1712
+ key: "set",
1713
+ value: function set(shadowTarget, key, value) {
1714
+ var originalTarget = this.originalTarget,
1715
+ valueMutated = this.membrane.valueMutated;
1716
+ var oldValue = originalTarget[key];
1672
1717
 
1718
+ if (oldValue !== value) {
1719
+ originalTarget[key] = value;
1720
+ valueMutated(originalTarget, key);
1721
+ } else if (key === 'length' && isArray(originalTarget)) {
1722
+ // fix for issue #236: push will add the new index, and by the time length
1723
+ // is updated, the internal length is already equal to the new length value
1724
+ // therefore, the oldValue is equal to the value. This is the forking logic
1725
+ // to support this use case.
1726
+ valueMutated(originalTarget, key);
1727
+ }
1673
1728
 
1674
- var HTMLElementConstructor$1 = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
1675
- var HTMLElementPrototype = HTMLElementConstructor$1.prototype;
1676
- /*
1677
- * Copyright (c) 2018, salesforce.com, inc.
1678
- * All rights reserved.
1679
- * SPDX-License-Identifier: MIT
1680
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1681
- */
1729
+ return true;
1730
+ }
1731
+ }, {
1732
+ key: "deleteProperty",
1733
+ value: function deleteProperty(shadowTarget, key) {
1734
+ var originalTarget = this.originalTarget,
1735
+ valueMutated = this.membrane.valueMutated;
1736
+ delete originalTarget[key];
1737
+ valueMutated(originalTarget, key);
1738
+ return true;
1739
+ }
1740
+ }, {
1741
+ key: "setPrototypeOf",
1742
+ value: function setPrototypeOf(shadowTarget, prototype) {
1743
+ }
1744
+ }, {
1745
+ key: "preventExtensions",
1746
+ value: function preventExtensions(shadowTarget) {
1747
+ if (_isExtensible(shadowTarget)) {
1748
+ var originalTarget = this.originalTarget;
1682
1749
 
1683
- /**
1684
- * This is a descriptor map that contains
1685
- * all standard properties that a Custom Element can support (including AOM properties), which
1686
- * determines what kind of capabilities the Base HTML Element and
1687
- * Base Lightning Element should support.
1688
- */
1750
+ _preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1751
+ // the preventExtension call, in which case we should not attempt to lock down
1752
+ // the shadow target.
1753
+ // TODO: It should not actually be possible to reach this `if` statement.
1754
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1755
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1689
1756
 
1690
- var HTMLElementOriginalDescriptors = create(null);
1691
- forEach.call(keys(AriaPropNameToAttrNameMap), function (propName) {
1692
- // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1693
- // in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
1694
- var descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
1757
+ /* istanbul ignore if */
1695
1758
 
1696
- if (!isUndefined$1(descriptor)) {
1697
- HTMLElementOriginalDescriptors[propName] = descriptor;
1698
- }
1699
- });
1700
- forEach.call(defaultDefHTMLPropertyNames, function (propName) {
1701
- // Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
1702
- // in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
1703
- // this category, so, better to be sure.
1704
- var descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
1705
1759
 
1706
- if (!isUndefined$1(descriptor)) {
1707
- HTMLElementOriginalDescriptors[propName] = descriptor;
1708
- }
1709
- });
1710
- /**
1711
- * Copyright (C) 2017 salesforce.com, inc.
1712
- */
1760
+ if (_isExtensible(originalTarget)) {
1761
+ return false;
1762
+ }
1713
1763
 
1714
- var isArray = Array.isArray;
1715
- var ObjectDotPrototype = Object.prototype,
1716
- _getPrototypeOf = Object.getPrototypeOf,
1717
- ObjectCreate = Object.create,
1718
- ObjectDefineProperty = Object.defineProperty,
1719
- _isExtensible = Object.isExtensible,
1720
- _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor,
1721
- getOwnPropertyNames = Object.getOwnPropertyNames,
1722
- getOwnPropertySymbols = Object.getOwnPropertySymbols,
1723
- _preventExtensions = Object.preventExtensions,
1724
- hasOwnProperty = Object.hasOwnProperty;
1725
- var _Array$prototype2 = Array.prototype,
1726
- ArrayPush = _Array$prototype2.push,
1727
- ArrayConcat = _Array$prototype2.concat;
1764
+ this.lockShadowTarget(shadowTarget);
1765
+ }
1728
1766
 
1729
- function isUndefined(obj) {
1730
- return obj === undefined;
1731
- }
1767
+ return true;
1768
+ }
1769
+ }, {
1770
+ key: "defineProperty",
1771
+ value: function defineProperty(shadowTarget, key, descriptor) {
1772
+ var originalTarget = this.originalTarget,
1773
+ _this$membrane3 = this.membrane,
1774
+ valueMutated = _this$membrane3.valueMutated,
1775
+ tagPropertyKey = _this$membrane3.tagPropertyKey;
1732
1776
 
1733
- function isFunction(obj) {
1734
- return typeof obj === 'function';
1735
- }
1777
+ if (key === tagPropertyKey && !hasOwnProperty.call(originalTarget, key)) {
1778
+ // To avoid leaking the membrane tag property into the original target, we must
1779
+ // be sure that the original target doesn't have yet.
1780
+ // NOTE: we do not return false here because Object.freeze and equivalent operations
1781
+ // will attempt to set the descriptor to the same value, and expect no to throw. This
1782
+ // is an small compromise for the sake of not having to diff the descriptors.
1783
+ return true;
1784
+ }
1736
1785
 
1737
- var proxyToValueMap = new WeakMap();
1786
+ ObjectDefineProperty(originalTarget, key, this.unwrapDescriptor(descriptor)); // intentionally testing if false since it could be undefined as well
1738
1787
 
1739
- function registerProxy(proxy, value) {
1740
- proxyToValueMap.set(proxy, value);
1741
- }
1788
+ if (descriptor.configurable === false) {
1789
+ this.copyDescriptorIntoShadowTarget(shadowTarget, key);
1790
+ }
1742
1791
 
1743
- var unwrap$1 = function unwrap$1(replicaOrAny) {
1744
- return proxyToValueMap.get(replicaOrAny) || replicaOrAny;
1745
- };
1792
+ valueMutated(originalTarget, key);
1793
+ return true;
1794
+ }
1795
+ }]);
1746
1796
 
1747
- var BaseProxyHandler = /*#__PURE__*/function () {
1748
- function BaseProxyHandler(membrane, value) {
1749
- _classCallCheck(this, BaseProxyHandler);
1797
+ return ReactiveProxyHandler;
1798
+ }(BaseProxyHandler);
1750
1799
 
1751
- this.originalTarget = value;
1752
- this.membrane = membrane;
1753
- } // Shared utility methods
1800
+ var getterMap = new WeakMap();
1801
+ var setterMap = new WeakMap();
1754
1802
 
1803
+ var ReadOnlyHandler = /*#__PURE__*/function (_BaseProxyHandler2) {
1804
+ _inherits(ReadOnlyHandler, _BaseProxyHandler2);
1755
1805
 
1756
- _createClass(BaseProxyHandler, [{
1757
- key: "wrapDescriptor",
1758
- value: function wrapDescriptor(descriptor) {
1759
- if (hasOwnProperty.call(descriptor, 'value')) {
1760
- descriptor.value = this.wrapValue(descriptor.value);
1761
- } else {
1762
- var originalSet = descriptor.set,
1763
- originalGet = descriptor.get;
1806
+ var _super2 = _createSuper(ReadOnlyHandler);
1764
1807
 
1765
- if (!isUndefined(originalGet)) {
1766
- descriptor.get = this.wrapGetter(originalGet);
1767
- }
1808
+ function ReadOnlyHandler() {
1809
+ _classCallCheck(this, ReadOnlyHandler);
1768
1810
 
1769
- if (!isUndefined(originalSet)) {
1770
- descriptor.set = this.wrapSetter(originalSet);
1771
- }
1772
- }
1811
+ return _super2.apply(this, arguments);
1812
+ }
1773
1813
 
1774
- return descriptor;
1814
+ _createClass(ReadOnlyHandler, [{
1815
+ key: "wrapValue",
1816
+ value: function wrapValue(value) {
1817
+ return this.membrane.getReadOnlyProxy(value);
1775
1818
  }
1776
1819
  }, {
1777
- key: "copyDescriptorIntoShadowTarget",
1778
- value: function copyDescriptorIntoShadowTarget(shadowTarget, key) {
1779
- var originalTarget = this.originalTarget; // Note: a property might get defined multiple times in the shadowTarget
1780
- // but it will always be compatible with the previous descriptor
1781
- // to preserve the object invariants, which makes these lines safe.
1820
+ key: "wrapGetter",
1821
+ value: function wrapGetter(originalGet) {
1822
+ var wrappedGetter = getterMap.get(originalGet);
1782
1823
 
1783
- var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1824
+ if (!isUndefined(wrappedGetter)) {
1825
+ return wrappedGetter;
1826
+ }
1784
1827
 
1785
- /* istanbul ignore else */
1828
+ var handler = this;
1786
1829
 
1830
+ var get = function get() {
1831
+ // invoking the original getter with the original target
1832
+ return handler.wrapValue(originalGet.call(unwrap$1(this)));
1833
+ };
1787
1834
 
1788
- if (!isUndefined(originalDescriptor)) {
1789
- var wrappedDesc = this.wrapDescriptor(originalDescriptor);
1790
- ObjectDefineProperty(shadowTarget, key, wrappedDesc);
1791
- }
1835
+ getterMap.set(originalGet, get);
1836
+ return get;
1792
1837
  }
1793
1838
  }, {
1794
- key: "lockShadowTarget",
1795
- value: function lockShadowTarget(shadowTarget) {
1796
- var _this = this;
1797
-
1798
- var originalTarget = this.originalTarget;
1799
- var targetKeys = ArrayConcat.call(getOwnPropertyNames(originalTarget), getOwnPropertySymbols(originalTarget));
1800
- targetKeys.forEach(function (key) {
1801
- _this.copyDescriptorIntoShadowTarget(shadowTarget, key);
1802
- });
1803
- var tagPropertyKey = this.membrane.tagPropertyKey;
1839
+ key: "wrapSetter",
1840
+ value: function wrapSetter(originalSet) {
1841
+ var wrappedSetter = setterMap.get(originalSet);
1804
1842
 
1805
- if (!isUndefined(tagPropertyKey) && !hasOwnProperty.call(shadowTarget, tagPropertyKey)) {
1806
- ObjectDefineProperty(shadowTarget, tagPropertyKey, ObjectCreate(null));
1843
+ if (!isUndefined(wrappedSetter)) {
1844
+ return wrappedSetter;
1807
1845
  }
1808
1846
 
1809
- _preventExtensions(shadowTarget);
1810
- } // Shared Traps
1811
- // TODO: apply() is never called
1812
-
1813
- /* istanbul ignore next */
1847
+ var set = function set(v) {
1848
+ };
1814
1849
 
1850
+ setterMap.set(originalSet, set);
1851
+ return set;
1852
+ }
1815
1853
  }, {
1816
- key: "apply",
1817
- value: function apply(shadowTarget, thisArg, argArray) {
1818
- /* No op */
1819
- } // TODO: construct() is never called
1854
+ key: "set",
1855
+ value: function set(shadowTarget, key, value) {
1856
+ /* istanbul ignore next */
1820
1857
 
1821
- /* istanbul ignore next */
1822
1858
 
1823
- }, {
1824
- key: "construct",
1825
- value: function construct(shadowTarget, argArray, newTarget) {
1826
- /* No op */
1859
+ return false;
1827
1860
  }
1828
1861
  }, {
1829
- key: "get",
1830
- value: function get(shadowTarget, key) {
1831
- var originalTarget = this.originalTarget,
1832
- valueObserved = this.membrane.valueObserved;
1833
- var value = originalTarget[key];
1834
- valueObserved(originalTarget, key);
1835
- return this.wrapValue(value);
1862
+ key: "deleteProperty",
1863
+ value: function deleteProperty(shadowTarget, key) {
1864
+ /* istanbul ignore next */
1865
+
1866
+
1867
+ return false;
1836
1868
  }
1837
1869
  }, {
1838
- key: "has",
1839
- value: function has(shadowTarget, key) {
1840
- var originalTarget = this.originalTarget,
1841
- _this$membrane = this.membrane,
1842
- tagPropertyKey = _this$membrane.tagPropertyKey,
1843
- valueObserved = _this$membrane.valueObserved;
1844
- valueObserved(originalTarget, key); // since key is never going to be undefined, and tagPropertyKey might be undefined
1845
- // we can simply compare them as the second part of the condition.
1846
-
1847
- return key in originalTarget || key === tagPropertyKey;
1870
+ key: "setPrototypeOf",
1871
+ value: function setPrototypeOf(shadowTarget, prototype) {
1848
1872
  }
1849
1873
  }, {
1850
- key: "ownKeys",
1851
- value: function ownKeys(shadowTarget) {
1852
- var originalTarget = this.originalTarget,
1853
- tagPropertyKey = this.membrane.tagPropertyKey; // if the membrane tag key exists and it is not in the original target, we add it to the keys.
1874
+ key: "preventExtensions",
1875
+ value: function preventExtensions(shadowTarget) {
1876
+ /* istanbul ignore next */
1854
1877
 
1855
- var keys = isUndefined(tagPropertyKey) || hasOwnProperty.call(originalTarget, tagPropertyKey) ? [] : [tagPropertyKey]; // small perf optimization using push instead of concat to avoid creating an extra array
1856
1878
 
1857
- ArrayPush.apply(keys, getOwnPropertyNames(originalTarget));
1858
- ArrayPush.apply(keys, getOwnPropertySymbols(originalTarget));
1859
- return keys;
1879
+ return false;
1860
1880
  }
1861
1881
  }, {
1862
- key: "isExtensible",
1863
- value: function isExtensible(shadowTarget) {
1864
- var originalTarget = this.originalTarget; // optimization to avoid attempting to lock down the shadowTarget multiple times
1865
-
1866
- if (!_isExtensible(shadowTarget)) {
1867
- return false; // was already locked down
1868
- }
1882
+ key: "defineProperty",
1883
+ value: function defineProperty(shadowTarget, key, descriptor) {
1884
+ /* istanbul ignore next */
1869
1885
 
1870
- if (!_isExtensible(originalTarget)) {
1871
- this.lockShadowTarget(shadowTarget);
1872
- return false;
1873
- }
1874
1886
 
1875
- return true;
1876
- }
1877
- }, {
1878
- key: "getPrototypeOf",
1879
- value: function getPrototypeOf(shadowTarget) {
1880
- var originalTarget = this.originalTarget;
1881
- return _getPrototypeOf(originalTarget);
1887
+ return false;
1882
1888
  }
1883
- }, {
1884
- key: "getOwnPropertyDescriptor",
1885
- value: function getOwnPropertyDescriptor(shadowTarget, key) {
1886
- var originalTarget = this.originalTarget,
1887
- _this$membrane2 = this.membrane,
1888
- valueObserved = _this$membrane2.valueObserved,
1889
- tagPropertyKey = _this$membrane2.tagPropertyKey; // keys looked up via getOwnPropertyDescriptor need to be reactive
1889
+ }]);
1890
1890
 
1891
- valueObserved(originalTarget, key);
1891
+ return ReadOnlyHandler;
1892
+ }(BaseProxyHandler);
1892
1893
 
1893
- var desc = _getOwnPropertyDescriptor(originalTarget, key);
1894
+ function defaultValueIsObservable(value) {
1895
+ // intentionally checking for null
1896
+ if (value === null) {
1897
+ return false;
1898
+ } // treat all non-object types, including undefined, as non-observable values
1894
1899
 
1895
- if (isUndefined(desc)) {
1896
- if (key !== tagPropertyKey) {
1897
- return undefined;
1898
- } // if the key is the membrane tag key, and is not in the original target,
1899
- // we produce a synthetic descriptor and install it on the shadow target
1900
1900
 
1901
+ if (_typeof(value) !== 'object') {
1902
+ return false;
1903
+ }
1901
1904
 
1902
- desc = {
1903
- value: undefined,
1904
- writable: false,
1905
- configurable: false,
1906
- enumerable: false
1907
- };
1908
- ObjectDefineProperty(shadowTarget, tagPropertyKey, desc);
1909
- return desc;
1910
- }
1905
+ if (isArray(value)) {
1906
+ return true;
1907
+ }
1911
1908
 
1912
- if (desc.configurable === false) {
1913
- // updating the descriptor to non-configurable on the shadow
1914
- this.copyDescriptorIntoShadowTarget(shadowTarget, key);
1915
- } // Note: by accessing the descriptor, the key is marked as observed
1916
- // but access to the value, setter or getter (if available) cannot observe
1917
- // mutations, just like regular methods, in which case we just do nothing.
1909
+ var proto = _getPrototypeOf(value);
1918
1910
 
1911
+ return proto === ObjectDotPrototype || proto === null || _getPrototypeOf(proto) === null;
1912
+ }
1919
1913
 
1920
- return this.wrapDescriptor(desc);
1921
- }
1922
- }]);
1914
+ var defaultValueObserved = function defaultValueObserved(obj, key) {
1915
+ /* do nothing */
1916
+ };
1923
1917
 
1924
- return BaseProxyHandler;
1925
- }();
1918
+ var defaultValueMutated = function defaultValueMutated(obj, key) {
1919
+ /* do nothing */
1920
+ };
1921
+
1922
+ function createShadowTarget(value) {
1923
+ return isArray(value) ? [] : {};
1924
+ }
1925
+
1926
+ var ObservableMembrane = /*#__PURE__*/function () {
1927
+ function ObservableMembrane() {
1928
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1926
1929
 
1927
- var getterMap$1 = new WeakMap();
1928
- var setterMap$1 = new WeakMap();
1929
- var reverseGetterMap = new WeakMap();
1930
- var reverseSetterMap = new WeakMap();
1930
+ _classCallCheck(this, ObservableMembrane);
1931
1931
 
1932
- var ReactiveProxyHandler = /*#__PURE__*/function (_BaseProxyHandler) {
1933
- _inherits(ReactiveProxyHandler, _BaseProxyHandler);
1932
+ this.readOnlyObjectGraph = new WeakMap();
1933
+ this.reactiveObjectGraph = new WeakMap();
1934
+ var valueMutated = options.valueMutated,
1935
+ valueObserved = options.valueObserved,
1936
+ valueIsObservable = options.valueIsObservable,
1937
+ tagPropertyKey = options.tagPropertyKey;
1938
+ this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
1939
+ this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
1940
+ this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
1941
+ this.tagPropertyKey = tagPropertyKey;
1942
+ }
1934
1943
 
1935
- var _super = _createSuper(ReactiveProxyHandler);
1944
+ _createClass(ObservableMembrane, [{
1945
+ key: "getProxy",
1946
+ value: function getProxy(value) {
1947
+ var unwrappedValue = unwrap$1(value);
1936
1948
 
1937
- function ReactiveProxyHandler() {
1938
- _classCallCheck(this, ReactiveProxyHandler);
1949
+ if (this.valueIsObservable(unwrappedValue)) {
1950
+ // When trying to extract the writable version of a readonly we return the readonly.
1951
+ if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
1952
+ return value;
1953
+ }
1939
1954
 
1940
- return _super.apply(this, arguments);
1941
- }
1955
+ return this.getReactiveHandler(unwrappedValue);
1956
+ }
1942
1957
 
1943
- _createClass(ReactiveProxyHandler, [{
1944
- key: "wrapValue",
1945
- value: function wrapValue(value) {
1946
- return this.membrane.getProxy(value);
1958
+ return unwrappedValue;
1947
1959
  }
1948
1960
  }, {
1949
- key: "wrapGetter",
1950
- value: function wrapGetter(originalGet) {
1951
- var wrappedGetter = getterMap$1.get(originalGet);
1961
+ key: "getReadOnlyProxy",
1962
+ value: function getReadOnlyProxy(value) {
1963
+ value = unwrap$1(value);
1952
1964
 
1953
- if (!isUndefined(wrappedGetter)) {
1954
- return wrappedGetter;
1965
+ if (this.valueIsObservable(value)) {
1966
+ return this.getReadOnlyHandler(value);
1955
1967
  }
1956
1968
 
1957
- var handler = this;
1958
-
1959
- var get = function get() {
1960
- // invoking the original getter with the original target
1961
- return handler.wrapValue(originalGet.call(unwrap$1(this)));
1962
- };
1963
-
1964
- getterMap$1.set(originalGet, get);
1965
- reverseGetterMap.set(get, originalGet);
1966
- return get;
1969
+ return value;
1967
1970
  }
1968
1971
  }, {
1969
- key: "wrapSetter",
1970
- value: function wrapSetter(originalSet) {
1971
- var wrappedSetter = setterMap$1.get(originalSet);
1972
+ key: "unwrapProxy",
1973
+ value: function unwrapProxy(p) {
1974
+ return unwrap$1(p);
1975
+ }
1976
+ }, {
1977
+ key: "getReactiveHandler",
1978
+ value: function getReactiveHandler(value) {
1979
+ var proxy = this.reactiveObjectGraph.get(value);
1972
1980
 
1973
- if (!isUndefined(wrappedSetter)) {
1974
- return wrappedSetter;
1981
+ if (isUndefined(proxy)) {
1982
+ // caching the proxy after the first time it is accessed
1983
+ var handler = new ReactiveProxyHandler(this, value);
1984
+ proxy = new Proxy(createShadowTarget(value), handler);
1985
+ registerProxy(proxy, value);
1986
+ this.reactiveObjectGraph.set(value, proxy);
1975
1987
  }
1976
1988
 
1977
- var set = function set(v) {
1978
- // invoking the original setter with the original target
1979
- originalSet.call(unwrap$1(this), unwrap$1(v));
1980
- };
1981
-
1982
- setterMap$1.set(originalSet, set);
1983
- reverseSetterMap.set(set, originalSet);
1984
- return set;
1989
+ return proxy;
1985
1990
  }
1986
1991
  }, {
1987
- key: "unwrapDescriptor",
1988
- value: function unwrapDescriptor(descriptor) {
1989
- if (hasOwnProperty.call(descriptor, 'value')) {
1990
- // dealing with a data descriptor
1991
- descriptor.value = unwrap$1(descriptor.value);
1992
- } else {
1993
- var set = descriptor.set,
1994
- get = descriptor.get;
1995
-
1996
- if (!isUndefined(get)) {
1997
- descriptor.get = this.unwrapGetter(get);
1998
- }
1992
+ key: "getReadOnlyHandler",
1993
+ value: function getReadOnlyHandler(value) {
1994
+ var proxy = this.readOnlyObjectGraph.get(value);
1999
1995
 
2000
- if (!isUndefined(set)) {
2001
- descriptor.set = this.unwrapSetter(set);
2002
- }
1996
+ if (isUndefined(proxy)) {
1997
+ // caching the proxy after the first time it is accessed
1998
+ var handler = new ReadOnlyHandler(this, value);
1999
+ proxy = new Proxy(createShadowTarget(value), handler);
2000
+ registerProxy(proxy, value);
2001
+ this.readOnlyObjectGraph.set(value, proxy);
2003
2002
  }
2004
2003
 
2005
- return descriptor;
2004
+ return proxy;
2006
2005
  }
2007
- }, {
2008
- key: "unwrapGetter",
2009
- value: function unwrapGetter(redGet) {
2010
- var reverseGetter = reverseGetterMap.get(redGet);
2006
+ }]);
2011
2007
 
2012
- if (!isUndefined(reverseGetter)) {
2013
- return reverseGetter;
2014
- }
2008
+ return ObservableMembrane;
2009
+ }();
2010
+ /** version: 2.0.0 */
2015
2011
 
2016
- var handler = this;
2012
+ /*
2013
+ * Copyright (c) 2018, salesforce.com, inc.
2014
+ * All rights reserved.
2015
+ * SPDX-License-Identifier: MIT
2016
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2017
+ */
2017
2018
 
2018
- var get = function get() {
2019
- // invoking the red getter with the proxy of this
2020
- return unwrap$1(redGet.call(handler.wrapValue(this)));
2021
- };
2022
2019
 
2023
- getterMap$1.set(get, redGet);
2024
- reverseGetterMap.set(redGet, get);
2025
- return get;
2026
- }
2027
- }, {
2028
- key: "unwrapSetter",
2029
- value: function unwrapSetter(redSet) {
2030
- var reverseSetter = reverseSetterMap.get(redSet);
2020
+ var lockerLivePropertyKey = Symbol.for('@@lockerLiveValue');
2021
+ var reactiveMembrane = new ObservableMembrane({
2022
+ valueObserved: valueObserved,
2023
+ valueMutated: valueMutated,
2024
+ tagPropertyKey: lockerLivePropertyKey
2025
+ });
2026
+ /**
2027
+ * EXPERIMENTAL: This function implements an unwrap mechanism that
2028
+ * works for observable membrane objects. This API is subject to
2029
+ * change or being removed.
2030
+ */
2031
2031
 
2032
- if (!isUndefined(reverseSetter)) {
2033
- return reverseSetter;
2034
- }
2032
+ function unwrap(value) {
2033
+ return reactiveMembrane.unwrapProxy(value);
2034
+ }
2035
+ /*
2036
+ * Copyright (c) 2018, salesforce.com, inc.
2037
+ * All rights reserved.
2038
+ * SPDX-License-Identifier: MIT
2039
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2040
+ */
2035
2041
 
2036
- var handler = this;
2042
+ /**
2043
+ * This operation is called with a descriptor of an standard html property
2044
+ * that a Custom Element can support (including AOM properties), which
2045
+ * determines what kind of capabilities the Base Lightning Element should support. When producing the new descriptors
2046
+ * for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
2047
+ */
2037
2048
 
2038
- var set = function set(v) {
2039
- // invoking the red setter with the proxy of this
2040
- redSet.call(handler.wrapValue(this), handler.wrapValue(v));
2041
- };
2042
2049
 
2043
- setterMap$1.set(set, redSet);
2044
- reverseSetterMap.set(redSet, set);
2045
- return set;
2046
- }
2047
- }, {
2048
- key: "set",
2049
- value: function set(shadowTarget, key, value) {
2050
- var originalTarget = this.originalTarget,
2051
- valueMutated = this.membrane.valueMutated;
2052
- var oldValue = originalTarget[key];
2050
+ function createBridgeToElementDescriptor(propName, descriptor) {
2051
+ var _get = descriptor.get,
2052
+ _set = descriptor.set,
2053
+ enumerable = descriptor.enumerable,
2054
+ configurable = descriptor.configurable;
2053
2055
 
2054
- if (oldValue !== value) {
2055
- originalTarget[key] = value;
2056
- valueMutated(originalTarget, key);
2057
- } else if (key === 'length' && isArray(originalTarget)) {
2058
- // fix for issue #236: push will add the new index, and by the time length
2059
- // is updated, the internal length is already equal to the new length value
2060
- // therefore, the oldValue is equal to the value. This is the forking logic
2061
- // to support this use case.
2062
- valueMutated(originalTarget, key);
2056
+ if (!isFunction$1(_get)) {
2057
+
2058
+ throw new TypeError();
2059
+ }
2060
+
2061
+ if (!isFunction$1(_set)) {
2062
+
2063
+ throw new TypeError();
2064
+ }
2065
+
2066
+ return {
2067
+ enumerable: enumerable,
2068
+ configurable: configurable,
2069
+ get: function get() {
2070
+ var vm = getAssociatedVM(this);
2071
+
2072
+ if (isBeingConstructed(vm)) {
2073
+
2074
+ return;
2063
2075
  }
2064
2076
 
2065
- return true;
2066
- }
2067
- }, {
2068
- key: "deleteProperty",
2069
- value: function deleteProperty(shadowTarget, key) {
2070
- var originalTarget = this.originalTarget,
2071
- valueMutated = this.membrane.valueMutated;
2072
- delete originalTarget[key];
2073
- valueMutated(originalTarget, key);
2074
- return true;
2075
- }
2076
- }, {
2077
- key: "setPrototypeOf",
2078
- value: function setPrototypeOf(shadowTarget, prototype) {
2077
+ componentValueObserved(vm, propName);
2078
+ return _get.call(vm.elm);
2079
+ },
2080
+ set: function set(newValue) {
2081
+ var vm = getAssociatedVM(this);
2082
+
2083
+ if (newValue !== vm.cmpProps[propName]) {
2084
+ vm.cmpProps[propName] = newValue;
2085
+ componentValueMutated(vm, propName);
2086
+ }
2087
+
2088
+ return _set.call(vm.elm, newValue);
2079
2089
  }
2080
- }, {
2081
- key: "preventExtensions",
2082
- value: function preventExtensions(shadowTarget) {
2083
- if (_isExtensible(shadowTarget)) {
2084
- var originalTarget = this.originalTarget;
2090
+ };
2091
+ }
2092
+ /**
2093
+ * This class is the base class for any LWC element.
2094
+ * Some elements directly extends this class, others implement it via inheritance.
2095
+ **/
2096
+ // @ts-ignore
2085
2097
 
2086
- _preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
2087
- // the preventExtension call, in which case we should not attempt to lock down
2088
- // the shadow target.
2089
- // TODO: It should not actually be possible to reach this `if` statement.
2090
- // If a proxy rejects extensions, then calling preventExtensions will throw an error:
2091
- // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
2092
2098
 
2093
- /* istanbul ignore if */
2099
+ var LightningElement = function LightningElement() {
2100
+ // This should be as performant as possible, while any initialization should be done lazily
2101
+ if (isNull(vmBeingConstructed)) {
2102
+ throw new ReferenceError('Illegal constructor');
2103
+ }
2094
2104
 
2105
+ var vm = vmBeingConstructed;
2106
+ var def = vm.def,
2107
+ elm = vm.elm;
2108
+ var bridge = def.bridge;
2095
2109
 
2096
- if (_isExtensible(originalTarget)) {
2097
- return false;
2098
- }
2110
+ var component = this;
2111
+ setPrototypeOf(elm, bridge.prototype);
2112
+ vm.component = this; // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
2113
+ // component creation and passes hooks to instrument all the component interactions with the
2114
+ // engine. We are intentionally hiding this argument from the formal API of LightningElement
2115
+ // because we don't want folks to know about it just yet.
2099
2116
 
2100
- this.lockShadowTarget(shadowTarget);
2101
- }
2117
+ if (arguments.length === 1) {
2118
+ var _arguments$ = arguments[0],
2119
+ _callHook = _arguments$.callHook,
2120
+ _setHook = _arguments$.setHook,
2121
+ _getHook = _arguments$.getHook;
2122
+ vm.callHook = _callHook;
2123
+ vm.setHook = _setHook;
2124
+ vm.getHook = _getHook;
2125
+ } // Making the component instance a live value when using Locker to support expandos.
2102
2126
 
2103
- return true;
2104
- }
2105
- }, {
2106
- key: "defineProperty",
2107
- value: function defineProperty(shadowTarget, key, descriptor) {
2108
- var originalTarget = this.originalTarget,
2109
- _this$membrane3 = this.membrane,
2110
- valueMutated = _this$membrane3.valueMutated,
2111
- tagPropertyKey = _this$membrane3.tagPropertyKey;
2112
2127
 
2113
- if (key === tagPropertyKey && !hasOwnProperty.call(originalTarget, key)) {
2114
- // To avoid leaking the membrane tag property into the original target, we must
2115
- // be sure that the original target doesn't have yet.
2116
- // NOTE: we do not return false here because Object.freeze and equivalent operations
2117
- // will attempt to set the descriptor to the same value, and expect no to throw. This
2118
- // is an small compromise for the sake of not having to diff the descriptors.
2119
- return true;
2120
- }
2128
+ this[lockerLivePropertyKey] = undefined; // Linking elm, shadow root and component with the VM.
2121
2129
 
2122
- ObjectDefineProperty(originalTarget, key, this.unwrapDescriptor(descriptor)); // intentionally testing if false since it could be undefined as well
2130
+ associateVM(component, vm);
2131
+ associateVM(elm, vm);
2123
2132
 
2124
- if (descriptor.configurable === false) {
2125
- this.copyDescriptorIntoShadowTarget(shadowTarget, key);
2126
- }
2133
+ if (vm.renderMode === 1
2134
+ /* Shadow */
2135
+ ) {
2136
+ doAttachShadow(vm);
2137
+ } // Adding extra guard rails in DEV mode.
2127
2138
 
2128
- valueMutated(originalTarget, key);
2129
- return true;
2130
- }
2131
- }]);
2139
+ return this;
2140
+ };
2132
2141
 
2133
- return ReactiveProxyHandler;
2134
- }(BaseProxyHandler);
2142
+ function doAttachShadow(vm) {
2143
+ var _attachShadow$;
2135
2144
 
2136
- var getterMap = new WeakMap();
2137
- var setterMap = new WeakMap();
2145
+ var elm = vm.elm,
2146
+ mode = vm.mode,
2147
+ shadowMode = vm.shadowMode,
2148
+ ctor = vm.def.ctor;
2149
+ var cmpRoot = attachShadow$1(elm, (_attachShadow$ = {}, _defineProperty(_attachShadow$, KEY__SYNTHETIC_MODE, shadowMode === 1), _defineProperty(_attachShadow$, "delegatesFocus", Boolean(ctor.delegatesFocus)), _defineProperty(_attachShadow$, "mode", mode), _attachShadow$));
2150
+ vm.cmpRoot = cmpRoot;
2151
+ associateVM(cmpRoot, vm);
2152
+ }
2138
2153
 
2139
- var ReadOnlyHandler = /*#__PURE__*/function (_BaseProxyHandler2) {
2140
- _inherits(ReadOnlyHandler, _BaseProxyHandler2);
2141
2154
 
2142
- var _super2 = _createSuper(ReadOnlyHandler);
2155
+ LightningElement.prototype = {
2156
+ constructor: LightningElement,
2157
+ dispatchEvent: function dispatchEvent(event) {
2158
+ var _getAssociatedVM = getAssociatedVM(this),
2159
+ elm = _getAssociatedVM.elm;
2143
2160
 
2144
- function ReadOnlyHandler() {
2145
- _classCallCheck(this, ReadOnlyHandler);
2161
+ return dispatchEvent$1(elm, event);
2162
+ },
2163
+ addEventListener: function addEventListener(type, listener, options) {
2164
+ var vm = getAssociatedVM(this);
2165
+ var elm = vm.elm;
2146
2166
 
2147
- return _super2.apply(this, arguments);
2148
- }
2167
+ var wrappedListener = getWrappedComponentsListener(vm, listener);
2168
+ addEventListener$1(elm, type, wrappedListener, options);
2169
+ },
2170
+ removeEventListener: function removeEventListener(type, listener, options) {
2171
+ var vm = getAssociatedVM(this);
2172
+ var elm = vm.elm;
2173
+ var wrappedListener = getWrappedComponentsListener(vm, listener);
2174
+ removeEventListener$1(elm, type, wrappedListener, options);
2175
+ },
2176
+ hasAttribute: function hasAttribute(name) {
2177
+ var _getAssociatedVM2 = getAssociatedVM(this),
2178
+ elm = _getAssociatedVM2.elm;
2149
2179
 
2150
- _createClass(ReadOnlyHandler, [{
2151
- key: "wrapValue",
2152
- value: function wrapValue(value) {
2153
- return this.membrane.getReadOnlyProxy(value);
2154
- }
2155
- }, {
2156
- key: "wrapGetter",
2157
- value: function wrapGetter(originalGet) {
2158
- var wrappedGetter = getterMap.get(originalGet);
2180
+ return !isNull(getAttribute$1(elm, name));
2181
+ },
2182
+ hasAttributeNS: function hasAttributeNS(namespace, name) {
2183
+ var _getAssociatedVM3 = getAssociatedVM(this),
2184
+ elm = _getAssociatedVM3.elm;
2159
2185
 
2160
- if (!isUndefined(wrappedGetter)) {
2161
- return wrappedGetter;
2162
- }
2186
+ return !isNull(getAttribute$1(elm, name, namespace));
2187
+ },
2188
+ removeAttribute: function removeAttribute(name) {
2189
+ var _getAssociatedVM4 = getAssociatedVM(this),
2190
+ elm = _getAssociatedVM4.elm;
2163
2191
 
2164
- var handler = this;
2192
+ unlockAttribute(elm, name);
2193
+ removeAttribute$1(elm, name);
2194
+ lockAttribute();
2195
+ },
2196
+ removeAttributeNS: function removeAttributeNS(namespace, name) {
2197
+ var _getAssociatedVM5 = getAssociatedVM(this),
2198
+ elm = _getAssociatedVM5.elm;
2165
2199
 
2166
- var get = function get() {
2167
- // invoking the original getter with the original target
2168
- return handler.wrapValue(originalGet.call(unwrap$1(this)));
2169
- };
2200
+ unlockAttribute(elm, name);
2201
+ removeAttribute$1(elm, name, namespace);
2202
+ lockAttribute();
2203
+ },
2204
+ getAttribute: function getAttribute(name) {
2205
+ var _getAssociatedVM6 = getAssociatedVM(this),
2206
+ elm = _getAssociatedVM6.elm;
2170
2207
 
2171
- getterMap.set(originalGet, get);
2172
- return get;
2173
- }
2174
- }, {
2175
- key: "wrapSetter",
2176
- value: function wrapSetter(originalSet) {
2177
- var wrappedSetter = setterMap.get(originalSet);
2208
+ return getAttribute$1(elm, name);
2209
+ },
2210
+ getAttributeNS: function getAttributeNS(namespace, name) {
2211
+ var _getAssociatedVM7 = getAssociatedVM(this),
2212
+ elm = _getAssociatedVM7.elm;
2178
2213
 
2179
- if (!isUndefined(wrappedSetter)) {
2180
- return wrappedSetter;
2181
- }
2214
+ return getAttribute$1(elm, name, namespace);
2215
+ },
2216
+ setAttribute: function setAttribute(name, value) {
2217
+ var vm = getAssociatedVM(this);
2218
+ var elm = vm.elm;
2182
2219
 
2183
- var set = function set(v) {
2184
- };
2220
+ unlockAttribute(elm, name);
2221
+ setAttribute$1(elm, name, value);
2222
+ lockAttribute();
2223
+ },
2224
+ setAttributeNS: function setAttributeNS(namespace, name, value) {
2225
+ var vm = getAssociatedVM(this);
2226
+ var elm = vm.elm;
2185
2227
 
2186
- setterMap.set(originalSet, set);
2187
- return set;
2188
- }
2189
- }, {
2190
- key: "set",
2191
- value: function set(shadowTarget, key, value) {
2192
- /* istanbul ignore next */
2228
+ unlockAttribute(elm, name);
2229
+ setAttribute$1(elm, name, value, namespace);
2230
+ lockAttribute();
2231
+ },
2232
+ getBoundingClientRect: function getBoundingClientRect() {
2233
+ var vm = getAssociatedVM(this);
2234
+ var elm = vm.elm;
2193
2235
 
2236
+ return getBoundingClientRect$1(elm);
2237
+ },
2194
2238
 
2195
- return false;
2196
- }
2197
- }, {
2198
- key: "deleteProperty",
2199
- value: function deleteProperty(shadowTarget, key) {
2200
- /* istanbul ignore next */
2239
+ get isConnected() {
2240
+ var _getAssociatedVM8 = getAssociatedVM(this),
2241
+ elm = _getAssociatedVM8.elm;
2201
2242
 
2243
+ return isConnected$1(elm);
2244
+ },
2202
2245
 
2203
- return false;
2204
- }
2205
- }, {
2206
- key: "setPrototypeOf",
2207
- value: function setPrototypeOf(shadowTarget, prototype) {
2208
- }
2209
- }, {
2210
- key: "preventExtensions",
2211
- value: function preventExtensions(shadowTarget) {
2212
- /* istanbul ignore next */
2246
+ get classList() {
2247
+ var vm = getAssociatedVM(this);
2248
+ var elm = vm.elm;
2213
2249
 
2250
+ return getClassList$1(elm);
2251
+ },
2214
2252
 
2215
- return false;
2216
- }
2217
- }, {
2218
- key: "defineProperty",
2219
- value: function defineProperty(shadowTarget, key, descriptor) {
2220
- /* istanbul ignore next */
2253
+ get template() {
2254
+ var vm = getAssociatedVM(this);
2255
+
2256
+ return vm.cmpRoot;
2257
+ },
2258
+
2259
+ get shadowRoot() {
2260
+ // From within the component instance, the shadowRoot is always reported as "closed".
2261
+ // Authors should rely on this.template instead.
2262
+ return null;
2263
+ },
2264
+
2265
+ render: function render() {
2266
+ var vm = getAssociatedVM(this);
2267
+ return vm.def.template;
2268
+ },
2269
+ toString: function toString() {
2270
+ var vm = getAssociatedVM(this);
2271
+ return "[object ".concat(vm.def.name, "]");
2272
+ }
2273
+ };
2274
+ var queryAndChildGetterDescriptors = create(null); // The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
2275
+ // is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
2276
+ // object representing the renderer, with a lot of methods we don't actually need.
2221
2277
 
2278
+ var childGetters = ['children', 'childNodes', 'firstChild', 'firstElementChild', 'lastChild', 'lastElementChild'];
2222
2279
 
2223
- return false;
2224
- }
2225
- }]);
2280
+ function getChildGetter(methodName) {
2281
+ switch (methodName) {
2282
+ case 'children':
2283
+ return getChildren$1;
2226
2284
 
2227
- return ReadOnlyHandler;
2228
- }(BaseProxyHandler);
2285
+ case 'childNodes':
2286
+ return getChildNodes$1;
2229
2287
 
2230
- function defaultValueIsObservable(value) {
2231
- // intentionally checking for null
2232
- if (value === null) {
2233
- return false;
2234
- } // treat all non-object types, including undefined, as non-observable values
2288
+ case 'firstChild':
2289
+ return getFirstChild$1;
2235
2290
 
2291
+ case 'firstElementChild':
2292
+ return getFirstElementChild$1;
2236
2293
 
2237
- if (_typeof(value) !== 'object') {
2238
- return false;
2239
- }
2294
+ case 'lastChild':
2295
+ return getLastChild$1;
2240
2296
 
2241
- if (isArray(value)) {
2242
- return true;
2297
+ case 'lastElementChild':
2298
+ return getLastElementChild$1;
2243
2299
  }
2300
+ } // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
2244
2301
 
2245
- var proto = _getPrototypeOf(value);
2246
-
2247
- return proto === ObjectDotPrototype || proto === null || _getPrototypeOf(proto) === null;
2248
- }
2249
2302
 
2250
- var defaultValueObserved = function defaultValueObserved(obj, key) {
2251
- /* do nothing */
2252
- };
2303
+ var _loop = function _loop() {
2304
+ var childGetter = _childGetters[_i8];
2305
+ queryAndChildGetterDescriptors[childGetter] = {
2306
+ get: function get() {
2307
+ var vm = getAssociatedVM(this);
2308
+ var elm = vm.elm;
2253
2309
 
2254
- var defaultValueMutated = function defaultValueMutated(obj, key) {
2255
- /* do nothing */
2310
+ return getChildGetter(childGetter)(elm);
2311
+ },
2312
+ configurable: true,
2313
+ enumerable: true
2314
+ };
2256
2315
  };
2257
2316
 
2258
- function createShadowTarget(value) {
2259
- return isArray(value) ? [] : {};
2317
+ for (var _i8 = 0, _childGetters = childGetters; _i8 < _childGetters.length; _i8++) {
2318
+ _loop();
2260
2319
  }
2261
2320
 
2262
- var ObservableMembrane = /*#__PURE__*/function () {
2263
- function ObservableMembrane() {
2264
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2321
+ var queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
2265
2322
 
2266
- _classCallCheck(this, ObservableMembrane);
2323
+ function getQueryMethod(methodName) {
2324
+ switch (methodName) {
2325
+ case 'getElementsByClassName':
2326
+ return getElementsByClassName$1;
2267
2327
 
2268
- this.readOnlyObjectGraph = new WeakMap();
2269
- this.reactiveObjectGraph = new WeakMap();
2270
- var valueMutated = options.valueMutated,
2271
- valueObserved = options.valueObserved,
2272
- valueIsObservable = options.valueIsObservable,
2273
- tagPropertyKey = options.tagPropertyKey;
2274
- this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2275
- this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2276
- this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2277
- this.tagPropertyKey = tagPropertyKey;
2328
+ case 'getElementsByTagName':
2329
+ return getElementsByTagName$1;
2330
+
2331
+ case 'querySelector':
2332
+ return querySelector$1;
2333
+
2334
+ case 'querySelectorAll':
2335
+ return querySelectorAll$1;
2278
2336
  }
2337
+ } // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
2279
2338
 
2280
- _createClass(ObservableMembrane, [{
2281
- key: "getProxy",
2282
- value: function getProxy(value) {
2283
- var unwrappedValue = unwrap$1(value);
2284
2339
 
2285
- if (this.valueIsObservable(unwrappedValue)) {
2286
- // When trying to extract the writable version of a readonly we return the readonly.
2287
- if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
2288
- return value;
2289
- }
2340
+ var _loop2 = function _loop2() {
2341
+ var queryMethod = _queryMethods[_i9];
2342
+ queryAndChildGetterDescriptors[queryMethod] = {
2343
+ value: function value(arg) {
2344
+ var vm = getAssociatedVM(this);
2345
+ var elm = vm.elm;
2290
2346
 
2291
- return this.getReactiveHandler(unwrappedValue);
2292
- }
2347
+ return getQueryMethod(queryMethod)(elm, arg);
2348
+ },
2349
+ configurable: true,
2350
+ enumerable: true,
2351
+ writable: true
2352
+ };
2353
+ };
2293
2354
 
2294
- return unwrappedValue;
2295
- }
2296
- }, {
2297
- key: "getReadOnlyProxy",
2298
- value: function getReadOnlyProxy(value) {
2299
- value = unwrap$1(value);
2355
+ for (var _i9 = 0, _queryMethods = queryMethods; _i9 < _queryMethods.length; _i9++) {
2356
+ _loop2();
2357
+ }
2300
2358
 
2301
- if (this.valueIsObservable(value)) {
2302
- return this.getReadOnlyHandler(value);
2303
- }
2359
+ defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
2360
+ var lightningBasedDescriptors = create(null);
2304
2361
 
2305
- return value;
2306
- }
2307
- }, {
2308
- key: "unwrapProxy",
2309
- value: function unwrapProxy(p) {
2310
- return unwrap$1(p);
2311
- }
2312
- }, {
2313
- key: "getReactiveHandler",
2314
- value: function getReactiveHandler(value) {
2315
- var proxy = this.reactiveObjectGraph.get(value);
2362
+ for (var _propName in HTMLElementOriginalDescriptors) {
2363
+ lightningBasedDescriptors[_propName] = createBridgeToElementDescriptor(_propName, HTMLElementOriginalDescriptors[_propName]);
2364
+ }
2316
2365
 
2317
- if (isUndefined(proxy)) {
2318
- // caching the proxy after the first time it is accessed
2319
- var handler = new ReactiveProxyHandler(this, value);
2320
- proxy = new Proxy(createShadowTarget(value), handler);
2321
- registerProxy(proxy, value);
2322
- this.reactiveObjectGraph.set(value, proxy);
2323
- }
2366
+ defineProperties(LightningElement.prototype, lightningBasedDescriptors);
2367
+ defineProperty(LightningElement, 'CustomElementConstructor', {
2368
+ get: function get() {
2369
+ // If required, a runtime-specific implementation must be defined.
2370
+ throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
2371
+ },
2372
+ configurable: true
2373
+ });
2374
+ /*
2375
+ * Copyright (c) 2018, salesforce.com, inc.
2376
+ * All rights reserved.
2377
+ * SPDX-License-Identifier: MIT
2378
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2379
+ */
2324
2380
 
2325
- return proxy;
2326
- }
2327
- }, {
2328
- key: "getReadOnlyHandler",
2329
- value: function getReadOnlyHandler(value) {
2330
- var proxy = this.readOnlyObjectGraph.get(value);
2381
+ /**
2382
+ * @wire decorator to wire fields and methods to a wire adapter in
2383
+ * LWC Components. This function implements the internals of this
2384
+ * decorator.
2385
+ */
2331
2386
 
2332
- if (isUndefined(proxy)) {
2333
- // caching the proxy after the first time it is accessed
2334
- var handler = new ReadOnlyHandler(this, value);
2335
- proxy = new Proxy(createShadowTarget(value), handler);
2336
- registerProxy(proxy, value);
2337
- this.readOnlyObjectGraph.set(value, proxy);
2338
- }
2339
2387
 
2340
- return proxy;
2341
- }
2342
- }]);
2388
+ function wire(_adapter, _config) {
2343
2389
 
2344
- return ObservableMembrane;
2345
- }();
2346
- /** version: 2.0.0 */
2390
+ throw new Error();
2391
+ }
2392
+
2393
+ function internalWireFieldDecorator(key) {
2394
+ return {
2395
+ get: function get() {
2396
+ var vm = getAssociatedVM(this);
2397
+ componentValueObserved(vm, key);
2398
+ return vm.cmpFields[key];
2399
+ },
2400
+ set: function set(value) {
2401
+ var vm = getAssociatedVM(this);
2402
+ /**
2403
+ * Reactivity for wired fields is provided in wiring.
2404
+ * We intentionally add reactivity here since this is just
2405
+ * letting the author to do the wrong thing, but it will keep our
2406
+ * system to be backward compatible.
2407
+ */
2347
2408
 
2409
+ if (value !== vm.cmpFields[key]) {
2410
+ vm.cmpFields[key] = value;
2411
+ componentValueMutated(vm, key);
2412
+ }
2413
+ },
2414
+ enumerable: true,
2415
+ configurable: true
2416
+ };
2417
+ }
2348
2418
  /*
2349
2419
  * Copyright (c) 2018, salesforce.com, inc.
2350
2420
  * All rights reserved.
@@ -2353,20 +2423,34 @@
2353
2423
  */
2354
2424
 
2355
2425
 
2356
- var lockerLivePropertyKey = Symbol.for('@@lockerLiveValue');
2357
- var reactiveMembrane = new ObservableMembrane({
2358
- valueObserved: valueObserved,
2359
- valueMutated: valueMutated,
2360
- tagPropertyKey: lockerLivePropertyKey
2361
- });
2362
- /**
2363
- * EXPERIMENTAL: This function implements an unwrap mechanism that
2364
- * works for observable membrane objects. This API is subject to
2365
- * change or being removed.
2366
- */
2426
+ function track(target) {
2427
+ if (arguments.length === 1) {
2428
+ return reactiveMembrane.getProxy(target);
2429
+ }
2367
2430
 
2368
- function unwrap(value) {
2369
- return reactiveMembrane.unwrapProxy(value);
2431
+ throw new Error();
2432
+ }
2433
+
2434
+ function internalTrackDecorator(key) {
2435
+ return {
2436
+ get: function get() {
2437
+ var vm = getAssociatedVM(this);
2438
+ componentValueObserved(vm, key);
2439
+ return vm.cmpFields[key];
2440
+ },
2441
+ set: function set(newValue) {
2442
+ var vm = getAssociatedVM(this);
2443
+
2444
+ var reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2445
+
2446
+ if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2447
+ vm.cmpFields[key] = reactiveOrAnyValue;
2448
+ componentValueMutated(vm, key);
2449
+ }
2450
+ },
2451
+ enumerable: true,
2452
+ configurable: true
2453
+ };
2370
2454
  }
2371
2455
  /*
2372
2456
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2375,33 +2459,14 @@
2375
2459
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2376
2460
  */
2377
2461
 
2378
- /**
2379
- * This operation is called with a descriptor of an standard html property
2380
- * that a Custom Element can support (including AOM properties), which
2381
- * determines what kind of capabilities the Base Lightning Element should support. When producing the new descriptors
2382
- * for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
2383
- */
2384
-
2385
2462
 
2386
- function createBridgeToElementDescriptor(propName, descriptor) {
2387
- var _get = descriptor.get,
2388
- _set = descriptor.set,
2389
- enumerable = descriptor.enumerable,
2390
- configurable = descriptor.configurable;
2391
-
2392
- if (!isFunction$1(_get)) {
2393
-
2394
- throw new TypeError();
2395
- }
2396
-
2397
- if (!isFunction$1(_set)) {
2463
+ function api$1() {
2398
2464
 
2399
- throw new TypeError();
2400
- }
2465
+ throw new Error();
2466
+ }
2401
2467
 
2468
+ function createPublicPropertyDescriptor(key) {
2402
2469
  return {
2403
- enumerable: enumerable,
2404
- configurable: configurable,
2405
2470
  get: function get() {
2406
2471
  var vm = getAssociatedVM(this);
2407
2472
 
@@ -2410,383 +2475,323 @@
2410
2475
  return;
2411
2476
  }
2412
2477
 
2413
- componentValueObserved(vm, propName);
2414
- return _get.call(vm.elm);
2478
+ componentValueObserved(vm, key);
2479
+ return vm.cmpProps[key];
2415
2480
  },
2416
2481
  set: function set(newValue) {
2417
2482
  var vm = getAssociatedVM(this);
2418
2483
 
2419
- if (newValue !== vm.cmpProps[propName]) {
2420
- vm.cmpProps[propName] = newValue;
2421
- componentValueMutated(vm, propName);
2422
- }
2423
-
2424
- return _set.call(vm.elm, newValue);
2425
- }
2484
+ vm.cmpProps[key] = newValue;
2485
+ componentValueMutated(vm, key);
2486
+ },
2487
+ enumerable: true,
2488
+ configurable: true
2426
2489
  };
2427
2490
  }
2428
- /**
2429
- * This class is the base class for any LWC element.
2430
- * Some elements directly extends this class, others implement it via inheritance.
2431
- **/
2432
- // @ts-ignore
2433
2491
 
2492
+ var AccessorReactiveObserver = /*#__PURE__*/function (_ReactiveObserver) {
2493
+ _inherits(AccessorReactiveObserver, _ReactiveObserver);
2434
2494
 
2435
- var LightningElement = function LightningElement() {
2436
- // This should be as performant as possible, while any initialization should be done lazily
2437
- if (isNull(vmBeingConstructed)) {
2438
- throw new ReferenceError('Illegal constructor');
2439
- }
2495
+ var _super3 = _createSuper(AccessorReactiveObserver);
2440
2496
 
2441
- var vm = vmBeingConstructed;
2442
- var def = vm.def,
2443
- elm = vm.elm;
2444
- var bridge = def.bridge;
2497
+ function AccessorReactiveObserver(vm, set) {
2498
+ var _this2;
2445
2499
 
2446
- var component = this;
2447
- setPrototypeOf(elm, bridge.prototype);
2448
- vm.component = this; // Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
2449
- // component creation and passes hooks to instrument all the component interactions with the
2450
- // engine. We are intentionally hiding this argument from the formal API of LightningElement
2451
- // because we don't want folks to know about it just yet.
2500
+ _classCallCheck(this, AccessorReactiveObserver);
2452
2501
 
2453
- if (arguments.length === 1) {
2454
- var _arguments$ = arguments[0],
2455
- _callHook = _arguments$.callHook,
2456
- _setHook = _arguments$.setHook,
2457
- _getHook = _arguments$.getHook;
2458
- vm.callHook = _callHook;
2459
- vm.setHook = _setHook;
2460
- vm.getHook = _getHook;
2461
- } // Making the component instance a live value when using Locker to support expandos.
2502
+ _this2 = _super3.call(this, function () {
2503
+ if (isFalse(_this2.debouncing)) {
2504
+ _this2.debouncing = true;
2505
+ addCallbackToNextTick(function () {
2506
+ if (isTrue(_this2.debouncing)) {
2507
+ var _assertThisInitialize = _assertThisInitialized(_this2),
2508
+ value = _assertThisInitialize.value;
2462
2509
 
2510
+ var dirtyStateBeforeSetterCall = vm.isDirty,
2511
+ component = vm.component,
2512
+ _idx = vm.idx;
2513
+ set.call(component, value); // de-bouncing after the call to the original setter to prevent
2514
+ // infinity loop if the setter itself is mutating things that
2515
+ // were accessed during the previous invocation.
2463
2516
 
2464
- this[lockerLivePropertyKey] = undefined; // Linking elm, shadow root and component with the VM.
2517
+ _this2.debouncing = false;
2465
2518
 
2466
- associateVM(component, vm);
2467
- associateVM(elm, vm);
2519
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && _idx > 0) {
2520
+ // immediate rehydration due to a setter driven mutation, otherwise
2521
+ // the component will get rendered on the second tick, which it is not
2522
+ // desirable.
2523
+ rerenderVM(vm);
2524
+ }
2525
+ }
2526
+ });
2527
+ }
2528
+ });
2529
+ _this2.debouncing = false;
2530
+ return _this2;
2531
+ }
2468
2532
 
2469
- if (vm.renderMode === 1
2470
- /* Shadow */
2471
- ) {
2472
- doAttachShadow(vm);
2473
- } // Adding extra guard rails in DEV mode.
2533
+ _createClass(AccessorReactiveObserver, [{
2534
+ key: "reset",
2535
+ value: function reset(value) {
2536
+ _get2(_getPrototypeOf2(AccessorReactiveObserver.prototype), "reset", this).call(this);
2474
2537
 
2475
- return this;
2476
- };
2538
+ this.debouncing = false;
2477
2539
 
2478
- function doAttachShadow(vm) {
2479
- var _attachShadow$;
2540
+ if (arguments.length > 0) {
2541
+ this.value = value;
2542
+ }
2543
+ }
2544
+ }]);
2480
2545
 
2481
- var elm = vm.elm,
2482
- mode = vm.mode,
2483
- shadowMode = vm.shadowMode,
2484
- ctor = vm.def.ctor;
2485
- var cmpRoot = attachShadow$1(elm, (_attachShadow$ = {}, _defineProperty(_attachShadow$, KEY__SYNTHETIC_MODE, shadowMode === 1), _defineProperty(_attachShadow$, "delegatesFocus", Boolean(ctor.delegatesFocus)), _defineProperty(_attachShadow$, "mode", mode), _attachShadow$));
2486
- vm.cmpRoot = cmpRoot;
2487
- associateVM(cmpRoot, vm);
2488
- }
2546
+ return AccessorReactiveObserver;
2547
+ }(ReactiveObserver);
2489
2548
 
2549
+ function createPublicAccessorDescriptor(key, descriptor) {
2550
+ var _get3 = descriptor.get,
2551
+ _set2 = descriptor.set,
2552
+ enumerable = descriptor.enumerable,
2553
+ configurable = descriptor.configurable;
2490
2554
 
2491
- LightningElement.prototype = {
2492
- constructor: LightningElement,
2493
- dispatchEvent: function dispatchEvent(event) {
2494
- var _getAssociatedVM = getAssociatedVM(this),
2495
- elm = _getAssociatedVM.elm;
2555
+ if (!isFunction$1(_get3)) {
2496
2556
 
2497
- return dispatchEvent$1(elm, event);
2498
- },
2499
- addEventListener: function addEventListener(type, listener, options) {
2500
- var vm = getAssociatedVM(this);
2501
- var elm = vm.elm;
2557
+ throw new Error();
2558
+ }
2502
2559
 
2503
- var wrappedListener = getWrappedComponentsListener(vm, listener);
2504
- addEventListener$1(elm, type, wrappedListener, options);
2505
- },
2506
- removeEventListener: function removeEventListener(type, listener, options) {
2507
- var vm = getAssociatedVM(this);
2508
- var elm = vm.elm;
2509
- var wrappedListener = getWrappedComponentsListener(vm, listener);
2510
- removeEventListener$1(elm, type, wrappedListener, options);
2511
- },
2512
- hasAttribute: function hasAttribute(name) {
2513
- var _getAssociatedVM2 = getAssociatedVM(this),
2514
- elm = _getAssociatedVM2.elm;
2560
+ return {
2561
+ get: function get() {
2515
2562
 
2516
- return !isNull(getAttribute$1(elm, name));
2517
- },
2518
- hasAttributeNS: function hasAttributeNS(namespace, name) {
2519
- var _getAssociatedVM3 = getAssociatedVM(this),
2520
- elm = _getAssociatedVM3.elm;
2563
+ return _get3.call(this);
2564
+ },
2565
+ set: function set(newValue) {
2566
+ var _this3 = this;
2521
2567
 
2522
- return !isNull(getAttribute$1(elm, name, namespace));
2523
- },
2524
- removeAttribute: function removeAttribute(name) {
2525
- var _getAssociatedVM4 = getAssociatedVM(this),
2526
- elm = _getAssociatedVM4.elm;
2568
+ var vm = getAssociatedVM(this);
2527
2569
 
2528
- unlockAttribute(elm, name);
2529
- removeAttribute$1(elm, name);
2530
- lockAttribute();
2531
- },
2532
- removeAttributeNS: function removeAttributeNS(namespace, name) {
2533
- var _getAssociatedVM5 = getAssociatedVM(this),
2534
- elm = _getAssociatedVM5.elm;
2570
+ if (_set2) {
2571
+ if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
2572
+ var ro = vm.oar[key];
2535
2573
 
2536
- unlockAttribute(elm, name);
2537
- removeAttribute$1(elm, name, namespace);
2538
- lockAttribute();
2539
- },
2540
- getAttribute: function getAttribute(name) {
2541
- var _getAssociatedVM6 = getAssociatedVM(this),
2542
- elm = _getAssociatedVM6.elm;
2574
+ if (isUndefined$1(ro)) {
2575
+ ro = vm.oar[key] = new AccessorReactiveObserver(vm, _set2);
2576
+ } // every time we invoke this setter from outside (through this wrapper setter)
2577
+ // we should reset the value and then debounce just in case there is a pending
2578
+ // invocation the next tick that is not longer relevant since the value is changing
2579
+ // from outside.
2543
2580
 
2544
- return getAttribute$1(elm, name);
2545
- },
2546
- getAttributeNS: function getAttributeNS(namespace, name) {
2547
- var _getAssociatedVM7 = getAssociatedVM(this),
2548
- elm = _getAssociatedVM7.elm;
2549
2581
 
2550
- return getAttribute$1(elm, name, namespace);
2551
- },
2552
- setAttribute: function setAttribute(name, value) {
2553
- var vm = getAssociatedVM(this);
2554
- var elm = vm.elm;
2582
+ ro.reset(newValue);
2583
+ ro.observe(function () {
2584
+ _set2.call(_this3, newValue);
2585
+ });
2586
+ } else {
2587
+ _set2.call(this, newValue);
2588
+ }
2589
+ }
2590
+ },
2591
+ enumerable: enumerable,
2592
+ configurable: configurable
2593
+ };
2594
+ }
2555
2595
 
2556
- unlockAttribute(elm, name);
2557
- setAttribute$1(elm, name, value);
2558
- lockAttribute();
2559
- },
2560
- setAttributeNS: function setAttributeNS(namespace, name, value) {
2561
- var vm = getAssociatedVM(this);
2562
- var elm = vm.elm;
2596
+ function createObservedFieldPropertyDescriptor(key) {
2597
+ return {
2598
+ get: function get() {
2599
+ var vm = getAssociatedVM(this);
2600
+ componentValueObserved(vm, key);
2601
+ return vm.cmpFields[key];
2602
+ },
2603
+ set: function set(newValue) {
2604
+ var vm = getAssociatedVM(this);
2563
2605
 
2564
- unlockAttribute(elm, name);
2565
- setAttribute$1(elm, name, value, namespace);
2566
- lockAttribute();
2567
- },
2568
- getBoundingClientRect: function getBoundingClientRect() {
2569
- var vm = getAssociatedVM(this);
2570
- var elm = vm.elm;
2606
+ if (newValue !== vm.cmpFields[key]) {
2607
+ vm.cmpFields[key] = newValue;
2608
+ componentValueMutated(vm, key);
2609
+ }
2610
+ },
2611
+ enumerable: true,
2612
+ configurable: true
2613
+ };
2614
+ }
2615
+ /**
2616
+ * INTERNAL: This function can only be invoked by compiled code. The compiler
2617
+ * will prevent this function from being imported by user-land code.
2618
+ */
2571
2619
 
2572
- return getBoundingClientRect$1(elm);
2573
- },
2574
2620
 
2575
- get isConnected() {
2576
- var _getAssociatedVM8 = getAssociatedVM(this),
2577
- elm = _getAssociatedVM8.elm;
2621
+ function registerDecorators(Ctor, meta) {
2622
+ var proto = Ctor.prototype;
2623
+ var publicProps = meta.publicProps,
2624
+ publicMethods = meta.publicMethods,
2625
+ wire = meta.wire,
2626
+ track = meta.track,
2627
+ fields = meta.fields;
2628
+ var apiMethods = create(null);
2629
+ var apiFields = create(null);
2630
+ var wiredMethods = create(null);
2631
+ var wiredFields = create(null);
2632
+ var observedFields = create(null);
2633
+ var apiFieldsConfig = create(null);
2634
+ var descriptor;
2578
2635
 
2579
- return isConnected$1(elm);
2580
- },
2636
+ if (!isUndefined$1(publicProps)) {
2637
+ for (var fieldName in publicProps) {
2638
+ var propConfig = publicProps[fieldName];
2639
+ apiFieldsConfig[fieldName] = propConfig.config;
2640
+ descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
2581
2641
 
2582
- get classList() {
2583
- var vm = getAssociatedVM(this);
2584
- var elm = vm.elm;
2642
+ if (propConfig.config > 0) {
2585
2643
 
2586
- return getClassList$1(elm);
2587
- },
2644
+ if (isUndefined$1(descriptor)) {
2645
+ throw new Error();
2646
+ }
2588
2647
 
2589
- get template() {
2590
- var vm = getAssociatedVM(this);
2648
+ descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
2649
+ } else {
2650
+ // with the same name, the property is defined as a public accessor. This branch is
2651
+ // only here for backward compatibility reasons.
2591
2652
 
2592
- return vm.cmpRoot;
2593
- },
2594
2653
 
2595
- get shadowRoot() {
2596
- // From within the component instance, the shadowRoot is always reported as "closed".
2597
- // Authors should rely on this.template instead.
2598
- return null;
2599
- },
2654
+ if (!isUndefined$1(descriptor) && !isUndefined$1(descriptor.get)) {
2655
+ descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
2656
+ } else {
2657
+ descriptor = createPublicPropertyDescriptor(fieldName);
2658
+ }
2659
+ }
2600
2660
 
2601
- render: function render() {
2602
- var vm = getAssociatedVM(this);
2603
- return vm.def.template;
2604
- },
2605
- toString: function toString() {
2606
- var vm = getAssociatedVM(this);
2607
- return "[object ".concat(vm.def.name, "]");
2661
+ apiFields[fieldName] = descriptor;
2662
+ defineProperty(proto, fieldName, descriptor);
2663
+ }
2608
2664
  }
2609
- };
2610
- var queryAndChildGetterDescriptors = create(null); // The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
2611
- // is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
2612
- // object representing the renderer, with a lot of methods we don't actually need.
2613
-
2614
- var childGetters = ['children', 'childNodes', 'firstChild', 'firstElementChild', 'lastChild', 'lastElementChild'];
2615
-
2616
- function getChildGetter(methodName) {
2617
- switch (methodName) {
2618
- case 'children':
2619
- return getChildren$1;
2620
-
2621
- case 'childNodes':
2622
- return getChildNodes$1;
2623
-
2624
- case 'firstChild':
2625
- return getFirstChild$1;
2626
2665
 
2627
- case 'firstElementChild':
2628
- return getFirstElementChild$1;
2666
+ if (!isUndefined$1(publicMethods)) {
2667
+ forEach.call(publicMethods, function (methodName) {
2668
+ descriptor = getOwnPropertyDescriptor$1(proto, methodName);
2629
2669
 
2630
- case 'lastChild':
2631
- return getLastChild$1;
2670
+ if (isUndefined$1(descriptor)) {
2671
+ throw new Error();
2672
+ }
2632
2673
 
2633
- case 'lastElementChild':
2634
- return getLastElementChild$1;
2674
+ apiMethods[methodName] = descriptor;
2675
+ });
2635
2676
  }
2636
- } // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
2637
-
2638
-
2639
- var _loop = function _loop() {
2640
- var childGetter = _childGetters[_i9];
2641
- queryAndChildGetterDescriptors[childGetter] = {
2642
- get: function get() {
2643
- var vm = getAssociatedVM(this);
2644
- var elm = vm.elm;
2645
2677
 
2646
- return getChildGetter(childGetter)(elm);
2647
- },
2648
- configurable: true,
2649
- enumerable: true
2650
- };
2651
- };
2678
+ if (!isUndefined$1(wire)) {
2679
+ for (var fieldOrMethodName in wire) {
2680
+ var _wire$fieldOrMethodNa = wire[fieldOrMethodName],
2681
+ adapter = _wire$fieldOrMethodNa.adapter,
2682
+ method = _wire$fieldOrMethodNa.method,
2683
+ configCallback = _wire$fieldOrMethodNa.config,
2684
+ _wire$fieldOrMethodNa2 = _wire$fieldOrMethodNa.dynamic,
2685
+ dynamic = _wire$fieldOrMethodNa2 === void 0 ? [] : _wire$fieldOrMethodNa2;
2686
+ descriptor = getOwnPropertyDescriptor$1(proto, fieldOrMethodName);
2652
2687
 
2653
- for (var _i9 = 0, _childGetters = childGetters; _i9 < _childGetters.length; _i9++) {
2654
- _loop();
2655
- }
2688
+ if (method === 1) {
2656
2689
 
2657
- var queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
2690
+ if (isUndefined$1(descriptor)) {
2691
+ throw new Error();
2692
+ }
2658
2693
 
2659
- function getQueryMethod(methodName) {
2660
- switch (methodName) {
2661
- case 'getElementsByClassName':
2662
- return getElementsByClassName$1;
2694
+ wiredMethods[fieldOrMethodName] = descriptor;
2695
+ storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
2696
+ } else {
2663
2697
 
2664
- case 'getElementsByTagName':
2665
- return getElementsByTagName$1;
2698
+ descriptor = internalWireFieldDecorator(fieldOrMethodName);
2699
+ wiredFields[fieldOrMethodName] = descriptor;
2700
+ storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic);
2701
+ defineProperty(proto, fieldOrMethodName, descriptor);
2702
+ }
2703
+ }
2704
+ }
2666
2705
 
2667
- case 'querySelector':
2668
- return querySelector$1;
2706
+ if (!isUndefined$1(track)) {
2707
+ for (var _fieldName in track) {
2708
+ descriptor = getOwnPropertyDescriptor$1(proto, _fieldName);
2669
2709
 
2670
- case 'querySelectorAll':
2671
- return querySelectorAll$1;
2710
+ descriptor = internalTrackDecorator(_fieldName);
2711
+ defineProperty(proto, _fieldName, descriptor);
2712
+ }
2672
2713
  }
2673
- } // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
2674
2714
 
2715
+ if (!isUndefined$1(fields)) {
2716
+ for (var _i10 = 0, n = fields.length; _i10 < n; _i10++) {
2717
+ var _fieldName2 = fields[_i10];
2718
+ descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
2719
+ // tracked property. This is only here for backward compatibility purposes.
2675
2720
 
2676
- var _loop2 = function _loop2() {
2677
- var queryMethod = _queryMethods[_i10];
2678
- queryAndChildGetterDescriptors[queryMethod] = {
2679
- value: function value(arg) {
2680
- var vm = getAssociatedVM(this);
2681
- var elm = vm.elm;
2682
2721
 
2683
- return getQueryMethod(queryMethod)(elm, arg);
2684
- },
2685
- configurable: true,
2686
- enumerable: true,
2687
- writable: true
2688
- };
2689
- };
2722
+ var isDuplicatePublicProp = !isUndefined$1(publicProps) && _fieldName2 in publicProps;
2723
+ var isDuplicateTrackedProp = !isUndefined$1(track) && _fieldName2 in track;
2690
2724
 
2691
- for (var _i10 = 0, _queryMethods = queryMethods; _i10 < _queryMethods.length; _i10++) {
2692
- _loop2();
2725
+ if (!isDuplicatePublicProp && !isDuplicateTrackedProp) {
2726
+ observedFields[_fieldName2] = createObservedFieldPropertyDescriptor(_fieldName2);
2727
+ }
2728
+ }
2729
+ }
2730
+
2731
+ setDecoratorsMeta(Ctor, {
2732
+ apiMethods: apiMethods,
2733
+ apiFields: apiFields,
2734
+ apiFieldsConfig: apiFieldsConfig,
2735
+ wiredMethods: wiredMethods,
2736
+ wiredFields: wiredFields,
2737
+ observedFields: observedFields
2738
+ });
2739
+ return Ctor;
2693
2740
  }
2694
2741
 
2695
- defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
2696
- var lightningBasedDescriptors = create(null);
2742
+ var signedDecoratorToMetaMap = new Map();
2697
2743
 
2698
- for (var _propName in HTMLElementOriginalDescriptors) {
2699
- lightningBasedDescriptors[_propName] = createBridgeToElementDescriptor(_propName, HTMLElementOriginalDescriptors[_propName]);
2744
+ function setDecoratorsMeta(Ctor, meta) {
2745
+ signedDecoratorToMetaMap.set(Ctor, meta);
2700
2746
  }
2701
2747
 
2702
- defineProperties(LightningElement.prototype, lightningBasedDescriptors);
2703
- defineProperty(LightningElement, 'CustomElementConstructor', {
2704
- get: function get() {
2705
- // If required, a runtime-specific implementation must be defined.
2706
- throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
2707
- },
2708
- configurable: true
2709
- });
2710
- /*
2711
- * Copyright (c) 2018, salesforce.com, inc.
2712
- * All rights reserved.
2713
- * SPDX-License-Identifier: MIT
2714
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2715
- */
2716
-
2717
- /**
2718
- * @wire decorator to wire fields and methods to a wire adapter in
2719
- * LWC Components. This function implements the internals of this
2720
- * decorator.
2721
- */
2748
+ var defaultMeta = {
2749
+ apiMethods: EmptyObject,
2750
+ apiFields: EmptyObject,
2751
+ apiFieldsConfig: EmptyObject,
2752
+ wiredMethods: EmptyObject,
2753
+ wiredFields: EmptyObject,
2754
+ observedFields: EmptyObject
2755
+ };
2722
2756
 
2757
+ function getDecoratorsMeta(Ctor) {
2758
+ var meta = signedDecoratorToMetaMap.get(Ctor);
2759
+ return isUndefined$1(meta) ? defaultMeta : meta;
2760
+ }
2723
2761
 
2724
- function wire(_adapter, _config) {
2762
+ var signedTemplateSet = new Set();
2725
2763
 
2726
- throw new Error();
2764
+ function defaultEmptyTemplate() {
2765
+ return [];
2727
2766
  }
2728
2767
 
2729
- function internalWireFieldDecorator(key) {
2730
- return {
2731
- get: function get() {
2732
- var vm = getAssociatedVM(this);
2733
- componentValueObserved(vm, key);
2734
- return vm.cmpFields[key];
2735
- },
2736
- set: function set(value) {
2737
- var vm = getAssociatedVM(this);
2738
- /**
2739
- * Reactivity for wired fields is provided in wiring.
2740
- * We intentionally add reactivity here since this is just
2741
- * letting the author to do the wrong thing, but it will keep our
2742
- * system to be backward compatible.
2743
- */
2744
-
2745
- if (value !== vm.cmpFields[key]) {
2746
- vm.cmpFields[key] = value;
2747
- componentValueMutated(vm, key);
2748
- }
2749
- },
2750
- enumerable: true,
2751
- configurable: true
2752
- };
2768
+ signedTemplateSet.add(defaultEmptyTemplate);
2769
+
2770
+ function isTemplateRegistered(tpl) {
2771
+ return signedTemplateSet.has(tpl);
2753
2772
  }
2754
- /*
2755
- * Copyright (c) 2018, salesforce.com, inc.
2756
- * All rights reserved.
2757
- * SPDX-License-Identifier: MIT
2758
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2773
+ /**
2774
+ * INTERNAL: This function can only be invoked by compiled code. The compiler
2775
+ * will prevent this function from being imported by userland code.
2759
2776
  */
2760
2777
 
2761
2778
 
2762
- function track(target) {
2763
- if (arguments.length === 1) {
2764
- return reactiveMembrane.getProxy(target);
2765
- }
2779
+ function registerTemplate(tpl) {
2780
+ signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
2781
+ // assignment of templates easily, without too much transformation
2766
2782
 
2767
- throw new Error();
2783
+ return tpl;
2768
2784
  }
2785
+ /**
2786
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
2787
+ * libraries to sanitize vulnerable attributes.
2788
+ */
2769
2789
 
2770
- function internalTrackDecorator(key) {
2771
- return {
2772
- get: function get() {
2773
- var vm = getAssociatedVM(this);
2774
- componentValueObserved(vm, key);
2775
- return vm.cmpFields[key];
2776
- },
2777
- set: function set(newValue) {
2778
- var vm = getAssociatedVM(this);
2779
-
2780
- var reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2781
2790
 
2782
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2783
- vm.cmpFields[key] = reactiveOrAnyValue;
2784
- componentValueMutated(vm, key);
2785
- }
2786
- },
2787
- enumerable: true,
2788
- configurable: true
2789
- };
2791
+ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
2792
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
2793
+ // ran off-core this function becomes a noop and returns the user authored value.
2794
+ return attrValue;
2790
2795
  }
2791
2796
  /*
2792
2797
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2794,569 +2799,545 @@
2794
2799
  * SPDX-License-Identifier: MIT
2795
2800
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2796
2801
  */
2802
+ // from the element instance, and get the value or set a new value on the component.
2803
+ // This means that across different elements, similar names can get the exact same
2804
+ // descriptor, so we can cache them:
2797
2805
 
2798
2806
 
2799
- function api$1() {
2807
+ var cachedGetterByKey = create(null);
2808
+ var cachedSetterByKey = create(null);
2800
2809
 
2801
- throw new Error();
2802
- }
2810
+ function createGetter(key) {
2811
+ var fn = cachedGetterByKey[key];
2803
2812
 
2804
- function createPublicPropertyDescriptor(key) {
2805
- return {
2806
- get: function get() {
2813
+ if (isUndefined$1(fn)) {
2814
+ fn = cachedGetterByKey[key] = function () {
2807
2815
  var vm = getAssociatedVM(this);
2816
+ var getHook = vm.getHook;
2817
+ return getHook(vm.component, key);
2818
+ };
2819
+ }
2808
2820
 
2809
- if (isBeingConstructed(vm)) {
2821
+ return fn;
2822
+ }
2810
2823
 
2811
- return;
2812
- }
2824
+ function createSetter(key) {
2825
+ var fn = cachedSetterByKey[key];
2813
2826
 
2814
- componentValueObserved(vm, key);
2815
- return vm.cmpProps[key];
2816
- },
2817
- set: function set(newValue) {
2827
+ if (isUndefined$1(fn)) {
2828
+ fn = cachedSetterByKey[key] = function (newValue) {
2818
2829
  var vm = getAssociatedVM(this);
2830
+ var setHook = vm.setHook;
2831
+ newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2832
+ setHook(vm.component, key, newValue);
2833
+ };
2834
+ }
2819
2835
 
2820
- vm.cmpProps[key] = newValue;
2821
- componentValueMutated(vm, key);
2822
- },
2823
- enumerable: true,
2824
- configurable: true
2825
- };
2836
+ return fn;
2826
2837
  }
2827
2838
 
2828
- var AccessorReactiveObserver = /*#__PURE__*/function (_ReactiveObserver) {
2829
- _inherits(AccessorReactiveObserver, _ReactiveObserver);
2830
-
2831
- var _super3 = _createSuper(AccessorReactiveObserver);
2832
-
2833
- function AccessorReactiveObserver(vm, set) {
2834
- var _this2;
2835
-
2836
- _classCallCheck(this, AccessorReactiveObserver);
2837
-
2838
- _this2 = _super3.call(this, function () {
2839
- if (isFalse(_this2.debouncing)) {
2840
- _this2.debouncing = true;
2841
- addCallbackToNextTick(function () {
2842
- if (isTrue(_this2.debouncing)) {
2843
- var _assertThisInitialize = _assertThisInitialized(_this2),
2844
- value = _assertThisInitialize.value;
2839
+ function createMethodCaller(methodName) {
2840
+ return function () {
2841
+ var vm = getAssociatedVM(this);
2842
+ var callHook = vm.callHook,
2843
+ component = vm.component;
2844
+ var fn = component[methodName];
2845
+ return callHook(vm.component, fn, ArraySlice.call(arguments));
2846
+ };
2847
+ }
2845
2848
 
2846
- var dirtyStateBeforeSetterCall = vm.isDirty,
2847
- component = vm.component,
2848
- _idx = vm.idx;
2849
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
2850
- // infinity loop if the setter itself is mutating things that
2851
- // were accessed during the previous invocation.
2849
+ function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
2850
+ return function attributeChangedCallback(attrName, oldValue, newValue) {
2851
+ if (oldValue === newValue) {
2852
+ // Ignore same values.
2853
+ return;
2854
+ }
2852
2855
 
2853
- _this2.debouncing = false;
2856
+ var propName = attributeToPropMap[attrName];
2854
2857
 
2855
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && _idx > 0) {
2856
- // immediate rehydration due to a setter driven mutation, otherwise
2857
- // the component will get rendered on the second tick, which it is not
2858
- // desirable.
2859
- rerenderVM(vm);
2860
- }
2861
- }
2862
- });
2858
+ if (isUndefined$1(propName)) {
2859
+ if (!isUndefined$1(superAttributeChangedCallback)) {
2860
+ // delegate unknown attributes to the super.
2861
+ // Typescript does not like it when you treat the `arguments` object as an array
2862
+ // @ts-ignore type-mismatch
2863
+ superAttributeChangedCallback.apply(this, arguments);
2863
2864
  }
2864
- });
2865
- _this2.debouncing = false;
2866
- return _this2;
2867
- }
2868
-
2869
- _createClass(AccessorReactiveObserver, [{
2870
- key: "reset",
2871
- value: function reset(value) {
2872
- _get2(_getPrototypeOf2(AccessorReactiveObserver.prototype), "reset", this).call(this);
2873
-
2874
- this.debouncing = false;
2875
2865
 
2876
- if (arguments.length > 0) {
2877
- this.value = value;
2878
- }
2866
+ return;
2879
2867
  }
2880
- }]);
2881
-
2882
- return AccessorReactiveObserver;
2883
- }(ReactiveObserver);
2884
-
2885
- function createPublicAccessorDescriptor(key, descriptor) {
2886
- var _get3 = descriptor.get,
2887
- _set2 = descriptor.set,
2888
- enumerable = descriptor.enumerable,
2889
- configurable = descriptor.configurable;
2890
-
2891
- if (!isFunction$1(_get3)) {
2892
-
2893
- throw new Error();
2894
- }
2895
2868
 
2896
- return {
2897
- get: function get() {
2898
-
2899
- return _get3.call(this);
2900
- },
2901
- set: function set(newValue) {
2902
- var _this3 = this;
2869
+ if (!isAttributeLocked(this, attrName)) {
2870
+ // Ignore changes triggered by the engine itself during:
2871
+ // * diffing when public props are attempting to reflect to the DOM
2872
+ // * component via `this.setAttribute()`, should never update the prop
2873
+ // Both cases, the setAttribute call is always wrapped by the unlocking of the
2874
+ // attribute to be changed
2875
+ return;
2876
+ } // Reflect attribute change to the corresponding property when changed from outside.
2903
2877
 
2904
- var vm = getAssociatedVM(this);
2905
2878
 
2906
- if (_set2) {
2907
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
2908
- var ro = vm.oar[key];
2879
+ this[propName] = newValue;
2880
+ };
2881
+ }
2909
2882
 
2910
- if (isUndefined$1(ro)) {
2911
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, _set2);
2912
- } // every time we invoke this setter from outside (through this wrapper setter)
2913
- // we should reset the value and then debounce just in case there is a pending
2914
- // invocation the next tick that is not longer relevant since the value is changing
2915
- // from outside.
2883
+ function HTMLBridgeElementFactory(SuperClass, props, methods) {
2884
+ var HTMLBridgeElement;
2885
+ /**
2886
+ * Modern browsers will have all Native Constructors as regular Classes
2887
+ * and must be instantiated with the new keyword. In older browsers,
2888
+ * specifically IE11, those are objects with a prototype property defined,
2889
+ * since they are not supposed to be extended or instantiated with the
2890
+ * new keyword. This forking logic supports both cases, specifically because
2891
+ * wc.ts relies on the construction path of the bridges to create new
2892
+ * fully qualifying web components.
2893
+ */
2916
2894
 
2895
+ if (isFunction$1(SuperClass)) {
2896
+ HTMLBridgeElement = /*#__PURE__*/function (_SuperClass) {
2897
+ _inherits(HTMLBridgeElement, _SuperClass);
2917
2898
 
2918
- ro.reset(newValue);
2919
- ro.observe(function () {
2920
- _set2.call(_this3, newValue);
2921
- });
2922
- } else {
2923
- _set2.call(this, newValue);
2924
- }
2925
- }
2926
- },
2927
- enumerable: enumerable,
2928
- configurable: configurable
2929
- };
2930
- }
2899
+ var _super4 = _createSuper(HTMLBridgeElement);
2931
2900
 
2932
- function createObservedFieldPropertyDescriptor(key) {
2933
- return {
2934
- get: function get() {
2935
- var vm = getAssociatedVM(this);
2936
- componentValueObserved(vm, key);
2937
- return vm.cmpFields[key];
2938
- },
2939
- set: function set(newValue) {
2940
- var vm = getAssociatedVM(this);
2901
+ function HTMLBridgeElement() {
2902
+ _classCallCheck(this, HTMLBridgeElement);
2941
2903
 
2942
- if (newValue !== vm.cmpFields[key]) {
2943
- vm.cmpFields[key] = newValue;
2944
- componentValueMutated(vm, key);
2945
- }
2946
- },
2947
- enumerable: true,
2948
- configurable: true
2949
- };
2950
- }
2951
- /**
2952
- * INTERNAL: This function can only be invoked by compiled code. The compiler
2953
- * will prevent this function from being imported by user-land code.
2954
- */
2904
+ return _super4.apply(this, arguments);
2905
+ }
2955
2906
 
2907
+ return _createClass(HTMLBridgeElement);
2908
+ }(SuperClass);
2909
+ } else {
2910
+ HTMLBridgeElement = function HTMLBridgeElement() {
2911
+ // Bridge classes are not supposed to be instantiated directly in
2912
+ // browsers that do not support web components.
2913
+ throw new TypeError('Illegal constructor');
2914
+ }; // prototype inheritance dance
2956
2915
 
2957
- function registerDecorators(Ctor, meta) {
2958
- var proto = Ctor.prototype;
2959
- var publicProps = meta.publicProps,
2960
- publicMethods = meta.publicMethods,
2961
- wire = meta.wire,
2962
- track = meta.track,
2963
- fields = meta.fields;
2964
- var apiMethods = create(null);
2965
- var apiFields = create(null);
2966
- var wiredMethods = create(null);
2967
- var wiredFields = create(null);
2968
- var observedFields = create(null);
2969
- var apiFieldsConfig = create(null);
2970
- var descriptor;
2971
2916
 
2972
- if (!isUndefined$1(publicProps)) {
2973
- for (var fieldName in publicProps) {
2974
- var propConfig = publicProps[fieldName];
2975
- apiFieldsConfig[fieldName] = propConfig.config;
2976
- descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
2917
+ setPrototypeOf(HTMLBridgeElement, SuperClass);
2918
+ setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
2919
+ defineProperty(HTMLBridgeElement.prototype, 'constructor', {
2920
+ writable: true,
2921
+ configurable: true,
2922
+ value: HTMLBridgeElement
2923
+ });
2924
+ } // generating the hash table for attributes to avoid duplicate fields and facilitate validation
2925
+ // and false positives in case of inheritance.
2977
2926
 
2978
- if (propConfig.config > 0) {
2979
2927
 
2980
- if (isUndefined$1(descriptor)) {
2981
- throw new Error();
2982
- }
2928
+ var attributeToPropMap = create(null);
2929
+ var superAttributeChangedCallback = SuperClass.prototype.attributeChangedCallback;
2930
+ var _SuperClass$observedA = SuperClass.observedAttributes,
2931
+ superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
2932
+ var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
2983
2933
 
2984
- descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
2985
- } else {
2986
- // with the same name, the property is defined as a public accessor. This branch is
2987
- // only here for backward compatibility reasons.
2934
+ for (var _i11 = 0, _len3 = props.length; _i11 < _len3; _i11 += 1) {
2935
+ var _propName2 = props[_i11];
2936
+ attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
2937
+ descriptors[_propName2] = {
2938
+ get: createGetter(_propName2),
2939
+ set: createSetter(_propName2),
2940
+ enumerable: true,
2941
+ configurable: true
2942
+ };
2943
+ } // expose public methods as props on the new Element Bridge
2988
2944
 
2989
2945
 
2990
- if (!isUndefined$1(descriptor) && !isUndefined$1(descriptor.get)) {
2991
- descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
2992
- } else {
2993
- descriptor = createPublicPropertyDescriptor(fieldName);
2994
- }
2995
- }
2946
+ for (var _i12 = 0, _len4 = methods.length; _i12 < _len4; _i12 += 1) {
2947
+ var methodName = methods[_i12];
2948
+ descriptors[methodName] = {
2949
+ value: createMethodCaller(methodName),
2950
+ writable: true,
2951
+ configurable: true
2952
+ };
2953
+ } // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
2954
+ // map of attributes to props. We do this after all other props and methods to avoid the possibility
2955
+ // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
2956
+ // to preserve this definition.
2996
2957
 
2997
- apiFields[fieldName] = descriptor;
2998
- defineProperty(proto, fieldName, descriptor);
2958
+
2959
+ descriptors.attributeChangedCallback = {
2960
+ value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
2961
+ }; // Specify attributes for which we want to reflect changes back to their corresponding
2962
+ // properties via attributeChangedCallback.
2963
+
2964
+ defineProperty(HTMLBridgeElement, 'observedAttributes', {
2965
+ get: function get() {
2966
+ return [].concat(_toConsumableArray(superObservedAttributes), _toConsumableArray(keys(attributeToPropMap)));
2999
2967
  }
3000
- }
2968
+ });
2969
+ defineProperties(HTMLBridgeElement.prototype, descriptors);
2970
+ return HTMLBridgeElement;
2971
+ }
3001
2972
 
3002
- if (!isUndefined$1(publicMethods)) {
3003
- forEach.call(publicMethods, function (methodName) {
3004
- descriptor = getOwnPropertyDescriptor$1(proto, methodName);
2973
+ var BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor$1, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
2974
+ freeze(BaseBridgeElement);
2975
+ seal(BaseBridgeElement.prototype);
2976
+ /*
2977
+ * Copyright (c) 2020, salesforce.com, inc.
2978
+ * All rights reserved.
2979
+ * SPDX-License-Identifier: MIT
2980
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2981
+ */
3005
2982
 
3006
- if (isUndefined$1(descriptor)) {
3007
- throw new Error();
3008
- }
2983
+ function resolveCircularModuleDependency(fn) {
2984
+ var module = fn();
2985
+ return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
2986
+ }
3009
2987
 
3010
- apiMethods[methodName] = descriptor;
3011
- });
2988
+ function isCircularModuleDependency(obj) {
2989
+ return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
2990
+ }
2991
+
2992
+ function setActiveVM(vm) {
2993
+ {
2994
+ // this method should never leak to prod
2995
+ throw new ReferenceError();
3012
2996
  }
2997
+ }
3013
2998
 
3014
- if (!isUndefined$1(wire)) {
3015
- for (var fieldOrMethodName in wire) {
3016
- var _wire$fieldOrMethodNa = wire[fieldOrMethodName],
3017
- adapter = _wire$fieldOrMethodNa.adapter,
3018
- method = _wire$fieldOrMethodNa.method,
3019
- configCallback = _wire$fieldOrMethodNa.config,
3020
- _wire$fieldOrMethodNa2 = _wire$fieldOrMethodNa.dynamic,
3021
- dynamic = _wire$fieldOrMethodNa2 === void 0 ? [] : _wire$fieldOrMethodNa2;
3022
- descriptor = getOwnPropertyDescriptor$1(proto, fieldOrMethodName);
2999
+ function swapTemplate(oldTpl, newTpl) {
3023
3000
 
3024
- if (method === 1) {
3001
+ if (!runtimeFlags.ENABLE_HMR) {
3002
+ throw new Error('HMR is not enabled');
3003
+ }
3025
3004
 
3026
- if (isUndefined$1(descriptor)) {
3027
- throw new Error();
3028
- }
3005
+ return false;
3006
+ }
3029
3007
 
3030
- wiredMethods[fieldOrMethodName] = descriptor;
3031
- storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
3032
- } else {
3008
+ function swapComponent(oldComponent, newComponent) {
3033
3009
 
3034
- descriptor = internalWireFieldDecorator(fieldOrMethodName);
3035
- wiredFields[fieldOrMethodName] = descriptor;
3036
- storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic);
3037
- defineProperty(proto, fieldOrMethodName, descriptor);
3038
- }
3039
- }
3010
+ if (!runtimeFlags.ENABLE_HMR) {
3011
+ throw new Error('HMR is not enabled');
3040
3012
  }
3041
3013
 
3042
- if (!isUndefined$1(track)) {
3043
- for (var _fieldName in track) {
3044
- descriptor = getOwnPropertyDescriptor$1(proto, _fieldName);
3014
+ return false;
3015
+ }
3045
3016
 
3046
- descriptor = internalTrackDecorator(_fieldName);
3047
- defineProperty(proto, _fieldName, descriptor);
3048
- }
3017
+ function swapStyle(oldStyle, newStyle) {
3018
+
3019
+ if (!runtimeFlags.ENABLE_HMR) {
3020
+ throw new Error('HMR is not enabled');
3049
3021
  }
3050
3022
 
3051
- if (!isUndefined$1(fields)) {
3052
- for (var _i11 = 0, n = fields.length; _i11 < n; _i11++) {
3053
- var _fieldName2 = fields[_i11];
3054
- descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
3055
- // tracked property. This is only here for backward compatibility purposes.
3023
+ return false;
3024
+ }
3025
+ /*
3026
+ * Copyright (c) 2018, salesforce.com, inc.
3027
+ * All rights reserved.
3028
+ * SPDX-License-Identifier: MIT
3029
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3030
+ */
3056
3031
 
3057
3032
 
3058
- var isDuplicatePublicProp = !isUndefined$1(publicProps) && _fieldName2 in publicProps;
3059
- var isDuplicateTrackedProp = !isUndefined$1(track) && _fieldName2 in track;
3033
+ var CtorToDefMap = new WeakMap();
3060
3034
 
3061
- if (!isDuplicatePublicProp && !isDuplicateTrackedProp) {
3062
- observedFields[_fieldName2] = createObservedFieldPropertyDescriptor(_fieldName2);
3063
- }
3064
- }
3065
- }
3035
+ function getCtorProto(Ctor) {
3036
+ var proto = getPrototypeOf$1(Ctor);
3066
3037
 
3067
- setDecoratorsMeta(Ctor, {
3068
- apiMethods: apiMethods,
3069
- apiFields: apiFields,
3070
- apiFieldsConfig: apiFieldsConfig,
3071
- wiredMethods: wiredMethods,
3072
- wiredFields: wiredFields,
3073
- observedFields: observedFields
3074
- });
3075
- return Ctor;
3076
- }
3038
+ if (isNull(proto)) {
3039
+ throw new ReferenceError("Invalid prototype chain for ".concat(Ctor.name, ", you must extend LightningElement."));
3040
+ } // covering the cases where the ref is circular in AMD
3077
3041
 
3078
- var signedDecoratorToMetaMap = new Map();
3079
3042
 
3080
- function setDecoratorsMeta(Ctor, meta) {
3081
- signedDecoratorToMetaMap.set(Ctor, meta);
3082
- }
3043
+ if (isCircularModuleDependency(proto)) {
3044
+ var p = resolveCircularModuleDependency(proto);
3045
+ // of our Base class without having to leak it to user-land. If the circular function returns
3046
+ // itself, that's the signal that we have hit the end of the proto chain, which must always
3047
+ // be base.
3083
3048
 
3084
- var defaultMeta = {
3085
- apiMethods: EmptyObject,
3086
- apiFields: EmptyObject,
3087
- apiFieldsConfig: EmptyObject,
3088
- wiredMethods: EmptyObject,
3089
- wiredFields: EmptyObject,
3090
- observedFields: EmptyObject
3091
- };
3092
3049
 
3093
- function getDecoratorsMeta(Ctor) {
3094
- var meta = signedDecoratorToMetaMap.get(Ctor);
3095
- return isUndefined$1(meta) ? defaultMeta : meta;
3050
+ proto = p === proto ? LightningElement : p;
3051
+ }
3052
+
3053
+ return proto;
3096
3054
  }
3097
3055
 
3098
- var signedTemplateSet = new Set();
3056
+ function createComponentDef(Ctor) {
3057
+ var ctorShadowSupportMode = Ctor.shadowSupportMode,
3058
+ ctorRenderMode = Ctor.renderMode;
3099
3059
 
3100
- function defaultEmptyTemplate() {
3101
- return [];
3102
- }
3060
+ var decoratorsMeta = getDecoratorsMeta(Ctor);
3061
+ var apiFields = decoratorsMeta.apiFields,
3062
+ apiFieldsConfig = decoratorsMeta.apiFieldsConfig,
3063
+ apiMethods = decoratorsMeta.apiMethods,
3064
+ wiredFields = decoratorsMeta.wiredFields,
3065
+ wiredMethods = decoratorsMeta.wiredMethods,
3066
+ observedFields = decoratorsMeta.observedFields;
3067
+ var proto = Ctor.prototype;
3068
+ var connectedCallback = proto.connectedCallback,
3069
+ disconnectedCallback = proto.disconnectedCallback,
3070
+ renderedCallback = proto.renderedCallback,
3071
+ errorCallback = proto.errorCallback,
3072
+ render = proto.render;
3073
+ var superProto = getCtorProto(Ctor);
3074
+ var superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
3075
+ var bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
3076
+ var props = assign(create(null), superDef.props, apiFields);
3077
+ var propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
3078
+ var methods = assign(create(null), superDef.methods, apiMethods);
3079
+ var wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
3080
+ connectedCallback = connectedCallback || superDef.connectedCallback;
3081
+ disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
3082
+ renderedCallback = renderedCallback || superDef.renderedCallback;
3083
+ errorCallback = errorCallback || superDef.errorCallback;
3084
+ render = render || superDef.render;
3085
+ var shadowSupportMode = superDef.shadowSupportMode;
3086
+
3087
+ if (!isUndefined$1(ctorShadowSupportMode)) {
3088
+ shadowSupportMode = ctorShadowSupportMode;
3089
+ }
3103
3090
 
3104
- signedTemplateSet.add(defaultEmptyTemplate);
3091
+ var renderMode = superDef.renderMode;
3105
3092
 
3106
- function isTemplateRegistered(tpl) {
3107
- return signedTemplateSet.has(tpl);
3108
- }
3109
- /**
3110
- * INTERNAL: This function can only be invoked by compiled code. The compiler
3111
- * will prevent this function from being imported by userland code.
3112
- */
3093
+ if (!isUndefined$1(ctorRenderMode)) {
3094
+ renderMode = ctorRenderMode === 'light' ? 0
3095
+ /* Light */
3096
+ : 1
3097
+ /* Shadow */
3098
+ ;
3099
+ }
3113
3100
 
3101
+ var template = getComponentRegisteredTemplate(Ctor) || superDef.template;
3102
+ var name = Ctor.name || superDef.name; // installing observed fields into the prototype.
3114
3103
 
3115
- function registerTemplate(tpl) {
3116
- signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3117
- // assignment of templates easily, without too much transformation
3104
+ defineProperties(proto, observedFields);
3105
+ var def = {
3106
+ ctor: Ctor,
3107
+ name: name,
3108
+ wire: wire,
3109
+ props: props,
3110
+ propsConfig: propsConfig,
3111
+ methods: methods,
3112
+ bridge: bridge,
3113
+ template: template,
3114
+ renderMode: renderMode,
3115
+ shadowSupportMode: shadowSupportMode,
3116
+ connectedCallback: connectedCallback,
3117
+ disconnectedCallback: disconnectedCallback,
3118
+ renderedCallback: renderedCallback,
3119
+ errorCallback: errorCallback,
3120
+ render: render
3121
+ };
3118
3122
 
3119
- return tpl;
3123
+ return def;
3120
3124
  }
3121
3125
  /**
3122
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3123
- * libraries to sanitize vulnerable attributes.
3126
+ * EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
3127
+ * subject to change or being removed.
3124
3128
  */
3125
3129
 
3126
3130
 
3127
- function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3128
- // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3129
- // ran off-core this function becomes a noop and returns the user authored value.
3130
- return attrValue;
3131
- }
3132
- /*
3133
- * Copyright (c) 2018, salesforce.com, inc.
3134
- * All rights reserved.
3135
- * SPDX-License-Identifier: MIT
3136
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3137
- */
3138
- // from the element instance, and get the value or set a new value on the component.
3139
- // This means that across different elements, similar names can get the exact same
3140
- // descriptor, so we can cache them:
3131
+ function isComponentConstructor(ctor) {
3132
+ if (!isFunction$1(ctor)) {
3133
+ return false;
3134
+ } // Fast path: LightningElement is part of the prototype chain of the constructor.
3141
3135
 
3142
3136
 
3143
- var cachedGetterByKey = create(null);
3144
- var cachedSetterByKey = create(null);
3137
+ if (ctor.prototype instanceof LightningElement) {
3138
+ return true;
3139
+ } // Slow path: LightningElement is not part of the prototype chain of the constructor, we need
3140
+ // climb up the constructor prototype chain to check in case there are circular dependencies
3141
+ // to resolve.
3145
3142
 
3146
- function createGetter(key) {
3147
- var fn = cachedGetterByKey[key];
3148
3143
 
3149
- if (isUndefined$1(fn)) {
3150
- fn = cachedGetterByKey[key] = function () {
3151
- var vm = getAssociatedVM(this);
3152
- var getHook = vm.getHook;
3153
- return getHook(vm.component, key);
3154
- };
3155
- }
3144
+ var current = ctor;
3156
3145
 
3157
- return fn;
3158
- }
3146
+ do {
3147
+ if (isCircularModuleDependency(current)) {
3148
+ var circularResolved = resolveCircularModuleDependency(current); // If the circular function returns itself, that's the signal that we have hit the end
3149
+ // of the proto chain, which must always be a valid base constructor.
3159
3150
 
3160
- function createSetter(key) {
3161
- var fn = cachedSetterByKey[key];
3151
+ if (circularResolved === current) {
3152
+ return true;
3153
+ }
3162
3154
 
3163
- if (isUndefined$1(fn)) {
3164
- fn = cachedSetterByKey[key] = function (newValue) {
3165
- var vm = getAssociatedVM(this);
3166
- var setHook = vm.setHook;
3167
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
3168
- setHook(vm.component, key, newValue);
3169
- };
3170
- }
3155
+ current = circularResolved;
3156
+ }
3171
3157
 
3172
- return fn;
3173
- }
3158
+ if (current === LightningElement) {
3159
+ return true;
3160
+ }
3161
+ } while (!isNull(current) && (current = getPrototypeOf$1(current))); // Finally return false if the LightningElement is not part of the prototype chain.
3174
3162
 
3175
- function createMethodCaller(methodName) {
3176
- return function () {
3177
- var vm = getAssociatedVM(this);
3178
- var callHook = vm.callHook,
3179
- component = vm.component;
3180
- var fn = component[methodName];
3181
- return callHook(vm.component, fn, ArraySlice.call(arguments));
3182
- };
3163
+
3164
+ return false;
3183
3165
  }
3184
3166
 
3185
- function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
3186
- return function attributeChangedCallback(attrName, oldValue, newValue) {
3187
- if (oldValue === newValue) {
3188
- // Ignore same values.
3189
- return;
3190
- }
3167
+ function getComponentInternalDef(Ctor) {
3191
3168
 
3192
- var propName = attributeToPropMap[attrName];
3169
+ var def = CtorToDefMap.get(Ctor);
3193
3170
 
3194
- if (isUndefined$1(propName)) {
3195
- if (!isUndefined$1(superAttributeChangedCallback)) {
3196
- // delegate unknown attributes to the super.
3197
- // Typescript does not like it when you treat the `arguments` object as an array
3198
- // @ts-ignore type-mismatch
3199
- superAttributeChangedCallback.apply(this, arguments);
3200
- }
3171
+ if (isUndefined$1(def)) {
3172
+ if (isCircularModuleDependency(Ctor)) {
3173
+ var resolvedCtor = resolveCircularModuleDependency(Ctor);
3174
+ def = getComponentInternalDef(resolvedCtor); // Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
3175
+ // look up the definition in cache instead of re-resolving and recreating the def.
3201
3176
 
3202
- return;
3177
+ CtorToDefMap.set(Ctor, def);
3178
+ return def;
3203
3179
  }
3204
3180
 
3205
- if (!isAttributeLocked(this, attrName)) {
3206
- // Ignore changes triggered by the engine itself during:
3207
- // * diffing when public props are attempting to reflect to the DOM
3208
- // * component via `this.setAttribute()`, should never update the prop
3209
- // Both cases, the setAttribute call is always wrapped by the unlocking of the
3210
- // attribute to be changed
3211
- return;
3212
- } // Reflect attribute change to the corresponding property when changed from outside.
3181
+ if (!isComponentConstructor(Ctor)) {
3182
+ 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."));
3183
+ }
3213
3184
 
3185
+ def = createComponentDef(Ctor);
3186
+ CtorToDefMap.set(Ctor, def);
3187
+ }
3214
3188
 
3215
- this[propName] = newValue;
3216
- };
3189
+ return def;
3217
3190
  }
3218
3191
 
3219
- function HTMLBridgeElementFactory(SuperClass, props, methods) {
3220
- var HTMLBridgeElement;
3221
- /**
3222
- * Modern browsers will have all Native Constructors as regular Classes
3223
- * and must be instantiated with the new keyword. In older browsers,
3224
- * specifically IE11, those are objects with a prototype property defined,
3225
- * since they are not supposed to be extended or instantiated with the
3226
- * new keyword. This forking logic supports both cases, specifically because
3227
- * wc.ts relies on the construction path of the bridges to create new
3228
- * fully qualifying web components.
3229
- */
3192
+ var lightingElementDef = {
3193
+ ctor: LightningElement,
3194
+ name: LightningElement.name,
3195
+ props: lightningBasedDescriptors,
3196
+ propsConfig: EmptyObject,
3197
+ methods: EmptyObject,
3198
+ renderMode: 1
3199
+ /* Shadow */
3200
+ ,
3201
+ shadowSupportMode: "reset"
3202
+ /* Default */
3203
+ ,
3204
+ wire: EmptyObject,
3205
+ bridge: BaseBridgeElement,
3206
+ template: defaultEmptyTemplate,
3207
+ render: LightningElement.prototype.render
3208
+ };
3209
+ /**
3210
+ * EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
3211
+ * subject to change or being removed.
3212
+ */
3230
3213
 
3231
- if (isFunction$1(SuperClass)) {
3232
- HTMLBridgeElement = /*#__PURE__*/function (_SuperClass) {
3233
- _inherits(HTMLBridgeElement, _SuperClass);
3214
+ function getComponentDef(Ctor) {
3215
+ var def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
3216
+ // for some external services, e.g.: Locker Service, usually, all they care
3217
+ // is about the shape of the constructor, the internals of it are not relevant
3218
+ // because they don't have a way to mess with that.
3234
3219
 
3235
- var _super4 = _createSuper(HTMLBridgeElement);
3220
+ var ctor = def.ctor,
3221
+ name = def.name,
3222
+ props = def.props,
3223
+ propsConfig = def.propsConfig,
3224
+ methods = def.methods;
3225
+ var publicProps = {};
3236
3226
 
3237
- function HTMLBridgeElement() {
3238
- _classCallCheck(this, HTMLBridgeElement);
3227
+ for (var key in props) {
3228
+ // avoid leaking the reference to the public props descriptors
3229
+ publicProps[key] = {
3230
+ config: propsConfig[key] || 0,
3231
+ type: "any"
3232
+ /* any */
3233
+ ,
3234
+ attr: htmlPropertyToAttribute(key)
3235
+ };
3236
+ }
3239
3237
 
3240
- return _super4.apply(this, arguments);
3241
- }
3238
+ var publicMethods = {};
3242
3239
 
3243
- return _createClass(HTMLBridgeElement);
3244
- }(SuperClass);
3245
- } else {
3246
- HTMLBridgeElement = function HTMLBridgeElement() {
3247
- // Bridge classes are not supposed to be instantiated directly in
3248
- // browsers that do not support web components.
3249
- throw new TypeError('Illegal constructor');
3250
- }; // prototype inheritance dance
3240
+ for (var _key2 in methods) {
3241
+ // avoid leaking the reference to the public method descriptors
3242
+ publicMethods[_key2] = methods[_key2].value;
3243
+ }
3251
3244
 
3245
+ return {
3246
+ ctor: ctor,
3247
+ name: name,
3248
+ props: publicProps,
3249
+ methods: publicMethods
3250
+ };
3251
+ }
3252
+ /*
3253
+ * Copyright (c) 2018, salesforce.com, inc.
3254
+ * All rights reserved.
3255
+ * SPDX-License-Identifier: MIT
3256
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3257
+ */
3252
3258
 
3253
- setPrototypeOf(HTMLBridgeElement, SuperClass);
3254
- setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
3255
- defineProperty(HTMLBridgeElement.prototype, 'constructor', {
3256
- writable: true,
3257
- configurable: true,
3258
- value: HTMLBridgeElement
3259
- });
3260
- } // generating the hash table for attributes to avoid duplicate fields and facilitate validation
3261
- // and false positives in case of inheritance.
3262
3259
 
3260
+ var xlinkNS = 'http://www.w3.org/1999/xlink';
3261
+ var xmlNS = 'http://www.w3.org/XML/1998/namespace';
3262
+ var ColonCharCode = 58;
3263
3263
 
3264
- var attributeToPropMap = create(null);
3265
- var superAttributeChangedCallback = SuperClass.prototype.attributeChangedCallback;
3266
- var _SuperClass$observedA = SuperClass.observedAttributes,
3267
- superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
3268
- var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
3264
+ function patchAttributes(oldVnode, vnode) {
3265
+ var attrs = vnode.data.attrs;
3269
3266
 
3270
- for (var _i12 = 0, _len3 = props.length; _i12 < _len3; _i12 += 1) {
3271
- var _propName2 = props[_i12];
3272
- attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
3273
- descriptors[_propName2] = {
3274
- get: createGetter(_propName2),
3275
- set: createSetter(_propName2),
3276
- enumerable: true,
3277
- configurable: true
3278
- };
3279
- } // expose public methods as props on the new Element Bridge
3267
+ if (isUndefined$1(attrs)) {
3268
+ return;
3269
+ }
3280
3270
 
3271
+ var oldAttrs = isNull(oldVnode) ? EmptyObject : oldVnode.data.attrs;
3281
3272
 
3282
- for (var _i13 = 0, _len4 = methods.length; _i13 < _len4; _i13 += 1) {
3283
- var methodName = methods[_i13];
3284
- descriptors[methodName] = {
3285
- value: createMethodCaller(methodName),
3286
- writable: true,
3287
- configurable: true
3288
- };
3289
- } // creating a new attributeChangedCallback per bridge because they are bound to the corresponding
3290
- // map of attributes to props. We do this after all other props and methods to avoid the possibility
3291
- // of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
3292
- // to preserve this definition.
3273
+ if (oldAttrs === attrs) {
3274
+ return;
3275
+ }
3293
3276
 
3277
+ var elm = vnode.elm;
3294
3278
 
3295
- descriptors.attributeChangedCallback = {
3296
- value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
3297
- }; // Specify attributes for which we want to reflect changes back to their corresponding
3298
- // properties via attributeChangedCallback.
3279
+ for (var key in attrs) {
3280
+ var cur = attrs[key];
3281
+ var old = oldAttrs[key];
3299
3282
 
3300
- defineProperty(HTMLBridgeElement, 'observedAttributes', {
3301
- get: function get() {
3302
- return [].concat(_toConsumableArray(superObservedAttributes), _toConsumableArray(keys(attributeToPropMap)));
3283
+ if (old !== cur) {
3284
+ unlockAttribute(elm, key);
3285
+
3286
+ if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
3287
+ // Assume xml namespace
3288
+ setAttribute$1(elm, key, cur, xmlNS);
3289
+ } else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
3290
+ // Assume xlink namespace
3291
+ setAttribute$1(elm, key, cur, xlinkNS);
3292
+ } else if (isNull(cur) || isUndefined$1(cur)) {
3293
+ removeAttribute$1(elm, key);
3294
+ } else {
3295
+ setAttribute$1(elm, key, cur);
3296
+ }
3297
+
3298
+ lockAttribute();
3303
3299
  }
3304
- });
3305
- defineProperties(HTMLBridgeElement.prototype, descriptors);
3306
- return HTMLBridgeElement;
3300
+ }
3307
3301
  }
3308
-
3309
- var BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor$1, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
3310
- freeze(BaseBridgeElement);
3311
- seal(BaseBridgeElement.prototype);
3312
3302
  /*
3313
- * Copyright (c) 2020, salesforce.com, inc.
3303
+ * Copyright (c) 2018, salesforce.com, inc.
3314
3304
  * All rights reserved.
3315
3305
  * SPDX-License-Identifier: MIT
3316
3306
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3317
3307
  */
3318
3308
 
3319
- function resolveCircularModuleDependency(fn) {
3320
- var module = fn();
3321
- return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
3322
- }
3323
-
3324
- function isCircularModuleDependency(obj) {
3325
- return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
3326
- }
3327
3309
 
3328
- function setActiveVM(vm) {
3329
- {
3330
- // this method should never leak to prod
3331
- throw new ReferenceError();
3332
- }
3310
+ function isLiveBindingProp(sel, key) {
3311
+ // For properties with live bindings, we read values from the DOM element
3312
+ // instead of relying on internally tracked values.
3313
+ return sel === 'input' && (key === 'value' || key === 'checked');
3333
3314
  }
3334
3315
 
3335
- function swapTemplate(oldTpl, newTpl) {
3316
+ function patchProps(oldVnode, vnode) {
3317
+ var props = vnode.data.props;
3336
3318
 
3337
- if (!runtimeFlags.ENABLE_HMR) {
3338
- throw new Error('HMR is not enabled');
3319
+ if (isUndefined$1(props)) {
3320
+ return;
3339
3321
  }
3340
3322
 
3341
- return false;
3342
- }
3343
-
3344
- function swapComponent(oldComponent, newComponent) {
3323
+ var oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
3345
3324
 
3346
- if (!runtimeFlags.ENABLE_HMR) {
3347
- throw new Error('HMR is not enabled');
3325
+ if (oldProps === props) {
3326
+ return;
3348
3327
  }
3349
3328
 
3350
- return false;
3351
- }
3329
+ var isFirstPatch = isNull(oldVnode);
3330
+ var elm = vnode.elm,
3331
+ sel = vnode.sel;
3352
3332
 
3353
- function swapStyle(oldStyle, newStyle) {
3333
+ for (var key in props) {
3334
+ var cur = props[key]; // Set the property if it's the first time is is patched or if the previous property is
3335
+ // different than the one previously set.
3354
3336
 
3355
- if (!runtimeFlags.ENABLE_HMR) {
3356
- throw new Error('HMR is not enabled');
3337
+ if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty$1(elm, key) : oldProps[key])) {
3338
+ setProperty$1(elm, key, cur);
3339
+ }
3357
3340
  }
3358
-
3359
- return false;
3360
3341
  }
3361
3342
  /*
3362
3343
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3366,224 +3347,167 @@
3366
3347
  */
3367
3348
 
3368
3349
 
3369
- var CtorToDefMap = new WeakMap();
3370
-
3371
- function getCtorProto(Ctor) {
3372
- var proto = getPrototypeOf$1(Ctor);
3373
-
3374
- if (isNull(proto)) {
3375
- throw new ReferenceError("Invalid prototype chain for ".concat(Ctor.name, ", you must extend LightningElement."));
3376
- } // covering the cases where the ref is circular in AMD
3350
+ var classNameToClassMap = create(null);
3377
3351
 
3352
+ function getMapFromClassName(className) {
3353
+ // Intentionally using == to match undefined and null values from computed style attribute
3354
+ if (className == null) {
3355
+ return EmptyObject;
3356
+ } // computed class names must be string
3378
3357
 
3379
- if (isCircularModuleDependency(proto)) {
3380
- var p = resolveCircularModuleDependency(proto);
3381
- // of our Base class without having to leak it to user-land. If the circular function returns
3382
- // itself, that's the signal that we have hit the end of the proto chain, which must always
3383
- // be base.
3384
3358
 
3359
+ className = isString(className) ? className : className + '';
3360
+ var map = classNameToClassMap[className];
3385
3361
 
3386
- proto = p === proto ? LightningElement : p;
3362
+ if (map) {
3363
+ return map;
3387
3364
  }
3388
3365
 
3389
- return proto;
3390
- }
3391
-
3392
- function createComponentDef(Ctor) {
3393
- var ctorShadowSupportMode = Ctor.shadowSupportMode,
3394
- ctorRenderMode = Ctor.renderMode;
3366
+ map = create(null);
3367
+ var start = 0;
3368
+ var o;
3369
+ var len = className.length;
3395
3370
 
3396
- var decoratorsMeta = getDecoratorsMeta(Ctor);
3397
- var apiFields = decoratorsMeta.apiFields,
3398
- apiFieldsConfig = decoratorsMeta.apiFieldsConfig,
3399
- apiMethods = decoratorsMeta.apiMethods,
3400
- wiredFields = decoratorsMeta.wiredFields,
3401
- wiredMethods = decoratorsMeta.wiredMethods,
3402
- observedFields = decoratorsMeta.observedFields;
3403
- var proto = Ctor.prototype;
3404
- var connectedCallback = proto.connectedCallback,
3405
- disconnectedCallback = proto.disconnectedCallback,
3406
- renderedCallback = proto.renderedCallback,
3407
- errorCallback = proto.errorCallback,
3408
- render = proto.render;
3409
- var superProto = getCtorProto(Ctor);
3410
- var superDef = superProto !== LightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
3411
- var bridge = HTMLBridgeElementFactory(superDef.bridge, keys(apiFields), keys(apiMethods));
3412
- var props = assign(create(null), superDef.props, apiFields);
3413
- var propsConfig = assign(create(null), superDef.propsConfig, apiFieldsConfig);
3414
- var methods = assign(create(null), superDef.methods, apiMethods);
3415
- var wire = assign(create(null), superDef.wire, wiredFields, wiredMethods);
3416
- connectedCallback = connectedCallback || superDef.connectedCallback;
3417
- disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
3418
- renderedCallback = renderedCallback || superDef.renderedCallback;
3419
- errorCallback = errorCallback || superDef.errorCallback;
3420
- render = render || superDef.render;
3421
- var shadowSupportMode = superDef.shadowSupportMode;
3371
+ for (o = 0; o < len; o++) {
3372
+ if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
3373
+ if (o > start) {
3374
+ map[StringSlice.call(className, start, o)] = true;
3375
+ }
3422
3376
 
3423
- if (!isUndefined$1(ctorShadowSupportMode)) {
3424
- shadowSupportMode = ctorShadowSupportMode;
3377
+ start = o + 1;
3378
+ }
3425
3379
  }
3426
3380
 
3427
- var renderMode = superDef.renderMode;
3428
-
3429
- if (!isUndefined$1(ctorRenderMode)) {
3430
- renderMode = ctorRenderMode === 'light' ? 0
3431
- /* Light */
3432
- : 1
3433
- /* Shadow */
3434
- ;
3381
+ if (o > start) {
3382
+ map[StringSlice.call(className, start, o)] = true;
3435
3383
  }
3436
3384
 
3437
- var template = getComponentRegisteredTemplate(Ctor) || superDef.template;
3438
- var name = Ctor.name || superDef.name; // installing observed fields into the prototype.
3439
-
3440
- defineProperties(proto, observedFields);
3441
- var def = {
3442
- ctor: Ctor,
3443
- name: name,
3444
- wire: wire,
3445
- props: props,
3446
- propsConfig: propsConfig,
3447
- methods: methods,
3448
- bridge: bridge,
3449
- template: template,
3450
- renderMode: renderMode,
3451
- shadowSupportMode: shadowSupportMode,
3452
- connectedCallback: connectedCallback,
3453
- disconnectedCallback: disconnectedCallback,
3454
- renderedCallback: renderedCallback,
3455
- errorCallback: errorCallback,
3456
- render: render
3457
- };
3385
+ classNameToClassMap[className] = map;
3458
3386
 
3459
- return def;
3387
+ return map;
3460
3388
  }
3461
- /**
3462
- * EXPERIMENTAL: This function allows for the identification of LWC constructors. This API is
3463
- * subject to change or being removed.
3464
- */
3465
3389
 
3390
+ function patchClassAttribute(oldVnode, vnode) {
3391
+ var elm = vnode.elm,
3392
+ newClass = vnode.data.className;
3393
+ var oldClass = isNull(oldVnode) ? undefined : oldVnode.data.className;
3466
3394
 
3467
- function isComponentConstructor(ctor) {
3468
- if (!isFunction$1(ctor)) {
3469
- return false;
3470
- } // Fast path: LightningElement is part of the prototype chain of the constructor.
3395
+ if (oldClass === newClass) {
3396
+ return;
3397
+ }
3471
3398
 
3399
+ var classList = getClassList$1(elm);
3400
+ var newClassMap = getMapFromClassName(newClass);
3401
+ var oldClassMap = getMapFromClassName(oldClass);
3402
+ var name;
3472
3403
 
3473
- if (ctor.prototype instanceof LightningElement) {
3474
- return true;
3475
- } // Slow path: LightningElement is not part of the prototype chain of the constructor, we need
3476
- // climb up the constructor prototype chain to check in case there are circular dependencies
3477
- // to resolve.
3404
+ for (name in oldClassMap) {
3405
+ // remove only if it is not in the new class collection and it is not set from within the instance
3406
+ if (isUndefined$1(newClassMap[name])) {
3407
+ classList.remove(name);
3408
+ }
3409
+ }
3410
+
3411
+ for (name in newClassMap) {
3412
+ if (isUndefined$1(oldClassMap[name])) {
3413
+ classList.add(name);
3414
+ }
3415
+ }
3416
+ }
3417
+ /*
3418
+ * Copyright (c) 2018, salesforce.com, inc.
3419
+ * All rights reserved.
3420
+ * SPDX-License-Identifier: MIT
3421
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3422
+ */
3478
3423
 
3479
3424
 
3480
- var current = ctor;
3425
+ function patchStyleAttribute(oldVnode, vnode) {
3426
+ var elm = vnode.elm,
3427
+ newStyle = vnode.data.style;
3428
+ var oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
3481
3429
 
3482
- do {
3483
- if (isCircularModuleDependency(current)) {
3484
- var circularResolved = resolveCircularModuleDependency(current); // If the circular function returns itself, that's the signal that we have hit the end
3485
- // of the proto chain, which must always be a valid base constructor.
3430
+ if (oldStyle === newStyle) {
3431
+ return;
3432
+ }
3486
3433
 
3487
- if (circularResolved === current) {
3488
- return true;
3489
- }
3434
+ if (!isString(newStyle) || newStyle === '') {
3435
+ removeAttribute$1(elm, 'style');
3436
+ } else {
3437
+ setAttribute$1(elm, 'style', newStyle);
3438
+ }
3439
+ }
3440
+ /*
3441
+ * Copyright (c) 2018, salesforce.com, inc.
3442
+ * All rights reserved.
3443
+ * SPDX-License-Identifier: MIT
3444
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3445
+ */
3490
3446
 
3491
- current = circularResolved;
3492
- }
3493
3447
 
3494
- if (current === LightningElement) {
3495
- return true;
3496
- }
3497
- } while (!isNull(current) && (current = getPrototypeOf$1(current))); // Finally return false if the LightningElement is not part of the prototype chain.
3448
+ function applyEventListeners(vnode) {
3449
+ var elm = vnode.elm,
3450
+ on = vnode.data.on;
3498
3451
 
3452
+ if (isUndefined$1(on)) {
3453
+ return;
3454
+ }
3499
3455
 
3500
- return false;
3456
+ for (var name in on) {
3457
+ var handler = on[name];
3458
+ addEventListener$1(elm, name, handler);
3459
+ }
3501
3460
  }
3461
+ /*
3462
+ * Copyright (c) 2018, salesforce.com, inc.
3463
+ * All rights reserved.
3464
+ * SPDX-License-Identifier: MIT
3465
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3466
+ */
3467
+ // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
3468
+ // different classnames properties individually instead of via a string.
3502
3469
 
3503
- function getComponentInternalDef(Ctor) {
3504
-
3505
- var def = CtorToDefMap.get(Ctor);
3506
3470
 
3507
- if (isUndefined$1(def)) {
3508
- if (isCircularModuleDependency(Ctor)) {
3509
- var resolvedCtor = resolveCircularModuleDependency(Ctor);
3510
- def = getComponentInternalDef(resolvedCtor); // Cache the unresolved component ctor too. The next time if the same unresolved ctor is used,
3511
- // look up the definition in cache instead of re-resolving and recreating the def.
3471
+ function applyStaticClassAttribute(vnode) {
3472
+ var elm = vnode.elm,
3473
+ classMap = vnode.data.classMap;
3512
3474
 
3513
- CtorToDefMap.set(Ctor, def);
3514
- return def;
3515
- }
3475
+ if (isUndefined$1(classMap)) {
3476
+ return;
3477
+ }
3516
3478
 
3517
- if (!isComponentConstructor(Ctor)) {
3518
- 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."));
3519
- }
3479
+ var classList = getClassList$1(elm);
3520
3480
 
3521
- def = createComponentDef(Ctor);
3522
- CtorToDefMap.set(Ctor, def);
3481
+ for (var name in classMap) {
3482
+ classList.add(name);
3523
3483
  }
3524
-
3525
- return def;
3526
3484
  }
3527
-
3528
- var lightingElementDef = {
3529
- ctor: LightningElement,
3530
- name: LightningElement.name,
3531
- props: lightningBasedDescriptors,
3532
- propsConfig: EmptyObject,
3533
- methods: EmptyObject,
3534
- renderMode: 1
3535
- /* Shadow */
3536
- ,
3537
- shadowSupportMode: "reset"
3538
- /* Default */
3539
- ,
3540
- wire: EmptyObject,
3541
- bridge: BaseBridgeElement,
3542
- template: defaultEmptyTemplate,
3543
- render: LightningElement.prototype.render
3544
- };
3545
- /**
3546
- * EXPERIMENTAL: This function allows for the collection of internal component metadata. This API is
3547
- * subject to change or being removed.
3485
+ /*
3486
+ * Copyright (c) 2018, salesforce.com, inc.
3487
+ * All rights reserved.
3488
+ * SPDX-License-Identifier: MIT
3489
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3548
3490
  */
3491
+ // The compiler takes care of transforming the inline style into an object. It's faster to set the
3492
+ // different style properties individually instead of via a string.
3549
3493
 
3550
- function getComponentDef(Ctor) {
3551
- var def = getComponentInternalDef(Ctor); // From the internal def object, we need to extract the info that is useful
3552
- // for some external services, e.g.: Locker Service, usually, all they care
3553
- // is about the shape of the constructor, the internals of it are not relevant
3554
- // because they don't have a way to mess with that.
3555
3494
 
3556
- var ctor = def.ctor,
3557
- name = def.name,
3558
- props = def.props,
3559
- propsConfig = def.propsConfig,
3560
- methods = def.methods;
3561
- var publicProps = {};
3495
+ function applyStaticStyleAttribute(vnode) {
3496
+ var elm = vnode.elm,
3497
+ styleDecls = vnode.data.styleDecls;
3562
3498
 
3563
- for (var key in props) {
3564
- // avoid leaking the reference to the public props descriptors
3565
- publicProps[key] = {
3566
- config: propsConfig[key] || 0,
3567
- type: "any"
3568
- /* any */
3569
- ,
3570
- attr: htmlPropertyToAttribute(key)
3571
- };
3499
+ if (isUndefined$1(styleDecls)) {
3500
+ return;
3572
3501
  }
3573
3502
 
3574
- var publicMethods = {};
3503
+ for (var _i13 = 0; _i13 < styleDecls.length; _i13++) {
3504
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i13], 3),
3505
+ prop = _styleDecls$_i[0],
3506
+ value = _styleDecls$_i[1],
3507
+ important = _styleDecls$_i[2];
3575
3508
 
3576
- for (var _key2 in methods) {
3577
- // avoid leaking the reference to the public method descriptors
3578
- publicMethods[_key2] = methods[_key2].value;
3509
+ setCSSStyleProperty$1(elm, prop, value, important);
3579
3510
  }
3580
-
3581
- return {
3582
- ctor: ctor,
3583
- name: name,
3584
- props: publicProps,
3585
- methods: publicMethods
3586
- };
3587
3511
  }
3588
3512
  /*
3589
3513
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3632,28 +3556,24 @@
3632
3556
  remove$1(vnode.elm, parentNode);
3633
3557
  }
3634
3558
 
3635
- function createElmHook(vnode) {
3636
- modEvents.create(vnode); // Attrs need to be applied to element before props
3637
- // IE11 will wipe out value on radio inputs if value
3638
- // is set before type=radio.
3559
+ function patchElementPropsAndAttrs(oldVnode, vnode) {
3560
+ if (isNull(oldVnode)) {
3561
+ applyEventListeners(vnode);
3562
+ applyStaticClassAttribute(vnode);
3563
+ applyStaticStyleAttribute(vnode);
3564
+ } // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
3565
+ // value is set before type=radio.
3639
3566
 
3640
- modAttrs.create(vnode);
3641
- modProps.create(vnode);
3642
- modStaticClassName.create(vnode);
3643
- modStaticStyle.create(vnode);
3644
- modComputedClassName.create(vnode);
3645
- modComputedStyle.create(vnode);
3567
+
3568
+ patchClassAttribute(oldVnode, vnode);
3569
+ patchStyleAttribute(oldVnode, vnode);
3570
+ patchAttributes(oldVnode, vnode);
3571
+ patchProps(oldVnode, vnode);
3646
3572
  }
3647
3573
 
3648
3574
  function hydrateElmHook(vnode) {
3649
- modEvents.create(vnode); // Attrs are already on the element.
3650
- // modAttrs.create(vnode);
3651
-
3652
- modProps.create(vnode); // Already set.
3653
- // modStaticClassName.create(vnode);
3654
- // modStaticStyle.create(vnode);
3655
- // modComputedClassName.create(vnode);
3656
- // modComputedStyle.create(vnode);
3575
+ applyEventListeners(vnode);
3576
+ patchProps(null, vnode);
3657
3577
  }
3658
3578
 
3659
3579
  function fallbackElmHook(elm, vnode) {
@@ -3679,24 +3599,11 @@
3679
3599
  }
3680
3600
  }
3681
3601
 
3682
- function updateElmHook(oldVnode, vnode) {
3683
- // Attrs need to be applied to element before props
3684
- // IE11 will wipe out value on radio inputs if value
3685
- // is set before type=radio.
3686
- modAttrs.update(oldVnode, vnode);
3687
- modProps.update(oldVnode, vnode);
3688
- modComputedClassName.update(oldVnode, vnode);
3689
- modComputedStyle.update(oldVnode, vnode);
3690
- }
3691
-
3692
- function updateChildrenHook(oldVnode, vnode) {
3693
- var elm = vnode.elm,
3694
- children = vnode.children;
3695
-
3696
- if (hasDynamicChildren(children)) {
3697
- updateDynamicChildren(elm, oldVnode.children, children);
3602
+ function patchChildren(parent, oldCh, newCh) {
3603
+ if (hasDynamicChildren(newCh)) {
3604
+ updateDynamicChildren(parent, oldCh, newCh);
3698
3605
  } else {
3699
- updateStaticChildren(elm, oldVnode.children, children);
3606
+ updateStaticChildren(parent, oldCh, newCh);
3700
3607
  }
3701
3608
  }
3702
3609
 
@@ -3761,19 +3668,6 @@
3761
3668
  });
3762
3669
  }
3763
3670
 
3764
- function createCustomElmHook(vnode) {
3765
- modEvents.create(vnode); // Attrs need to be applied to element before props
3766
- // IE11 will wipe out value on radio inputs if value
3767
- // is set before type=radio.
3768
-
3769
- modAttrs.create(vnode);
3770
- modProps.create(vnode);
3771
- modStaticClassName.create(vnode);
3772
- modStaticStyle.create(vnode);
3773
- modComputedClassName.create(vnode);
3774
- modComputedStyle.create(vnode);
3775
- }
3776
-
3777
3671
  function createChildrenHook(vnode) {
3778
3672
  var elm = vnode.elm,
3779
3673
  children = vnode.children;
@@ -3804,16 +3698,6 @@
3804
3698
  }
3805
3699
  }
3806
3700
 
3807
- function updateCustomElmHook(oldVnode, vnode) {
3808
- // Attrs need to be applied to element before props
3809
- // IE11 will wipe out value on radio inputs if value
3810
- // is set before type=radio.
3811
- modAttrs.update(oldVnode, vnode);
3812
- modProps.update(oldVnode, vnode);
3813
- modComputedClassName.update(oldVnode, vnode);
3814
- modComputedStyle.update(oldVnode, vnode);
3815
- }
3816
-
3817
3701
  function removeElmHook(vnode) {
3818
3702
  // this method only needs to search on child vnodes from template
3819
3703
  // to trigger the remove hook just in case some of those children
@@ -3828,6 +3712,62 @@
3828
3712
  ch.hook.remove(ch, elm);
3829
3713
  }
3830
3714
  }
3715
+ }
3716
+
3717
+ function allocateInSlot(vm, children) {
3718
+ var oldSlots = vm.cmpSlots;
3719
+ var cmpSlots = vm.cmpSlots = create(null);
3720
+
3721
+ for (var _i16 = 0, _len6 = children.length; _i16 < _len6; _i16 += 1) {
3722
+ var vnode = children[_i16];
3723
+
3724
+ if (isNull(vnode)) {
3725
+ continue;
3726
+ }
3727
+
3728
+ var data = vnode.data;
3729
+ var slotName = data.attrs && data.attrs.slot || '';
3730
+ var vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
3731
+ // which might have similar keys. Each vnode will always have a key that
3732
+ // starts with a numeric character from compiler. In this case, we add a unique
3733
+ // notation for slotted vnodes keys, e.g.: `@foo:1:1`
3734
+
3735
+ if (!isUndefined$1(vnode.key)) {
3736
+ vnode.key = "@".concat(slotName, ":").concat(vnode.key);
3737
+ }
3738
+
3739
+ ArrayPush$1.call(vnodes, vnode);
3740
+ }
3741
+
3742
+ if (isFalse(vm.isDirty)) {
3743
+ // We need to determine if the old allocation is really different from the new one
3744
+ // and mark the vm as dirty
3745
+ var oldKeys = keys(oldSlots);
3746
+
3747
+ if (oldKeys.length !== keys(cmpSlots).length) {
3748
+ markComponentAsDirty(vm);
3749
+ return;
3750
+ }
3751
+
3752
+ for (var _i17 = 0, _len7 = oldKeys.length; _i17 < _len7; _i17 += 1) {
3753
+ var key = oldKeys[_i17];
3754
+
3755
+ if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3756
+ markComponentAsDirty(vm);
3757
+ return;
3758
+ }
3759
+
3760
+ var oldVNodes = oldSlots[key];
3761
+ var _vnodes = cmpSlots[key];
3762
+
3763
+ for (var j = 0, a = cmpSlots[key].length; j < a; j += 1) {
3764
+ if (oldVNodes[j] !== _vnodes[j]) {
3765
+ markComponentAsDirty(vm);
3766
+ return;
3767
+ }
3768
+ }
3769
+ }
3770
+ }
3831
3771
  } // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
3832
3772
 
3833
3773
 
@@ -3954,11 +3894,11 @@
3954
3894
  linkNodeToShadow(elm, owner);
3955
3895
  fallbackElmHook(elm, vnode);
3956
3896
  vnode.elm = elm;
3957
- createElmHook(vnode);
3897
+ patchElementPropsAndAttrs(null, vnode);
3958
3898
  },
3959
3899
  update: function update(oldVnode, vnode) {
3960
- updateElmHook(oldVnode, vnode);
3961
- updateChildrenHook(oldVnode, vnode);
3900
+ patchElementPropsAndAttrs(oldVnode, vnode);
3901
+ patchChildren(vnode.elm, oldVnode.children, vnode.children);
3962
3902
  },
3963
3903
  insert: function insert(vnode, parentNode, referenceNode) {
3964
3904
  insertNodeHook(vnode, parentNode, referenceNode);
@@ -4026,10 +3966,10 @@
4026
3966
  throw new TypeError("Incorrect Component Constructor");
4027
3967
  }
4028
3968
 
4029
- createCustomElmHook(vnode);
3969
+ patchElementPropsAndAttrs(null, vnode);
4030
3970
  },
4031
3971
  update: function update(oldVnode, vnode) {
4032
- updateCustomElmHook(oldVnode, vnode);
3972
+ patchElementPropsAndAttrs(oldVnode, vnode);
4033
3973
  var vm = getAssociatedVMIfPresent(vnode.elm);
4034
3974
 
4035
3975
  if (vm) {
@@ -4040,7 +3980,7 @@
4040
3980
  // will happen, but in native, it does allocate the light dom
4041
3981
 
4042
3982
 
4043
- updateChildrenHook(oldVnode, vnode);
3983
+ patchChildren(vnode.elm, oldVnode.children, vnode.children);
4044
3984
 
4045
3985
  if (vm) {
4046
3986
  // this is important to preserve the top to bottom synchronous rendering phase.
@@ -4566,8 +4506,8 @@
4566
4506
  var content = [];
4567
4507
  var root;
4568
4508
 
4569
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4570
- var stylesheet = stylesheets[_i16];
4509
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4510
+ var stylesheet = stylesheets[_i18];
4571
4511
 
4572
4512
  if (isArray$1(stylesheet)) {
4573
4513
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4671,8 +4611,8 @@
4671
4611
  && shadowMode === 1
4672
4612
  /* Synthetic */
4673
4613
  ) {
4674
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4675
- insertGlobalStylesheet$1(stylesheets[_i17]);
4614
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4615
+ insertGlobalStylesheet$1(stylesheets[_i19]);
4676
4616
  }
4677
4617
  } else if (ssr$1 || isHydrating$1()) {
4678
4618
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -4686,12 +4626,12 @@
4686
4626
  var root = getNearestNativeShadowComponent(vm);
4687
4627
  var isGlobal = isNull(root);
4688
4628
 
4689
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4629
+ for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
4690
4630
  if (isGlobal) {
4691
- insertGlobalStylesheet$1(stylesheets[_i18]);
4631
+ insertGlobalStylesheet$1(stylesheets[_i20]);
4692
4632
  } else {
4693
4633
  // local level
4694
- insertStylesheet$1(stylesheets[_i18], root.cmpRoot);
4634
+ insertStylesheet$1(stylesheets[_i20], root.cmpRoot);
4695
4635
  }
4696
4636
  }
4697
4637
  }
@@ -4876,8 +4816,8 @@
4876
4816
  var stylesheets = template.stylesheets;
4877
4817
 
4878
4818
  if (!isUndefined$1(stylesheets)) {
4879
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4880
- if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4819
+ for (var _i21 = 0; _i21 < stylesheets.length; _i21++) {
4820
+ if (isTrue(stylesheets[_i21][KEY__SCOPED_CSS])) {
4881
4821
  return true;
4882
4822
  }
4883
4823
  }
@@ -5078,8 +5018,8 @@
5078
5018
 
5079
5019
  function register(service) {
5080
5020
 
5081
- for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
5082
- var hookName = hooks[_i20];
5021
+ for (var _i22 = 0; _i22 < hooks.length; ++_i22) {
5022
+ var hookName = hooks[_i22];
5083
5023
 
5084
5024
  if (hookName in service) {
5085
5025
  var l = Services[hookName];
@@ -5099,8 +5039,8 @@
5099
5039
  def = vm.def,
5100
5040
  context = vm.context;
5101
5041
 
5102
- for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
5103
- cbs[_i21].call(undefined, component, {}, def, context);
5042
+ for (var _i23 = 0, _len8 = cbs.length; _i23 < _len8; ++_i23) {
5043
+ cbs[_i23].call(undefined, component, {}, def, context);
5104
5044
  }
5105
5045
  }
5106
5046
  /*
@@ -5374,7 +5314,6 @@
5374
5314
  // patch function mutates vnodes by adding the element reference,
5375
5315
  // however, if patching fails it contains partial changes.
5376
5316
  if (oldCh !== newCh) {
5377
- var fn = hasDynamicChildren(newCh) ? updateDynamicChildren : updateStaticChildren;
5378
5317
  runWithBoundaryProtection(vm, vm, function () {
5379
5318
  // pre
5380
5319
  logOperationStart(2
@@ -5382,8 +5321,8 @@
5382
5321
  , vm);
5383
5322
  }, function () {
5384
5323
  // job
5385
- var elementToRenderTo = getRenderRoot(vm);
5386
- fn(elementToRenderTo, oldCh, newCh);
5324
+ var renderRoot = getRenderRoot(vm);
5325
+ patchChildren(renderRoot, oldCh, newCh);
5387
5326
  }, function () {
5388
5327
  // post
5389
5328
  logOperationEnd(2
@@ -5440,19 +5379,19 @@
5440
5379
  });
5441
5380
  rehydrateQueue = []; // reset to a new queue
5442
5381
 
5443
- for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5444
- var vm = vms[_i22];
5382
+ for (var _i24 = 0, _len9 = vms.length; _i24 < _len9; _i24 += 1) {
5383
+ var vm = vms[_i24];
5445
5384
 
5446
5385
  try {
5447
5386
  rehydrate(vm);
5448
5387
  } catch (error) {
5449
- if (_i22 + 1 < _len7) {
5388
+ if (_i24 + 1 < _len9) {
5450
5389
  // pieces of the queue are still pending to be rehydrated, those should have priority
5451
5390
  if (rehydrateQueue.length === 0) {
5452
5391
  addCallbackToNextTick(flushRehydrationQueue);
5453
5392
  }
5454
5393
 
5455
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5394
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i24 + 1));
5456
5395
  } // we need to end the measure before throwing.
5457
5396
 
5458
5397
 
@@ -5551,8 +5490,8 @@
5551
5490
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5552
5491
  // inserted in reserved order.
5553
5492
 
5554
- for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
5555
- var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
5493
+ for (var _i25 = vCustomElementCollection.length - 1; _i25 >= 0; _i25 -= 1) {
5494
+ var elm = vCustomElementCollection[_i25].elm; // There are two cases where the element could be undefined:
5556
5495
  // * when there is an error during the construction phase, and an error
5557
5496
  // boundary picks it, there is a possibility that the VCustomElement
5558
5497
  // is not properly initialized, and therefore is should be ignored.
@@ -5586,8 +5525,8 @@
5586
5525
 
5587
5526
 
5588
5527
  function recursivelyDisconnectChildren(vnodes) {
5589
- for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5590
- var vnode = vnodes[_i24];
5528
+ for (var _i26 = 0, _len10 = vnodes.length; _i26 < _len10; _i26 += 1) {
5529
+ var vnode = vnodes[_i26];
5591
5530
 
5592
5531
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5593
5532
  // vnode is a VElement with children
@@ -5610,8 +5549,8 @@
5610
5549
  var children = vm.children;
5611
5550
  var rootNode = getRenderRoot(vm);
5612
5551
 
5613
- for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5614
- var child = children[_i25];
5552
+ for (var _i27 = 0, _len11 = children.length; _i27 < _len11; _i27++) {
5553
+ var child = children[_i27];
5615
5554
 
5616
5555
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5617
5556
  remove$1(child.elm, rootNode);
@@ -5647,65 +5586,6 @@
5647
5586
 
5648
5587
  currentVm = currentVm.owner;
5649
5588
  }
5650
- } // slow path routine
5651
- // NOTE: we should probably more this routine to the synthetic shadow folder
5652
- // and get the allocation to be cached by in the elm instead of in the VM
5653
-
5654
-
5655
- function allocateInSlot(vm, children) {
5656
- var oldSlots = vm.cmpSlots;
5657
- var cmpSlots = vm.cmpSlots = create(null);
5658
-
5659
- for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5660
- var vnode = children[_i26];
5661
-
5662
- if (isNull(vnode)) {
5663
- continue;
5664
- }
5665
-
5666
- var data = vnode.data;
5667
- var slotName = data.attrs && data.attrs.slot || '';
5668
- var vnodes = cmpSlots[slotName] = cmpSlots[slotName] || []; // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
5669
- // which might have similar keys. Each vnode will always have a key that
5670
- // starts with a numeric character from compiler. In this case, we add a unique
5671
- // notation for slotted vnodes keys, e.g.: `@foo:1:1`
5672
-
5673
- if (!isUndefined$1(vnode.key)) {
5674
- vnode.key = "@".concat(slotName, ":").concat(vnode.key);
5675
- }
5676
-
5677
- ArrayPush$1.call(vnodes, vnode);
5678
- }
5679
-
5680
- if (isFalse(vm.isDirty)) {
5681
- // We need to determine if the old allocation is really different from the new one
5682
- // and mark the vm as dirty
5683
- var oldKeys = keys(oldSlots);
5684
-
5685
- if (oldKeys.length !== keys(cmpSlots).length) {
5686
- markComponentAsDirty(vm);
5687
- return;
5688
- }
5689
-
5690
- for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5691
- var key = oldKeys[_i27];
5692
-
5693
- if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5694
- markComponentAsDirty(vm);
5695
- return;
5696
- }
5697
-
5698
- var oldVNodes = oldSlots[key];
5699
- var _vnodes = cmpSlots[key];
5700
-
5701
- for (var j = 0, a = cmpSlots[key].length; j < a; j += 1) {
5702
- if (oldVNodes[j] !== _vnodes[j]) {
5703
- markComponentAsDirty(vm);
5704
- return;
5705
- }
5706
- }
5707
- }
5708
- }
5709
5589
  }
5710
5590
 
5711
5591
  function runWithBoundaryProtection(vm, owner, pre, job, post) {
@@ -6120,7 +6000,7 @@
6120
6000
  hooksAreSet = true;
6121
6001
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6122
6002
  }
6123
- /* version: 2.7.2 */
6003
+ /* version: 2.7.3 */
6124
6004
 
6125
6005
  /*
6126
6006
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6820,7 +6700,7 @@
6820
6700
  });
6821
6701
  freeze(LightningElement);
6822
6702
  seal(LightningElement.prototype);
6823
- /* version: 2.7.2 */
6703
+ /* version: 2.7.3 */
6824
6704
 
6825
6705
  exports.LightningElement = LightningElement;
6826
6706
  exports.__unstable__ProfilerControl = profilerControl;