lwc 2.7.4 → 2.10.0

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 (36) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +663 -470
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +663 -470
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +544 -426
  5. package/dist/engine-dom/iife/es5/engine-dom.js +816 -594
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +624 -497
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +663 -470
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +544 -426
  11. package/dist/engine-dom/umd/es5/engine-dom.js +816 -594
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +624 -497
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +427 -299
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +427 -299
  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
  36. package/LICENSE +0 -10
@@ -7,14 +7,6 @@ var LWC = (function (exports) {
7
7
 
8
8
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
9
9
 
10
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
-
12
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
-
14
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
-
16
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
-
18
10
  function _get2() { if (typeof Reflect !== "undefined" && Reflect.get) { _get2 = Reflect.get; } else { _get2 = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get2.apply(this, arguments); }
19
11
 
20
12
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf2(object); if (object === null) break; } return object; }
@@ -41,6 +33,14 @@ var LWC = (function (exports) {
41
33
 
42
34
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
43
35
 
36
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
37
+
38
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
39
+
40
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
41
+
42
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
43
+
44
44
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
45
45
 
46
46
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -345,7 +345,7 @@ var LWC = (function (exports) {
345
345
  var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
346
346
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
347
347
  var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
348
- /** version: 2.7.4 */
348
+ /** version: 2.10.0 */
349
349
 
350
350
  /*
351
351
  * Copyright (c) 2018, salesforce.com, inc.
@@ -410,7 +410,7 @@ var LWC = (function (exports) {
410
410
  };
411
411
  }
412
412
 
413
- function patch(propName) {
413
+ function patch$1(propName) {
414
414
  // Typescript is inferring the wrong function type for this particular
415
415
  // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
416
416
  // @ts-ignore type-mismatch
@@ -432,7 +432,7 @@ var LWC = (function (exports) {
432
432
  var propName = ElementPrototypeAriaPropertyNames[_i2];
433
433
 
434
434
  if (detect(propName)) {
435
- patch(propName);
435
+ patch$1(propName);
436
436
  }
437
437
  }
438
438
  /**
@@ -448,14 +448,15 @@ var LWC = (function (exports) {
448
448
 
449
449
 
450
450
  var features = {
451
- ENABLE_REACTIVE_SETTER: null,
452
- ENABLE_HMR: null,
453
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
451
+ DISABLE_MIXED_SHADOW_MODE: null,
454
452
  ENABLE_ELEMENT_PATCH: null,
455
453
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
456
- ENABLE_NODE_LIST_PATCH: null,
454
+ ENABLE_HMR: null,
457
455
  ENABLE_HTML_COLLECTIONS_PATCH: null,
456
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
457
+ ENABLE_NODE_LIST_PATCH: null,
458
458
  ENABLE_NODE_PATCH: null,
459
+ ENABLE_REACTIVE_SETTER: null,
459
460
  ENABLE_WIRE_SYNC_EMIT: null
460
461
  };
461
462
 
@@ -514,7 +515,7 @@ var LWC = (function (exports) {
514
515
 
515
516
  function setFeatureFlagForTest(name, value) {
516
517
  }
517
- /** version: 2.7.4 */
518
+ /** version: 2.10.0 */
518
519
 
519
520
  /* proxy-compat-disable */
520
521
 
@@ -557,6 +558,21 @@ var LWC = (function (exports) {
557
558
 
558
559
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
559
560
  } // Borrowed from Vue template compiler.
561
+
562
+
563
+ function cloneAndOmitKey(object, keyToOmit) {
564
+ var result = {};
565
+
566
+ for (var _i4 = 0, _Object$keys = Object.keys(object); _i4 < _Object$keys.length; _i4++) {
567
+ var key = _Object$keys[_i4];
568
+
569
+ if (key !== keyToOmit) {
570
+ result[key] = object[key];
571
+ }
572
+ }
573
+
574
+ return result;
575
+ }
560
576
  // Primitives
561
577
  //
562
578
 
@@ -825,8 +841,8 @@ var LWC = (function (exports) {
825
841
  var reactiveObservers = reactiveRecord[key];
826
842
 
827
843
  if (!isUndefined$1(reactiveObservers)) {
828
- for (var _i4 = 0, _len2 = reactiveObservers.length; _i4 < _len2; _i4 += 1) {
829
- var ro = reactiveObservers[_i4];
844
+ for (var _i5 = 0, _len2 = reactiveObservers.length; _i5 < _len2; _i5 += 1) {
845
+ var ro = reactiveObservers[_i5];
830
846
  ro.notify();
831
847
  }
832
848
  }
@@ -895,9 +911,9 @@ var LWC = (function (exports) {
895
911
  var len = listeners.length;
896
912
 
897
913
  if (len > 0) {
898
- for (var _i5 = 0; _i5 < len; _i5 += 1) {
899
- var set = listeners[_i5];
900
- var pos = ArrayIndexOf.call(listeners[_i5], this);
914
+ for (var _i6 = 0; _i6 < len; _i6 += 1) {
915
+ var set = listeners[_i6];
916
+ var pos = ArrayIndexOf.call(listeners[_i6], this);
901
917
  ArraySplice.call(set, pos, 1);
902
918
  }
903
919
 
@@ -2117,7 +2133,7 @@ var LWC = (function (exports) {
2117
2133
 
2118
2134
 
2119
2135
  var _loop = function _loop() {
2120
- var childGetter = _childGetters[_i6];
2136
+ var childGetter = _childGetters[_i7];
2121
2137
  queryAndChildGetterDescriptors[childGetter] = {
2122
2138
  get: function get() {
2123
2139
  var vm = getAssociatedVM(this);
@@ -2130,7 +2146,7 @@ var LWC = (function (exports) {
2130
2146
  };
2131
2147
  };
2132
2148
 
2133
- for (var _i6 = 0, _childGetters = childGetters; _i6 < _childGetters.length; _i6++) {
2149
+ for (var _i7 = 0, _childGetters = childGetters; _i7 < _childGetters.length; _i7++) {
2134
2150
  _loop();
2135
2151
  }
2136
2152
 
@@ -2154,7 +2170,7 @@ var LWC = (function (exports) {
2154
2170
 
2155
2171
 
2156
2172
  var _loop2 = function _loop2() {
2157
- var queryMethod = _queryMethods[_i7];
2173
+ var queryMethod = _queryMethods[_i8];
2158
2174
  queryAndChildGetterDescriptors[queryMethod] = {
2159
2175
  value: function value(arg) {
2160
2176
  var vm = getAssociatedVM(this);
@@ -2168,7 +2184,7 @@ var LWC = (function (exports) {
2168
2184
  };
2169
2185
  };
2170
2186
 
2171
- for (var _i7 = 0, _queryMethods = queryMethods; _i7 < _queryMethods.length; _i7++) {
2187
+ for (var _i8 = 0, _queryMethods = queryMethods; _i8 < _queryMethods.length; _i8++) {
2172
2188
  _loop2();
2173
2189
  }
2174
2190
 
@@ -2529,8 +2545,8 @@ var LWC = (function (exports) {
2529
2545
  }
2530
2546
 
2531
2547
  if (!isUndefined$1(fields)) {
2532
- for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
2533
- var _fieldName2 = fields[_i8];
2548
+ for (var _i9 = 0, n = fields.length; _i9 < n; _i9++) {
2549
+ var _fieldName2 = fields[_i9];
2534
2550
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
2535
2551
  // tracked property. This is only here for backward compatibility purposes.
2536
2552
 
@@ -2574,6 +2590,13 @@ var LWC = (function (exports) {
2574
2590
  var meta = signedDecoratorToMetaMap.get(Ctor);
2575
2591
  return isUndefined$1(meta) ? defaultMeta : meta;
2576
2592
  }
2593
+ /*
2594
+ * Copyright (c) 2018, salesforce.com, inc.
2595
+ * All rights reserved.
2596
+ * SPDX-License-Identifier: MIT
2597
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2598
+ */
2599
+
2577
2600
 
2578
2601
  var signedTemplateSet = new Set();
2579
2602
 
@@ -2593,6 +2616,7 @@ var LWC = (function (exports) {
2593
2616
 
2594
2617
 
2595
2618
  function registerTemplate(tpl) {
2619
+
2596
2620
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
2597
2621
  // assignment of templates easily, without too much transformation
2598
2622
 
@@ -2747,8 +2771,8 @@ var LWC = (function (exports) {
2747
2771
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
2748
2772
  var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
2749
2773
 
2750
- for (var _i9 = 0, _len3 = props.length; _i9 < _len3; _i9 += 1) {
2751
- var _propName2 = props[_i9];
2774
+ for (var _i10 = 0, _len3 = props.length; _i10 < _len3; _i10 += 1) {
2775
+ var _propName2 = props[_i10];
2752
2776
  attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
2753
2777
  descriptors[_propName2] = {
2754
2778
  get: createGetter(_propName2),
@@ -2759,8 +2783,8 @@ var LWC = (function (exports) {
2759
2783
  } // expose public methods as props on the new Element Bridge
2760
2784
 
2761
2785
 
2762
- for (var _i10 = 0, _len4 = methods.length; _i10 < _len4; _i10 += 1) {
2763
- var methodName = methods[_i10];
2786
+ for (var _i11 = 0, _len4 = methods.length; _i11 < _len4; _i11 += 1) {
2787
+ var methodName = methods[_i11];
2764
2788
  descriptors[methodName] = {
2765
2789
  value: createMethodCaller(methodName),
2766
2790
  writable: true,
@@ -3388,8 +3412,8 @@ var LWC = (function (exports) {
3388
3412
  return;
3389
3413
  }
3390
3414
 
3391
- for (var _i11 = 0; _i11 < styleDecls.length; _i11++) {
3392
- var _styleDecls$_i = _slicedToArray(styleDecls[_i11], 3),
3415
+ for (var _i12 = 0; _i12 < styleDecls.length; _i12++) {
3416
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i12], 3),
3393
3417
  prop = _styleDecls$_i[0],
3394
3418
  value = _styleDecls$_i[1],
3395
3419
  important = _styleDecls$_i[2];
@@ -3405,138 +3429,245 @@ var LWC = (function (exports) {
3405
3429
  */
3406
3430
 
3407
3431
 
3408
- var TextHook = {
3409
- create: function create(vnode) {
3410
- var owner = vnode.owner;
3411
- var elm = createText$1(vnode.text);
3412
- linkNodeToShadow(elm, owner);
3413
- vnode.elm = elm;
3414
- },
3415
- update: updateNodeHook,
3416
- insert: insertNode,
3417
- move: insertNode,
3418
- remove: removeNode
3419
- };
3420
- var CommentHook = {
3421
- create: function create(vnode) {
3422
- var owner = vnode.owner,
3423
- text = vnode.text;
3424
- var elm = createComment$1(text);
3425
- linkNodeToShadow(elm, owner);
3426
- vnode.elm = elm;
3427
- },
3428
- update: updateNodeHook,
3429
- insert: insertNode,
3430
- move: insertNode,
3431
- remove: removeNode
3432
- }; // insert is called after update, which is used somewhere else (via a module)
3433
- // to mark the vm as inserted, that means we cannot use update as the main channel
3434
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
3435
- // which breaks some invariants. For that reason, we have the following for any
3436
- // Custom Element that is inserted via a template.
3437
-
3438
- var ElementHook = {
3439
- create: function create(vnode) {
3440
- var sel = vnode.sel,
3441
- owner = vnode.owner,
3442
- svg = vnode.data.svg;
3443
- var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3444
- var elm = createElement$2(sel, namespace);
3445
- linkNodeToShadow(elm, owner);
3446
- fallbackElmHook(elm, vnode);
3447
- vnode.elm = elm;
3448
- patchElementPropsAndAttrs$1(null, vnode);
3449
- },
3450
- update: function update(oldVnode, vnode) {
3451
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3452
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3453
- },
3454
- insert: function insert(vnode, parentNode, referenceNode) {
3455
- insertNode(vnode, parentNode, referenceNode);
3456
- createChildrenHook(vnode);
3457
- },
3458
- move: insertNode,
3459
- remove: function remove(vnode, parentNode) {
3460
- removeNode(vnode, parentNode);
3461
- removeChildren(vnode);
3432
+ function patchChildren(c1, c2, parent) {
3433
+ if (hasDynamicChildren(c2)) {
3434
+ updateDynamicChildren(c1, c2, parent);
3435
+ } else {
3436
+ updateStaticChildren(c1, c2, parent);
3462
3437
  }
3463
- };
3464
- var CustomElementHook = {
3465
- create: function create(vnode) {
3466
- var sel = vnode.sel,
3467
- owner = vnode.owner;
3468
- var UpgradableConstructor = getUpgradableConstructor(sel);
3469
- /**
3470
- * Note: if the upgradable constructor does not expect, or throw when we new it
3471
- * with a callback as the first argument, we could implement a more advanced
3472
- * mechanism that only passes that argument if the constructor is known to be
3473
- * an upgradable custom element.
3474
- */
3438
+ }
3475
3439
 
3476
- var vm;
3477
- var elm = new UpgradableConstructor(function (elm) {
3478
- // the custom element from the registry is expecting an upgrade callback
3479
- vm = createViewModelHook(elm, vnode);
3480
- });
3481
- linkNodeToShadow(elm, owner);
3482
- vnode.elm = elm;
3440
+ function patch(n1, n2) {
3441
+ if (n1 === n2) {
3442
+ return;
3443
+ }
3483
3444
 
3484
- if (vm) {
3485
- allocateChildren(vnode, vm);
3486
- } else if (vnode.ctor !== UpgradableConstructor) {
3487
- throw new TypeError("Incorrect Component Constructor");
3488
- }
3445
+ switch (n2.type) {
3446
+ case 0
3447
+ /* Text */
3448
+ :
3449
+ patchText(n1, n2);
3450
+ break;
3489
3451
 
3490
- patchElementPropsAndAttrs$1(null, vnode);
3491
- },
3492
- update: function update(oldVnode, vnode) {
3493
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3494
- var vm = getAssociatedVMIfPresent(vnode.elm);
3452
+ case 1
3453
+ /* Comment */
3454
+ :
3455
+ patchComment(n1, n2);
3456
+ break;
3495
3457
 
3496
- if (vm) {
3497
- // in fallback mode, the allocation will always set children to
3498
- // empty and delegate the real allocation to the slot elements
3499
- allocateChildren(vnode, vm);
3500
- } // in fallback mode, the children will be always empty, so, nothing
3501
- // will happen, but in native, it does allocate the light dom
3458
+ case 2
3459
+ /* Element */
3460
+ :
3461
+ patchElement(n1, n2);
3462
+ break;
3502
3463
 
3464
+ case 3
3465
+ /* CustomElement */
3466
+ :
3467
+ patchCustomElement(n1, n2);
3468
+ break;
3469
+ }
3470
+ }
3503
3471
 
3504
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3472
+ function mount(node, parent, anchor) {
3473
+ switch (node.type) {
3474
+ case 0
3475
+ /* Text */
3476
+ :
3477
+ mountText(node, parent, anchor);
3478
+ break;
3505
3479
 
3506
- if (vm) {
3507
- // this is important to preserve the top to bottom synchronous rendering phase.
3480
+ case 1
3481
+ /* Comment */
3482
+ :
3483
+ mountComment(node, parent, anchor);
3484
+ break;
3508
3485
 
3486
+ case 2
3487
+ /* Element */
3488
+ :
3489
+ mountElement(node, parent, anchor);
3490
+ break;
3509
3491
 
3510
- rerenderVM(vm);
3511
- }
3512
- },
3513
- insert: function insert(vnode, parentNode, referenceNode) {
3514
- insertNode(vnode, parentNode, referenceNode);
3515
- var vm = getAssociatedVMIfPresent(vnode.elm);
3492
+ case 3
3493
+ /* CustomElement */
3494
+ :
3495
+ mountCustomElement(node, parent, anchor);
3496
+ break;
3497
+ }
3498
+ }
3516
3499
 
3517
- if (vm) {
3500
+ function patchText(n1, n2) {
3501
+ n2.elm = n1.elm;
3518
3502
 
3519
- runConnectedCallback(vm);
3520
- }
3503
+ if (n2.text !== n1.text) {
3504
+ updateTextContent(n2);
3505
+ }
3506
+ }
3507
+
3508
+ function mountText(node, parent, anchor) {
3509
+ var owner = node.owner;
3510
+ var textNode = node.elm = createText$1(node.text);
3511
+ linkNodeToShadow(textNode, owner);
3512
+ insertNode(textNode, parent, anchor);
3513
+ }
3514
+
3515
+ function patchComment(n1, n2) {
3516
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3517
+ // it is the case today.
3518
+
3519
+ if (n2.text !== n1.text) {
3520
+ updateTextContent(n2);
3521
+ }
3522
+ }
3523
+
3524
+ function mountComment(node, parent, anchor) {
3525
+ var owner = node.owner;
3526
+ var commentNode = node.elm = createComment$1(node.text);
3527
+ linkNodeToShadow(commentNode, owner);
3528
+ insertNode(commentNode, parent, anchor);
3529
+ }
3521
3530
 
3522
- createChildrenHook(vnode);
3531
+ function mountElement(vnode, parent, anchor) {
3532
+ var sel = vnode.sel,
3533
+ owner = vnode.owner,
3534
+ svg = vnode.data.svg;
3535
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3536
+ var elm = createElement$2(sel, namespace);
3537
+ linkNodeToShadow(elm, owner);
3538
+ fallbackElmHook(elm, vnode);
3539
+ vnode.elm = elm;
3540
+ patchElementPropsAndAttrs$1(null, vnode);
3541
+ insertNode(elm, parent, anchor);
3542
+ mountVNodes(vnode.children, elm, null);
3543
+ }
3523
3544
 
3524
- if (vm) {
3525
- appendVM(vm);
3545
+ function patchElement(n1, n2) {
3546
+ var elm = n2.elm = n1.elm;
3547
+ patchElementPropsAndAttrs$1(n1, n2);
3548
+ patchChildren(n1.children, n2.children, elm);
3549
+ }
3550
+
3551
+ function mountCustomElement(vnode, parent, anchor) {
3552
+ var sel = vnode.sel,
3553
+ owner = vnode.owner;
3554
+ var UpgradableConstructor = getUpgradableConstructor(sel);
3555
+ /**
3556
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3557
+ * with a callback as the first argument, we could implement a more advanced
3558
+ * mechanism that only passes that argument if the constructor is known to be
3559
+ * an upgradable custom element.
3560
+ */
3561
+
3562
+ var vm;
3563
+ var elm = new UpgradableConstructor(function (elm) {
3564
+ // the custom element from the registry is expecting an upgrade callback
3565
+ vm = createViewModelHook(elm, vnode);
3566
+ });
3567
+ linkNodeToShadow(elm, owner);
3568
+ vnode.elm = elm;
3569
+ vnode.vm = vm;
3570
+
3571
+ if (vm) {
3572
+ allocateChildren(vnode, vm);
3573
+ } else if (vnode.ctor !== UpgradableConstructor) {
3574
+ throw new TypeError("Incorrect Component Constructor");
3575
+ }
3576
+
3577
+ patchElementPropsAndAttrs$1(null, vnode);
3578
+ insertNode(elm, parent, anchor);
3579
+
3580
+ if (vm) {
3581
+
3582
+ runConnectedCallback(vm);
3583
+ }
3584
+
3585
+ mountVNodes(vnode.children, elm, null);
3586
+
3587
+ if (vm) {
3588
+ appendVM(vm);
3589
+ }
3590
+ }
3591
+
3592
+ function patchCustomElement(n1, n2) {
3593
+ var elm = n2.elm = n1.elm;
3594
+ var vm = n2.vm = n1.vm;
3595
+ patchElementPropsAndAttrs$1(n1, n2);
3596
+
3597
+ if (!isUndefined$1(vm)) {
3598
+ // in fallback mode, the allocation will always set children to
3599
+ // empty and delegate the real allocation to the slot elements
3600
+ allocateChildren(n2, vm);
3601
+ } // in fallback mode, the children will be always empty, so, nothing
3602
+ // will happen, but in native, it does allocate the light dom
3603
+
3604
+
3605
+ patchChildren(n1.children, n2.children, elm);
3606
+
3607
+ if (!isUndefined$1(vm)) {
3608
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3609
+ // this is important to preserve the top to bottom synchronous rendering phase.
3610
+ rerenderVM(vm);
3611
+ }
3612
+ }
3613
+
3614
+ function mountVNodes(vnodes, parent, anchor) {
3615
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
3616
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
3617
+
3618
+ for (; start < end; ++start) {
3619
+ var vnode = vnodes[start];
3620
+
3621
+ if (isVNode(vnode)) {
3622
+ mount(vnode, parent, anchor);
3526
3623
  }
3527
- },
3528
- move: insertNode,
3529
- remove: function remove(vnode, parentNode) {
3530
- removeNode(vnode, parentNode);
3531
- var vm = getAssociatedVMIfPresent(vnode.elm);
3532
-
3533
- if (vm) {
3534
- // for custom elements we don't have to go recursively because the removeVM routine
3535
- // will take care of disconnecting any child VM attached to its shadow as well.
3536
- removeVM(vm);
3624
+ }
3625
+ }
3626
+
3627
+ function unmount(vnode, parent) {
3628
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3629
+ var type = vnode.type,
3630
+ elm = vnode.elm; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3631
+ // subtree root, is the only element worth unmounting from the subtree.
3632
+
3633
+ if (doRemove) {
3634
+ removeNode(elm, parent);
3635
+ }
3636
+
3637
+ switch (type) {
3638
+ case 2
3639
+ /* Element */
3640
+ :
3641
+ unmountVNodes(vnode.children, elm);
3642
+ break;
3643
+
3644
+ case 3
3645
+ /* CustomElement */
3646
+ :
3647
+ {
3648
+ var vm = vnode.vm; // No need to unmount the children here, `removeVM` will take care of removing the
3649
+ // children.
3650
+
3651
+ if (!isUndefined$1(vm)) {
3652
+ removeVM(vm);
3653
+ }
3654
+ }
3655
+ }
3656
+ }
3657
+
3658
+ function unmountVNodes(vnodes, parent) {
3659
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3660
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
3661
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
3662
+
3663
+ for (; start < end; ++start) {
3664
+ var ch = vnodes[start];
3665
+
3666
+ if (isVNode(ch)) {
3667
+ unmount(ch, parent, doRemove);
3537
3668
  }
3538
3669
  }
3539
- };
3670
+ }
3540
3671
 
3541
3672
  function isVNode(vnode) {
3542
3673
  return vnode != null;
@@ -3577,24 +3708,21 @@ var LWC = (function (exports) {
3577
3708
  }
3578
3709
  }
3579
3710
 
3580
- function updateNodeHook(oldVnode, vnode) {
3711
+ function updateTextContent(vnode) {
3581
3712
  var elm = vnode.elm,
3582
3713
  text = vnode.text;
3583
3714
 
3584
- if (oldVnode.text !== text) {
3585
-
3586
- setText$1(elm, text);
3587
- }
3715
+ setText$1(elm, text);
3588
3716
  }
3589
3717
 
3590
- function insertNode(vnode, parentNode, referenceNode) {
3718
+ function insertNode(node, parent, anchor) {
3591
3719
 
3592
- insert$1(vnode.elm, parentNode, referenceNode);
3720
+ insert$1(node, parent, anchor);
3593
3721
  }
3594
3722
 
3595
- function removeNode(vnode, parentNode) {
3723
+ function removeNode(node, parent) {
3596
3724
 
3597
- remove$1(vnode.elm, parentNode);
3725
+ remove$1(node, parent);
3598
3726
  }
3599
3727
 
3600
3728
  function patchElementPropsAndAttrs$1(oldVnode, vnode) {
@@ -3627,19 +3755,13 @@ var LWC = (function (exports) {
3627
3755
  ) {
3628
3756
  // this element will now accept any manual content inserted into it
3629
3757
  observeElementChildNodes(elm);
3630
- } // when running in synthetic shadow mode, we need to set the shadowToken value
3631
- // into each element from the template, so they can be styled accordingly.
3632
-
3633
-
3634
- setElementShadowToken(elm, stylesheetToken);
3635
- }
3636
- }
3758
+ }
3637
3759
 
3638
- function patchChildren(parent, oldCh, newCh) {
3639
- if (hasDynamicChildren(newCh)) {
3640
- updateDynamicChildren(parent, oldCh, newCh);
3641
- } else {
3642
- updateStaticChildren(parent, oldCh, newCh);
3760
+ if (!isUndefined$1(stylesheetToken)) {
3761
+ // when running in synthetic shadow mode, we need to set the shadowToken value
3762
+ // into each element from the template, so they can be styled accordingly.
3763
+ setElementShadowToken(elm, stylesheetToken);
3764
+ }
3643
3765
  }
3644
3766
  }
3645
3767
 
@@ -3694,7 +3816,9 @@ var LWC = (function (exports) {
3694
3816
  var stylesheetToken = owner.context.stylesheetToken; // when running in synthetic shadow mode, we need to set the shadowToken value
3695
3817
  // into each element from the template, so they can be styled accordingly.
3696
3818
 
3697
- setElementShadowToken(elm, stylesheetToken);
3819
+ if (!isUndefined$1(stylesheetToken)) {
3820
+ setElementShadowToken(elm, stylesheetToken);
3821
+ }
3698
3822
  }
3699
3823
 
3700
3824
  vm = createVM(elm, ctor, {
@@ -3706,44 +3830,14 @@ var LWC = (function (exports) {
3706
3830
  return vm;
3707
3831
  }
3708
3832
 
3709
- function createChildrenHook(vnode) {
3710
- var elm = vnode.elm,
3711
- children = vnode.children;
3712
-
3713
- for (var j = 0; j < children.length; ++j) {
3714
- var ch = children[j];
3715
-
3716
- if (ch != null) {
3717
- ch.hook.create(ch);
3718
- ch.hook.insert(ch, elm, null);
3719
- }
3720
- }
3721
- }
3722
-
3723
- function removeChildren(vnode) {
3724
- // this method only needs to search on child vnodes from template
3725
- // to trigger the remove hook just in case some of those children
3726
- // are custom elements.
3727
- var children = vnode.children,
3728
- elm = vnode.elm;
3729
-
3730
- for (var j = 0, _len5 = children.length; j < _len5; ++j) {
3731
- var ch = children[j];
3732
-
3733
- if (!isNull(ch)) {
3734
- ch.hook.remove(ch, elm);
3735
- }
3736
- }
3737
- }
3738
-
3739
3833
  function allocateInSlot(vm, children) {
3740
3834
  var _a;
3741
3835
 
3742
3836
  var oldSlots = vm.cmpSlots;
3743
3837
  var cmpSlots = vm.cmpSlots = create(null);
3744
3838
 
3745
- for (var _i12 = 0, _len6 = children.length; _i12 < _len6; _i12 += 1) {
3746
- var vnode = children[_i12];
3839
+ for (var _i13 = 0, _len5 = children.length; _i13 < _len5; _i13 += 1) {
3840
+ var vnode = children[_i13];
3747
3841
 
3748
3842
  if (isNull(vnode)) {
3749
3843
  continue;
@@ -3777,8 +3871,8 @@ var LWC = (function (exports) {
3777
3871
  return;
3778
3872
  }
3779
3873
 
3780
- for (var _i13 = 0, _len7 = oldKeys.length; _i13 < _len7; _i13 += 1) {
3781
- var key = oldKeys[_i13];
3874
+ for (var _i14 = 0, _len6 = oldKeys.length; _i14 < _len6; _i14 += 1) {
3875
+ var key = oldKeys[_i14];
3782
3876
 
3783
3877
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3784
3878
  markComponentAsDirty(vm);
@@ -3828,28 +3922,7 @@ var LWC = (function (exports) {
3828
3922
  return map;
3829
3923
  }
3830
3924
 
3831
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
3832
- for (; startIdx <= endIdx; ++startIdx) {
3833
- var ch = vnodes[startIdx];
3834
-
3835
- if (isVNode(ch)) {
3836
- ch.hook.create(ch);
3837
- ch.hook.insert(ch, parentElm, before);
3838
- }
3839
- }
3840
- }
3841
-
3842
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
3843
- for (; startIdx <= endIdx; ++startIdx) {
3844
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
3845
-
3846
- if (isVNode(ch)) {
3847
- ch.hook.remove(ch, parentElm);
3848
- }
3849
- }
3850
- }
3851
-
3852
- function updateDynamicChildren(parentElm, oldCh, newCh) {
3925
+ function updateDynamicChildren(oldCh, newCh, parent) {
3853
3926
  var oldStartIdx = 0;
3854
3927
  var newStartIdx = 0;
3855
3928
  var oldEndIdx = oldCh.length - 1;
@@ -3863,6 +3936,7 @@ var LWC = (function (exports) {
3863
3936
  var idxInOld;
3864
3937
  var elmToMove;
3865
3938
  var before;
3939
+ var clonedOldCh = false;
3866
3940
 
3867
3941
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3868
3942
  if (!isVNode(oldStartVnode)) {
@@ -3874,23 +3948,23 @@ var LWC = (function (exports) {
3874
3948
  } else if (!isVNode(newEndVnode)) {
3875
3949
  newEndVnode = newCh[--newEndIdx];
3876
3950
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
3877
- patchVnode(oldStartVnode, newStartVnode);
3951
+ patch(oldStartVnode, newStartVnode);
3878
3952
  oldStartVnode = oldCh[++oldStartIdx];
3879
3953
  newStartVnode = newCh[++newStartIdx];
3880
3954
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
3881
- patchVnode(oldEndVnode, newEndVnode);
3955
+ patch(oldEndVnode, newEndVnode);
3882
3956
  oldEndVnode = oldCh[--oldEndIdx];
3883
3957
  newEndVnode = newCh[--newEndIdx];
3884
3958
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
3885
3959
  // Vnode moved right
3886
- patchVnode(oldStartVnode, newEndVnode);
3887
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
3960
+ patch(oldStartVnode, newEndVnode);
3961
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
3888
3962
  oldStartVnode = oldCh[++oldStartIdx];
3889
3963
  newEndVnode = newCh[--newEndIdx];
3890
3964
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
3891
3965
  // Vnode moved left
3892
- patchVnode(oldEndVnode, newStartVnode);
3893
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
3966
+ patch(oldEndVnode, newStartVnode);
3967
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
3894
3968
  oldEndVnode = oldCh[--oldEndIdx];
3895
3969
  newStartVnode = newCh[++newStartIdx];
3896
3970
  } else {
@@ -3902,8 +3976,7 @@ var LWC = (function (exports) {
3902
3976
 
3903
3977
  if (isUndefined$1(idxInOld)) {
3904
3978
  // New element
3905
- newStartVnode.hook.create(newStartVnode);
3906
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3979
+ mount(newStartVnode, parent, oldStartVnode.elm);
3907
3980
  newStartVnode = newCh[++newStartIdx];
3908
3981
  } else {
3909
3982
  elmToMove = oldCh[idxInOld];
@@ -3911,12 +3984,22 @@ var LWC = (function (exports) {
3911
3984
  if (isVNode(elmToMove)) {
3912
3985
  if (elmToMove.sel !== newStartVnode.sel) {
3913
3986
  // New element
3914
- newStartVnode.hook.create(newStartVnode);
3915
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3987
+ mount(newStartVnode, parent, oldStartVnode.elm);
3916
3988
  } else {
3917
- patchVnode(elmToMove, newStartVnode);
3989
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
3990
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3991
+ // so we only care about the `oldCh` object inside this function.
3992
+ // To avoid cloning over and over again, we check `clonedOldCh`
3993
+ // and only clone once.
3994
+
3995
+ if (!clonedOldCh) {
3996
+ clonedOldCh = true;
3997
+ oldCh = _toConsumableArray(oldCh);
3998
+ } // We've already cloned at least once, so it's no longer read-only
3999
+
4000
+
3918
4001
  oldCh[idxInOld] = undefined;
3919
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
4002
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
3920
4003
  }
3921
4004
  }
3922
4005
 
@@ -3929,73 +4012,63 @@ var LWC = (function (exports) {
3929
4012
  if (oldStartIdx > oldEndIdx) {
3930
4013
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3931
4014
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3932
- var _i14 = newEndIdx;
4015
+ var _i15 = newEndIdx;
3933
4016
  var n;
3934
4017
 
3935
4018
  do {
3936
- n = newCh[++_i14];
3937
- } while (!isVNode(n) && _i14 < newChEnd);
4019
+ n = newCh[++_i15];
4020
+ } while (!isVNode(n) && _i15 < newChEnd);
3938
4021
 
3939
4022
  before = isVNode(n) ? n.elm : null;
3940
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
4023
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
3941
4024
  } else {
3942
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
4025
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
3943
4026
  }
3944
4027
  }
3945
4028
  }
3946
4029
 
3947
- function updateStaticChildren(parentElm, oldCh, newCh) {
3948
- var oldChLength = oldCh.length;
3949
- var newChLength = newCh.length;
4030
+ function updateStaticChildren(c1, c2, parent) {
4031
+ var c1Length = c1.length;
4032
+ var c2Length = c2.length;
3950
4033
 
3951
- if (oldChLength === 0) {
4034
+ if (c1Length === 0) {
3952
4035
  // the old list is empty, we can directly insert anything new
3953
- addVnodes(parentElm, null, newCh, 0, newChLength);
4036
+ mountVNodes(c2, parent, null);
3954
4037
  return;
3955
4038
  }
3956
4039
 
3957
- if (newChLength === 0) {
4040
+ if (c2Length === 0) {
3958
4041
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3959
4042
  // this is the case in which the dynamic children of an if-directive should be removed
3960
- removeVnodes(parentElm, oldCh, 0, oldChLength);
4043
+ unmountVNodes(c1, parent, true);
3961
4044
  return;
3962
4045
  } // if the old list is not empty, the new list MUST have the same
3963
4046
  // amount of nodes, that's why we call this static children
3964
4047
 
3965
4048
 
3966
- var referenceElm = null;
4049
+ var anchor = null;
3967
4050
 
3968
- for (var _i15 = newChLength - 1; _i15 >= 0; _i15 -= 1) {
3969
- var vnode = newCh[_i15];
3970
- var oldVNode = oldCh[_i15];
4051
+ for (var _i16 = c2Length - 1; _i16 >= 0; _i16 -= 1) {
4052
+ var n1 = c1[_i16];
4053
+ var n2 = c2[_i16];
3971
4054
 
3972
- if (vnode !== oldVNode) {
3973
- if (isVNode(oldVNode)) {
3974
- if (isVNode(vnode)) {
3975
- // both vnodes must be equivalent, and se just need to patch them
3976
- patchVnode(oldVNode, vnode);
3977
- referenceElm = vnode.elm;
4055
+ if (n2 !== n1) {
4056
+ if (isVNode(n1)) {
4057
+ if (isVNode(n2)) {
4058
+ // both vnodes are equivalent, and we just need to patch them
4059
+ patch(n1, n2);
4060
+ anchor = n2.elm;
3978
4061
  } else {
3979
4062
  // removing the old vnode since the new one is null
3980
- oldVNode.hook.remove(oldVNode, parentElm);
4063
+ unmount(n1, parent, true);
3981
4064
  }
3982
- } else if (isVNode(vnode)) {
3983
- // this condition is unnecessary
3984
- vnode.hook.create(vnode); // insert the new node one since the old one is null
3985
-
3986
- vnode.hook.insert(vnode, parentElm, referenceElm);
3987
- referenceElm = vnode.elm;
4065
+ } else if (isVNode(n2)) {
4066
+ mount(n2, parent, anchor);
4067
+ anchor = n2.elm;
3988
4068
  }
3989
4069
  }
3990
4070
  }
3991
4071
  }
3992
-
3993
- function patchVnode(oldVnode, vnode) {
3994
- if (oldVnode !== vnode) {
3995
- vnode.elm = oldVnode.elm;
3996
- vnode.hook.update(oldVnode, vnode);
3997
- }
3998
- }
3999
4072
  /*
4000
4073
  * Copyright (c) 2018, salesforce.com, inc.
4001
4074
  * All rights reserved.
@@ -4011,7 +4084,8 @@ var LWC = (function (exports) {
4011
4084
  } // [h]tml node
4012
4085
 
4013
4086
 
4014
- function h(sel, data, children) {
4087
+ function h(sel, data) {
4088
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EmptyArray;
4015
4089
  var vmBeingRendered = getVMBeingRendered();
4016
4090
 
4017
4091
  var elm;
@@ -4025,7 +4099,6 @@ var LWC = (function (exports) {
4025
4099
  children: children,
4026
4100
  elm: elm,
4027
4101
  key: key,
4028
- hook: ElementHook,
4029
4102
  owner: vmBeingRendered
4030
4103
  };
4031
4104
  } // [t]ab[i]ndex function
@@ -4074,7 +4147,7 @@ var LWC = (function (exports) {
4074
4147
  var vmBeingRendered = getVMBeingRendered();
4075
4148
 
4076
4149
  var key = data.key;
4077
- var elm;
4150
+ var elm, aChildren, vm;
4078
4151
  var vnode = {
4079
4152
  type: 3
4080
4153
  /* CustomElement */
@@ -4084,11 +4157,11 @@ var LWC = (function (exports) {
4084
4157
  children: children,
4085
4158
  elm: elm,
4086
4159
  key: key,
4087
- hook: CustomElementHook,
4088
4160
  ctor: Ctor,
4089
4161
  owner: vmBeingRendered,
4090
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
4091
-
4162
+ mode: 'open',
4163
+ aChildren: aChildren,
4164
+ vm: vm
4092
4165
  };
4093
4166
  addVNodeToChildLWC(vnode);
4094
4167
  return vnode;
@@ -4169,7 +4242,6 @@ var LWC = (function (exports) {
4169
4242
  text: text,
4170
4243
  elm: elm,
4171
4244
  key: key,
4172
- hook: TextHook,
4173
4245
  owner: getVMBeingRendered()
4174
4246
  };
4175
4247
  } // [co]mment node
@@ -4185,7 +4257,6 @@ var LWC = (function (exports) {
4185
4257
  text: text,
4186
4258
  elm: elm,
4187
4259
  key: key,
4188
- hook: CommentHook,
4189
4260
  owner: getVMBeingRendered()
4190
4261
  };
4191
4262
  } // [d]ynamic text
@@ -4285,7 +4356,8 @@ var LWC = (function (exports) {
4285
4356
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4286
4357
  */
4287
4358
 
4288
- function dc(sel, Ctor, data, children) {
4359
+ function dc(sel, Ctor, data) {
4360
+ var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : EmptyArray;
4289
4361
 
4290
4362
 
4291
4363
  if (Ctor == null) {
@@ -4304,10 +4376,14 @@ var LWC = (function (exports) {
4304
4376
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4305
4377
  // to identify different constructors as vnodes with different keys to avoid reusing the
4306
4378
  // element used for previous constructors.
4379
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4380
+ // hoisting optimization.
4307
4381
 
4308
4382
 
4309
- data.key = "dc:".concat(idx, ":").concat(data.key);
4310
- return c(sel, Ctor, data, children);
4383
+ var newData = Object.assign(Object.assign({}, data), {
4384
+ key: "dc:".concat(idx, ":").concat(data.key)
4385
+ });
4386
+ return c(sel, Ctor, newData, children);
4311
4387
  }
4312
4388
  /**
4313
4389
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -4416,12 +4492,14 @@ var LWC = (function (exports) {
4416
4492
  oldHasTokenInClass = context.hasTokenInClass,
4417
4493
  oldHasTokenInAttribute = context.hasTokenInAttribute;
4418
4494
 
4419
- if (oldHasTokenInClass) {
4420
- getClassList$1(elm).remove(makeHostToken(oldToken));
4421
- }
4495
+ if (!isUndefined$1(oldToken)) {
4496
+ if (oldHasTokenInClass) {
4497
+ getClassList$1(elm).remove(makeHostToken(oldToken));
4498
+ }
4422
4499
 
4423
- if (oldHasTokenInAttribute) {
4424
- removeAttribute$1(elm, makeHostToken(oldToken));
4500
+ if (oldHasTokenInAttribute) {
4501
+ removeAttribute$1(elm, makeHostToken(oldToken));
4502
+ }
4425
4503
  } // Apply the new template styling token to the host element, if the new template has any
4426
4504
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
4427
4505
 
@@ -4453,8 +4531,8 @@ var LWC = (function (exports) {
4453
4531
  var content = [];
4454
4532
  var root;
4455
4533
 
4456
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4457
- var stylesheet = stylesheets[_i16];
4534
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4535
+ var stylesheet = stylesheets[_i17];
4458
4536
 
4459
4537
  if (isArray$1(stylesheet)) {
4460
4538
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4558,8 +4636,8 @@ var LWC = (function (exports) {
4558
4636
  && shadowMode === 1
4559
4637
  /* Synthetic */
4560
4638
  ) {
4561
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4562
- insertGlobalStylesheet$1(stylesheets[_i17]);
4639
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4640
+ insertGlobalStylesheet$1(stylesheets[_i18]);
4563
4641
  }
4564
4642
  } else if (ssr$1 || isHydrating$1()) {
4565
4643
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -4573,12 +4651,12 @@ var LWC = (function (exports) {
4573
4651
  var root = getNearestNativeShadowComponent(vm);
4574
4652
  var isGlobal = isNull(root);
4575
4653
 
4576
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4654
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4577
4655
  if (isGlobal) {
4578
- insertGlobalStylesheet$1(stylesheets[_i18]);
4656
+ insertGlobalStylesheet$1(stylesheets[_i19]);
4579
4657
  } else {
4580
4658
  // local level
4581
- insertStylesheet$1(stylesheets[_i18], root.shadowRoot);
4659
+ insertStylesheet$1(stylesheets[_i19], root.shadowRoot);
4582
4660
  }
4583
4661
  }
4584
4662
  }
@@ -4763,8 +4841,8 @@ var LWC = (function (exports) {
4763
4841
  var stylesheets = template.stylesheets;
4764
4842
 
4765
4843
  if (!isUndefined$1(stylesheets)) {
4766
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4767
- if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4844
+ for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
4845
+ if (isTrue(stylesheets[_i20][KEY__SCOPED_CSS])) {
4768
4846
  return true;
4769
4847
  }
4770
4848
  }
@@ -4875,6 +4953,7 @@ var LWC = (function (exports) {
4875
4953
 
4876
4954
  function registerComponent(Ctor, _ref2) {
4877
4955
  var tmpl = _ref2.tmpl;
4956
+
4878
4957
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
4879
4958
  // without too much transformation
4880
4959
 
@@ -4947,8 +5026,8 @@ var LWC = (function (exports) {
4947
5026
 
4948
5027
  function register(service) {
4949
5028
 
4950
- for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4951
- var hookName = hooks[_i20];
5029
+ for (var _i21 = 0; _i21 < hooks.length; ++_i21) {
5030
+ var hookName = hooks[_i21];
4952
5031
 
4953
5032
  if (hookName in service) {
4954
5033
  var l = Services[hookName];
@@ -4968,8 +5047,8 @@ var LWC = (function (exports) {
4968
5047
  def = vm.def,
4969
5048
  context = vm.context;
4970
5049
 
4971
- for (var _i21 = 0, _len8 = cbs.length; _i21 < _len8; ++_i21) {
4972
- cbs[_i21].call(undefined, component, {}, def, context);
5050
+ for (var _i22 = 0, _len7 = cbs.length; _i22 < _len7; ++_i22) {
5051
+ cbs[_i22].call(undefined, component, {}, def, context);
4973
5052
  }
4974
5053
  }
4975
5054
  /*
@@ -4980,7 +5059,7 @@ var LWC = (function (exports) {
4980
5059
  */
4981
5060
 
4982
5061
 
4983
- function hydrate$1(vnode, node) {
5062
+ function hydrate(vnode, node) {
4984
5063
  switch (vnode.type) {
4985
5064
  case 0
4986
5065
  /* Text */
@@ -5012,7 +5091,7 @@ var LWC = (function (exports) {
5012
5091
  var _a;
5013
5092
 
5014
5093
 
5015
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5094
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5016
5095
  vnode.elm = node;
5017
5096
  }
5018
5097
 
@@ -5020,7 +5099,7 @@ var LWC = (function (exports) {
5020
5099
  var _a;
5021
5100
 
5022
5101
 
5023
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5102
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5024
5103
  vnode.elm = node;
5025
5104
  }
5026
5105
 
@@ -5039,10 +5118,13 @@ var LWC = (function (exports) {
5039
5118
  var props = vnode.data.props;
5040
5119
 
5041
5120
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5042
- if (elm.innerHTML === props.innerHTML) {
5043
- delete props.innerHTML;
5121
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
5122
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5123
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
5124
+ props: cloneAndOmitKey(props, 'innerHTML')
5125
+ });
5044
5126
  } else {
5045
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5127
+ logWarn("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5046
5128
  }
5047
5129
  }
5048
5130
  }
@@ -5050,14 +5132,13 @@ var LWC = (function (exports) {
5050
5132
  patchElementPropsAndAttrs(vnode);
5051
5133
 
5052
5134
  if (!isDomManual) {
5053
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
5135
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
5054
5136
  }
5055
5137
  }
5056
5138
 
5057
5139
  function hydrateCustomElement(vnode, node) {
5058
5140
 
5059
5141
  var elm = node;
5060
- vnode.elm = elm;
5061
5142
  var sel = vnode.sel,
5062
5143
  mode = vnode.mode,
5063
5144
  ctor = vnode.ctor,
@@ -5067,6 +5148,8 @@ var LWC = (function (exports) {
5067
5148
  owner: owner,
5068
5149
  tagName: sel
5069
5150
  });
5151
+ vnode.elm = elm;
5152
+ vnode.vm = vm;
5070
5153
  allocateChildren(vnode, vm);
5071
5154
  patchElementPropsAndAttrs(vnode); // Insert hook section:
5072
5155
 
@@ -5077,7 +5160,7 @@ var LWC = (function (exports) {
5077
5160
  ) {
5078
5161
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5079
5162
  // Note: for Light DOM, this is handled while hydrating the VM
5080
- hydrateChildren(vnode.elm.childNodes, vnode.children);
5163
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children);
5081
5164
  }
5082
5165
 
5083
5166
  hydrateVM(vm);
@@ -5087,12 +5170,12 @@ var LWC = (function (exports) {
5087
5170
 
5088
5171
  var childNodeIndex = 0;
5089
5172
 
5090
- for (var _i22 = 0; _i22 < children.length; _i22++) {
5091
- var childVnode = children[_i22];
5173
+ for (var _i23 = 0; _i23 < children.length; _i23++) {
5174
+ var childVnode = children[_i23];
5092
5175
 
5093
5176
  if (!isNull(childVnode)) {
5094
5177
  var childNode = elmChildren[childNodeIndex];
5095
- hydrate$1(childVnode, childNode);
5178
+ hydrate(childVnode, childNode);
5096
5179
  childNodeIndex++;
5097
5180
  }
5098
5181
  }
@@ -5168,7 +5251,19 @@ var LWC = (function (exports) {
5168
5251
  }
5169
5252
 
5170
5253
  function hydrateVM(vm) {
5171
- hydrate(vm);
5254
+ if (isTrue(vm.isDirty)) {
5255
+ // manually diffing/patching here.
5256
+ // This routine is:
5257
+ // patchShadowRoot(vm, children);
5258
+ // -> addVnodes.
5259
+ var children = renderComponent(vm);
5260
+ vm.children = children;
5261
+ var vmChildren = vm.renderMode === 0
5262
+ /* Light */
5263
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
5264
+ hydrateChildren(vmChildren, children);
5265
+ runRenderedCallback(vm);
5266
+ }
5172
5267
  } // just in case the component comes back, with this we guarantee re-rendering it
5173
5268
  // while preventing any attempt to rehydration until after reinsertion.
5174
5269
 
@@ -5288,7 +5383,11 @@ var LWC = (function (exports) {
5288
5383
  /* Native */
5289
5384
  ;
5290
5385
  } else if (isNativeShadowDefined$1) {
5291
- if (def.shadowSupportMode === "any"
5386
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
5387
+ shadowMode = 1
5388
+ /* Synthetic */
5389
+ ;
5390
+ } else if (def.shadowSupportMode === "any"
5292
5391
  /* Any */
5293
5392
  ) {
5294
5393
  shadowMode = 0
@@ -5352,22 +5451,6 @@ var LWC = (function (exports) {
5352
5451
  }
5353
5452
  }
5354
5453
 
5355
- function hydrate(vm) {
5356
- if (isTrue(vm.isDirty)) {
5357
- // manually diffing/patching here.
5358
- // This routine is:
5359
- // patchShadowRoot(vm, children);
5360
- // -> addVnodes.
5361
- var children = renderComponent(vm);
5362
- vm.children = children;
5363
- var vmChildren = vm.renderMode === 0
5364
- /* Light */
5365
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5366
- hydrateChildren(vmChildren, children);
5367
- runRenderedCallback(vm);
5368
- }
5369
- }
5370
-
5371
5454
  function patchShadowRoot(vm, newCh) {
5372
5455
  var renderRoot = vm.renderRoot,
5373
5456
  oldCh = vm.children; // caching the new children collection
@@ -5385,7 +5468,7 @@ var LWC = (function (exports) {
5385
5468
  , vm);
5386
5469
  }, function () {
5387
5470
  // job
5388
- patchChildren(renderRoot, oldCh, newCh);
5471
+ patchChildren(oldCh, newCh, renderRoot);
5389
5472
  }, function () {
5390
5473
  // post
5391
5474
  logOperationEnd(2
@@ -5442,19 +5525,19 @@ var LWC = (function (exports) {
5442
5525
  });
5443
5526
  rehydrateQueue = []; // reset to a new queue
5444
5527
 
5445
- for (var _i25 = 0, _len9 = vms.length; _i25 < _len9; _i25 += 1) {
5446
- var vm = vms[_i25];
5528
+ for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
5529
+ var vm = vms[_i26];
5447
5530
 
5448
5531
  try {
5449
5532
  rehydrate(vm);
5450
5533
  } catch (error) {
5451
- if (_i25 + 1 < _len9) {
5534
+ if (_i26 + 1 < _len8) {
5452
5535
  // pieces of the queue are still pending to be rehydrated, those should have priority
5453
5536
  if (rehydrateQueue.length === 0) {
5454
5537
  addCallbackToNextTick(flushRehydrationQueue);
5455
5538
  }
5456
5539
 
5457
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i25 + 1));
5540
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i26 + 1));
5458
5541
  } // we need to end the measure before throwing.
5459
5542
 
5460
5543
 
@@ -5553,8 +5636,8 @@ var LWC = (function (exports) {
5553
5636
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5554
5637
  // inserted in reserved order.
5555
5638
 
5556
- for (var _i26 = vCustomElementCollection.length - 1; _i26 >= 0; _i26 -= 1) {
5557
- var elm = vCustomElementCollection[_i26].elm; // There are two cases where the element could be undefined:
5639
+ for (var _i27 = vCustomElementCollection.length - 1; _i27 >= 0; _i27 -= 1) {
5640
+ var elm = vCustomElementCollection[_i27].elm; // There are two cases where the element could be undefined:
5558
5641
  // * when there is an error during the construction phase, and an error
5559
5642
  // boundary picks it, there is a possibility that the VCustomElement
5560
5643
  // is not properly initialized, and therefore is should be ignored.
@@ -5588,8 +5671,8 @@ var LWC = (function (exports) {
5588
5671
 
5589
5672
 
5590
5673
  function recursivelyDisconnectChildren(vnodes) {
5591
- for (var _i27 = 0, _len10 = vnodes.length; _i27 < _len10; _i27 += 1) {
5592
- var vnode = vnodes[_i27];
5674
+ for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
5675
+ var vnode = vnodes[_i28];
5593
5676
 
5594
5677
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
5595
5678
  switch (vnode.type) {
@@ -5620,8 +5703,8 @@ var LWC = (function (exports) {
5620
5703
  var children = vm.children,
5621
5704
  renderRoot = vm.renderRoot;
5622
5705
 
5623
- for (var _i28 = 0, _len11 = children.length; _i28 < _len11; _i28++) {
5624
- var child = children[_i28];
5706
+ for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
5707
+ var child = children[_i29];
5625
5708
 
5626
5709
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5627
5710
  remove$1(child.elm, renderRoot);
@@ -5971,8 +6054,8 @@ var LWC = (function (exports) {
5971
6054
  function connectWireAdapters(vm) {
5972
6055
  var wiredConnecting = vm.context.wiredConnecting;
5973
6056
 
5974
- for (var _i29 = 0, _len12 = wiredConnecting.length; _i29 < _len12; _i29 += 1) {
5975
- wiredConnecting[_i29]();
6057
+ for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
6058
+ wiredConnecting[_i30]();
5976
6059
  }
5977
6060
  }
5978
6061
 
@@ -5980,8 +6063,8 @@ var LWC = (function (exports) {
5980
6063
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5981
6064
  runWithBoundaryProtection(vm, vm, noop, function () {
5982
6065
  // job
5983
- for (var _i30 = 0, _len13 = wiredDisconnecting.length; _i30 < _len13; _i30 += 1) {
5984
- wiredDisconnecting[_i30]();
6066
+ for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
6067
+ wiredDisconnecting[_i31]();
5985
6068
  }
5986
6069
  }, noop);
5987
6070
  }
@@ -6065,7 +6148,7 @@ var LWC = (function (exports) {
6065
6148
  hooksAreSet = true;
6066
6149
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6067
6150
  }
6068
- /* version: 2.7.4 */
6151
+ /* version: 2.10.0 */
6069
6152
 
6070
6153
  /*
6071
6154
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6082,6 +6165,7 @@ var LWC = (function (exports) {
6082
6165
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6083
6166
 
6084
6167
  var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6168
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6085
6169
  var styleElements = create(null);
6086
6170
  var styleSheets = create(null);
6087
6171
  var nodesToStyleSheets = new WeakMap();
@@ -6137,7 +6221,13 @@ var LWC = (function (exports) {
6137
6221
  }
6138
6222
 
6139
6223
  if (!target.adoptedStyleSheets.includes(styleSheet)) {
6140
- target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
6224
+ if (supportsMutableAdoptedStyleSheets) {
6225
+ // This is only supported in later versions of Chromium:
6226
+ // https://chromestatus.com/feature/5638996492288000
6227
+ target.adoptedStyleSheets.push(styleSheet);
6228
+ } else {
6229
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
6230
+ }
6141
6231
  }
6142
6232
  }
6143
6233
 
@@ -6419,6 +6509,173 @@ var LWC = (function (exports) {
6419
6509
  setSetText(setText);
6420
6510
  setSsr(ssr);
6421
6511
  setAddEventListener(addEventListener);
6512
+ /*
6513
+ * Copyright (c) 2018, salesforce.com, inc.
6514
+ * All rights reserved.
6515
+ * SPDX-License-Identifier: MIT
6516
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6517
+ */
6518
+
6519
+ function resetShadowRootAndLightDom(element, Ctor) {
6520
+ if (element.shadowRoot) {
6521
+ var shadowRoot = element.shadowRoot;
6522
+
6523
+ while (!isNull(shadowRoot.firstChild)) {
6524
+ shadowRoot.removeChild(shadowRoot.firstChild);
6525
+ }
6526
+ }
6527
+
6528
+ if (Ctor.renderMode === 'light') {
6529
+ while (!isNull(element.firstChild)) {
6530
+ element.removeChild(element.firstChild);
6531
+ }
6532
+ }
6533
+ }
6534
+
6535
+ function createVMWithProps(element, Ctor, props) {
6536
+ createVM(element, Ctor, {
6537
+ mode: 'open',
6538
+ owner: null,
6539
+ tagName: element.tagName.toLowerCase()
6540
+ });
6541
+
6542
+ for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
6543
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
6544
+ key = _Object$entries2$_i[0],
6545
+ value = _Object$entries2$_i[1];
6546
+
6547
+ element[key] = value;
6548
+ }
6549
+ }
6550
+
6551
+ function hydrateComponent(element, Ctor) {
6552
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6553
+
6554
+ if (!(element instanceof Element)) {
6555
+ throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
6556
+ }
6557
+
6558
+ if (!isFunction$1(Ctor)) {
6559
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6560
+ }
6561
+
6562
+ if (!isObject(props) || isNull(props)) {
6563
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6564
+ }
6565
+
6566
+ if (getAssociatedVMIfPresent(element)) {
6567
+ /* eslint-disable-next-line no-console */
6568
+ console.warn("\"hydrateComponent\" expects an element that is not hydrated.", element);
6569
+ return;
6570
+ }
6571
+
6572
+ try {
6573
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6574
+ // and uses the same algo to create the stylesheets as in SSR.
6575
+ setIsHydrating(true);
6576
+ createVMWithProps(element, Ctor, props);
6577
+ hydrateRootElement(element); // set it back since now we finished hydration.
6578
+
6579
+ setIsHydrating(false);
6580
+ } catch (e) {
6581
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
6582
+ // with the client generated DOM.
6583
+
6584
+ /* eslint-disable-next-line no-console */
6585
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
6586
+
6587
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
6588
+
6589
+ createVMWithProps(element, Ctor, props);
6590
+ setIsHydrating(false);
6591
+ connectRootElement(element);
6592
+ } finally {
6593
+ // in case there's an error during recovery
6594
+ setIsHydrating(false);
6595
+ }
6596
+ }
6597
+ /*
6598
+ * Copyright (c) 2018, salesforce.com, inc.
6599
+ * All rights reserved.
6600
+ * SPDX-License-Identifier: MIT
6601
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6602
+ */
6603
+
6604
+ /**
6605
+ * This function builds a Web Component class from a LWC constructor so it can be
6606
+ * registered as a new element via customElements.define() at any given time.
6607
+ *
6608
+ * @deprecated since version 1.3.11
6609
+ *
6610
+ * @example
6611
+ * ```
6612
+ * import { buildCustomElementConstructor } from 'lwc';
6613
+ * import Foo from 'ns/foo';
6614
+ * const WC = buildCustomElementConstructor(Foo);
6615
+ * customElements.define('x-foo', WC);
6616
+ * const elm = document.createElement('x-foo');
6617
+ * ```
6618
+ */
6619
+
6620
+
6621
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6622
+
6623
+ return Ctor.CustomElementConstructor;
6624
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
6625
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
6626
+
6627
+
6628
+ var hydratedCustomElements = new WeakSet();
6629
+
6630
+ function buildCustomElementConstructor(Ctor) {
6631
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
6632
+ return /*#__PURE__*/function (_HtmlPrototype) {
6633
+ _inherits(_class, _HtmlPrototype);
6634
+
6635
+ var _super8 = _createSuper(_class);
6636
+
6637
+ function _class() {
6638
+ var _this6;
6639
+
6640
+ _classCallCheck(this, _class);
6641
+
6642
+ _this6 = _super8.call(this);
6643
+
6644
+ if (_this6.isConnected) {
6645
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
6646
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
6647
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
6648
+ } else {
6649
+ createVM(_assertThisInitialized(_this6), Ctor, {
6650
+ mode: 'open',
6651
+ owner: null,
6652
+ tagName: _this6.tagName
6653
+ });
6654
+ }
6655
+
6656
+ return _this6;
6657
+ }
6658
+
6659
+ _createClass(_class, [{
6660
+ key: "connectedCallback",
6661
+ value: function connectedCallback() {
6662
+ if (hydratedCustomElements.has(this)) {
6663
+ // This is an un-upgraded element that was hydrated in the constructor.
6664
+ hydratedCustomElements.delete(this);
6665
+ } else {
6666
+ connectRootElement(this);
6667
+ }
6668
+ }
6669
+ }, {
6670
+ key: "disconnectedCallback",
6671
+ value: function disconnectedCallback() {
6672
+ disconnectRootElement(this);
6673
+ }
6674
+ }]);
6675
+
6676
+ return _class;
6677
+ }(HtmlPrototype);
6678
+ }
6422
6679
  /*
6423
6680
  * Copyright (c) 2018, salesforce.com, inc.
6424
6681
  * All rights reserved.
@@ -6428,6 +6685,7 @@ var LWC = (function (exports) {
6428
6685
  // TODO [#2472]: Remove this workaround when appropriate.
6429
6686
  // eslint-disable-next-line lwc-internal/no-global-node
6430
6687
 
6688
+
6431
6689
  var _Node$1 = Node;
6432
6690
  var ConnectingSlot = new WeakMap();
6433
6691
  var DisconnectingSlot = new WeakMap();
@@ -6532,138 +6790,6 @@ var LWC = (function (exports) {
6532
6790
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6533
6791
  */
6534
6792
 
6535
-
6536
- function hydrateComponent(element, Ctor) {
6537
- var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6538
-
6539
- if (!(element instanceof Element)) {
6540
- throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
6541
- }
6542
-
6543
- if (!isFunction$1(Ctor)) {
6544
- throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6545
- }
6546
-
6547
- if (!isObject(props) || isNull(props)) {
6548
- throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6549
- }
6550
-
6551
- try {
6552
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6553
- // and uses the same algo to create the stylesheets as in SSR.
6554
- setIsHydrating(true);
6555
- createVM(element, Ctor, {
6556
- mode: 'open',
6557
- owner: null,
6558
- tagName: element.tagName.toLowerCase()
6559
- });
6560
-
6561
- for (var _i32 = 0, _Object$entries2 = Object.entries(props); _i32 < _Object$entries2.length; _i32++) {
6562
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i32], 2),
6563
- key = _Object$entries2$_i[0],
6564
- value = _Object$entries2$_i[1];
6565
-
6566
- element[key] = value;
6567
- }
6568
-
6569
- hydrateRootElement(element); // set it back since now we finished hydration.
6570
-
6571
- setIsHydrating(false);
6572
- } catch (e) {
6573
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6574
- // the client generated DOM.
6575
-
6576
- /* eslint-disable-next-line no-console */
6577
- console.error('Recovering from error while hydrating: ', e);
6578
- setIsHydrating(false);
6579
- var newElem = createElement(element.tagName, {
6580
- is: Ctor,
6581
- mode: 'open'
6582
- });
6583
-
6584
- for (var _i33 = 0, _Object$entries3 = Object.entries(props); _i33 < _Object$entries3.length; _i33++) {
6585
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i33], 2),
6586
- _key3 = _Object$entries3$_i[0],
6587
- _value2 = _Object$entries3$_i[1];
6588
-
6589
- newElem[_key3] = _value2;
6590
- }
6591
-
6592
- element.parentNode.replaceChild(newElem, element);
6593
- }
6594
- }
6595
- /*
6596
- * Copyright (c) 2018, salesforce.com, inc.
6597
- * All rights reserved.
6598
- * SPDX-License-Identifier: MIT
6599
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6600
- */
6601
-
6602
- /**
6603
- * This function builds a Web Component class from a LWC constructor so it can be
6604
- * registered as a new element via customElements.define() at any given time.
6605
- *
6606
- * @deprecated since version 1.3.11
6607
- *
6608
- * @example
6609
- * ```
6610
- * import { buildCustomElementConstructor } from 'lwc';
6611
- * import Foo from 'ns/foo';
6612
- * const WC = buildCustomElementConstructor(Foo);
6613
- * customElements.define('x-foo', WC);
6614
- * const elm = document.createElement('x-foo');
6615
- * ```
6616
- */
6617
-
6618
-
6619
- function deprecatedBuildCustomElementConstructor(Ctor) {
6620
-
6621
- return Ctor.CustomElementConstructor;
6622
- }
6623
-
6624
- function buildCustomElementConstructor(Ctor) {
6625
- var HtmlPrototype = getComponentHtmlPrototype(Ctor);
6626
- return /*#__PURE__*/function (_HtmlPrototype) {
6627
- _inherits(_class, _HtmlPrototype);
6628
-
6629
- var _super8 = _createSuper(_class);
6630
-
6631
- function _class() {
6632
- var _this6;
6633
-
6634
- _classCallCheck(this, _class);
6635
-
6636
- _this6 = _super8.call(this);
6637
- createVM(_assertThisInitialized(_this6), Ctor, {
6638
- mode: 'open',
6639
- owner: null,
6640
- tagName: _this6.tagName
6641
- });
6642
- return _this6;
6643
- }
6644
-
6645
- _createClass(_class, [{
6646
- key: "connectedCallback",
6647
- value: function connectedCallback() {
6648
- connectRootElement(this);
6649
- }
6650
- }, {
6651
- key: "disconnectedCallback",
6652
- value: function disconnectedCallback() {
6653
- disconnectRootElement(this);
6654
- }
6655
- }]);
6656
-
6657
- return _class;
6658
- }(HtmlPrototype);
6659
- }
6660
- /*
6661
- * Copyright (c) 2018, salesforce.com, inc.
6662
- * All rights reserved.
6663
- * SPDX-License-Identifier: MIT
6664
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6665
- */
6666
-
6667
6793
  /**
6668
6794
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6669
6795
  * This API is subject to change or being removed.
@@ -6695,30 +6821,31 @@ var LWC = (function (exports) {
6695
6821
 
6696
6822
  var _Node = Node;
6697
6823
  /**
6698
- * EXPERIMENTAL: This function detects whether or not a Node is controlled by a LWC template. This
6699
- * API is subject to change or being removed.
6824
+ * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
6825
+ * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
6700
6826
  */
6701
6827
 
6702
- function isNodeFromTemplate(node) {
6828
+ function isNodeShadowed(node) {
6703
6829
  if (isFalse(node instanceof _Node)) {
6704
6830
  return false;
6705
- } // TODO [#1250]: skipping the shadowRoot instances itself makes no sense, we need to revisit
6706
- // this with locker
6831
+ } // It's debatable whether shadow root instances should be considered as shadowed, but we keep
6832
+ // this unchanged for legacy reasons (#1250).
6707
6833
 
6708
6834
 
6709
6835
  if (node instanceof ShadowRoot) {
6710
6836
  return false;
6711
6837
  }
6712
6838
 
6713
- if (isSyntheticShadowDefined) {
6714
- // TODO [#1252]: old behavior that is still used by some pieces of the platform,
6715
- // specifically, nodes inserted manually on places where `lwc:dom="manual"` directive is not
6716
- // used, will be considered global elements.
6717
- return !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6718
- }
6839
+ var rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
6840
+ // synthetic roots cannot be descendants of native roots.
6841
+
6842
+ if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
6843
+ return true;
6844
+ } // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
6845
+ // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
6846
+
6719
6847
 
6720
- var root = node.getRootNode();
6721
- return root instanceof ShadowRoot;
6848
+ return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6722
6849
  }
6723
6850
  /*
6724
6851
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6762,7 +6889,7 @@ var LWC = (function (exports) {
6762
6889
  });
6763
6890
  freeze(LightningElement);
6764
6891
  seal(LightningElement.prototype);
6765
- /* version: 2.7.4 */
6892
+ /* version: 2.10.0 */
6766
6893
 
6767
6894
  exports.LightningElement = LightningElement;
6768
6895
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6774,7 +6901,7 @@ var LWC = (function (exports) {
6774
6901
  exports.getComponentDef = getComponentDef;
6775
6902
  exports.hydrateComponent = hydrateComponent;
6776
6903
  exports.isComponentConstructor = isComponentConstructor;
6777
- exports.isNodeFromTemplate = isNodeFromTemplate;
6904
+ exports.isNodeFromTemplate = isNodeShadowed;
6778
6905
  exports.readonly = readonly;
6779
6906
  exports.register = register;
6780
6907
  exports.registerComponent = registerComponent;