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."); }
@@ -352,7 +352,17 @@ var LWC = (function (exports) {
352
352
  var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
353
353
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
354
354
  var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
355
- /** version: 2.7.4 */
355
+ /*
356
+ * Copyright (c) 2018, salesforce.com, inc.
357
+ * All rights reserved.
358
+ * SPDX-License-Identifier: MIT
359
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
360
+ */
361
+ // Increment whenever the LWC template compiler changes
362
+
363
+ var LWC_VERSION = "2.10.0";
364
+ var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
365
+ /** version: 2.10.0 */
356
366
 
357
367
  /*
358
368
  * Copyright (c) 2018, salesforce.com, inc.
@@ -417,7 +427,7 @@ var LWC = (function (exports) {
417
427
  };
418
428
  }
419
429
 
420
- function patch(propName) {
430
+ function patch$1(propName) {
421
431
  // Typescript is inferring the wrong function type for this particular
422
432
  // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
423
433
  // @ts-ignore type-mismatch
@@ -439,7 +449,7 @@ var LWC = (function (exports) {
439
449
  var propName = ElementPrototypeAriaPropertyNames[_i2];
440
450
 
441
451
  if (detect(propName)) {
442
- patch(propName);
452
+ patch$1(propName);
443
453
  }
444
454
  }
445
455
  /**
@@ -455,14 +465,15 @@ var LWC = (function (exports) {
455
465
 
456
466
 
457
467
  var features = {
458
- ENABLE_REACTIVE_SETTER: null,
459
- ENABLE_HMR: null,
460
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
468
+ DISABLE_MIXED_SHADOW_MODE: null,
461
469
  ENABLE_ELEMENT_PATCH: null,
462
470
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
463
- ENABLE_NODE_LIST_PATCH: null,
471
+ ENABLE_HMR: null,
464
472
  ENABLE_HTML_COLLECTIONS_PATCH: null,
473
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
474
+ ENABLE_NODE_LIST_PATCH: null,
465
475
  ENABLE_NODE_PATCH: null,
476
+ ENABLE_REACTIVE_SETTER: null,
466
477
  ENABLE_WIRE_SYNC_EMIT: null
467
478
  };
468
479
 
@@ -529,7 +540,7 @@ var LWC = (function (exports) {
529
540
  setFeatureFlag(name, value);
530
541
  }
531
542
  }
532
- /** version: 2.7.4 */
543
+ /** version: 2.10.0 */
533
544
 
534
545
  /* proxy-compat-disable */
535
546
 
@@ -617,6 +628,46 @@ var LWC = (function (exports) {
617
628
  }
618
629
 
619
630
  return styleMap;
631
+ } // Make a shallow copy of an object but omit the given key
632
+
633
+
634
+ function cloneAndOmitKey(object, keyToOmit) {
635
+ var result = {};
636
+
637
+ for (var _i4 = 0, _Object$keys = Object.keys(object); _i4 < _Object$keys.length; _i4++) {
638
+ var key = _Object$keys[_i4];
639
+
640
+ if (key !== keyToOmit) {
641
+ result[key] = object[key];
642
+ }
643
+ }
644
+
645
+ return result;
646
+ }
647
+
648
+ function flattenStylesheets(stylesheets) {
649
+ var list = [];
650
+
651
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
652
+ _step2;
653
+
654
+ try {
655
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
656
+ var stylesheet = _step2.value;
657
+
658
+ if (!Array.isArray(stylesheet)) {
659
+ list.push(stylesheet);
660
+ } else {
661
+ list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
662
+ }
663
+ }
664
+ } catch (err) {
665
+ _iterator2.e(err);
666
+ } finally {
667
+ _iterator2.f();
668
+ }
669
+
670
+ return list;
620
671
  } //
621
672
  // Primitives
622
673
  //
@@ -892,8 +943,8 @@ var LWC = (function (exports) {
892
943
  var reactiveObservers = reactiveRecord[key];
893
944
 
894
945
  if (!isUndefined$1(reactiveObservers)) {
895
- for (var _i4 = 0, _len2 = reactiveObservers.length; _i4 < _len2; _i4 += 1) {
896
- var ro = reactiveObservers[_i4];
946
+ for (var _i5 = 0, _len2 = reactiveObservers.length; _i5 < _len2; _i5 += 1) {
947
+ var ro = reactiveObservers[_i5];
897
948
  ro.notify();
898
949
  }
899
950
  }
@@ -962,9 +1013,9 @@ var LWC = (function (exports) {
962
1013
  var len = listeners.length;
963
1014
 
964
1015
  if (len > 0) {
965
- for (var _i5 = 0; _i5 < len; _i5 += 1) {
966
- var set = listeners[_i5];
967
- var pos = ArrayIndexOf.call(listeners[_i5], this);
1016
+ for (var _i6 = 0; _i6 < len; _i6 += 1) {
1017
+ var set = listeners[_i6];
1018
+ var pos = ArrayIndexOf.call(listeners[_i6], this);
968
1019
  ArraySplice.call(set, pos, 1);
969
1020
  }
970
1021
 
@@ -2746,7 +2797,7 @@ var LWC = (function (exports) {
2746
2797
 
2747
2798
 
2748
2799
  var _loop = function _loop() {
2749
- var childGetter = _childGetters[_i6];
2800
+ var childGetter = _childGetters[_i7];
2750
2801
  queryAndChildGetterDescriptors[childGetter] = {
2751
2802
  get: function get() {
2752
2803
  var vm = getAssociatedVM(this);
@@ -2763,7 +2814,7 @@ var LWC = (function (exports) {
2763
2814
  };
2764
2815
  };
2765
2816
 
2766
- for (var _i6 = 0, _childGetters = childGetters; _i6 < _childGetters.length; _i6++) {
2817
+ for (var _i7 = 0, _childGetters = childGetters; _i7 < _childGetters.length; _i7++) {
2767
2818
  _loop();
2768
2819
  }
2769
2820
 
@@ -2787,7 +2838,7 @@ var LWC = (function (exports) {
2787
2838
 
2788
2839
 
2789
2840
  var _loop2 = function _loop2() {
2790
- var queryMethod = _queryMethods[_i7];
2841
+ var queryMethod = _queryMethods[_i8];
2791
2842
  queryAndChildGetterDescriptors[queryMethod] = {
2792
2843
  value: function value(arg) {
2793
2844
  var vm = getAssociatedVM(this);
@@ -2805,7 +2856,7 @@ var LWC = (function (exports) {
2805
2856
  };
2806
2857
  };
2807
2858
 
2808
- for (var _i7 = 0, _queryMethods = queryMethods; _i7 < _queryMethods.length; _i7++) {
2859
+ for (var _i8 = 0, _queryMethods = queryMethods; _i8 < _queryMethods.length; _i8++) {
2809
2860
  _loop2();
2810
2861
  }
2811
2862
 
@@ -3328,8 +3379,8 @@ var LWC = (function (exports) {
3328
3379
  }
3329
3380
 
3330
3381
  if (!isUndefined$1(fields)) {
3331
- for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
3332
- var _fieldName2 = fields[_i8];
3382
+ for (var _i9 = 0, n = fields.length; _i9 < n; _i9++) {
3383
+ var _fieldName2 = fields[_i9];
3333
3384
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
3334
3385
 
3335
3386
  if (process.env.NODE_ENV !== 'production') {
@@ -3377,6 +3428,55 @@ var LWC = (function (exports) {
3377
3428
  var meta = signedDecoratorToMetaMap.get(Ctor);
3378
3429
  return isUndefined$1(meta) ? defaultMeta : meta;
3379
3430
  }
3431
+ /*
3432
+ * Copyright (c) 2018, salesforce.com, inc.
3433
+ * All rights reserved.
3434
+ * SPDX-License-Identifier: MIT
3435
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3436
+ */
3437
+
3438
+
3439
+ var warned = false;
3440
+
3441
+ if (process.env.NODE_ENV === 'development') {
3442
+ // @ts-ignore
3443
+ window.__lwcResetWarnedOnVersionMismatch = function () {
3444
+ warned = false;
3445
+ };
3446
+ }
3447
+
3448
+ function checkVersionMismatch(func, type) {
3449
+ var versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
3450
+
3451
+ if (!isNull(versionMatcher) && !warned) {
3452
+ var version = versionMatcher[1];
3453
+
3454
+ var _version$split = version.split('.'),
3455
+ _version$split2 = _slicedToArray(_version$split, 2),
3456
+ major = _version$split2[0],
3457
+ minor = _version$split2[1];
3458
+
3459
+ var _LWC_VERSION$split = LWC_VERSION.split('.'),
3460
+ _LWC_VERSION$split2 = _slicedToArray(_LWC_VERSION$split, 2),
3461
+ expectedMajor = _LWC_VERSION$split2[0],
3462
+ expectedMinor = _LWC_VERSION$split2[1];
3463
+
3464
+ if (major !== expectedMajor || minor !== expectedMinor) {
3465
+ warned = true; // only warn once to avoid flooding the console
3466
+ // stylesheets and templates do not have user-meaningful names, but components do
3467
+
3468
+ var friendlyName = type === 'component' ? "".concat(type, " ").concat(func.name) : type;
3469
+ logError("LWC WARNING: current engine is v".concat(LWC_VERSION, ", but ").concat(friendlyName, " was compiled with v").concat(version, ".\nPlease update your compiled code or LWC engine so that the versions match.\nNo further warnings will appear."));
3470
+ }
3471
+ }
3472
+ }
3473
+ /*
3474
+ * Copyright (c) 2018, salesforce.com, inc.
3475
+ * All rights reserved.
3476
+ * SPDX-License-Identifier: MIT
3477
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3478
+ */
3479
+
3380
3480
 
3381
3481
  var signedTemplateSet = new Set();
3382
3482
 
@@ -3389,6 +3489,26 @@ var LWC = (function (exports) {
3389
3489
  function isTemplateRegistered(tpl) {
3390
3490
  return signedTemplateSet.has(tpl);
3391
3491
  }
3492
+
3493
+ function checkTemplateVersionMismatch(template) {
3494
+ checkVersionMismatch(template, 'template');
3495
+
3496
+ if (!isUndefined$1(template.stylesheets)) {
3497
+ var _iterator3 = _createForOfIteratorHelper(flattenStylesheets(template.stylesheets)),
3498
+ _step3;
3499
+
3500
+ try {
3501
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
3502
+ var stylesheet = _step3.value;
3503
+ checkVersionMismatch(stylesheet, 'stylesheet');
3504
+ }
3505
+ } catch (err) {
3506
+ _iterator3.e(err);
3507
+ } finally {
3508
+ _iterator3.f();
3509
+ }
3510
+ }
3511
+ }
3392
3512
  /**
3393
3513
  * INTERNAL: This function can only be invoked by compiled code. The compiler
3394
3514
  * will prevent this function from being imported by userland code.
@@ -3396,6 +3516,10 @@ var LWC = (function (exports) {
3396
3516
 
3397
3517
 
3398
3518
  function registerTemplate(tpl) {
3519
+ if (process.env.NODE_ENV !== 'production') {
3520
+ checkTemplateVersionMismatch(tpl);
3521
+ }
3522
+
3399
3523
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3400
3524
  // assignment of templates easily, without too much transformation
3401
3525
 
@@ -3550,8 +3674,8 @@ var LWC = (function (exports) {
3550
3674
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
3551
3675
  var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
3552
3676
 
3553
- for (var _i9 = 0, _len3 = props.length; _i9 < _len3; _i9 += 1) {
3554
- var _propName2 = props[_i9];
3677
+ for (var _i10 = 0, _len3 = props.length; _i10 < _len3; _i10 += 1) {
3678
+ var _propName2 = props[_i10];
3555
3679
  attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
3556
3680
  descriptors[_propName2] = {
3557
3681
  get: createGetter(_propName2),
@@ -3562,8 +3686,8 @@ var LWC = (function (exports) {
3562
3686
  } // expose public methods as props on the new Element Bridge
3563
3687
 
3564
3688
 
3565
- for (var _i10 = 0, _len4 = methods.length; _i10 < _len4; _i10 += 1) {
3566
- var methodName = methods[_i10];
3689
+ for (var _i11 = 0, _len4 = methods.length; _i11 < _len4; _i11 += 1) {
3690
+ var methodName = methods[_i11];
3567
3691
  descriptors[methodName] = {
3568
3692
  value: createMethodCaller(methodName),
3569
3693
  writable: true,
@@ -3691,31 +3815,6 @@ var LWC = (function (exports) {
3691
3815
  return canRefreshAllInstances;
3692
3816
  }
3693
3817
 
3694
- function flattenStylesheets(stylesheets) {
3695
- var list = [];
3696
-
3697
- var _iterator2 = _createForOfIteratorHelper(stylesheets),
3698
- _step2;
3699
-
3700
- try {
3701
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3702
- var stylesheet = _step2.value;
3703
-
3704
- if (!Array.isArray(stylesheet)) {
3705
- list.push(stylesheet);
3706
- } else {
3707
- list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
3708
- }
3709
- }
3710
- } catch (err) {
3711
- _iterator2.e(err);
3712
- } finally {
3713
- _iterator2.f();
3714
- }
3715
-
3716
- return list;
3717
- }
3718
-
3719
3818
  function getTemplateOrSwappedTemplate(tpl) {
3720
3819
  if (process.env.NODE_ENV === 'production') {
3721
3820
  // this method should never leak to prod
@@ -4507,8 +4606,8 @@ var LWC = (function (exports) {
4507
4606
  return;
4508
4607
  }
4509
4608
 
4510
- for (var _i11 = 0; _i11 < styleDecls.length; _i11++) {
4511
- var _styleDecls$_i = _slicedToArray(styleDecls[_i11], 3),
4609
+ for (var _i12 = 0; _i12 < styleDecls.length; _i12++) {
4610
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i12], 3),
4512
4611
  prop = _styleDecls$_i[0],
4513
4612
  value = _styleDecls$_i[1],
4514
4613
  important = _styleDecls$_i[2];
@@ -4524,221 +4623,335 @@ var LWC = (function (exports) {
4524
4623
  */
4525
4624
 
4526
4625
 
4527
- var TextHook = {
4528
- create: function create(vnode) {
4529
- var owner = vnode.owner;
4530
- var elm = createText$1(vnode.text);
4531
- linkNodeToShadow(elm, owner);
4532
- vnode.elm = elm;
4533
- },
4534
- update: updateNodeHook,
4535
- insert: insertNode,
4536
- move: insertNode,
4537
- remove: removeNode
4538
- };
4539
- var CommentHook = {
4540
- create: function create(vnode) {
4541
- var owner = vnode.owner,
4542
- text = vnode.text;
4543
- var elm = createComment$1(text);
4544
- linkNodeToShadow(elm, owner);
4545
- vnode.elm = elm;
4546
- },
4547
- update: updateNodeHook,
4548
- insert: insertNode,
4549
- move: insertNode,
4550
- remove: removeNode
4551
- }; // insert is called after update, which is used somewhere else (via a module)
4552
- // to mark the vm as inserted, that means we cannot use update as the main channel
4553
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
4554
- // which breaks some invariants. For that reason, we have the following for any
4555
- // Custom Element that is inserted via a template.
4556
-
4557
- var ElementHook = {
4558
- create: function create(vnode) {
4559
- var sel = vnode.sel,
4560
- owner = vnode.owner,
4561
- svg = vnode.data.svg;
4562
- var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4563
- var elm = createElement$2(sel, namespace);
4564
- linkNodeToShadow(elm, owner);
4565
- fallbackElmHook(elm, vnode);
4566
- vnode.elm = elm;
4567
- patchElementPropsAndAttrs$1(null, vnode);
4568
- },
4569
- update: function update(oldVnode, vnode) {
4570
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4571
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4572
- },
4573
- insert: function insert(vnode, parentNode, referenceNode) {
4574
- insertNode(vnode, parentNode, referenceNode);
4575
- createChildrenHook(vnode);
4576
- },
4577
- move: insertNode,
4578
- remove: function remove(vnode, parentNode) {
4579
- removeNode(vnode, parentNode);
4580
- removeChildren(vnode);
4626
+ function patchChildren(c1, c2, parent) {
4627
+ if (hasDynamicChildren(c2)) {
4628
+ updateDynamicChildren(c1, c2, parent);
4629
+ } else {
4630
+ updateStaticChildren(c1, c2, parent);
4581
4631
  }
4582
- };
4583
- var CustomElementHook = {
4584
- create: function create(vnode) {
4585
- var sel = vnode.sel,
4586
- owner = vnode.owner;
4587
- var UpgradableConstructor = getUpgradableConstructor(sel);
4588
- /**
4589
- * Note: if the upgradable constructor does not expect, or throw when we new it
4590
- * with a callback as the first argument, we could implement a more advanced
4591
- * mechanism that only passes that argument if the constructor is known to be
4592
- * an upgradable custom element.
4593
- */
4632
+ }
4594
4633
 
4595
- var vm;
4596
- var elm = new UpgradableConstructor(function (elm) {
4597
- // the custom element from the registry is expecting an upgrade callback
4598
- vm = createViewModelHook(elm, vnode);
4599
- });
4600
- linkNodeToShadow(elm, owner);
4601
- vnode.elm = elm;
4634
+ function patch(n1, n2) {
4635
+ if (n1 === n2) {
4636
+ return;
4637
+ }
4602
4638
 
4603
- if (vm) {
4604
- allocateChildren(vnode, vm);
4605
- } else if (vnode.ctor !== UpgradableConstructor) {
4606
- throw new TypeError("Incorrect Component Constructor");
4639
+ if (process.env.NODE_ENV !== 'production') {
4640
+ if (!isSameVnode(n1, n2)) {
4641
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
4642
+ sel: n1.sel,
4643
+ key: n1.key
4644
+ }) + ', ' + JSON.stringify({
4645
+ sel: n2.sel,
4646
+ key: n2.key
4647
+ }));
4607
4648
  }
4649
+ }
4608
4650
 
4609
- patchElementPropsAndAttrs$1(null, vnode);
4610
- },
4611
- update: function update(oldVnode, vnode) {
4612
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4613
- var vm = getAssociatedVMIfPresent(vnode.elm);
4651
+ switch (n2.type) {
4652
+ case 0
4653
+ /* Text */
4654
+ :
4655
+ patchText(n1, n2);
4656
+ break;
4614
4657
 
4615
- if (vm) {
4616
- // in fallback mode, the allocation will always set children to
4617
- // empty and delegate the real allocation to the slot elements
4618
- allocateChildren(vnode, vm);
4619
- } // in fallback mode, the children will be always empty, so, nothing
4620
- // will happen, but in native, it does allocate the light dom
4658
+ case 1
4659
+ /* Comment */
4660
+ :
4661
+ patchComment(n1, n2);
4662
+ break;
4621
4663
 
4664
+ case 2
4665
+ /* Element */
4666
+ :
4667
+ patchElement(n1, n2);
4668
+ break;
4622
4669
 
4623
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4670
+ case 3
4671
+ /* CustomElement */
4672
+ :
4673
+ patchCustomElement(n1, n2);
4674
+ break;
4675
+ }
4676
+ }
4624
4677
 
4625
- if (vm) {
4626
- if (process.env.NODE_ENV !== 'production') {
4627
- assert.isTrue(isArray$1(vnode.children), "Invalid vnode for a custom element, it must have children defined.");
4628
- } // this will probably update the shadowRoot, but only if the vm is in a dirty state
4629
- // this is important to preserve the top to bottom synchronous rendering phase.
4678
+ function mount(node, parent, anchor) {
4679
+ switch (node.type) {
4680
+ case 0
4681
+ /* Text */
4682
+ :
4683
+ mountText(node, parent, anchor);
4684
+ break;
4630
4685
 
4686
+ case 1
4687
+ /* Comment */
4688
+ :
4689
+ mountComment(node, parent, anchor);
4690
+ break;
4631
4691
 
4632
- rerenderVM(vm);
4633
- }
4634
- },
4635
- insert: function insert(vnode, parentNode, referenceNode) {
4636
- insertNode(vnode, parentNode, referenceNode);
4637
- var vm = getAssociatedVMIfPresent(vnode.elm);
4692
+ case 2
4693
+ /* Element */
4694
+ :
4695
+ mountElement(node, parent, anchor);
4696
+ break;
4638
4697
 
4639
- if (vm) {
4640
- if (process.env.NODE_ENV !== 'production') {
4641
- assert.isTrue(vm.state === 0
4642
- /* created */
4643
- , "".concat(vm, " cannot be recycled."));
4644
- }
4698
+ case 3
4699
+ /* CustomElement */
4700
+ :
4701
+ mountCustomElement(node, parent, anchor);
4702
+ break;
4703
+ }
4704
+ }
4645
4705
 
4646
- runConnectedCallback(vm);
4647
- }
4706
+ function patchText(n1, n2) {
4707
+ n2.elm = n1.elm;
4648
4708
 
4649
- createChildrenHook(vnode);
4709
+ if (n2.text !== n1.text) {
4710
+ updateTextContent(n2);
4711
+ }
4712
+ }
4650
4713
 
4651
- if (vm) {
4652
- appendVM(vm);
4653
- }
4654
- },
4655
- move: insertNode,
4656
- remove: function remove(vnode, parentNode) {
4657
- removeNode(vnode, parentNode);
4658
- var vm = getAssociatedVMIfPresent(vnode.elm);
4714
+ function mountText(node, parent, anchor) {
4715
+ var owner = node.owner;
4716
+ var textNode = node.elm = createText$1(node.text);
4717
+ linkNodeToShadow(textNode, owner);
4718
+ insertNode(textNode, parent, anchor);
4719
+ }
4659
4720
 
4660
- if (vm) {
4661
- // for custom elements we don't have to go recursively because the removeVM routine
4662
- // will take care of disconnecting any child VM attached to its shadow as well.
4663
- removeVM(vm);
4664
- }
4721
+ function patchComment(n1, n2) {
4722
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
4723
+ // it is the case today.
4724
+
4725
+ if (n2.text !== n1.text) {
4726
+ updateTextContent(n2);
4665
4727
  }
4666
- };
4728
+ }
4667
4729
 
4668
- function isVNode(vnode) {
4669
- return vnode != null;
4730
+ function mountComment(node, parent, anchor) {
4731
+ var owner = node.owner;
4732
+ var commentNode = node.elm = createComment$1(node.text);
4733
+ linkNodeToShadow(commentNode, owner);
4734
+ insertNode(commentNode, parent, anchor);
4670
4735
  }
4671
4736
 
4672
- function observeElementChildNodes(elm) {
4673
- elm.$domManual$ = true;
4737
+ function mountElement(vnode, parent, anchor) {
4738
+ var sel = vnode.sel,
4739
+ owner = vnode.owner,
4740
+ svg = vnode.data.svg;
4741
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4742
+ var elm = createElement$2(sel, namespace);
4743
+ linkNodeToShadow(elm, owner);
4744
+ fallbackElmHook(elm, vnode);
4745
+ vnode.elm = elm;
4746
+ patchElementPropsAndAttrs$1(null, vnode);
4747
+ insertNode(elm, parent, anchor);
4748
+ mountVNodes(vnode.children, elm, null);
4674
4749
  }
4675
4750
 
4676
- function setElementShadowToken(elm, token) {
4677
- elm.$shadowToken$ = token;
4678
- } // Set the scope token class for *.scoped.css styles
4751
+ function patchElement(n1, n2) {
4752
+ var elm = n2.elm = n1.elm;
4753
+ patchElementPropsAndAttrs$1(n1, n2);
4754
+ patchChildren(n1.children, n2.children, elm);
4755
+ }
4679
4756
 
4757
+ function mountCustomElement(vnode, parent, anchor) {
4758
+ var sel = vnode.sel,
4759
+ owner = vnode.owner;
4760
+ var UpgradableConstructor = getUpgradableConstructor(sel);
4761
+ /**
4762
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4763
+ * with a callback as the first argument, we could implement a more advanced
4764
+ * mechanism that only passes that argument if the constructor is known to be
4765
+ * an upgradable custom element.
4766
+ */
4680
4767
 
4681
- function setScopeTokenClassIfNecessary(elm, owner) {
4682
- var cmpTemplate = owner.cmpTemplate,
4683
- context = owner.context;
4684
- var token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
4768
+ var vm;
4769
+ var elm = new UpgradableConstructor(function (elm) {
4770
+ // the custom element from the registry is expecting an upgrade callback
4771
+ vm = createViewModelHook(elm, vnode);
4772
+ });
4773
+ linkNodeToShadow(elm, owner);
4774
+ vnode.elm = elm;
4775
+ vnode.vm = vm;
4685
4776
 
4686
- if (!isUndefined$1(token) && context.hasScopedStyles) {
4687
- getClassList$1(elm).add(token);
4777
+ if (vm) {
4778
+ allocateChildren(vnode, vm);
4779
+ } else if (vnode.ctor !== UpgradableConstructor) {
4780
+ throw new TypeError("Incorrect Component Constructor");
4688
4781
  }
4689
- }
4690
4782
 
4691
- function linkNodeToShadow(elm, owner) {
4692
- var renderRoot = owner.renderRoot,
4693
- renderMode = owner.renderMode,
4694
- shadowMode = owner.shadowMode; // TODO [#1164]: this should eventually be done by the polyfill directly
4783
+ patchElementPropsAndAttrs$1(null, vnode);
4784
+ insertNode(elm, parent, anchor);
4695
4785
 
4696
- if (isSyntheticShadowDefined$1) {
4697
- if (shadowMode === 1
4698
- /* Synthetic */
4699
- || renderMode === 0
4700
- /* Light */
4701
- ) {
4702
- elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
4786
+ if (vm) {
4787
+ if (process.env.NODE_ENV !== 'production') {
4788
+ assert.isTrue(vm.state === 0
4789
+ /* created */
4790
+ , "".concat(vm, " cannot be recycled."));
4703
4791
  }
4792
+
4793
+ runConnectedCallback(vm);
4794
+ }
4795
+
4796
+ mountVNodes(vnode.children, elm, null);
4797
+
4798
+ if (vm) {
4799
+ appendVM(vm);
4704
4800
  }
4705
4801
  }
4706
4802
 
4707
- function updateNodeHook(oldVnode, vnode) {
4708
- var elm = vnode.elm,
4709
- text = vnode.text;
4803
+ function patchCustomElement(n1, n2) {
4804
+ var elm = n2.elm = n1.elm;
4805
+ var vm = n2.vm = n1.vm;
4806
+ patchElementPropsAndAttrs$1(n1, n2);
4710
4807
 
4711
- if (oldVnode.text !== text) {
4712
- if (process.env.NODE_ENV !== 'production') {
4713
- unlockDomMutation();
4714
- }
4808
+ if (!isUndefined$1(vm)) {
4809
+ // in fallback mode, the allocation will always set children to
4810
+ // empty and delegate the real allocation to the slot elements
4811
+ allocateChildren(n2, vm);
4812
+ } // in fallback mode, the children will be always empty, so, nothing
4813
+ // will happen, but in native, it does allocate the light dom
4715
4814
 
4716
- setText$1(elm, text);
4717
4815
 
4718
- if (process.env.NODE_ENV !== 'production') {
4719
- lockDomMutation();
4720
- }
4816
+ patchChildren(n1.children, n2.children, elm);
4817
+
4818
+ if (!isUndefined$1(vm)) {
4819
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4820
+ // this is important to preserve the top to bottom synchronous rendering phase.
4821
+ rerenderVM(vm);
4721
4822
  }
4722
4823
  }
4723
4824
 
4724
- function insertNode(vnode, parentNode, referenceNode) {
4725
- if (process.env.NODE_ENV !== 'production') {
4726
- unlockDomMutation();
4727
- }
4825
+ function mountVNodes(vnodes, parent, anchor) {
4826
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4827
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
4728
4828
 
4729
- insert$1(vnode.elm, parentNode, referenceNode);
4829
+ for (; start < end; ++start) {
4830
+ var vnode = vnodes[start];
4730
4831
 
4731
- if (process.env.NODE_ENV !== 'production') {
4732
- lockDomMutation();
4832
+ if (isVNode(vnode)) {
4833
+ mount(vnode, parent, anchor);
4834
+ }
4733
4835
  }
4734
4836
  }
4735
4837
 
4736
- function removeNode(vnode, parentNode) {
4737
- if (process.env.NODE_ENV !== 'production') {
4838
+ function unmount(vnode, parent) {
4839
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4840
+ var type = vnode.type,
4841
+ elm = vnode.elm; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4842
+ // subtree root, is the only element worth unmounting from the subtree.
4843
+
4844
+ if (doRemove) {
4845
+ removeNode(elm, parent);
4846
+ }
4847
+
4848
+ switch (type) {
4849
+ case 2
4850
+ /* Element */
4851
+ :
4852
+ unmountVNodes(vnode.children, elm);
4853
+ break;
4854
+
4855
+ case 3
4856
+ /* CustomElement */
4857
+ :
4858
+ {
4859
+ var vm = vnode.vm; // No need to unmount the children here, `removeVM` will take care of removing the
4860
+ // children.
4861
+
4862
+ if (!isUndefined$1(vm)) {
4863
+ removeVM(vm);
4864
+ }
4865
+ }
4866
+ }
4867
+ }
4868
+
4869
+ function unmountVNodes(vnodes, parent) {
4870
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4871
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4872
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
4873
+
4874
+ for (; start < end; ++start) {
4875
+ var ch = vnodes[start];
4876
+
4877
+ if (isVNode(ch)) {
4878
+ unmount(ch, parent, doRemove);
4879
+ }
4880
+ }
4881
+ }
4882
+
4883
+ function isVNode(vnode) {
4884
+ return vnode != null;
4885
+ }
4886
+
4887
+ function observeElementChildNodes(elm) {
4888
+ elm.$domManual$ = true;
4889
+ }
4890
+
4891
+ function setElementShadowToken(elm, token) {
4892
+ elm.$shadowToken$ = token;
4893
+ } // Set the scope token class for *.scoped.css styles
4894
+
4895
+
4896
+ function setScopeTokenClassIfNecessary(elm, owner) {
4897
+ var cmpTemplate = owner.cmpTemplate,
4898
+ context = owner.context;
4899
+ var token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
4900
+
4901
+ if (!isUndefined$1(token) && context.hasScopedStyles) {
4902
+ getClassList$1(elm).add(token);
4903
+ }
4904
+ }
4905
+
4906
+ function linkNodeToShadow(elm, owner) {
4907
+ var renderRoot = owner.renderRoot,
4908
+ renderMode = owner.renderMode,
4909
+ shadowMode = owner.shadowMode; // TODO [#1164]: this should eventually be done by the polyfill directly
4910
+
4911
+ if (isSyntheticShadowDefined$1) {
4912
+ if (shadowMode === 1
4913
+ /* Synthetic */
4914
+ || renderMode === 0
4915
+ /* Light */
4916
+ ) {
4917
+ elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
4918
+ }
4919
+ }
4920
+ }
4921
+
4922
+ function updateTextContent(vnode) {
4923
+ var elm = vnode.elm,
4924
+ text = vnode.text;
4925
+
4926
+ if (process.env.NODE_ENV !== 'production') {
4738
4927
  unlockDomMutation();
4739
4928
  }
4740
4929
 
4741
- remove$1(vnode.elm, parentNode);
4930
+ setText$1(elm, text);
4931
+
4932
+ if (process.env.NODE_ENV !== 'production') {
4933
+ lockDomMutation();
4934
+ }
4935
+ }
4936
+
4937
+ function insertNode(node, parent, anchor) {
4938
+ if (process.env.NODE_ENV !== 'production') {
4939
+ unlockDomMutation();
4940
+ }
4941
+
4942
+ insert$1(node, parent, anchor);
4943
+
4944
+ if (process.env.NODE_ENV !== 'production') {
4945
+ lockDomMutation();
4946
+ }
4947
+ }
4948
+
4949
+ function removeNode(node, parent) {
4950
+ if (process.env.NODE_ENV !== 'production') {
4951
+ unlockDomMutation();
4952
+ }
4953
+
4954
+ remove$1(node, parent);
4742
4955
 
4743
4956
  if (process.env.NODE_ENV !== 'production') {
4744
4957
  lockDomMutation();
@@ -4775,11 +4988,13 @@ var LWC = (function (exports) {
4775
4988
  ) {
4776
4989
  // this element will now accept any manual content inserted into it
4777
4990
  observeElementChildNodes(elm);
4778
- } // when running in synthetic shadow mode, we need to set the shadowToken value
4779
- // into each element from the template, so they can be styled accordingly.
4780
-
4991
+ }
4781
4992
 
4782
- setElementShadowToken(elm, stylesheetToken);
4993
+ if (!isUndefined$1(stylesheetToken)) {
4994
+ // when running in synthetic shadow mode, we need to set the shadowToken value
4995
+ // into each element from the template, so they can be styled accordingly.
4996
+ setElementShadowToken(elm, stylesheetToken);
4997
+ }
4783
4998
  }
4784
4999
 
4785
5000
  if (process.env.NODE_ENV !== 'production') {
@@ -4797,14 +5012,6 @@ var LWC = (function (exports) {
4797
5012
  }
4798
5013
  }
4799
5014
 
4800
- function patchChildren(parent, oldCh, newCh) {
4801
- if (hasDynamicChildren(newCh)) {
4802
- updateDynamicChildren(parent, oldCh, newCh);
4803
- } else {
4804
- updateStaticChildren(parent, oldCh, newCh);
4805
- }
4806
- }
4807
-
4808
5015
  function allocateChildren(vnode, vm) {
4809
5016
  // A component with slots will re-render because:
4810
5017
  // 1- There is a change of the internal state.
@@ -4856,7 +5063,9 @@ var LWC = (function (exports) {
4856
5063
  var stylesheetToken = owner.context.stylesheetToken; // when running in synthetic shadow mode, we need to set the shadowToken value
4857
5064
  // into each element from the template, so they can be styled accordingly.
4858
5065
 
4859
- setElementShadowToken(elm, stylesheetToken);
5066
+ if (!isUndefined$1(stylesheetToken)) {
5067
+ setElementShadowToken(elm, stylesheetToken);
5068
+ }
4860
5069
  }
4861
5070
 
4862
5071
  vm = createVM(elm, ctor, {
@@ -4872,44 +5081,14 @@ var LWC = (function (exports) {
4872
5081
  return vm;
4873
5082
  }
4874
5083
 
4875
- function createChildrenHook(vnode) {
4876
- var elm = vnode.elm,
4877
- children = vnode.children;
4878
-
4879
- for (var j = 0; j < children.length; ++j) {
4880
- var ch = children[j];
4881
-
4882
- if (ch != null) {
4883
- ch.hook.create(ch);
4884
- ch.hook.insert(ch, elm, null);
4885
- }
4886
- }
4887
- }
4888
-
4889
- function removeChildren(vnode) {
4890
- // this method only needs to search on child vnodes from template
4891
- // to trigger the remove hook just in case some of those children
4892
- // are custom elements.
4893
- var children = vnode.children,
4894
- elm = vnode.elm;
4895
-
4896
- for (var j = 0, _len5 = children.length; j < _len5; ++j) {
4897
- var ch = children[j];
4898
-
4899
- if (!isNull(ch)) {
4900
- ch.hook.remove(ch, elm);
4901
- }
4902
- }
4903
- }
4904
-
4905
5084
  function allocateInSlot(vm, children) {
4906
5085
  var _a;
4907
5086
 
4908
5087
  var oldSlots = vm.cmpSlots;
4909
5088
  var cmpSlots = vm.cmpSlots = create(null);
4910
5089
 
4911
- for (var _i12 = 0, _len6 = children.length; _i12 < _len6; _i12 += 1) {
4912
- var vnode = children[_i12];
5090
+ for (var _i13 = 0, _len5 = children.length; _i13 < _len5; _i13 += 1) {
5091
+ var vnode = children[_i13];
4913
5092
 
4914
5093
  if (isNull(vnode)) {
4915
5094
  continue;
@@ -4943,8 +5122,8 @@ var LWC = (function (exports) {
4943
5122
  return;
4944
5123
  }
4945
5124
 
4946
- for (var _i13 = 0, _len7 = oldKeys.length; _i13 < _len7; _i13 += 1) {
4947
- var key = oldKeys[_i13];
5125
+ for (var _i14 = 0, _len6 = oldKeys.length; _i14 < _len6; _i14 += 1) {
5126
+ var key = oldKeys[_i14];
4948
5127
 
4949
5128
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4950
5129
  markComponentAsDirty(vm);
@@ -4994,28 +5173,7 @@ var LWC = (function (exports) {
4994
5173
  return map;
4995
5174
  }
4996
5175
 
4997
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
4998
- for (; startIdx <= endIdx; ++startIdx) {
4999
- var ch = vnodes[startIdx];
5000
-
5001
- if (isVNode(ch)) {
5002
- ch.hook.create(ch);
5003
- ch.hook.insert(ch, parentElm, before);
5004
- }
5005
- }
5006
- }
5007
-
5008
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
5009
- for (; startIdx <= endIdx; ++startIdx) {
5010
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
5011
-
5012
- if (isVNode(ch)) {
5013
- ch.hook.remove(ch, parentElm);
5014
- }
5015
- }
5016
- }
5017
-
5018
- function updateDynamicChildren(parentElm, oldCh, newCh) {
5176
+ function updateDynamicChildren(oldCh, newCh, parent) {
5019
5177
  var oldStartIdx = 0;
5020
5178
  var newStartIdx = 0;
5021
5179
  var oldEndIdx = oldCh.length - 1;
@@ -5029,6 +5187,7 @@ var LWC = (function (exports) {
5029
5187
  var idxInOld;
5030
5188
  var elmToMove;
5031
5189
  var before;
5190
+ var clonedOldCh = false;
5032
5191
 
5033
5192
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
5034
5193
  if (!isVNode(oldStartVnode)) {
@@ -5040,23 +5199,23 @@ var LWC = (function (exports) {
5040
5199
  } else if (!isVNode(newEndVnode)) {
5041
5200
  newEndVnode = newCh[--newEndIdx];
5042
5201
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
5043
- patchVnode(oldStartVnode, newStartVnode);
5202
+ patch(oldStartVnode, newStartVnode);
5044
5203
  oldStartVnode = oldCh[++oldStartIdx];
5045
5204
  newStartVnode = newCh[++newStartIdx];
5046
5205
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
5047
- patchVnode(oldEndVnode, newEndVnode);
5206
+ patch(oldEndVnode, newEndVnode);
5048
5207
  oldEndVnode = oldCh[--oldEndIdx];
5049
5208
  newEndVnode = newCh[--newEndIdx];
5050
5209
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
5051
5210
  // Vnode moved right
5052
- patchVnode(oldStartVnode, newEndVnode);
5053
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5211
+ patch(oldStartVnode, newEndVnode);
5212
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
5054
5213
  oldStartVnode = oldCh[++oldStartIdx];
5055
5214
  newEndVnode = newCh[--newEndIdx];
5056
5215
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
5057
5216
  // Vnode moved left
5058
- patchVnode(oldEndVnode, newStartVnode);
5059
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5217
+ patch(oldEndVnode, newStartVnode);
5218
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
5060
5219
  oldEndVnode = oldCh[--oldEndIdx];
5061
5220
  newStartVnode = newCh[++newStartIdx];
5062
5221
  } else {
@@ -5068,8 +5227,7 @@ var LWC = (function (exports) {
5068
5227
 
5069
5228
  if (isUndefined$1(idxInOld)) {
5070
5229
  // New element
5071
- newStartVnode.hook.create(newStartVnode);
5072
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5230
+ mount(newStartVnode, parent, oldStartVnode.elm);
5073
5231
  newStartVnode = newCh[++newStartIdx];
5074
5232
  } else {
5075
5233
  elmToMove = oldCh[idxInOld];
@@ -5077,12 +5235,22 @@ var LWC = (function (exports) {
5077
5235
  if (isVNode(elmToMove)) {
5078
5236
  if (elmToMove.sel !== newStartVnode.sel) {
5079
5237
  // New element
5080
- newStartVnode.hook.create(newStartVnode);
5081
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5238
+ mount(newStartVnode, parent, oldStartVnode.elm);
5082
5239
  } else {
5083
- patchVnode(elmToMove, newStartVnode);
5240
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5241
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
5242
+ // so we only care about the `oldCh` object inside this function.
5243
+ // To avoid cloning over and over again, we check `clonedOldCh`
5244
+ // and only clone once.
5245
+
5246
+ if (!clonedOldCh) {
5247
+ clonedOldCh = true;
5248
+ oldCh = _toConsumableArray(oldCh);
5249
+ } // We've already cloned at least once, so it's no longer read-only
5250
+
5251
+
5084
5252
  oldCh[idxInOld] = undefined;
5085
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5253
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
5086
5254
  }
5087
5255
  }
5088
5256
 
@@ -5095,73 +5263,63 @@ var LWC = (function (exports) {
5095
5263
  if (oldStartIdx > oldEndIdx) {
5096
5264
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
5097
5265
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
5098
- var _i14 = newEndIdx;
5266
+ var _i15 = newEndIdx;
5099
5267
  var n;
5100
5268
 
5101
5269
  do {
5102
- n = newCh[++_i14];
5103
- } while (!isVNode(n) && _i14 < newChEnd);
5270
+ n = newCh[++_i15];
5271
+ } while (!isVNode(n) && _i15 < newChEnd);
5104
5272
 
5105
5273
  before = isVNode(n) ? n.elm : null;
5106
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5274
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
5107
5275
  } else {
5108
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5276
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
5109
5277
  }
5110
5278
  }
5111
5279
  }
5112
5280
 
5113
- function updateStaticChildren(parentElm, oldCh, newCh) {
5114
- var oldChLength = oldCh.length;
5115
- var newChLength = newCh.length;
5281
+ function updateStaticChildren(c1, c2, parent) {
5282
+ var c1Length = c1.length;
5283
+ var c2Length = c2.length;
5116
5284
 
5117
- if (oldChLength === 0) {
5285
+ if (c1Length === 0) {
5118
5286
  // the old list is empty, we can directly insert anything new
5119
- addVnodes(parentElm, null, newCh, 0, newChLength);
5287
+ mountVNodes(c2, parent, null);
5120
5288
  return;
5121
5289
  }
5122
5290
 
5123
- if (newChLength === 0) {
5291
+ if (c2Length === 0) {
5124
5292
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5125
5293
  // this is the case in which the dynamic children of an if-directive should be removed
5126
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5294
+ unmountVNodes(c1, parent, true);
5127
5295
  return;
5128
5296
  } // if the old list is not empty, the new list MUST have the same
5129
5297
  // amount of nodes, that's why we call this static children
5130
5298
 
5131
5299
 
5132
- var referenceElm = null;
5300
+ var anchor = null;
5133
5301
 
5134
- for (var _i15 = newChLength - 1; _i15 >= 0; _i15 -= 1) {
5135
- var vnode = newCh[_i15];
5136
- var oldVNode = oldCh[_i15];
5302
+ for (var _i16 = c2Length - 1; _i16 >= 0; _i16 -= 1) {
5303
+ var n1 = c1[_i16];
5304
+ var n2 = c2[_i16];
5137
5305
 
5138
- if (vnode !== oldVNode) {
5139
- if (isVNode(oldVNode)) {
5140
- if (isVNode(vnode)) {
5141
- // both vnodes must be equivalent, and se just need to patch them
5142
- patchVnode(oldVNode, vnode);
5143
- referenceElm = vnode.elm;
5306
+ if (n2 !== n1) {
5307
+ if (isVNode(n1)) {
5308
+ if (isVNode(n2)) {
5309
+ // both vnodes are equivalent, and we just need to patch them
5310
+ patch(n1, n2);
5311
+ anchor = n2.elm;
5144
5312
  } else {
5145
5313
  // removing the old vnode since the new one is null
5146
- oldVNode.hook.remove(oldVNode, parentElm);
5314
+ unmount(n1, parent, true);
5147
5315
  }
5148
- } else if (isVNode(vnode)) {
5149
- // this condition is unnecessary
5150
- vnode.hook.create(vnode); // insert the new node one since the old one is null
5151
-
5152
- vnode.hook.insert(vnode, parentElm, referenceElm);
5153
- referenceElm = vnode.elm;
5316
+ } else if (isVNode(n2)) {
5317
+ mount(n2, parent, anchor);
5318
+ anchor = n2.elm;
5154
5319
  }
5155
5320
  }
5156
5321
  }
5157
5322
  }
5158
-
5159
- function patchVnode(oldVnode, vnode) {
5160
- if (oldVnode !== vnode) {
5161
- vnode.elm = oldVnode.elm;
5162
- vnode.hook.update(oldVnode, vnode);
5163
- }
5164
- }
5165
5323
  /*
5166
5324
  * Copyright (c) 2018, salesforce.com, inc.
5167
5325
  * All rights reserved.
@@ -5177,7 +5335,8 @@ var LWC = (function (exports) {
5177
5335
  } // [h]tml node
5178
5336
 
5179
5337
 
5180
- function h(sel, data, children) {
5338
+ function h(sel, data) {
5339
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EmptyArray;
5181
5340
  var vmBeingRendered = getVMBeingRendered();
5182
5341
 
5183
5342
  if (process.env.NODE_ENV !== 'production') {
@@ -5211,7 +5370,6 @@ var LWC = (function (exports) {
5211
5370
  children: children,
5212
5371
  elm: elm,
5213
5372
  key: key,
5214
- hook: ElementHook,
5215
5373
  owner: vmBeingRendered
5216
5374
  };
5217
5375
  } // [t]ab[i]ndex function
@@ -5295,7 +5453,7 @@ var LWC = (function (exports) {
5295
5453
  }
5296
5454
 
5297
5455
  var key = data.key;
5298
- var elm;
5456
+ var elm, aChildren, vm;
5299
5457
  var vnode = {
5300
5458
  type: 3
5301
5459
  /* CustomElement */
@@ -5305,11 +5463,11 @@ var LWC = (function (exports) {
5305
5463
  children: children,
5306
5464
  elm: elm,
5307
5465
  key: key,
5308
- hook: CustomElementHook,
5309
5466
  ctor: Ctor,
5310
5467
  owner: vmBeingRendered,
5311
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5312
-
5468
+ mode: 'open',
5469
+ aChildren: aChildren,
5470
+ vm: vm
5313
5471
  };
5314
5472
  addVNodeToChildLWC(vnode);
5315
5473
  return vnode;
@@ -5436,7 +5594,6 @@ var LWC = (function (exports) {
5436
5594
  text: text,
5437
5595
  elm: elm,
5438
5596
  key: key,
5439
- hook: TextHook,
5440
5597
  owner: getVMBeingRendered()
5441
5598
  };
5442
5599
  } // [co]mment node
@@ -5452,7 +5609,6 @@ var LWC = (function (exports) {
5452
5609
  text: text,
5453
5610
  elm: elm,
5454
5611
  key: key,
5455
- hook: CommentHook,
5456
5612
  owner: getVMBeingRendered()
5457
5613
  };
5458
5614
  } // [d]ynamic text
@@ -5565,7 +5721,9 @@ var LWC = (function (exports) {
5565
5721
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5566
5722
  */
5567
5723
 
5568
- function dc(sel, Ctor, data, children) {
5724
+ function dc(sel, Ctor, data) {
5725
+ var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : EmptyArray;
5726
+
5569
5727
  if (process.env.NODE_ENV !== 'production') {
5570
5728
  assert.isTrue(isString(sel), "dc() 1st argument sel must be a string.");
5571
5729
  assert.isTrue(isObject(data), "dc() 3nd argument data must be an object.");
@@ -5589,10 +5747,14 @@ var LWC = (function (exports) {
5589
5747
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
5590
5748
  // to identify different constructors as vnodes with different keys to avoid reusing the
5591
5749
  // element used for previous constructors.
5750
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
5751
+ // hoisting optimization.
5592
5752
 
5593
5753
 
5594
- data.key = "dc:".concat(idx, ":").concat(data.key);
5595
- return c(sel, Ctor, data, children);
5754
+ var newData = Object.assign(Object.assign({}, data), {
5755
+ key: "dc:".concat(idx, ":").concat(data.key)
5756
+ });
5757
+ return c(sel, Ctor, newData, children);
5596
5758
  }
5597
5759
  /**
5598
5760
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5704,12 +5866,14 @@ var LWC = (function (exports) {
5704
5866
  oldHasTokenInClass = context.hasTokenInClass,
5705
5867
  oldHasTokenInAttribute = context.hasTokenInAttribute;
5706
5868
 
5707
- if (oldHasTokenInClass) {
5708
- getClassList$1(elm).remove(makeHostToken(oldToken));
5709
- }
5869
+ if (!isUndefined$1(oldToken)) {
5870
+ if (oldHasTokenInClass) {
5871
+ getClassList$1(elm).remove(makeHostToken(oldToken));
5872
+ }
5710
5873
 
5711
- if (oldHasTokenInAttribute) {
5712
- removeAttribute$1(elm, makeHostToken(oldToken));
5874
+ if (oldHasTokenInAttribute) {
5875
+ removeAttribute$1(elm, makeHostToken(oldToken));
5876
+ }
5713
5877
  } // Apply the new template styling token to the host element, if the new template has any
5714
5878
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
5715
5879
 
@@ -5741,8 +5905,8 @@ var LWC = (function (exports) {
5741
5905
  var content = [];
5742
5906
  var root;
5743
5907
 
5744
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5745
- var stylesheet = stylesheets[_i16];
5908
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5909
+ var stylesheet = stylesheets[_i17];
5746
5910
 
5747
5911
  if (isArray$1(stylesheet)) {
5748
5912
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -5852,8 +6016,8 @@ var LWC = (function (exports) {
5852
6016
  && shadowMode === 1
5853
6017
  /* Synthetic */
5854
6018
  ) {
5855
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5856
- insertGlobalStylesheet$1(stylesheets[_i17]);
6019
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
6020
+ insertGlobalStylesheet$1(stylesheets[_i18]);
5857
6021
  }
5858
6022
  } else if (ssr$1 || isHydrating$1()) {
5859
6023
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -5867,12 +6031,12 @@ var LWC = (function (exports) {
5867
6031
  var root = getNearestNativeShadowComponent(vm);
5868
6032
  var isGlobal = isNull(root);
5869
6033
 
5870
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
6034
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
5871
6035
  if (isGlobal) {
5872
- insertGlobalStylesheet$1(stylesheets[_i18]);
6036
+ insertGlobalStylesheet$1(stylesheets[_i19]);
5873
6037
  } else {
5874
6038
  // local level
5875
- insertStylesheet$1(stylesheets[_i18], root.shadowRoot);
6039
+ insertStylesheet$1(stylesheets[_i19], root.shadowRoot);
5876
6040
  }
5877
6041
  }
5878
6042
  }
@@ -6149,8 +6313,8 @@ var LWC = (function (exports) {
6149
6313
  var stylesheets = template.stylesheets;
6150
6314
 
6151
6315
  if (!isUndefined$1(stylesheets)) {
6152
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6153
- if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
6316
+ for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
6317
+ if (isTrue(stylesheets[_i20][KEY__SCOPED_CSS])) {
6154
6318
  return true;
6155
6319
  }
6156
6320
  }
@@ -6277,6 +6441,11 @@ var LWC = (function (exports) {
6277
6441
 
6278
6442
  function registerComponent(Ctor, _ref2) {
6279
6443
  var tmpl = _ref2.tmpl;
6444
+
6445
+ if (process.env.NODE_ENV !== 'production') {
6446
+ checkVersionMismatch(Ctor, 'component');
6447
+ }
6448
+
6280
6449
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6281
6450
  // without too much transformation
6282
6451
 
@@ -6362,8 +6531,8 @@ var LWC = (function (exports) {
6362
6531
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6363
6532
  }
6364
6533
 
6365
- for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6366
- var hookName = hooks[_i20];
6534
+ for (var _i21 = 0; _i21 < hooks.length; ++_i21) {
6535
+ var hookName = hooks[_i21];
6367
6536
 
6368
6537
  if (hookName in service) {
6369
6538
  var l = Services[hookName];
@@ -6386,8 +6555,8 @@ var LWC = (function (exports) {
6386
6555
  def = vm.def,
6387
6556
  context = vm.context;
6388
6557
 
6389
- for (var _i21 = 0, _len8 = cbs.length; _i21 < _len8; ++_i21) {
6390
- cbs[_i21].call(undefined, component, {}, def, context);
6558
+ for (var _i22 = 0, _len7 = cbs.length; _i22 < _len7; ++_i22) {
6559
+ cbs[_i22].call(undefined, component, {}, def, context);
6391
6560
  }
6392
6561
  }
6393
6562
  /*
@@ -6398,7 +6567,7 @@ var LWC = (function (exports) {
6398
6567
  */
6399
6568
 
6400
6569
 
6401
- function hydrate$1(vnode, node) {
6570
+ function hydrate(vnode, node) {
6402
6571
  switch (vnode.type) {
6403
6572
  case 0
6404
6573
  /* Text */
@@ -6430,16 +6599,18 @@ var LWC = (function (exports) {
6430
6599
  var _a;
6431
6600
 
6432
6601
  if (process.env.NODE_ENV !== 'production') {
6433
- // eslint-disable-next-line lwc-internal/no-global-node
6434
- validateNodeType(vnode, node, Node.TEXT_NODE);
6602
+ validateNodeType(vnode, node, 3
6603
+ /* TEXT */
6604
+ );
6605
+ var nodeValue = getProperty$1(node, 'nodeValue');
6435
6606
 
6436
- if (node.nodeValue !== vnode.text && !(node.nodeValue === "\u200D" && vnode.text === '')) {
6607
+ if (nodeValue !== vnode.text && !(nodeValue === "\u200D" && vnode.text === '')) {
6437
6608
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6438
6609
  }
6439
6610
  } // always set the text value to the one from the vnode.
6440
6611
 
6441
6612
 
6442
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6613
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6443
6614
  vnode.elm = node;
6444
6615
  }
6445
6616
 
@@ -6447,23 +6618,25 @@ var LWC = (function (exports) {
6447
6618
  var _a;
6448
6619
 
6449
6620
  if (process.env.NODE_ENV !== 'production') {
6450
- // eslint-disable-next-line lwc-internal/no-global-node
6451
- validateNodeType(vnode, node, Node.COMMENT_NODE);
6621
+ validateNodeType(vnode, node, 8
6622
+ /* COMMENT */
6623
+ );
6452
6624
 
6453
- if (node.nodeValue !== vnode.text) {
6625
+ if (getProperty$1(node, 'nodeValue') !== vnode.text) {
6454
6626
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6455
6627
  }
6456
6628
  } // always set the text value to the one from the vnode.
6457
6629
 
6458
6630
 
6459
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6631
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6460
6632
  vnode.elm = node;
6461
6633
  }
6462
6634
 
6463
6635
  function hydrateElement(vnode, node) {
6464
6636
  if (process.env.NODE_ENV !== 'production') {
6465
- // eslint-disable-next-line lwc-internal/no-global-node
6466
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6637
+ validateNodeType(vnode, node, 1
6638
+ /* ELEMENT */
6639
+ );
6467
6640
  validateElement(vnode, node);
6468
6641
  }
6469
6642
 
@@ -6480,10 +6653,13 @@ var LWC = (function (exports) {
6480
6653
  var props = vnode.data.props;
6481
6654
 
6482
6655
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6483
- if (elm.innerHTML === props.innerHTML) {
6484
- delete props.innerHTML;
6656
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6657
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6658
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
6659
+ props: cloneAndOmitKey(props, 'innerHTML')
6660
+ });
6485
6661
  } else {
6486
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6662
+ logWarn("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6487
6663
  }
6488
6664
  }
6489
6665
  }
@@ -6491,19 +6667,19 @@ var LWC = (function (exports) {
6491
6667
  patchElementPropsAndAttrs(vnode);
6492
6668
 
6493
6669
  if (!isDomManual) {
6494
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
6670
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
6495
6671
  }
6496
6672
  }
6497
6673
 
6498
6674
  function hydrateCustomElement(vnode, node) {
6499
6675
  if (process.env.NODE_ENV !== 'production') {
6500
- // eslint-disable-next-line lwc-internal/no-global-node
6501
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6676
+ validateNodeType(vnode, node, 1
6677
+ /* ELEMENT */
6678
+ );
6502
6679
  validateElement(vnode, node);
6503
6680
  }
6504
6681
 
6505
6682
  var elm = node;
6506
- vnode.elm = elm;
6507
6683
  var sel = vnode.sel,
6508
6684
  mode = vnode.mode,
6509
6685
  ctor = vnode.ctor,
@@ -6513,6 +6689,8 @@ var LWC = (function (exports) {
6513
6689
  owner: owner,
6514
6690
  tagName: sel
6515
6691
  });
6692
+ vnode.elm = elm;
6693
+ vnode.vm = vm;
6516
6694
  allocateChildren(vnode, vm);
6517
6695
  patchElementPropsAndAttrs(vnode); // Insert hook section:
6518
6696
 
@@ -6529,7 +6707,7 @@ var LWC = (function (exports) {
6529
6707
  ) {
6530
6708
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6531
6709
  // Note: for Light DOM, this is handled while hydrating the VM
6532
- hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
6710
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vm);
6533
6711
  }
6534
6712
 
6535
6713
  hydrateVM(vm);
@@ -6549,12 +6727,12 @@ var LWC = (function (exports) {
6549
6727
 
6550
6728
  var childNodeIndex = 0;
6551
6729
 
6552
- for (var _i22 = 0; _i22 < children.length; _i22++) {
6553
- var childVnode = children[_i22];
6730
+ for (var _i23 = 0; _i23 < children.length; _i23++) {
6731
+ var childVnode = children[_i23];
6554
6732
 
6555
6733
  if (!isNull(childVnode)) {
6556
6734
  var childNode = elmChildren[childNodeIndex];
6557
- hydrate$1(childVnode, childNode);
6735
+ hydrate(childVnode, childNode);
6558
6736
  childNodeIndex++;
6559
6737
  }
6560
6738
  }
@@ -6570,15 +6748,15 @@ var LWC = (function (exports) {
6570
6748
  }
6571
6749
 
6572
6750
  function validateNodeType(vnode, node, nodeType) {
6573
- if (node.nodeType !== nodeType) {
6751
+ if (getProperty$1(node, 'nodeType') !== nodeType) {
6574
6752
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
6575
6753
  assert.fail('Hydration mismatch: incorrect node type received.');
6576
6754
  }
6577
6755
  }
6578
6756
 
6579
6757
  function validateElement(vnode, elm) {
6580
- if (vnode.sel.toLowerCase() !== elm.tagName.toLowerCase()) {
6581
- logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(elm.tagName.toLowerCase(), "\"."), vnode.owner);
6758
+ if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
6759
+ logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(getProperty$1(elm, 'tagName').toLowerCase(), "\"."), vnode.owner);
6582
6760
  throwHydrationError();
6583
6761
  }
6584
6762
 
@@ -6598,15 +6776,15 @@ var LWC = (function (exports) {
6598
6776
  var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
6599
6777
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6600
6778
 
6601
- for (var _i23 = 0, _Object$entries = Object.entries(attrs); _i23 < _Object$entries.length; _i23++) {
6602
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i23], 2),
6779
+ for (var _i24 = 0, _Object$entries = Object.entries(attrs); _i24 < _Object$entries.length; _i24++) {
6780
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i24], 2),
6603
6781
  attrName = _Object$entries$_i[0],
6604
6782
  attrValue = _Object$entries$_i[1];
6605
6783
 
6606
6784
  var elmAttrValue = getAttribute$1(elm, attrName);
6607
6785
 
6608
6786
  if (String(attrValue) !== elmAttrValue) {
6609
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
6787
+ logError("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
6610
6788
  nodesAreCompatible = false;
6611
6789
  }
6612
6790
  }
@@ -6621,7 +6799,7 @@ var LWC = (function (exports) {
6621
6799
  var nodesAreCompatible = true;
6622
6800
  var vnodeClassName;
6623
6801
 
6624
- if (!isUndefined$1(className) && String(className) !== elm.className) {
6802
+ if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6625
6803
  // className is used when class is bound to an expr.
6626
6804
  nodesAreCompatible = false;
6627
6805
  vnodeClassName = className;
@@ -6646,7 +6824,7 @@ var LWC = (function (exports) {
6646
6824
  }
6647
6825
 
6648
6826
  if (!nodesAreCompatible) {
6649
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(elm.className, "\""), vnode.owner);
6827
+ logError("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(getProperty$1(elm, 'className'), "\""), vnode.owner);
6650
6828
  }
6651
6829
 
6652
6830
  return nodesAreCompatible;
@@ -6667,8 +6845,8 @@ var LWC = (function (exports) {
6667
6845
  var parsedVnodeStyle = parseStyleText(elmStyle);
6668
6846
  var expectedStyle = []; // styleMap is used when style is set to static value.
6669
6847
 
6670
- for (var _i24 = 0, n = styleDecls.length; _i24 < n; _i24++) {
6671
- var _styleDecls$_i2 = _slicedToArray(styleDecls[_i24], 3),
6848
+ for (var _i25 = 0, n = styleDecls.length; _i25 < n; _i25++) {
6849
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i25], 3),
6672
6850
  prop = _styleDecls$_i2[0],
6673
6851
  value = _styleDecls$_i2[1],
6674
6852
  important = _styleDecls$_i2[2];
@@ -6694,7 +6872,7 @@ var LWC = (function (exports) {
6694
6872
 
6695
6873
  if (!nodesAreCompatible) {
6696
6874
  // style is used when class is bound to an expr.
6697
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
6875
+ logError("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
6698
6876
  }
6699
6877
 
6700
6878
  return nodesAreCompatible;
@@ -6765,7 +6943,19 @@ var LWC = (function (exports) {
6765
6943
  }
6766
6944
 
6767
6945
  function hydrateVM(vm) {
6768
- hydrate(vm);
6946
+ if (isTrue(vm.isDirty)) {
6947
+ // manually diffing/patching here.
6948
+ // This routine is:
6949
+ // patchShadowRoot(vm, children);
6950
+ // -> addVnodes.
6951
+ var children = renderComponent(vm);
6952
+ vm.children = children;
6953
+ var vmChildren = vm.renderMode === 0
6954
+ /* Light */
6955
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
6956
+ hydrateChildren(vmChildren, children, vm);
6957
+ runRenderedCallback(vm);
6958
+ }
6769
6959
  } // just in case the component comes back, with this we guarantee re-rendering it
6770
6960
  // while preventing any attempt to rehydration until after reinsertion.
6771
6961
 
@@ -6908,7 +7098,11 @@ var LWC = (function (exports) {
6908
7098
  /* Native */
6909
7099
  ;
6910
7100
  } else if (isNativeShadowDefined$1) {
6911
- if (def.shadowSupportMode === "any"
7101
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
7102
+ shadowMode = 1
7103
+ /* Synthetic */
7104
+ ;
7105
+ } else if (def.shadowSupportMode === "any"
6912
7106
  /* Any */
6913
7107
  ) {
6914
7108
  shadowMode = 0
@@ -6988,22 +7182,6 @@ var LWC = (function (exports) {
6988
7182
  }
6989
7183
  }
6990
7184
 
6991
- function hydrate(vm) {
6992
- if (isTrue(vm.isDirty)) {
6993
- // manually diffing/patching here.
6994
- // This routine is:
6995
- // patchShadowRoot(vm, children);
6996
- // -> addVnodes.
6997
- var children = renderComponent(vm);
6998
- vm.children = children;
6999
- var vmChildren = vm.renderMode === 0
7000
- /* Light */
7001
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
7002
- hydrateChildren(vmChildren, children, vm);
7003
- runRenderedCallback(vm);
7004
- }
7005
- }
7006
-
7007
7185
  function patchShadowRoot(vm, newCh) {
7008
7186
  var renderRoot = vm.renderRoot,
7009
7187
  oldCh = vm.children; // caching the new children collection
@@ -7021,7 +7199,7 @@ var LWC = (function (exports) {
7021
7199
  , vm);
7022
7200
  }, function () {
7023
7201
  // job
7024
- patchChildren(renderRoot, oldCh, newCh);
7202
+ patchChildren(oldCh, newCh, renderRoot);
7025
7203
  }, function () {
7026
7204
  // post
7027
7205
  logOperationEnd(2
@@ -7082,19 +7260,19 @@ var LWC = (function (exports) {
7082
7260
  });
7083
7261
  rehydrateQueue = []; // reset to a new queue
7084
7262
 
7085
- for (var _i25 = 0, _len9 = vms.length; _i25 < _len9; _i25 += 1) {
7086
- var vm = vms[_i25];
7263
+ for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
7264
+ var vm = vms[_i26];
7087
7265
 
7088
7266
  try {
7089
7267
  rehydrate(vm);
7090
7268
  } catch (error) {
7091
- if (_i25 + 1 < _len9) {
7269
+ if (_i26 + 1 < _len8) {
7092
7270
  // pieces of the queue are still pending to be rehydrated, those should have priority
7093
7271
  if (rehydrateQueue.length === 0) {
7094
7272
  addCallbackToNextTick(flushRehydrationQueue);
7095
7273
  }
7096
7274
 
7097
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i25 + 1));
7275
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i26 + 1));
7098
7276
  } // we need to end the measure before throwing.
7099
7277
 
7100
7278
 
@@ -7198,8 +7376,8 @@ var LWC = (function (exports) {
7198
7376
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
7199
7377
  // inserted in reserved order.
7200
7378
 
7201
- for (var _i26 = vCustomElementCollection.length - 1; _i26 >= 0; _i26 -= 1) {
7202
- var elm = vCustomElementCollection[_i26].elm; // There are two cases where the element could be undefined:
7379
+ for (var _i27 = vCustomElementCollection.length - 1; _i27 >= 0; _i27 -= 1) {
7380
+ var elm = vCustomElementCollection[_i27].elm; // There are two cases where the element could be undefined:
7203
7381
  // * when there is an error during the construction phase, and an error
7204
7382
  // boundary picks it, there is a possibility that the VCustomElement
7205
7383
  // is not properly initialized, and therefore is should be ignored.
@@ -7233,8 +7411,8 @@ var LWC = (function (exports) {
7233
7411
 
7234
7412
 
7235
7413
  function recursivelyDisconnectChildren(vnodes) {
7236
- for (var _i27 = 0, _len10 = vnodes.length; _i27 < _len10; _i27 += 1) {
7237
- var vnode = vnodes[_i27];
7414
+ for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
7415
+ var vnode = vnodes[_i28];
7238
7416
 
7239
7417
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
7240
7418
  switch (vnode.type) {
@@ -7265,8 +7443,8 @@ var LWC = (function (exports) {
7265
7443
  var children = vm.children,
7266
7444
  renderRoot = vm.renderRoot;
7267
7445
 
7268
- for (var _i28 = 0, _len11 = children.length; _i28 < _len11; _i28++) {
7269
- var child = children[_i28];
7446
+ for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
7447
+ var child = children[_i29];
7270
7448
 
7271
7449
  if (!isNull(child) && !isUndefined$1(child.elm)) {
7272
7450
  remove$1(child.elm, renderRoot);
@@ -7640,8 +7818,8 @@ var LWC = (function (exports) {
7640
7818
  function connectWireAdapters(vm) {
7641
7819
  var wiredConnecting = vm.context.wiredConnecting;
7642
7820
 
7643
- for (var _i29 = 0, _len12 = wiredConnecting.length; _i29 < _len12; _i29 += 1) {
7644
- wiredConnecting[_i29]();
7821
+ for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
7822
+ wiredConnecting[_i30]();
7645
7823
  }
7646
7824
  }
7647
7825
 
@@ -7649,8 +7827,8 @@ var LWC = (function (exports) {
7649
7827
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7650
7828
  runWithBoundaryProtection(vm, vm, noop, function () {
7651
7829
  // job
7652
- for (var _i30 = 0, _len13 = wiredDisconnecting.length; _i30 < _len13; _i30 += 1) {
7653
- wiredDisconnecting[_i30]();
7830
+ for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
7831
+ wiredDisconnecting[_i31]();
7654
7832
  }
7655
7833
  }, noop);
7656
7834
  }
@@ -7740,7 +7918,7 @@ var LWC = (function (exports) {
7740
7918
  hooksAreSet = true;
7741
7919
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7742
7920
  }
7743
- /* version: 2.7.4 */
7921
+ /* version: 2.10.0 */
7744
7922
 
7745
7923
  /*
7746
7924
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7755,8 +7933,8 @@ var LWC = (function (exports) {
7755
7933
  if (process.env.NODE_ENV === 'development') {
7756
7934
  // @ts-ignore
7757
7935
  window.__lwcResetGlobalStylesheets = function () {
7758
- for (var _i31 = 0, _Object$keys = Object.keys(globalStylesheets); _i31 < _Object$keys.length; _i31++) {
7759
- var key = _Object$keys[_i31];
7936
+ for (var _i32 = 0, _Object$keys2 = Object.keys(globalStylesheets); _i32 < _Object$keys2.length; _i32++) {
7937
+ var key = _Object$keys2[_i32];
7760
7938
  delete globalStylesheets[key];
7761
7939
  }
7762
7940
  };
@@ -7767,6 +7945,7 @@ var LWC = (function (exports) {
7767
7945
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7768
7946
 
7769
7947
  var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7948
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
7770
7949
  var styleElements = create(null);
7771
7950
  var styleSheets = create(null);
7772
7951
  var nodesToStyleSheets = new WeakMap();
@@ -7822,7 +8001,13 @@ var LWC = (function (exports) {
7822
8001
  }
7823
8002
 
7824
8003
  if (!target.adoptedStyleSheets.includes(styleSheet)) {
7825
- target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
8004
+ if (supportsMutableAdoptedStyleSheets) {
8005
+ // This is only supported in later versions of Chromium:
8006
+ // https://chromestatus.com/feature/5638996492288000
8007
+ target.adoptedStyleSheets.push(styleSheet);
8008
+ } else {
8009
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
8010
+ }
7826
8011
  }
7827
8012
  }
7828
8013
 
@@ -8122,6 +8307,177 @@ var LWC = (function (exports) {
8122
8307
  setSetText(setText);
8123
8308
  setSsr(ssr);
8124
8309
  setAddEventListener(addEventListener);
8310
+ /*
8311
+ * Copyright (c) 2018, salesforce.com, inc.
8312
+ * All rights reserved.
8313
+ * SPDX-License-Identifier: MIT
8314
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8315
+ */
8316
+
8317
+ function resetShadowRootAndLightDom(element, Ctor) {
8318
+ if (element.shadowRoot) {
8319
+ var shadowRoot = element.shadowRoot;
8320
+
8321
+ while (!isNull(shadowRoot.firstChild)) {
8322
+ shadowRoot.removeChild(shadowRoot.firstChild);
8323
+ }
8324
+ }
8325
+
8326
+ if (Ctor.renderMode === 'light') {
8327
+ while (!isNull(element.firstChild)) {
8328
+ element.removeChild(element.firstChild);
8329
+ }
8330
+ }
8331
+ }
8332
+
8333
+ function createVMWithProps(element, Ctor, props) {
8334
+ createVM(element, Ctor, {
8335
+ mode: 'open',
8336
+ owner: null,
8337
+ tagName: element.tagName.toLowerCase()
8338
+ });
8339
+
8340
+ for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
8341
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
8342
+ key = _Object$entries2$_i[0],
8343
+ value = _Object$entries2$_i[1];
8344
+
8345
+ element[key] = value;
8346
+ }
8347
+ }
8348
+
8349
+ function hydrateComponent(element, Ctor) {
8350
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8351
+
8352
+ if (!(element instanceof Element)) {
8353
+ throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
8354
+ }
8355
+
8356
+ if (!isFunction$1(Ctor)) {
8357
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8358
+ }
8359
+
8360
+ if (!isObject(props) || isNull(props)) {
8361
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8362
+ }
8363
+
8364
+ if (getAssociatedVMIfPresent(element)) {
8365
+ /* eslint-disable-next-line no-console */
8366
+ console.warn("\"hydrateComponent\" expects an element that is not hydrated.", element);
8367
+ return;
8368
+ }
8369
+
8370
+ try {
8371
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8372
+ // and uses the same algo to create the stylesheets as in SSR.
8373
+ setIsHydrating(true);
8374
+ createVMWithProps(element, Ctor, props);
8375
+ hydrateRootElement(element); // set it back since now we finished hydration.
8376
+
8377
+ setIsHydrating(false);
8378
+ } catch (e) {
8379
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
8380
+ // with the client generated DOM.
8381
+
8382
+ /* eslint-disable-next-line no-console */
8383
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
8384
+
8385
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
8386
+
8387
+ createVMWithProps(element, Ctor, props);
8388
+ setIsHydrating(false);
8389
+ connectRootElement(element);
8390
+ } finally {
8391
+ // in case there's an error during recovery
8392
+ setIsHydrating(false);
8393
+ }
8394
+ }
8395
+ /*
8396
+ * Copyright (c) 2018, salesforce.com, inc.
8397
+ * All rights reserved.
8398
+ * SPDX-License-Identifier: MIT
8399
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8400
+ */
8401
+
8402
+ /**
8403
+ * This function builds a Web Component class from a LWC constructor so it can be
8404
+ * registered as a new element via customElements.define() at any given time.
8405
+ *
8406
+ * @deprecated since version 1.3.11
8407
+ *
8408
+ * @example
8409
+ * ```
8410
+ * import { buildCustomElementConstructor } from 'lwc';
8411
+ * import Foo from 'ns/foo';
8412
+ * const WC = buildCustomElementConstructor(Foo);
8413
+ * customElements.define('x-foo', WC);
8414
+ * const elm = document.createElement('x-foo');
8415
+ * ```
8416
+ */
8417
+
8418
+
8419
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8420
+ if (process.env.NODE_ENV !== 'production') {
8421
+ /* eslint-disable-next-line no-console */
8422
+ console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + "Use \"".concat(Ctor.name, ".CustomElementConstructor\" static property of the component constructor to access the corresponding custom element constructor instead."));
8423
+ }
8424
+
8425
+ return Ctor.CustomElementConstructor;
8426
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
8427
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
8428
+
8429
+
8430
+ var hydratedCustomElements = new WeakSet();
8431
+
8432
+ function buildCustomElementConstructor(Ctor) {
8433
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8434
+ return /*#__PURE__*/function (_HtmlPrototype) {
8435
+ _inherits(_class, _HtmlPrototype);
8436
+
8437
+ var _super8 = _createSuper(_class);
8438
+
8439
+ function _class() {
8440
+ var _this6;
8441
+
8442
+ _classCallCheck(this, _class);
8443
+
8444
+ _this6 = _super8.call(this);
8445
+
8446
+ if (_this6.isConnected) {
8447
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
8448
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
8449
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
8450
+ } else {
8451
+ createVM(_assertThisInitialized(_this6), Ctor, {
8452
+ mode: 'open',
8453
+ owner: null,
8454
+ tagName: _this6.tagName
8455
+ });
8456
+ }
8457
+
8458
+ return _this6;
8459
+ }
8460
+
8461
+ _createClass(_class, [{
8462
+ key: "connectedCallback",
8463
+ value: function connectedCallback() {
8464
+ if (hydratedCustomElements.has(this)) {
8465
+ // This is an un-upgraded element that was hydrated in the constructor.
8466
+ hydratedCustomElements.delete(this);
8467
+ } else {
8468
+ connectRootElement(this);
8469
+ }
8470
+ }
8471
+ }, {
8472
+ key: "disconnectedCallback",
8473
+ value: function disconnectedCallback() {
8474
+ disconnectRootElement(this);
8475
+ }
8476
+ }]);
8477
+
8478
+ return _class;
8479
+ }(HtmlPrototype);
8480
+ }
8125
8481
  /*
8126
8482
  * Copyright (c) 2018, salesforce.com, inc.
8127
8483
  * All rights reserved.
@@ -8131,6 +8487,7 @@ var LWC = (function (exports) {
8131
8487
  // TODO [#2472]: Remove this workaround when appropriate.
8132
8488
  // eslint-disable-next-line lwc-internal/no-global-node
8133
8489
 
8490
+
8134
8491
  var _Node$1 = Node;
8135
8492
  var ConnectingSlot = new WeakMap();
8136
8493
  var DisconnectingSlot = new WeakMap();
@@ -8238,142 +8595,6 @@ var LWC = (function (exports) {
8238
8595
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8239
8596
  */
8240
8597
 
8241
-
8242
- function hydrateComponent(element, Ctor) {
8243
- var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8244
-
8245
- if (!(element instanceof Element)) {
8246
- throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
8247
- }
8248
-
8249
- if (!isFunction$1(Ctor)) {
8250
- throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8251
- }
8252
-
8253
- if (!isObject(props) || isNull(props)) {
8254
- throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8255
- }
8256
-
8257
- try {
8258
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8259
- // and uses the same algo to create the stylesheets as in SSR.
8260
- setIsHydrating(true);
8261
- createVM(element, Ctor, {
8262
- mode: 'open',
8263
- owner: null,
8264
- tagName: element.tagName.toLowerCase()
8265
- });
8266
-
8267
- for (var _i32 = 0, _Object$entries2 = Object.entries(props); _i32 < _Object$entries2.length; _i32++) {
8268
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i32], 2),
8269
- key = _Object$entries2$_i[0],
8270
- value = _Object$entries2$_i[1];
8271
-
8272
- element[key] = value;
8273
- }
8274
-
8275
- hydrateRootElement(element); // set it back since now we finished hydration.
8276
-
8277
- setIsHydrating(false);
8278
- } catch (e) {
8279
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8280
- // the client generated DOM.
8281
-
8282
- /* eslint-disable-next-line no-console */
8283
- console.error('Recovering from error while hydrating: ', e);
8284
- setIsHydrating(false);
8285
- var newElem = createElement(element.tagName, {
8286
- is: Ctor,
8287
- mode: 'open'
8288
- });
8289
-
8290
- for (var _i33 = 0, _Object$entries3 = Object.entries(props); _i33 < _Object$entries3.length; _i33++) {
8291
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i33], 2),
8292
- _key3 = _Object$entries3$_i[0],
8293
- _value2 = _Object$entries3$_i[1];
8294
-
8295
- newElem[_key3] = _value2;
8296
- }
8297
-
8298
- element.parentNode.replaceChild(newElem, element);
8299
- }
8300
- }
8301
- /*
8302
- * Copyright (c) 2018, salesforce.com, inc.
8303
- * All rights reserved.
8304
- * SPDX-License-Identifier: MIT
8305
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8306
- */
8307
-
8308
- /**
8309
- * This function builds a Web Component class from a LWC constructor so it can be
8310
- * registered as a new element via customElements.define() at any given time.
8311
- *
8312
- * @deprecated since version 1.3.11
8313
- *
8314
- * @example
8315
- * ```
8316
- * import { buildCustomElementConstructor } from 'lwc';
8317
- * import Foo from 'ns/foo';
8318
- * const WC = buildCustomElementConstructor(Foo);
8319
- * customElements.define('x-foo', WC);
8320
- * const elm = document.createElement('x-foo');
8321
- * ```
8322
- */
8323
-
8324
-
8325
- function deprecatedBuildCustomElementConstructor(Ctor) {
8326
- if (process.env.NODE_ENV !== 'production') {
8327
- /* eslint-disable-next-line no-console */
8328
- console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + "Use \"".concat(Ctor.name, ".CustomElementConstructor\" static property of the component constructor to access the corresponding custom element constructor instead."));
8329
- }
8330
-
8331
- return Ctor.CustomElementConstructor;
8332
- }
8333
-
8334
- function buildCustomElementConstructor(Ctor) {
8335
- var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8336
- return /*#__PURE__*/function (_HtmlPrototype) {
8337
- _inherits(_class, _HtmlPrototype);
8338
-
8339
- var _super8 = _createSuper(_class);
8340
-
8341
- function _class() {
8342
- var _this6;
8343
-
8344
- _classCallCheck(this, _class);
8345
-
8346
- _this6 = _super8.call(this);
8347
- createVM(_assertThisInitialized(_this6), Ctor, {
8348
- mode: 'open',
8349
- owner: null,
8350
- tagName: _this6.tagName
8351
- });
8352
- return _this6;
8353
- }
8354
-
8355
- _createClass(_class, [{
8356
- key: "connectedCallback",
8357
- value: function connectedCallback() {
8358
- connectRootElement(this);
8359
- }
8360
- }, {
8361
- key: "disconnectedCallback",
8362
- value: function disconnectedCallback() {
8363
- disconnectRootElement(this);
8364
- }
8365
- }]);
8366
-
8367
- return _class;
8368
- }(HtmlPrototype);
8369
- }
8370
- /*
8371
- * Copyright (c) 2018, salesforce.com, inc.
8372
- * All rights reserved.
8373
- * SPDX-License-Identifier: MIT
8374
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8375
- */
8376
-
8377
8598
  /**
8378
8599
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
8379
8600
  * This API is subject to change or being removed.
@@ -8405,30 +8626,31 @@ var LWC = (function (exports) {
8405
8626
 
8406
8627
  var _Node = Node;
8407
8628
  /**
8408
- * EXPERIMENTAL: This function detects whether or not a Node is controlled by a LWC template. This
8409
- * API is subject to change or being removed.
8629
+ * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
8630
+ * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
8410
8631
  */
8411
8632
 
8412
- function isNodeFromTemplate(node) {
8633
+ function isNodeShadowed(node) {
8413
8634
  if (isFalse(node instanceof _Node)) {
8414
8635
  return false;
8415
- } // TODO [#1250]: skipping the shadowRoot instances itself makes no sense, we need to revisit
8416
- // this with locker
8636
+ } // It's debatable whether shadow root instances should be considered as shadowed, but we keep
8637
+ // this unchanged for legacy reasons (#1250).
8417
8638
 
8418
8639
 
8419
8640
  if (node instanceof ShadowRoot) {
8420
8641
  return false;
8421
8642
  }
8422
8643
 
8423
- if (isSyntheticShadowDefined) {
8424
- // TODO [#1252]: old behavior that is still used by some pieces of the platform,
8425
- // specifically, nodes inserted manually on places where `lwc:dom="manual"` directive is not
8426
- // used, will be considered global elements.
8427
- return !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
8428
- }
8644
+ var rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
8645
+ // synthetic roots cannot be descendants of native roots.
8646
+
8647
+ if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
8648
+ return true;
8649
+ } // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
8650
+ // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
8651
+
8429
8652
 
8430
- var root = node.getRootNode();
8431
- return root instanceof ShadowRoot;
8653
+ return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
8432
8654
  }
8433
8655
  /*
8434
8656
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8472,7 +8694,7 @@ var LWC = (function (exports) {
8472
8694
  });
8473
8695
  freeze(LightningElement);
8474
8696
  seal(LightningElement.prototype);
8475
- /* version: 2.7.4 */
8697
+ /* version: 2.10.0 */
8476
8698
 
8477
8699
  exports.LightningElement = LightningElement;
8478
8700
  exports.__unstable__ProfilerControl = profilerControl;
@@ -8484,7 +8706,7 @@ var LWC = (function (exports) {
8484
8706
  exports.getComponentDef = getComponentDef;
8485
8707
  exports.hydrateComponent = hydrateComponent;
8486
8708
  exports.isComponentConstructor = isComponentConstructor;
8487
- exports.isNodeFromTemplate = isNodeFromTemplate;
8709
+ exports.isNodeFromTemplate = isNodeShadowed;
8488
8710
  exports.readonly = readonly;
8489
8711
  exports.register = register;
8490
8712
  exports.registerComponent = registerComponent;