lwc 2.8.0 → 2.11.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 (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +4362 -5763
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +4362 -5763
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +3303 -4535
  5. package/dist/engine-dom/iife/es5/engine-dom.js +789 -580
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +650 -518
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +4362 -5763
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +3303 -4535
  11. package/dist/engine-dom/umd/es5/engine-dom.js +789 -580
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +650 -518
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +4062 -5273
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +4062 -5273
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +2952 -3673
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +2952 -3673
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +2825 -3532
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +11 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +11 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +2952 -3673
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +2825 -3532
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +11 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +11 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +128 -174
  27. package/dist/wire-service/iife/es2017/wire-service.js +128 -174
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +128 -174
  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 +128 -174
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +128 -174
  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 +7 -7
@@ -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.8.0 */
348
+ /** version: 2.11.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,
454
451
  ENABLE_ELEMENT_PATCH: null,
455
452
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
456
- ENABLE_NODE_LIST_PATCH: null,
453
+ ENABLE_HMR: null,
457
454
  ENABLE_HTML_COLLECTIONS_PATCH: null,
455
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
456
+ ENABLE_MIXED_SHADOW_MODE: 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.8.0 */
518
+ /** version: 2.11.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
 
@@ -1035,6 +1051,7 @@ var LWC = (function (exports) {
1035
1051
  * SPDX-License-Identifier: MIT
1036
1052
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1037
1053
  */
1054
+ // These properties get added to LWCElement.prototype publicProps automatically
1038
1055
 
1039
1056
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1040
1057
 
@@ -2117,7 +2134,7 @@ var LWC = (function (exports) {
2117
2134
 
2118
2135
 
2119
2136
  var _loop = function _loop() {
2120
- var childGetter = _childGetters[_i6];
2137
+ var childGetter = _childGetters[_i7];
2121
2138
  queryAndChildGetterDescriptors[childGetter] = {
2122
2139
  get: function get() {
2123
2140
  var vm = getAssociatedVM(this);
@@ -2130,7 +2147,7 @@ var LWC = (function (exports) {
2130
2147
  };
2131
2148
  };
2132
2149
 
2133
- for (var _i6 = 0, _childGetters = childGetters; _i6 < _childGetters.length; _i6++) {
2150
+ for (var _i7 = 0, _childGetters = childGetters; _i7 < _childGetters.length; _i7++) {
2134
2151
  _loop();
2135
2152
  }
2136
2153
 
@@ -2154,7 +2171,7 @@ var LWC = (function (exports) {
2154
2171
 
2155
2172
 
2156
2173
  var _loop2 = function _loop2() {
2157
- var queryMethod = _queryMethods[_i7];
2174
+ var queryMethod = _queryMethods[_i8];
2158
2175
  queryAndChildGetterDescriptors[queryMethod] = {
2159
2176
  value: function value(arg) {
2160
2177
  var vm = getAssociatedVM(this);
@@ -2168,7 +2185,7 @@ var LWC = (function (exports) {
2168
2185
  };
2169
2186
  };
2170
2187
 
2171
- for (var _i7 = 0, _queryMethods = queryMethods; _i7 < _queryMethods.length; _i7++) {
2188
+ for (var _i8 = 0, _queryMethods = queryMethods; _i8 < _queryMethods.length; _i8++) {
2172
2189
  _loop2();
2173
2190
  }
2174
2191
 
@@ -2529,8 +2546,8 @@ var LWC = (function (exports) {
2529
2546
  }
2530
2547
 
2531
2548
  if (!isUndefined$1(fields)) {
2532
- for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
2533
- var _fieldName2 = fields[_i8];
2549
+ for (var _i9 = 0, n = fields.length; _i9 < n; _i9++) {
2550
+ var _fieldName2 = fields[_i9];
2534
2551
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
2535
2552
  // tracked property. This is only here for backward compatibility purposes.
2536
2553
 
@@ -2593,6 +2610,7 @@ var LWC = (function (exports) {
2593
2610
 
2594
2611
 
2595
2612
  function registerTemplate(tpl) {
2613
+
2596
2614
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
2597
2615
  // assignment of templates easily, without too much transformation
2598
2616
 
@@ -2615,6 +2633,7 @@ var LWC = (function (exports) {
2615
2633
  * SPDX-License-Identifier: MIT
2616
2634
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2617
2635
  */
2636
+ // A bridge descriptor is a descriptor whose job is just to get the component instance
2618
2637
  // from the element instance, and get the value or set a new value on the component.
2619
2638
  // This means that across different elements, similar names can get the exact same
2620
2639
  // descriptor, so we can cache them:
@@ -2747,8 +2766,8 @@ var LWC = (function (exports) {
2747
2766
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
2748
2767
  var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
2749
2768
 
2750
- for (var _i9 = 0, _len3 = props.length; _i9 < _len3; _i9 += 1) {
2751
- var _propName2 = props[_i9];
2769
+ for (var _i10 = 0, _len3 = props.length; _i10 < _len3; _i10 += 1) {
2770
+ var _propName2 = props[_i10];
2752
2771
  attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
2753
2772
  descriptors[_propName2] = {
2754
2773
  get: createGetter(_propName2),
@@ -2759,8 +2778,8 @@ var LWC = (function (exports) {
2759
2778
  } // expose public methods as props on the new Element Bridge
2760
2779
 
2761
2780
 
2762
- for (var _i10 = 0, _len4 = methods.length; _i10 < _len4; _i10 += 1) {
2763
- var methodName = methods[_i10];
2781
+ for (var _i11 = 0, _len4 = methods.length; _i11 < _len4; _i11 += 1) {
2782
+ var methodName = methods[_i11];
2764
2783
  descriptors[methodName] = {
2765
2784
  value: createMethodCaller(methodName),
2766
2785
  writable: true,
@@ -3308,6 +3327,7 @@ var LWC = (function (exports) {
3308
3327
  * SPDX-License-Identifier: MIT
3309
3328
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3310
3329
  */
3330
+ // The style property is a string when defined via an expression in the template.
3311
3331
 
3312
3332
 
3313
3333
  function patchStyleAttribute(oldVnode, vnode) {
@@ -3352,6 +3372,7 @@ var LWC = (function (exports) {
3352
3372
  * SPDX-License-Identifier: MIT
3353
3373
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3354
3374
  */
3375
+ // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
3355
3376
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
3356
3377
  // different classnames properties individually instead of via a string.
3357
3378
 
@@ -3376,6 +3397,7 @@ var LWC = (function (exports) {
3376
3397
  * SPDX-License-Identifier: MIT
3377
3398
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3378
3399
  */
3400
+ // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
3379
3401
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
3380
3402
  // different style properties individually instead of via a string.
3381
3403
 
@@ -3388,8 +3410,8 @@ var LWC = (function (exports) {
3388
3410
  return;
3389
3411
  }
3390
3412
 
3391
- for (var _i11 = 0; _i11 < styleDecls.length; _i11++) {
3392
- var _styleDecls$_i = _slicedToArray(styleDecls[_i11], 3),
3413
+ for (var _i12 = 0; _i12 < styleDecls.length; _i12++) {
3414
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i12], 3),
3393
3415
  prop = _styleDecls$_i[0],
3394
3416
  value = _styleDecls$_i[1],
3395
3417
  important = _styleDecls$_i[2];
@@ -3405,138 +3427,245 @@ var LWC = (function (exports) {
3405
3427
  */
3406
3428
 
3407
3429
 
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);
3430
+ function patchChildren(c1, c2, parent) {
3431
+ if (hasDynamicChildren(c2)) {
3432
+ updateDynamicChildren(c1, c2, parent);
3433
+ } else {
3434
+ updateStaticChildren(c1, c2, parent);
3462
3435
  }
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
- */
3436
+ }
3475
3437
 
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;
3438
+ function patch(n1, n2) {
3439
+ if (n1 === n2) {
3440
+ return;
3441
+ }
3483
3442
 
3484
- if (vm) {
3485
- allocateChildren(vnode, vm);
3486
- } else if (vnode.ctor !== UpgradableConstructor) {
3487
- throw new TypeError("Incorrect Component Constructor");
3488
- }
3443
+ switch (n2.type) {
3444
+ case 0
3445
+ /* Text */
3446
+ :
3447
+ patchText(n1, n2);
3448
+ break;
3489
3449
 
3490
- patchElementPropsAndAttrs$1(null, vnode);
3491
- },
3492
- update: function update(oldVnode, vnode) {
3493
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3494
- var vm = getAssociatedVMIfPresent(vnode.elm);
3450
+ case 1
3451
+ /* Comment */
3452
+ :
3453
+ patchComment(n1, n2);
3454
+ break;
3495
3455
 
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
3456
+ case 2
3457
+ /* Element */
3458
+ :
3459
+ patchElement(n1, n2);
3460
+ break;
3502
3461
 
3462
+ case 3
3463
+ /* CustomElement */
3464
+ :
3465
+ patchCustomElement(n1, n2);
3466
+ break;
3467
+ }
3468
+ }
3503
3469
 
3504
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3470
+ function mount(node, parent, anchor) {
3471
+ switch (node.type) {
3472
+ case 0
3473
+ /* Text */
3474
+ :
3475
+ mountText(node, parent, anchor);
3476
+ break;
3505
3477
 
3506
- if (vm) {
3507
- // this is important to preserve the top to bottom synchronous rendering phase.
3478
+ case 1
3479
+ /* Comment */
3480
+ :
3481
+ mountComment(node, parent, anchor);
3482
+ break;
3508
3483
 
3484
+ case 2
3485
+ /* Element */
3486
+ :
3487
+ mountElement(node, parent, anchor);
3488
+ break;
3509
3489
 
3510
- rerenderVM(vm);
3511
- }
3512
- },
3513
- insert: function insert(vnode, parentNode, referenceNode) {
3514
- insertNode(vnode, parentNode, referenceNode);
3515
- var vm = getAssociatedVMIfPresent(vnode.elm);
3490
+ case 3
3491
+ /* CustomElement */
3492
+ :
3493
+ mountCustomElement(node, parent, anchor);
3494
+ break;
3495
+ }
3496
+ }
3516
3497
 
3517
- if (vm) {
3498
+ function patchText(n1, n2) {
3499
+ n2.elm = n1.elm;
3518
3500
 
3519
- runConnectedCallback(vm);
3520
- }
3501
+ if (n2.text !== n1.text) {
3502
+ updateTextContent(n2);
3503
+ }
3504
+ }
3505
+
3506
+ function mountText(node, parent, anchor) {
3507
+ var owner = node.owner;
3508
+ var textNode = node.elm = createText$1(node.text);
3509
+ linkNodeToShadow(textNode, owner);
3510
+ insertNode(textNode, parent, anchor);
3511
+ }
3512
+
3513
+ function patchComment(n1, n2) {
3514
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3515
+ // it is the case today.
3516
+
3517
+ if (n2.text !== n1.text) {
3518
+ updateTextContent(n2);
3519
+ }
3520
+ }
3521
+
3522
+ function mountComment(node, parent, anchor) {
3523
+ var owner = node.owner;
3524
+ var commentNode = node.elm = createComment$1(node.text);
3525
+ linkNodeToShadow(commentNode, owner);
3526
+ insertNode(commentNode, parent, anchor);
3527
+ }
3528
+
3529
+ function mountElement(vnode, parent, anchor) {
3530
+ var sel = vnode.sel,
3531
+ owner = vnode.owner,
3532
+ svg = vnode.data.svg;
3533
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3534
+ var elm = createElement$2(sel, namespace);
3535
+ linkNodeToShadow(elm, owner);
3536
+ fallbackElmHook(elm, vnode);
3537
+ vnode.elm = elm;
3538
+ patchElementPropsAndAttrs$1(null, vnode);
3539
+ insertNode(elm, parent, anchor);
3540
+ mountVNodes(vnode.children, elm, null);
3541
+ }
3542
+
3543
+ function patchElement(n1, n2) {
3544
+ var elm = n2.elm = n1.elm;
3545
+ patchElementPropsAndAttrs$1(n1, n2);
3546
+ patchChildren(n1.children, n2.children, elm);
3547
+ }
3548
+
3549
+ function mountCustomElement(vnode, parent, anchor) {
3550
+ var sel = vnode.sel,
3551
+ owner = vnode.owner;
3552
+ var UpgradableConstructor = getUpgradableConstructor(sel);
3553
+ /**
3554
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3555
+ * with a callback as the first argument, we could implement a more advanced
3556
+ * mechanism that only passes that argument if the constructor is known to be
3557
+ * an upgradable custom element.
3558
+ */
3559
+
3560
+ var vm;
3561
+ var elm = new UpgradableConstructor(function (elm) {
3562
+ // the custom element from the registry is expecting an upgrade callback
3563
+ vm = createViewModelHook(elm, vnode);
3564
+ });
3565
+ linkNodeToShadow(elm, owner);
3566
+ vnode.elm = elm;
3567
+ vnode.vm = vm;
3568
+
3569
+ if (vm) {
3570
+ allocateChildren(vnode, vm);
3571
+ } else if (vnode.ctor !== UpgradableConstructor) {
3572
+ throw new TypeError("Incorrect Component Constructor");
3573
+ }
3574
+
3575
+ patchElementPropsAndAttrs$1(null, vnode);
3576
+ insertNode(elm, parent, anchor);
3577
+
3578
+ if (vm) {
3579
+
3580
+ runConnectedCallback(vm);
3581
+ }
3582
+
3583
+ mountVNodes(vnode.children, elm, null);
3584
+
3585
+ if (vm) {
3586
+ appendVM(vm);
3587
+ }
3588
+ }
3589
+
3590
+ function patchCustomElement(n1, n2) {
3591
+ var elm = n2.elm = n1.elm;
3592
+ var vm = n2.vm = n1.vm;
3593
+ patchElementPropsAndAttrs$1(n1, n2);
3594
+
3595
+ if (!isUndefined$1(vm)) {
3596
+ // in fallback mode, the allocation will always set children to
3597
+ // empty and delegate the real allocation to the slot elements
3598
+ allocateChildren(n2, vm);
3599
+ } // in fallback mode, the children will be always empty, so, nothing
3600
+ // will happen, but in native, it does allocate the light dom
3601
+
3602
+
3603
+ patchChildren(n1.children, n2.children, elm);
3604
+
3605
+ if (!isUndefined$1(vm)) {
3606
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3607
+ // this is important to preserve the top to bottom synchronous rendering phase.
3608
+ rerenderVM(vm);
3609
+ }
3610
+ }
3611
+
3612
+ function mountVNodes(vnodes, parent, anchor) {
3613
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
3614
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
3521
3615
 
3522
- createChildrenHook(vnode);
3616
+ for (; start < end; ++start) {
3617
+ var vnode = vnodes[start];
3523
3618
 
3524
- if (vm) {
3525
- appendVM(vm);
3619
+ if (isVNode(vnode)) {
3620
+ mount(vnode, parent, anchor);
3526
3621
  }
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);
3622
+ }
3623
+ }
3624
+
3625
+ function unmount(vnode, parent) {
3626
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3627
+ var type = vnode.type,
3628
+ elm = vnode.elm; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3629
+ // subtree root, is the only element worth unmounting from the subtree.
3630
+
3631
+ if (doRemove) {
3632
+ removeNode(elm, parent);
3633
+ }
3634
+
3635
+ switch (type) {
3636
+ case 2
3637
+ /* Element */
3638
+ :
3639
+ unmountVNodes(vnode.children, elm);
3640
+ break;
3641
+
3642
+ case 3
3643
+ /* CustomElement */
3644
+ :
3645
+ {
3646
+ var vm = vnode.vm; // No need to unmount the children here, `removeVM` will take care of removing the
3647
+ // children.
3648
+
3649
+ if (!isUndefined$1(vm)) {
3650
+ removeVM(vm);
3651
+ }
3652
+ }
3653
+ }
3654
+ }
3655
+
3656
+ function unmountVNodes(vnodes, parent) {
3657
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3658
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
3659
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
3660
+
3661
+ for (; start < end; ++start) {
3662
+ var ch = vnodes[start];
3663
+
3664
+ if (isVNode(ch)) {
3665
+ unmount(ch, parent, doRemove);
3537
3666
  }
3538
3667
  }
3539
- };
3668
+ }
3540
3669
 
3541
3670
  function isVNode(vnode) {
3542
3671
  return vnode != null;
@@ -3577,24 +3706,21 @@ var LWC = (function (exports) {
3577
3706
  }
3578
3707
  }
3579
3708
 
3580
- function updateNodeHook(oldVnode, vnode) {
3709
+ function updateTextContent(vnode) {
3581
3710
  var elm = vnode.elm,
3582
3711
  text = vnode.text;
3583
3712
 
3584
- if (oldVnode.text !== text) {
3585
-
3586
- setText$1(elm, text);
3587
- }
3713
+ setText$1(elm, text);
3588
3714
  }
3589
3715
 
3590
- function insertNode(vnode, parentNode, referenceNode) {
3716
+ function insertNode(node, parent, anchor) {
3591
3717
 
3592
- insert$1(vnode.elm, parentNode, referenceNode);
3718
+ insert$1(node, parent, anchor);
3593
3719
  }
3594
3720
 
3595
- function removeNode(vnode, parentNode) {
3721
+ function removeNode(node, parent) {
3596
3722
 
3597
- remove$1(vnode.elm, parentNode);
3723
+ remove$1(node, parent);
3598
3724
  }
3599
3725
 
3600
3726
  function patchElementPropsAndAttrs$1(oldVnode, vnode) {
@@ -3627,19 +3753,13 @@ var LWC = (function (exports) {
3627
3753
  ) {
3628
3754
  // this element will now accept any manual content inserted into it
3629
3755
  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
- }
3756
+ }
3637
3757
 
3638
- function patchChildren(parent, oldCh, newCh) {
3639
- if (hasDynamicChildren(newCh)) {
3640
- updateDynamicChildren(parent, oldCh, newCh);
3641
- } else {
3642
- updateStaticChildren(parent, oldCh, newCh);
3758
+ if (!isUndefined$1(stylesheetToken)) {
3759
+ // when running in synthetic shadow mode, we need to set the shadowToken value
3760
+ // into each element from the template, so they can be styled accordingly.
3761
+ setElementShadowToken(elm, stylesheetToken);
3762
+ }
3643
3763
  }
3644
3764
  }
3645
3765
 
@@ -3694,7 +3814,9 @@ var LWC = (function (exports) {
3694
3814
  var stylesheetToken = owner.context.stylesheetToken; // when running in synthetic shadow mode, we need to set the shadowToken value
3695
3815
  // into each element from the template, so they can be styled accordingly.
3696
3816
 
3697
- setElementShadowToken(elm, stylesheetToken);
3817
+ if (!isUndefined$1(stylesheetToken)) {
3818
+ setElementShadowToken(elm, stylesheetToken);
3819
+ }
3698
3820
  }
3699
3821
 
3700
3822
  vm = createVM(elm, ctor, {
@@ -3706,44 +3828,14 @@ var LWC = (function (exports) {
3706
3828
  return vm;
3707
3829
  }
3708
3830
 
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
3831
  function allocateInSlot(vm, children) {
3740
3832
  var _a;
3741
3833
 
3742
3834
  var oldSlots = vm.cmpSlots;
3743
3835
  var cmpSlots = vm.cmpSlots = create(null);
3744
3836
 
3745
- for (var _i12 = 0, _len6 = children.length; _i12 < _len6; _i12 += 1) {
3746
- var vnode = children[_i12];
3837
+ for (var _i13 = 0, _len5 = children.length; _i13 < _len5; _i13 += 1) {
3838
+ var vnode = children[_i13];
3747
3839
 
3748
3840
  if (isNull(vnode)) {
3749
3841
  continue;
@@ -3777,8 +3869,8 @@ var LWC = (function (exports) {
3777
3869
  return;
3778
3870
  }
3779
3871
 
3780
- for (var _i13 = 0, _len7 = oldKeys.length; _i13 < _len7; _i13 += 1) {
3781
- var key = oldKeys[_i13];
3872
+ for (var _i14 = 0, _len6 = oldKeys.length; _i14 < _len6; _i14 += 1) {
3873
+ var key = oldKeys[_i14];
3782
3874
 
3783
3875
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
3784
3876
  markComponentAsDirty(vm);
@@ -3828,28 +3920,7 @@ var LWC = (function (exports) {
3828
3920
  return map;
3829
3921
  }
3830
3922
 
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) {
3923
+ function updateDynamicChildren(oldCh, newCh, parent) {
3853
3924
  var oldStartIdx = 0;
3854
3925
  var newStartIdx = 0;
3855
3926
  var oldEndIdx = oldCh.length - 1;
@@ -3863,6 +3934,7 @@ var LWC = (function (exports) {
3863
3934
  var idxInOld;
3864
3935
  var elmToMove;
3865
3936
  var before;
3937
+ var clonedOldCh = false;
3866
3938
 
3867
3939
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3868
3940
  if (!isVNode(oldStartVnode)) {
@@ -3874,23 +3946,23 @@ var LWC = (function (exports) {
3874
3946
  } else if (!isVNode(newEndVnode)) {
3875
3947
  newEndVnode = newCh[--newEndIdx];
3876
3948
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
3877
- patchVnode(oldStartVnode, newStartVnode);
3949
+ patch(oldStartVnode, newStartVnode);
3878
3950
  oldStartVnode = oldCh[++oldStartIdx];
3879
3951
  newStartVnode = newCh[++newStartIdx];
3880
3952
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
3881
- patchVnode(oldEndVnode, newEndVnode);
3953
+ patch(oldEndVnode, newEndVnode);
3882
3954
  oldEndVnode = oldCh[--oldEndIdx];
3883
3955
  newEndVnode = newCh[--newEndIdx];
3884
3956
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
3885
3957
  // Vnode moved right
3886
- patchVnode(oldStartVnode, newEndVnode);
3887
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
3958
+ patch(oldStartVnode, newEndVnode);
3959
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
3888
3960
  oldStartVnode = oldCh[++oldStartIdx];
3889
3961
  newEndVnode = newCh[--newEndIdx];
3890
3962
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
3891
3963
  // Vnode moved left
3892
- patchVnode(oldEndVnode, newStartVnode);
3893
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
3964
+ patch(oldEndVnode, newStartVnode);
3965
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
3894
3966
  oldEndVnode = oldCh[--oldEndIdx];
3895
3967
  newStartVnode = newCh[++newStartIdx];
3896
3968
  } else {
@@ -3902,8 +3974,7 @@ var LWC = (function (exports) {
3902
3974
 
3903
3975
  if (isUndefined$1(idxInOld)) {
3904
3976
  // New element
3905
- newStartVnode.hook.create(newStartVnode);
3906
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3977
+ mount(newStartVnode, parent, oldStartVnode.elm);
3907
3978
  newStartVnode = newCh[++newStartIdx];
3908
3979
  } else {
3909
3980
  elmToMove = oldCh[idxInOld];
@@ -3911,12 +3982,22 @@ var LWC = (function (exports) {
3911
3982
  if (isVNode(elmToMove)) {
3912
3983
  if (elmToMove.sel !== newStartVnode.sel) {
3913
3984
  // New element
3914
- newStartVnode.hook.create(newStartVnode);
3915
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3985
+ mount(newStartVnode, parent, oldStartVnode.elm);
3916
3986
  } else {
3917
- patchVnode(elmToMove, newStartVnode);
3987
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
3988
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3989
+ // so we only care about the `oldCh` object inside this function.
3990
+ // To avoid cloning over and over again, we check `clonedOldCh`
3991
+ // and only clone once.
3992
+
3993
+ if (!clonedOldCh) {
3994
+ clonedOldCh = true;
3995
+ oldCh = _toConsumableArray(oldCh);
3996
+ } // We've already cloned at least once, so it's no longer read-only
3997
+
3998
+
3918
3999
  oldCh[idxInOld] = undefined;
3919
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
4000
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
3920
4001
  }
3921
4002
  }
3922
4003
 
@@ -3929,73 +4010,63 @@ var LWC = (function (exports) {
3929
4010
  if (oldStartIdx > oldEndIdx) {
3930
4011
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
3931
4012
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
3932
- var _i14 = newEndIdx;
4013
+ var _i15 = newEndIdx;
3933
4014
  var n;
3934
4015
 
3935
4016
  do {
3936
- n = newCh[++_i14];
3937
- } while (!isVNode(n) && _i14 < newChEnd);
4017
+ n = newCh[++_i15];
4018
+ } while (!isVNode(n) && _i15 < newChEnd);
3938
4019
 
3939
4020
  before = isVNode(n) ? n.elm : null;
3940
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
4021
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
3941
4022
  } else {
3942
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
4023
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
3943
4024
  }
3944
4025
  }
3945
4026
  }
3946
4027
 
3947
- function updateStaticChildren(parentElm, oldCh, newCh) {
3948
- var oldChLength = oldCh.length;
3949
- var newChLength = newCh.length;
4028
+ function updateStaticChildren(c1, c2, parent) {
4029
+ var c1Length = c1.length;
4030
+ var c2Length = c2.length;
3950
4031
 
3951
- if (oldChLength === 0) {
4032
+ if (c1Length === 0) {
3952
4033
  // the old list is empty, we can directly insert anything new
3953
- addVnodes(parentElm, null, newCh, 0, newChLength);
4034
+ mountVNodes(c2, parent, null);
3954
4035
  return;
3955
4036
  }
3956
4037
 
3957
- if (newChLength === 0) {
4038
+ if (c2Length === 0) {
3958
4039
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3959
4040
  // this is the case in which the dynamic children of an if-directive should be removed
3960
- removeVnodes(parentElm, oldCh, 0, oldChLength);
4041
+ unmountVNodes(c1, parent, true);
3961
4042
  return;
3962
4043
  } // if the old list is not empty, the new list MUST have the same
3963
4044
  // amount of nodes, that's why we call this static children
3964
4045
 
3965
4046
 
3966
- var referenceElm = null;
4047
+ var anchor = null;
3967
4048
 
3968
- for (var _i15 = newChLength - 1; _i15 >= 0; _i15 -= 1) {
3969
- var vnode = newCh[_i15];
3970
- var oldVNode = oldCh[_i15];
4049
+ for (var _i16 = c2Length - 1; _i16 >= 0; _i16 -= 1) {
4050
+ var n1 = c1[_i16];
4051
+ var n2 = c2[_i16];
3971
4052
 
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;
4053
+ if (n2 !== n1) {
4054
+ if (isVNode(n1)) {
4055
+ if (isVNode(n2)) {
4056
+ // both vnodes are equivalent, and we just need to patch them
4057
+ patch(n1, n2);
4058
+ anchor = n2.elm;
3978
4059
  } else {
3979
4060
  // removing the old vnode since the new one is null
3980
- oldVNode.hook.remove(oldVNode, parentElm);
4061
+ unmount(n1, parent, true);
3981
4062
  }
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;
4063
+ } else if (isVNode(n2)) {
4064
+ mount(n2, parent, anchor);
4065
+ anchor = n2.elm;
3988
4066
  }
3989
4067
  }
3990
4068
  }
3991
4069
  }
3992
-
3993
- function patchVnode(oldVnode, vnode) {
3994
- if (oldVnode !== vnode) {
3995
- vnode.elm = oldVnode.elm;
3996
- vnode.hook.update(oldVnode, vnode);
3997
- }
3998
- }
3999
4070
  /*
4000
4071
  * Copyright (c) 2018, salesforce.com, inc.
4001
4072
  * All rights reserved.
@@ -4011,7 +4082,8 @@ var LWC = (function (exports) {
4011
4082
  } // [h]tml node
4012
4083
 
4013
4084
 
4014
- function h(sel, data, children) {
4085
+ function h(sel, data) {
4086
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EmptyArray;
4015
4087
  var vmBeingRendered = getVMBeingRendered();
4016
4088
 
4017
4089
  var elm;
@@ -4025,7 +4097,6 @@ var LWC = (function (exports) {
4025
4097
  children: children,
4026
4098
  elm: elm,
4027
4099
  key: key,
4028
- hook: ElementHook,
4029
4100
  owner: vmBeingRendered
4030
4101
  };
4031
4102
  } // [t]ab[i]ndex function
@@ -4074,7 +4145,7 @@ var LWC = (function (exports) {
4074
4145
  var vmBeingRendered = getVMBeingRendered();
4075
4146
 
4076
4147
  var key = data.key;
4077
- var elm;
4148
+ var elm, aChildren, vm;
4078
4149
  var vnode = {
4079
4150
  type: 3
4080
4151
  /* CustomElement */
@@ -4084,11 +4155,11 @@ var LWC = (function (exports) {
4084
4155
  children: children,
4085
4156
  elm: elm,
4086
4157
  key: key,
4087
- hook: CustomElementHook,
4088
4158
  ctor: Ctor,
4089
4159
  owner: vmBeingRendered,
4090
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
4091
-
4160
+ mode: 'open',
4161
+ aChildren: aChildren,
4162
+ vm: vm
4092
4163
  };
4093
4164
  addVNodeToChildLWC(vnode);
4094
4165
  return vnode;
@@ -4169,7 +4240,6 @@ var LWC = (function (exports) {
4169
4240
  text: text,
4170
4241
  elm: elm,
4171
4242
  key: key,
4172
- hook: TextHook,
4173
4243
  owner: getVMBeingRendered()
4174
4244
  };
4175
4245
  } // [co]mment node
@@ -4185,7 +4255,6 @@ var LWC = (function (exports) {
4185
4255
  text: text,
4186
4256
  elm: elm,
4187
4257
  key: key,
4188
- hook: CommentHook,
4189
4258
  owner: getVMBeingRendered()
4190
4259
  };
4191
4260
  } // [d]ynamic text
@@ -4285,7 +4354,8 @@ var LWC = (function (exports) {
4285
4354
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4286
4355
  */
4287
4356
 
4288
- function dc(sel, Ctor, data, children) {
4357
+ function dc(sel, Ctor, data) {
4358
+ var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : EmptyArray;
4289
4359
 
4290
4360
 
4291
4361
  if (Ctor == null) {
@@ -4304,10 +4374,14 @@ var LWC = (function (exports) {
4304
4374
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4305
4375
  // to identify different constructors as vnodes with different keys to avoid reusing the
4306
4376
  // element used for previous constructors.
4377
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4378
+ // hoisting optimization.
4307
4379
 
4308
4380
 
4309
- data.key = "dc:".concat(idx, ":").concat(data.key);
4310
- return c(sel, Ctor, data, children);
4381
+ var newData = Object.assign(Object.assign({}, data), {
4382
+ key: "dc:".concat(idx, ":").concat(data.key)
4383
+ });
4384
+ return c(sel, Ctor, newData, children);
4311
4385
  }
4312
4386
  /**
4313
4387
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -4416,12 +4490,14 @@ var LWC = (function (exports) {
4416
4490
  oldHasTokenInClass = context.hasTokenInClass,
4417
4491
  oldHasTokenInAttribute = context.hasTokenInAttribute;
4418
4492
 
4419
- if (oldHasTokenInClass) {
4420
- getClassList$1(elm).remove(makeHostToken(oldToken));
4421
- }
4493
+ if (!isUndefined$1(oldToken)) {
4494
+ if (oldHasTokenInClass) {
4495
+ getClassList$1(elm).remove(makeHostToken(oldToken));
4496
+ }
4422
4497
 
4423
- if (oldHasTokenInAttribute) {
4424
- removeAttribute$1(elm, makeHostToken(oldToken));
4498
+ if (oldHasTokenInAttribute) {
4499
+ removeAttribute$1(elm, makeHostToken(oldToken));
4500
+ }
4425
4501
  } // Apply the new template styling token to the host element, if the new template has any
4426
4502
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
4427
4503
 
@@ -4453,8 +4529,8 @@ var LWC = (function (exports) {
4453
4529
  var content = [];
4454
4530
  var root;
4455
4531
 
4456
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4457
- var stylesheet = stylesheets[_i16];
4532
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4533
+ var stylesheet = stylesheets[_i17];
4458
4534
 
4459
4535
  if (isArray$1(stylesheet)) {
4460
4536
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4558,8 +4634,8 @@ var LWC = (function (exports) {
4558
4634
  && shadowMode === 1
4559
4635
  /* Synthetic */
4560
4636
  ) {
4561
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4562
- insertGlobalStylesheet$1(stylesheets[_i17]);
4637
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4638
+ insertGlobalStylesheet$1(stylesheets[_i18]);
4563
4639
  }
4564
4640
  } else if (ssr$1 || isHydrating$1()) {
4565
4641
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -4573,12 +4649,12 @@ var LWC = (function (exports) {
4573
4649
  var root = getNearestNativeShadowComponent(vm);
4574
4650
  var isGlobal = isNull(root);
4575
4651
 
4576
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4652
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4577
4653
  if (isGlobal) {
4578
- insertGlobalStylesheet$1(stylesheets[_i18]);
4654
+ insertGlobalStylesheet$1(stylesheets[_i19]);
4579
4655
  } else {
4580
4656
  // local level
4581
- insertStylesheet$1(stylesheets[_i18], root.shadowRoot);
4657
+ insertStylesheet$1(stylesheets[_i19], root.shadowRoot);
4582
4658
  }
4583
4659
  }
4584
4660
  }
@@ -4763,8 +4839,8 @@ var LWC = (function (exports) {
4763
4839
  var stylesheets = template.stylesheets;
4764
4840
 
4765
4841
  if (!isUndefined$1(stylesheets)) {
4766
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4767
- if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4842
+ for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
4843
+ if (isTrue(stylesheets[_i20][KEY__SCOPED_CSS])) {
4768
4844
  return true;
4769
4845
  }
4770
4846
  }
@@ -4875,6 +4951,7 @@ var LWC = (function (exports) {
4875
4951
 
4876
4952
  function registerComponent(Ctor, _ref2) {
4877
4953
  var tmpl = _ref2.tmpl;
4954
+
4878
4955
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
4879
4956
  // without too much transformation
4880
4957
 
@@ -4947,8 +5024,8 @@ var LWC = (function (exports) {
4947
5024
 
4948
5025
  function register(service) {
4949
5026
 
4950
- for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4951
- var hookName = hooks[_i20];
5027
+ for (var _i21 = 0; _i21 < hooks.length; ++_i21) {
5028
+ var hookName = hooks[_i21];
4952
5029
 
4953
5030
  if (hookName in service) {
4954
5031
  var l = Services[hookName];
@@ -4968,8 +5045,8 @@ var LWC = (function (exports) {
4968
5045
  def = vm.def,
4969
5046
  context = vm.context;
4970
5047
 
4971
- for (var _i21 = 0, _len8 = cbs.length; _i21 < _len8; ++_i21) {
4972
- cbs[_i21].call(undefined, component, {}, def, context);
5048
+ for (var _i22 = 0, _len7 = cbs.length; _i22 < _len7; ++_i22) {
5049
+ cbs[_i22].call(undefined, component, {}, def, context);
4973
5050
  }
4974
5051
  }
4975
5052
  /*
@@ -4980,7 +5057,7 @@ var LWC = (function (exports) {
4980
5057
  */
4981
5058
 
4982
5059
 
4983
- function hydrate$1(vnode, node) {
5060
+ function hydrate(vnode, node) {
4984
5061
  switch (vnode.type) {
4985
5062
  case 0
4986
5063
  /* Text */
@@ -5012,7 +5089,7 @@ var LWC = (function (exports) {
5012
5089
  var _a;
5013
5090
 
5014
5091
 
5015
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5092
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5016
5093
  vnode.elm = node;
5017
5094
  }
5018
5095
 
@@ -5020,7 +5097,7 @@ var LWC = (function (exports) {
5020
5097
  var _a;
5021
5098
 
5022
5099
 
5023
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5100
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5024
5101
  vnode.elm = node;
5025
5102
  }
5026
5103
 
@@ -5039,10 +5116,13 @@ var LWC = (function (exports) {
5039
5116
  var props = vnode.data.props;
5040
5117
 
5041
5118
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5042
- if (elm.innerHTML === props.innerHTML) {
5043
- delete props.innerHTML;
5119
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
5120
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5121
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
5122
+ props: cloneAndOmitKey(props, 'innerHTML')
5123
+ });
5044
5124
  } else {
5045
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5125
+ 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
5126
  }
5047
5127
  }
5048
5128
  }
@@ -5050,14 +5130,13 @@ var LWC = (function (exports) {
5050
5130
  patchElementPropsAndAttrs(vnode);
5051
5131
 
5052
5132
  if (!isDomManual) {
5053
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
5133
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
5054
5134
  }
5055
5135
  }
5056
5136
 
5057
5137
  function hydrateCustomElement(vnode, node) {
5058
5138
 
5059
5139
  var elm = node;
5060
- vnode.elm = elm;
5061
5140
  var sel = vnode.sel,
5062
5141
  mode = vnode.mode,
5063
5142
  ctor = vnode.ctor,
@@ -5067,6 +5146,8 @@ var LWC = (function (exports) {
5067
5146
  owner: owner,
5068
5147
  tagName: sel
5069
5148
  });
5149
+ vnode.elm = elm;
5150
+ vnode.vm = vm;
5070
5151
  allocateChildren(vnode, vm);
5071
5152
  patchElementPropsAndAttrs(vnode); // Insert hook section:
5072
5153
 
@@ -5077,7 +5158,7 @@ var LWC = (function (exports) {
5077
5158
  ) {
5078
5159
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5079
5160
  // Note: for Light DOM, this is handled while hydrating the VM
5080
- hydrateChildren(vnode.elm.childNodes, vnode.children);
5161
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children);
5081
5162
  }
5082
5163
 
5083
5164
  hydrateVM(vm);
@@ -5087,12 +5168,12 @@ var LWC = (function (exports) {
5087
5168
 
5088
5169
  var childNodeIndex = 0;
5089
5170
 
5090
- for (var _i22 = 0; _i22 < children.length; _i22++) {
5091
- var childVnode = children[_i22];
5171
+ for (var _i23 = 0; _i23 < children.length; _i23++) {
5172
+ var childVnode = children[_i23];
5092
5173
 
5093
5174
  if (!isNull(childVnode)) {
5094
5175
  var childNode = elmChildren[childNodeIndex];
5095
- hydrate$1(childVnode, childNode);
5176
+ hydrate(childVnode, childNode);
5096
5177
  childNodeIndex++;
5097
5178
  }
5098
5179
  }
@@ -5168,7 +5249,19 @@ var LWC = (function (exports) {
5168
5249
  }
5169
5250
 
5170
5251
  function hydrateVM(vm) {
5171
- hydrate(vm);
5252
+ if (isTrue(vm.isDirty)) {
5253
+ // manually diffing/patching here.
5254
+ // This routine is:
5255
+ // patchShadowRoot(vm, children);
5256
+ // -> addVnodes.
5257
+ var children = renderComponent(vm);
5258
+ vm.children = children;
5259
+ var vmChildren = vm.renderMode === 0
5260
+ /* Light */
5261
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
5262
+ hydrateChildren(vmChildren, children);
5263
+ runRenderedCallback(vm);
5264
+ }
5172
5265
  } // just in case the component comes back, with this we guarantee re-rendering it
5173
5266
  // while preventing any attempt to rehydration until after reinsertion.
5174
5267
 
@@ -5288,30 +5381,38 @@ var LWC = (function (exports) {
5288
5381
  /* Native */
5289
5382
  ;
5290
5383
  } else if (isNativeShadowDefined$1) {
5291
- if (def.shadowSupportMode === "any"
5292
- /* Any */
5293
- ) {
5294
- shadowMode = 0
5295
- /* Native */
5296
- ;
5297
- } else {
5298
- var shadowAncestor = getNearestShadowAncestor(vm);
5299
-
5300
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5301
- /* Native */
5384
+ // Not combined with above condition because @lwc/features only supports identifiers in
5385
+ // the if-condition.
5386
+ if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5387
+ if (def.shadowSupportMode === "any"
5388
+ /* Any */
5302
5389
  ) {
5303
- // Transitive support for native Shadow DOM. A component in native mode
5304
- // transitively opts all of its descendants into native.
5305
5390
  shadowMode = 0
5306
5391
  /* Native */
5307
5392
  ;
5308
5393
  } else {
5309
- // Synthetic if neither this component nor any of its ancestors are configured
5310
- // to be native.
5311
- shadowMode = 1
5312
- /* Synthetic */
5313
- ;
5394
+ var shadowAncestor = getNearestShadowAncestor(vm);
5395
+
5396
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5397
+ /* Native */
5398
+ ) {
5399
+ // Transitive support for native Shadow DOM. A component in native mode
5400
+ // transitively opts all of its descendants into native.
5401
+ shadowMode = 0
5402
+ /* Native */
5403
+ ;
5404
+ } else {
5405
+ // Synthetic if neither this component nor any of its ancestors are configured
5406
+ // to be native.
5407
+ shadowMode = 1
5408
+ /* Synthetic */
5409
+ ;
5410
+ }
5314
5411
  }
5412
+ } else {
5413
+ shadowMode = 1
5414
+ /* Synthetic */
5415
+ ;
5315
5416
  }
5316
5417
  } else {
5317
5418
  // Synthetic if there is no native Shadow DOM support.
@@ -5352,22 +5453,6 @@ var LWC = (function (exports) {
5352
5453
  }
5353
5454
  }
5354
5455
 
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
5456
  function patchShadowRoot(vm, newCh) {
5372
5457
  var renderRoot = vm.renderRoot,
5373
5458
  oldCh = vm.children; // caching the new children collection
@@ -5385,7 +5470,7 @@ var LWC = (function (exports) {
5385
5470
  , vm);
5386
5471
  }, function () {
5387
5472
  // job
5388
- patchChildren(renderRoot, oldCh, newCh);
5473
+ patchChildren(oldCh, newCh, renderRoot);
5389
5474
  }, function () {
5390
5475
  // post
5391
5476
  logOperationEnd(2
@@ -5442,19 +5527,19 @@ var LWC = (function (exports) {
5442
5527
  });
5443
5528
  rehydrateQueue = []; // reset to a new queue
5444
5529
 
5445
- for (var _i25 = 0, _len9 = vms.length; _i25 < _len9; _i25 += 1) {
5446
- var vm = vms[_i25];
5530
+ for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
5531
+ var vm = vms[_i26];
5447
5532
 
5448
5533
  try {
5449
5534
  rehydrate(vm);
5450
5535
  } catch (error) {
5451
- if (_i25 + 1 < _len9) {
5536
+ if (_i26 + 1 < _len8) {
5452
5537
  // pieces of the queue are still pending to be rehydrated, those should have priority
5453
5538
  if (rehydrateQueue.length === 0) {
5454
5539
  addCallbackToNextTick(flushRehydrationQueue);
5455
5540
  }
5456
5541
 
5457
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i25 + 1));
5542
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i26 + 1));
5458
5543
  } // we need to end the measure before throwing.
5459
5544
 
5460
5545
 
@@ -5553,8 +5638,8 @@ var LWC = (function (exports) {
5553
5638
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5554
5639
  // inserted in reserved order.
5555
5640
 
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:
5641
+ for (var _i27 = vCustomElementCollection.length - 1; _i27 >= 0; _i27 -= 1) {
5642
+ var elm = vCustomElementCollection[_i27].elm; // There are two cases where the element could be undefined:
5558
5643
  // * when there is an error during the construction phase, and an error
5559
5644
  // boundary picks it, there is a possibility that the VCustomElement
5560
5645
  // is not properly initialized, and therefore is should be ignored.
@@ -5588,8 +5673,8 @@ var LWC = (function (exports) {
5588
5673
 
5589
5674
 
5590
5675
  function recursivelyDisconnectChildren(vnodes) {
5591
- for (var _i27 = 0, _len10 = vnodes.length; _i27 < _len10; _i27 += 1) {
5592
- var vnode = vnodes[_i27];
5676
+ for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
5677
+ var vnode = vnodes[_i28];
5593
5678
 
5594
5679
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
5595
5680
  switch (vnode.type) {
@@ -5620,8 +5705,8 @@ var LWC = (function (exports) {
5620
5705
  var children = vm.children,
5621
5706
  renderRoot = vm.renderRoot;
5622
5707
 
5623
- for (var _i28 = 0, _len11 = children.length; _i28 < _len11; _i28++) {
5624
- var child = children[_i28];
5708
+ for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
5709
+ var child = children[_i29];
5625
5710
 
5626
5711
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5627
5712
  remove$1(child.elm, renderRoot);
@@ -5971,8 +6056,8 @@ var LWC = (function (exports) {
5971
6056
  function connectWireAdapters(vm) {
5972
6057
  var wiredConnecting = vm.context.wiredConnecting;
5973
6058
 
5974
- for (var _i29 = 0, _len12 = wiredConnecting.length; _i29 < _len12; _i29 += 1) {
5975
- wiredConnecting[_i29]();
6059
+ for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
6060
+ wiredConnecting[_i30]();
5976
6061
  }
5977
6062
  }
5978
6063
 
@@ -5980,8 +6065,8 @@ var LWC = (function (exports) {
5980
6065
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5981
6066
  runWithBoundaryProtection(vm, vm, noop, function () {
5982
6067
  // job
5983
- for (var _i30 = 0, _len13 = wiredDisconnecting.length; _i30 < _len13; _i30 += 1) {
5984
- wiredDisconnecting[_i30]();
6068
+ for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
6069
+ wiredDisconnecting[_i31]();
5985
6070
  }
5986
6071
  }, noop);
5987
6072
  }
@@ -5991,6 +6076,7 @@ var LWC = (function (exports) {
5991
6076
  * SPDX-License-Identifier: MIT
5992
6077
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5993
6078
  */
6079
+ // this is lwc internal implementation
5994
6080
 
5995
6081
 
5996
6082
  function createContextProvider(adapter) {
@@ -6065,7 +6151,7 @@ var LWC = (function (exports) {
6065
6151
  hooksAreSet = true;
6066
6152
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6067
6153
  }
6068
- /* version: 2.8.0 */
6154
+ /* version: 2.11.0 */
6069
6155
 
6070
6156
  /*
6071
6157
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6082,9 +6168,10 @@ var LWC = (function (exports) {
6082
6168
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6083
6169
 
6084
6170
  var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6171
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6085
6172
  var styleElements = create(null);
6086
6173
  var styleSheets = create(null);
6087
- var nodesToStyleSheets = new WeakMap();
6174
+ var shadowRootsToStyleSheets = new WeakMap();
6088
6175
  var getCustomElement;
6089
6176
  var defineCustomElement;
6090
6177
  var HTMLElementConstructor;
@@ -6136,18 +6223,26 @@ var LWC = (function (exports) {
6136
6223
  styleSheets[content] = styleSheet;
6137
6224
  }
6138
6225
 
6139
- if (!target.adoptedStyleSheets.includes(styleSheet)) {
6140
- target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
6226
+ var adoptedStyleSheets = target.adoptedStyleSheets;
6227
+
6228
+ if (!adoptedStyleSheets.includes(styleSheet)) {
6229
+ if (supportsMutableAdoptedStyleSheets) {
6230
+ // This is only supported in later versions of Chromium:
6231
+ // https://chromestatus.com/feature/5638996492288000
6232
+ adoptedStyleSheets.push(styleSheet);
6233
+ } else {
6234
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(adoptedStyleSheets), [styleSheet]);
6235
+ }
6141
6236
  }
6142
6237
  }
6143
6238
 
6144
6239
  function insertStyleElement(content, target) {
6145
6240
  // Avoid inserting duplicate `<style>`s
6146
- var sheets = nodesToStyleSheets.get(target);
6241
+ var sheets = shadowRootsToStyleSheets.get(target);
6147
6242
 
6148
6243
  if (isUndefined$1(sheets)) {
6149
6244
  sheets = create(null);
6150
- nodesToStyleSheets.set(target, sheets);
6245
+ shadowRootsToStyleSheets.set(target, sheets);
6151
6246
  }
6152
6247
 
6153
6248
  if (sheets[content]) {
@@ -6419,6 +6514,173 @@ var LWC = (function (exports) {
6419
6514
  setSetText(setText);
6420
6515
  setSsr(ssr);
6421
6516
  setAddEventListener(addEventListener);
6517
+ /*
6518
+ * Copyright (c) 2018, salesforce.com, inc.
6519
+ * All rights reserved.
6520
+ * SPDX-License-Identifier: MIT
6521
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6522
+ */
6523
+
6524
+ function resetShadowRootAndLightDom(element, Ctor) {
6525
+ if (element.shadowRoot) {
6526
+ var shadowRoot = element.shadowRoot;
6527
+
6528
+ while (!isNull(shadowRoot.firstChild)) {
6529
+ shadowRoot.removeChild(shadowRoot.firstChild);
6530
+ }
6531
+ }
6532
+
6533
+ if (Ctor.renderMode === 'light') {
6534
+ while (!isNull(element.firstChild)) {
6535
+ element.removeChild(element.firstChild);
6536
+ }
6537
+ }
6538
+ }
6539
+
6540
+ function createVMWithProps(element, Ctor, props) {
6541
+ createVM(element, Ctor, {
6542
+ mode: 'open',
6543
+ owner: null,
6544
+ tagName: element.tagName.toLowerCase()
6545
+ });
6546
+
6547
+ for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
6548
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
6549
+ key = _Object$entries2$_i[0],
6550
+ value = _Object$entries2$_i[1];
6551
+
6552
+ element[key] = value;
6553
+ }
6554
+ }
6555
+
6556
+ function hydrateComponent(element, Ctor) {
6557
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6558
+
6559
+ if (!(element instanceof Element)) {
6560
+ throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
6561
+ }
6562
+
6563
+ if (!isFunction$1(Ctor)) {
6564
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6565
+ }
6566
+
6567
+ if (!isObject(props) || isNull(props)) {
6568
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6569
+ }
6570
+
6571
+ if (getAssociatedVMIfPresent(element)) {
6572
+ /* eslint-disable-next-line no-console */
6573
+ console.warn("\"hydrateComponent\" expects an element that is not hydrated.", element);
6574
+ return;
6575
+ }
6576
+
6577
+ try {
6578
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6579
+ // and uses the same algo to create the stylesheets as in SSR.
6580
+ setIsHydrating(true);
6581
+ createVMWithProps(element, Ctor, props);
6582
+ hydrateRootElement(element); // set it back since now we finished hydration.
6583
+
6584
+ setIsHydrating(false);
6585
+ } catch (e) {
6586
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
6587
+ // with the client generated DOM.
6588
+
6589
+ /* eslint-disable-next-line no-console */
6590
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
6591
+
6592
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
6593
+
6594
+ createVMWithProps(element, Ctor, props);
6595
+ setIsHydrating(false);
6596
+ connectRootElement(element);
6597
+ } finally {
6598
+ // in case there's an error during recovery
6599
+ setIsHydrating(false);
6600
+ }
6601
+ }
6602
+ /*
6603
+ * Copyright (c) 2018, salesforce.com, inc.
6604
+ * All rights reserved.
6605
+ * SPDX-License-Identifier: MIT
6606
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6607
+ */
6608
+
6609
+ /**
6610
+ * This function builds a Web Component class from a LWC constructor so it can be
6611
+ * registered as a new element via customElements.define() at any given time.
6612
+ *
6613
+ * @deprecated since version 1.3.11
6614
+ *
6615
+ * @example
6616
+ * ```
6617
+ * import { buildCustomElementConstructor } from 'lwc';
6618
+ * import Foo from 'ns/foo';
6619
+ * const WC = buildCustomElementConstructor(Foo);
6620
+ * customElements.define('x-foo', WC);
6621
+ * const elm = document.createElement('x-foo');
6622
+ * ```
6623
+ */
6624
+
6625
+
6626
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6627
+
6628
+ return Ctor.CustomElementConstructor;
6629
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
6630
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
6631
+
6632
+
6633
+ var hydratedCustomElements = new WeakSet();
6634
+
6635
+ function buildCustomElementConstructor(Ctor) {
6636
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
6637
+ return /*#__PURE__*/function (_HtmlPrototype) {
6638
+ _inherits(_class, _HtmlPrototype);
6639
+
6640
+ var _super8 = _createSuper(_class);
6641
+
6642
+ function _class() {
6643
+ var _this6;
6644
+
6645
+ _classCallCheck(this, _class);
6646
+
6647
+ _this6 = _super8.call(this);
6648
+
6649
+ if (_this6.isConnected) {
6650
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
6651
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
6652
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
6653
+ } else {
6654
+ createVM(_assertThisInitialized(_this6), Ctor, {
6655
+ mode: 'open',
6656
+ owner: null,
6657
+ tagName: _this6.tagName
6658
+ });
6659
+ }
6660
+
6661
+ return _this6;
6662
+ }
6663
+
6664
+ _createClass(_class, [{
6665
+ key: "connectedCallback",
6666
+ value: function connectedCallback() {
6667
+ if (hydratedCustomElements.has(this)) {
6668
+ // This is an un-upgraded element that was hydrated in the constructor.
6669
+ hydratedCustomElements.delete(this);
6670
+ } else {
6671
+ connectRootElement(this);
6672
+ }
6673
+ }
6674
+ }, {
6675
+ key: "disconnectedCallback",
6676
+ value: function disconnectedCallback() {
6677
+ disconnectRootElement(this);
6678
+ }
6679
+ }]);
6680
+
6681
+ return _class;
6682
+ }(HtmlPrototype);
6683
+ }
6422
6684
  /*
6423
6685
  * Copyright (c) 2018, salesforce.com, inc.
6424
6686
  * All rights reserved.
@@ -6428,6 +6690,7 @@ var LWC = (function (exports) {
6428
6690
  // TODO [#2472]: Remove this workaround when appropriate.
6429
6691
  // eslint-disable-next-line lwc-internal/no-global-node
6430
6692
 
6693
+
6431
6694
  var _Node$1 = Node;
6432
6695
  var ConnectingSlot = new WeakMap();
6433
6696
  var DisconnectingSlot = new WeakMap();
@@ -6532,138 +6795,6 @@ var LWC = (function (exports) {
6532
6795
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6533
6796
  */
6534
6797
 
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
6798
  /**
6668
6799
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6669
6800
  * This API is subject to change or being removed.
@@ -6695,30 +6826,31 @@ var LWC = (function (exports) {
6695
6826
 
6696
6827
  var _Node = Node;
6697
6828
  /**
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.
6829
+ * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
6830
+ * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
6700
6831
  */
6701
6832
 
6702
- function isNodeFromTemplate(node) {
6833
+ function isNodeShadowed(node) {
6703
6834
  if (isFalse(node instanceof _Node)) {
6704
6835
  return false;
6705
- } // TODO [#1250]: skipping the shadowRoot instances itself makes no sense, we need to revisit
6706
- // this with locker
6836
+ } // It's debatable whether shadow root instances should be considered as shadowed, but we keep
6837
+ // this unchanged for legacy reasons (#1250).
6707
6838
 
6708
6839
 
6709
6840
  if (node instanceof ShadowRoot) {
6710
6841
  return false;
6711
6842
  }
6712
6843
 
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
- }
6844
+ var rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
6845
+ // synthetic roots cannot be descendants of native roots.
6846
+
6847
+ if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
6848
+ return true;
6849
+ } // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
6850
+ // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
6851
+
6719
6852
 
6720
- var root = node.getRootNode();
6721
- return root instanceof ShadowRoot;
6853
+ return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6722
6854
  }
6723
6855
  /*
6724
6856
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6762,7 +6894,7 @@ var LWC = (function (exports) {
6762
6894
  });
6763
6895
  freeze(LightningElement);
6764
6896
  seal(LightningElement.prototype);
6765
- /* version: 2.8.0 */
6897
+ /* version: 2.11.0 */
6766
6898
 
6767
6899
  exports.LightningElement = LightningElement;
6768
6900
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6774,7 +6906,7 @@ var LWC = (function (exports) {
6774
6906
  exports.getComponentDef = getComponentDef;
6775
6907
  exports.hydrateComponent = hydrateComponent;
6776
6908
  exports.isComponentConstructor = isComponentConstructor;
6777
- exports.isNodeFromTemplate = isNodeFromTemplate;
6909
+ exports.isNodeFromTemplate = isNodeShadowed;
6778
6910
  exports.readonly = readonly;
6779
6911
  exports.register = register;
6780
6912
  exports.registerComponent = registerComponent;