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