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."); }
@@ -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.8.0 */
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.11.0";
364
+ var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
365
+ /** version: 2.11.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,
461
468
  ENABLE_ELEMENT_PATCH: null,
462
469
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
463
- ENABLE_NODE_LIST_PATCH: null,
470
+ ENABLE_HMR: null,
464
471
  ENABLE_HTML_COLLECTIONS_PATCH: null,
472
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
473
+ ENABLE_MIXED_SHADOW_MODE: 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.8.0 */
543
+ /** version: 2.11.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
 
@@ -1112,6 +1163,7 @@ var LWC = (function (exports) {
1112
1163
  * SPDX-License-Identifier: MIT
1113
1164
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1114
1165
  */
1166
+ // These properties get added to LWCElement.prototype publicProps automatically
1115
1167
 
1116
1168
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1117
1169
 
@@ -2746,7 +2798,7 @@ var LWC = (function (exports) {
2746
2798
 
2747
2799
 
2748
2800
  var _loop = function _loop() {
2749
- var childGetter = _childGetters[_i6];
2801
+ var childGetter = _childGetters[_i7];
2750
2802
  queryAndChildGetterDescriptors[childGetter] = {
2751
2803
  get: function get() {
2752
2804
  var vm = getAssociatedVM(this);
@@ -2763,7 +2815,7 @@ var LWC = (function (exports) {
2763
2815
  };
2764
2816
  };
2765
2817
 
2766
- for (var _i6 = 0, _childGetters = childGetters; _i6 < _childGetters.length; _i6++) {
2818
+ for (var _i7 = 0, _childGetters = childGetters; _i7 < _childGetters.length; _i7++) {
2767
2819
  _loop();
2768
2820
  }
2769
2821
 
@@ -2787,7 +2839,7 @@ var LWC = (function (exports) {
2787
2839
 
2788
2840
 
2789
2841
  var _loop2 = function _loop2() {
2790
- var queryMethod = _queryMethods[_i7];
2842
+ var queryMethod = _queryMethods[_i8];
2791
2843
  queryAndChildGetterDescriptors[queryMethod] = {
2792
2844
  value: function value(arg) {
2793
2845
  var vm = getAssociatedVM(this);
@@ -2805,7 +2857,7 @@ var LWC = (function (exports) {
2805
2857
  };
2806
2858
  };
2807
2859
 
2808
- for (var _i7 = 0, _queryMethods = queryMethods; _i7 < _queryMethods.length; _i7++) {
2860
+ for (var _i8 = 0, _queryMethods = queryMethods; _i8 < _queryMethods.length; _i8++) {
2809
2861
  _loop2();
2810
2862
  }
2811
2863
 
@@ -3328,8 +3380,8 @@ var LWC = (function (exports) {
3328
3380
  }
3329
3381
 
3330
3382
  if (!isUndefined$1(fields)) {
3331
- for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
3332
- var _fieldName2 = fields[_i8];
3383
+ for (var _i9 = 0, n = fields.length; _i9 < n; _i9++) {
3384
+ var _fieldName2 = fields[_i9];
3333
3385
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
3334
3386
 
3335
3387
  if (process.env.NODE_ENV !== 'production') {
@@ -3377,6 +3429,48 @@ var LWC = (function (exports) {
3377
3429
  var meta = signedDecoratorToMetaMap.get(Ctor);
3378
3430
  return isUndefined$1(meta) ? defaultMeta : meta;
3379
3431
  }
3432
+ /*
3433
+ * Copyright (c) 2018, salesforce.com, inc.
3434
+ * All rights reserved.
3435
+ * SPDX-License-Identifier: MIT
3436
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3437
+ */
3438
+
3439
+
3440
+ var warned = false;
3441
+
3442
+ if (process.env.NODE_ENV === 'development') {
3443
+ // @ts-ignore
3444
+ window.__lwcResetWarnedOnVersionMismatch = function () {
3445
+ warned = false;
3446
+ };
3447
+ }
3448
+
3449
+ function checkVersionMismatch(func, type) {
3450
+ var versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
3451
+
3452
+ if (!isNull(versionMatcher) && !warned) {
3453
+ var version = versionMatcher[1];
3454
+
3455
+ var _version$split = version.split('.'),
3456
+ _version$split2 = _slicedToArray(_version$split, 2),
3457
+ major = _version$split2[0],
3458
+ minor = _version$split2[1];
3459
+
3460
+ var _LWC_VERSION$split = LWC_VERSION.split('.'),
3461
+ _LWC_VERSION$split2 = _slicedToArray(_LWC_VERSION$split, 2),
3462
+ expectedMajor = _LWC_VERSION$split2[0],
3463
+ expectedMinor = _LWC_VERSION$split2[1];
3464
+
3465
+ if (major !== expectedMajor || minor !== expectedMinor) {
3466
+ warned = true; // only warn once to avoid flooding the console
3467
+ // stylesheets and templates do not have user-meaningful names, but components do
3468
+
3469
+ var friendlyName = type === 'component' ? "".concat(type, " ").concat(func.name) : type;
3470
+ 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."));
3471
+ }
3472
+ }
3473
+ }
3380
3474
 
3381
3475
  var signedTemplateSet = new Set();
3382
3476
 
@@ -3396,6 +3490,10 @@ var LWC = (function (exports) {
3396
3490
 
3397
3491
 
3398
3492
  function registerTemplate(tpl) {
3493
+ if (process.env.NODE_ENV !== 'production') {
3494
+ checkVersionMismatch(tpl, 'template');
3495
+ }
3496
+
3399
3497
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3400
3498
  // assignment of templates easily, without too much transformation
3401
3499
 
@@ -3418,6 +3516,7 @@ var LWC = (function (exports) {
3418
3516
  * SPDX-License-Identifier: MIT
3419
3517
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3420
3518
  */
3519
+ // A bridge descriptor is a descriptor whose job is just to get the component instance
3421
3520
  // from the element instance, and get the value or set a new value on the component.
3422
3521
  // This means that across different elements, similar names can get the exact same
3423
3522
  // descriptor, so we can cache them:
@@ -3550,8 +3649,8 @@ var LWC = (function (exports) {
3550
3649
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
3551
3650
  var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
3552
3651
 
3553
- for (var _i9 = 0, _len3 = props.length; _i9 < _len3; _i9 += 1) {
3554
- var _propName2 = props[_i9];
3652
+ for (var _i10 = 0, _len3 = props.length; _i10 < _len3; _i10 += 1) {
3653
+ var _propName2 = props[_i10];
3555
3654
  attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
3556
3655
  descriptors[_propName2] = {
3557
3656
  get: createGetter(_propName2),
@@ -3562,8 +3661,8 @@ var LWC = (function (exports) {
3562
3661
  } // expose public methods as props on the new Element Bridge
3563
3662
 
3564
3663
 
3565
- for (var _i10 = 0, _len4 = methods.length; _i10 < _len4; _i10 += 1) {
3566
- var methodName = methods[_i10];
3664
+ for (var _i11 = 0, _len4 = methods.length; _i11 < _len4; _i11 += 1) {
3665
+ var methodName = methods[_i11];
3567
3666
  descriptors[methodName] = {
3568
3667
  value: createMethodCaller(methodName),
3569
3668
  writable: true,
@@ -3691,31 +3790,6 @@ var LWC = (function (exports) {
3691
3790
  return canRefreshAllInstances;
3692
3791
  }
3693
3792
 
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
3793
  function getTemplateOrSwappedTemplate(tpl) {
3720
3794
  if (process.env.NODE_ENV === 'production') {
3721
3795
  // this method should never leak to prod
@@ -4427,6 +4501,7 @@ var LWC = (function (exports) {
4427
4501
  * SPDX-License-Identifier: MIT
4428
4502
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4429
4503
  */
4504
+ // The style property is a string when defined via an expression in the template.
4430
4505
 
4431
4506
 
4432
4507
  function patchStyleAttribute(oldVnode, vnode) {
@@ -4471,6 +4546,7 @@ var LWC = (function (exports) {
4471
4546
  * SPDX-License-Identifier: MIT
4472
4547
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4473
4548
  */
4549
+ // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
4474
4550
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
4475
4551
  // different classnames properties individually instead of via a string.
4476
4552
 
@@ -4495,6 +4571,7 @@ var LWC = (function (exports) {
4495
4571
  * SPDX-License-Identifier: MIT
4496
4572
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4497
4573
  */
4574
+ // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
4498
4575
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
4499
4576
  // different style properties individually instead of via a string.
4500
4577
 
@@ -4507,8 +4584,8 @@ var LWC = (function (exports) {
4507
4584
  return;
4508
4585
  }
4509
4586
 
4510
- for (var _i11 = 0; _i11 < styleDecls.length; _i11++) {
4511
- var _styleDecls$_i = _slicedToArray(styleDecls[_i11], 3),
4587
+ for (var _i12 = 0; _i12 < styleDecls.length; _i12++) {
4588
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i12], 3),
4512
4589
  prop = _styleDecls$_i[0],
4513
4590
  value = _styleDecls$_i[1],
4514
4591
  important = _styleDecls$_i[2];
@@ -4524,146 +4601,262 @@ var LWC = (function (exports) {
4524
4601
  */
4525
4602
 
4526
4603
 
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);
4604
+ function patchChildren(c1, c2, parent) {
4605
+ if (hasDynamicChildren(c2)) {
4606
+ updateDynamicChildren(c1, c2, parent);
4607
+ } else {
4608
+ updateStaticChildren(c1, c2, parent);
4581
4609
  }
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
- */
4610
+ }
4594
4611
 
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;
4612
+ function patch(n1, n2) {
4613
+ if (n1 === n2) {
4614
+ return;
4615
+ }
4602
4616
 
4603
- if (vm) {
4604
- allocateChildren(vnode, vm);
4605
- } else if (vnode.ctor !== UpgradableConstructor) {
4606
- throw new TypeError("Incorrect Component Constructor");
4617
+ if (process.env.NODE_ENV !== 'production') {
4618
+ if (!isSameVnode(n1, n2)) {
4619
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
4620
+ sel: n1.sel,
4621
+ key: n1.key
4622
+ }) + ', ' + JSON.stringify({
4623
+ sel: n2.sel,
4624
+ key: n2.key
4625
+ }));
4607
4626
  }
4627
+ }
4608
4628
 
4609
- patchElementPropsAndAttrs$1(null, vnode);
4610
- },
4611
- update: function update(oldVnode, vnode) {
4612
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4613
- var vm = getAssociatedVMIfPresent(vnode.elm);
4629
+ switch (n2.type) {
4630
+ case 0
4631
+ /* Text */
4632
+ :
4633
+ patchText(n1, n2);
4634
+ break;
4614
4635
 
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
4636
+ case 1
4637
+ /* Comment */
4638
+ :
4639
+ patchComment(n1, n2);
4640
+ break;
4621
4641
 
4642
+ case 2
4643
+ /* Element */
4644
+ :
4645
+ patchElement(n1, n2);
4646
+ break;
4622
4647
 
4623
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4648
+ case 3
4649
+ /* CustomElement */
4650
+ :
4651
+ patchCustomElement(n1, n2);
4652
+ break;
4653
+ }
4654
+ }
4624
4655
 
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.
4656
+ function mount(node, parent, anchor) {
4657
+ switch (node.type) {
4658
+ case 0
4659
+ /* Text */
4660
+ :
4661
+ mountText(node, parent, anchor);
4662
+ break;
4630
4663
 
4664
+ case 1
4665
+ /* Comment */
4666
+ :
4667
+ mountComment(node, parent, anchor);
4668
+ break;
4631
4669
 
4632
- rerenderVM(vm);
4633
- }
4634
- },
4635
- insert: function insert(vnode, parentNode, referenceNode) {
4636
- insertNode(vnode, parentNode, referenceNode);
4637
- var vm = getAssociatedVMIfPresent(vnode.elm);
4670
+ case 2
4671
+ /* Element */
4672
+ :
4673
+ mountElement(node, parent, anchor);
4674
+ break;
4638
4675
 
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
- }
4676
+ case 3
4677
+ /* CustomElement */
4678
+ :
4679
+ mountCustomElement(node, parent, anchor);
4680
+ break;
4681
+ }
4682
+ }
4683
+
4684
+ function patchText(n1, n2) {
4685
+ n2.elm = n1.elm;
4686
+
4687
+ if (n2.text !== n1.text) {
4688
+ updateTextContent(n2);
4689
+ }
4690
+ }
4691
+
4692
+ function mountText(node, parent, anchor) {
4693
+ var owner = node.owner;
4694
+ var textNode = node.elm = createText$1(node.text);
4695
+ linkNodeToShadow(textNode, owner);
4696
+ insertNode(textNode, parent, anchor);
4697
+ }
4698
+
4699
+ function patchComment(n1, n2) {
4700
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
4701
+ // it is the case today.
4702
+
4703
+ if (n2.text !== n1.text) {
4704
+ updateTextContent(n2);
4705
+ }
4706
+ }
4707
+
4708
+ function mountComment(node, parent, anchor) {
4709
+ var owner = node.owner;
4710
+ var commentNode = node.elm = createComment$1(node.text);
4711
+ linkNodeToShadow(commentNode, owner);
4712
+ insertNode(commentNode, parent, anchor);
4713
+ }
4714
+
4715
+ function mountElement(vnode, parent, anchor) {
4716
+ var sel = vnode.sel,
4717
+ owner = vnode.owner,
4718
+ svg = vnode.data.svg;
4719
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4720
+ var elm = createElement$2(sel, namespace);
4721
+ linkNodeToShadow(elm, owner);
4722
+ fallbackElmHook(elm, vnode);
4723
+ vnode.elm = elm;
4724
+ patchElementPropsAndAttrs$1(null, vnode);
4725
+ insertNode(elm, parent, anchor);
4726
+ mountVNodes(vnode.children, elm, null);
4727
+ }
4728
+
4729
+ function patchElement(n1, n2) {
4730
+ var elm = n2.elm = n1.elm;
4731
+ patchElementPropsAndAttrs$1(n1, n2);
4732
+ patchChildren(n1.children, n2.children, elm);
4733
+ }
4734
+
4735
+ function mountCustomElement(vnode, parent, anchor) {
4736
+ var sel = vnode.sel,
4737
+ owner = vnode.owner;
4738
+ var UpgradableConstructor = getUpgradableConstructor(sel);
4739
+ /**
4740
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4741
+ * with a callback as the first argument, we could implement a more advanced
4742
+ * mechanism that only passes that argument if the constructor is known to be
4743
+ * an upgradable custom element.
4744
+ */
4745
+
4746
+ var vm;
4747
+ var elm = new UpgradableConstructor(function (elm) {
4748
+ // the custom element from the registry is expecting an upgrade callback
4749
+ vm = createViewModelHook(elm, vnode);
4750
+ });
4751
+ linkNodeToShadow(elm, owner);
4752
+ vnode.elm = elm;
4753
+ vnode.vm = vm;
4754
+
4755
+ if (vm) {
4756
+ allocateChildren(vnode, vm);
4757
+ } else if (vnode.ctor !== UpgradableConstructor) {
4758
+ throw new TypeError("Incorrect Component Constructor");
4759
+ }
4645
4760
 
4646
- runConnectedCallback(vm);
4761
+ patchElementPropsAndAttrs$1(null, vnode);
4762
+ insertNode(elm, parent, anchor);
4763
+
4764
+ if (vm) {
4765
+ if (process.env.NODE_ENV !== 'production') {
4766
+ assert.isTrue(vm.state === 0
4767
+ /* created */
4768
+ , "".concat(vm, " cannot be recycled."));
4647
4769
  }
4648
4770
 
4649
- createChildrenHook(vnode);
4771
+ runConnectedCallback(vm);
4772
+ }
4773
+
4774
+ mountVNodes(vnode.children, elm, null);
4650
4775
 
4651
- if (vm) {
4652
- appendVM(vm);
4776
+ if (vm) {
4777
+ appendVM(vm);
4778
+ }
4779
+ }
4780
+
4781
+ function patchCustomElement(n1, n2) {
4782
+ var elm = n2.elm = n1.elm;
4783
+ var vm = n2.vm = n1.vm;
4784
+ patchElementPropsAndAttrs$1(n1, n2);
4785
+
4786
+ if (!isUndefined$1(vm)) {
4787
+ // in fallback mode, the allocation will always set children to
4788
+ // empty and delegate the real allocation to the slot elements
4789
+ allocateChildren(n2, vm);
4790
+ } // in fallback mode, the children will be always empty, so, nothing
4791
+ // will happen, but in native, it does allocate the light dom
4792
+
4793
+
4794
+ patchChildren(n1.children, n2.children, elm);
4795
+
4796
+ if (!isUndefined$1(vm)) {
4797
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4798
+ // this is important to preserve the top to bottom synchronous rendering phase.
4799
+ rerenderVM(vm);
4800
+ }
4801
+ }
4802
+
4803
+ function mountVNodes(vnodes, parent, anchor) {
4804
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4805
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
4806
+
4807
+ for (; start < end; ++start) {
4808
+ var vnode = vnodes[start];
4809
+
4810
+ if (isVNode(vnode)) {
4811
+ mount(vnode, parent, anchor);
4653
4812
  }
4654
- },
4655
- move: insertNode,
4656
- remove: function remove(vnode, parentNode) {
4657
- removeNode(vnode, parentNode);
4658
- var vm = getAssociatedVMIfPresent(vnode.elm);
4813
+ }
4814
+ }
4815
+
4816
+ function unmount(vnode, parent) {
4817
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4818
+ var type = vnode.type,
4819
+ elm = vnode.elm; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4820
+ // subtree root, is the only element worth unmounting from the subtree.
4821
+
4822
+ if (doRemove) {
4823
+ removeNode(elm, parent);
4824
+ }
4825
+
4826
+ switch (type) {
4827
+ case 2
4828
+ /* Element */
4829
+ :
4830
+ unmountVNodes(vnode.children, elm);
4831
+ break;
4832
+
4833
+ case 3
4834
+ /* CustomElement */
4835
+ :
4836
+ {
4837
+ var vm = vnode.vm; // No need to unmount the children here, `removeVM` will take care of removing the
4838
+ // children.
4839
+
4840
+ if (!isUndefined$1(vm)) {
4841
+ removeVM(vm);
4842
+ }
4843
+ }
4844
+ }
4845
+ }
4846
+
4847
+ function unmountVNodes(vnodes, parent) {
4848
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4849
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4850
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
4851
+
4852
+ for (; start < end; ++start) {
4853
+ var ch = vnodes[start];
4659
4854
 
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);
4855
+ if (isVNode(ch)) {
4856
+ unmount(ch, parent, doRemove);
4664
4857
  }
4665
4858
  }
4666
- };
4859
+ }
4667
4860
 
4668
4861
  function isVNode(vnode) {
4669
4862
  return vnode != null;
@@ -4704,41 +4897,39 @@ var LWC = (function (exports) {
4704
4897
  }
4705
4898
  }
4706
4899
 
4707
- function updateNodeHook(oldVnode, vnode) {
4900
+ function updateTextContent(vnode) {
4708
4901
  var elm = vnode.elm,
4709
4902
  text = vnode.text;
4710
4903
 
4711
- if (oldVnode.text !== text) {
4712
- if (process.env.NODE_ENV !== 'production') {
4713
- unlockDomMutation();
4714
- }
4904
+ if (process.env.NODE_ENV !== 'production') {
4905
+ unlockDomMutation();
4906
+ }
4715
4907
 
4716
- setText$1(elm, text);
4908
+ setText$1(elm, text);
4717
4909
 
4718
- if (process.env.NODE_ENV !== 'production') {
4719
- lockDomMutation();
4720
- }
4910
+ if (process.env.NODE_ENV !== 'production') {
4911
+ lockDomMutation();
4721
4912
  }
4722
4913
  }
4723
4914
 
4724
- function insertNode(vnode, parentNode, referenceNode) {
4915
+ function insertNode(node, parent, anchor) {
4725
4916
  if (process.env.NODE_ENV !== 'production') {
4726
4917
  unlockDomMutation();
4727
4918
  }
4728
4919
 
4729
- insert$1(vnode.elm, parentNode, referenceNode);
4920
+ insert$1(node, parent, anchor);
4730
4921
 
4731
4922
  if (process.env.NODE_ENV !== 'production') {
4732
4923
  lockDomMutation();
4733
4924
  }
4734
4925
  }
4735
4926
 
4736
- function removeNode(vnode, parentNode) {
4927
+ function removeNode(node, parent) {
4737
4928
  if (process.env.NODE_ENV !== 'production') {
4738
4929
  unlockDomMutation();
4739
4930
  }
4740
4931
 
4741
- remove$1(vnode.elm, parentNode);
4932
+ remove$1(node, parent);
4742
4933
 
4743
4934
  if (process.env.NODE_ENV !== 'production') {
4744
4935
  lockDomMutation();
@@ -4775,11 +4966,13 @@ var LWC = (function (exports) {
4775
4966
  ) {
4776
4967
  // this element will now accept any manual content inserted into it
4777
4968
  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
-
4969
+ }
4781
4970
 
4782
- setElementShadowToken(elm, stylesheetToken);
4971
+ if (!isUndefined$1(stylesheetToken)) {
4972
+ // when running in synthetic shadow mode, we need to set the shadowToken value
4973
+ // into each element from the template, so they can be styled accordingly.
4974
+ setElementShadowToken(elm, stylesheetToken);
4975
+ }
4783
4976
  }
4784
4977
 
4785
4978
  if (process.env.NODE_ENV !== 'production') {
@@ -4797,14 +4990,6 @@ var LWC = (function (exports) {
4797
4990
  }
4798
4991
  }
4799
4992
 
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
4993
  function allocateChildren(vnode, vm) {
4809
4994
  // A component with slots will re-render because:
4810
4995
  // 1- There is a change of the internal state.
@@ -4856,7 +5041,9 @@ var LWC = (function (exports) {
4856
5041
  var stylesheetToken = owner.context.stylesheetToken; // when running in synthetic shadow mode, we need to set the shadowToken value
4857
5042
  // into each element from the template, so they can be styled accordingly.
4858
5043
 
4859
- setElementShadowToken(elm, stylesheetToken);
5044
+ if (!isUndefined$1(stylesheetToken)) {
5045
+ setElementShadowToken(elm, stylesheetToken);
5046
+ }
4860
5047
  }
4861
5048
 
4862
5049
  vm = createVM(elm, ctor, {
@@ -4872,44 +5059,14 @@ var LWC = (function (exports) {
4872
5059
  return vm;
4873
5060
  }
4874
5061
 
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
5062
  function allocateInSlot(vm, children) {
4906
5063
  var _a;
4907
5064
 
4908
5065
  var oldSlots = vm.cmpSlots;
4909
5066
  var cmpSlots = vm.cmpSlots = create(null);
4910
5067
 
4911
- for (var _i12 = 0, _len6 = children.length; _i12 < _len6; _i12 += 1) {
4912
- var vnode = children[_i12];
5068
+ for (var _i13 = 0, _len5 = children.length; _i13 < _len5; _i13 += 1) {
5069
+ var vnode = children[_i13];
4913
5070
 
4914
5071
  if (isNull(vnode)) {
4915
5072
  continue;
@@ -4943,8 +5100,8 @@ var LWC = (function (exports) {
4943
5100
  return;
4944
5101
  }
4945
5102
 
4946
- for (var _i13 = 0, _len7 = oldKeys.length; _i13 < _len7; _i13 += 1) {
4947
- var key = oldKeys[_i13];
5103
+ for (var _i14 = 0, _len6 = oldKeys.length; _i14 < _len6; _i14 += 1) {
5104
+ var key = oldKeys[_i14];
4948
5105
 
4949
5106
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4950
5107
  markComponentAsDirty(vm);
@@ -4994,28 +5151,7 @@ var LWC = (function (exports) {
4994
5151
  return map;
4995
5152
  }
4996
5153
 
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) {
5154
+ function updateDynamicChildren(oldCh, newCh, parent) {
5019
5155
  var oldStartIdx = 0;
5020
5156
  var newStartIdx = 0;
5021
5157
  var oldEndIdx = oldCh.length - 1;
@@ -5029,6 +5165,7 @@ var LWC = (function (exports) {
5029
5165
  var idxInOld;
5030
5166
  var elmToMove;
5031
5167
  var before;
5168
+ var clonedOldCh = false;
5032
5169
 
5033
5170
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
5034
5171
  if (!isVNode(oldStartVnode)) {
@@ -5040,23 +5177,23 @@ var LWC = (function (exports) {
5040
5177
  } else if (!isVNode(newEndVnode)) {
5041
5178
  newEndVnode = newCh[--newEndIdx];
5042
5179
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
5043
- patchVnode(oldStartVnode, newStartVnode);
5180
+ patch(oldStartVnode, newStartVnode);
5044
5181
  oldStartVnode = oldCh[++oldStartIdx];
5045
5182
  newStartVnode = newCh[++newStartIdx];
5046
5183
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
5047
- patchVnode(oldEndVnode, newEndVnode);
5184
+ patch(oldEndVnode, newEndVnode);
5048
5185
  oldEndVnode = oldCh[--oldEndIdx];
5049
5186
  newEndVnode = newCh[--newEndIdx];
5050
5187
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
5051
5188
  // Vnode moved right
5052
- patchVnode(oldStartVnode, newEndVnode);
5053
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5189
+ patch(oldStartVnode, newEndVnode);
5190
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
5054
5191
  oldStartVnode = oldCh[++oldStartIdx];
5055
5192
  newEndVnode = newCh[--newEndIdx];
5056
5193
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
5057
5194
  // Vnode moved left
5058
- patchVnode(oldEndVnode, newStartVnode);
5059
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5195
+ patch(oldEndVnode, newStartVnode);
5196
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
5060
5197
  oldEndVnode = oldCh[--oldEndIdx];
5061
5198
  newStartVnode = newCh[++newStartIdx];
5062
5199
  } else {
@@ -5068,8 +5205,7 @@ var LWC = (function (exports) {
5068
5205
 
5069
5206
  if (isUndefined$1(idxInOld)) {
5070
5207
  // New element
5071
- newStartVnode.hook.create(newStartVnode);
5072
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5208
+ mount(newStartVnode, parent, oldStartVnode.elm);
5073
5209
  newStartVnode = newCh[++newStartIdx];
5074
5210
  } else {
5075
5211
  elmToMove = oldCh[idxInOld];
@@ -5077,12 +5213,22 @@ var LWC = (function (exports) {
5077
5213
  if (isVNode(elmToMove)) {
5078
5214
  if (elmToMove.sel !== newStartVnode.sel) {
5079
5215
  // New element
5080
- newStartVnode.hook.create(newStartVnode);
5081
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5216
+ mount(newStartVnode, parent, oldStartVnode.elm);
5082
5217
  } else {
5083
- patchVnode(elmToMove, newStartVnode);
5218
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5219
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
5220
+ // so we only care about the `oldCh` object inside this function.
5221
+ // To avoid cloning over and over again, we check `clonedOldCh`
5222
+ // and only clone once.
5223
+
5224
+ if (!clonedOldCh) {
5225
+ clonedOldCh = true;
5226
+ oldCh = _toConsumableArray(oldCh);
5227
+ } // We've already cloned at least once, so it's no longer read-only
5228
+
5229
+
5084
5230
  oldCh[idxInOld] = undefined;
5085
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5231
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
5086
5232
  }
5087
5233
  }
5088
5234
 
@@ -5095,73 +5241,63 @@ var LWC = (function (exports) {
5095
5241
  if (oldStartIdx > oldEndIdx) {
5096
5242
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
5097
5243
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
5098
- var _i14 = newEndIdx;
5244
+ var _i15 = newEndIdx;
5099
5245
  var n;
5100
5246
 
5101
5247
  do {
5102
- n = newCh[++_i14];
5103
- } while (!isVNode(n) && _i14 < newChEnd);
5248
+ n = newCh[++_i15];
5249
+ } while (!isVNode(n) && _i15 < newChEnd);
5104
5250
 
5105
5251
  before = isVNode(n) ? n.elm : null;
5106
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5252
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
5107
5253
  } else {
5108
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5254
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
5109
5255
  }
5110
5256
  }
5111
5257
  }
5112
5258
 
5113
- function updateStaticChildren(parentElm, oldCh, newCh) {
5114
- var oldChLength = oldCh.length;
5115
- var newChLength = newCh.length;
5259
+ function updateStaticChildren(c1, c2, parent) {
5260
+ var c1Length = c1.length;
5261
+ var c2Length = c2.length;
5116
5262
 
5117
- if (oldChLength === 0) {
5263
+ if (c1Length === 0) {
5118
5264
  // the old list is empty, we can directly insert anything new
5119
- addVnodes(parentElm, null, newCh, 0, newChLength);
5265
+ mountVNodes(c2, parent, null);
5120
5266
  return;
5121
5267
  }
5122
5268
 
5123
- if (newChLength === 0) {
5269
+ if (c2Length === 0) {
5124
5270
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5125
5271
  // this is the case in which the dynamic children of an if-directive should be removed
5126
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5272
+ unmountVNodes(c1, parent, true);
5127
5273
  return;
5128
5274
  } // if the old list is not empty, the new list MUST have the same
5129
5275
  // amount of nodes, that's why we call this static children
5130
5276
 
5131
5277
 
5132
- var referenceElm = null;
5278
+ var anchor = null;
5133
5279
 
5134
- for (var _i15 = newChLength - 1; _i15 >= 0; _i15 -= 1) {
5135
- var vnode = newCh[_i15];
5136
- var oldVNode = oldCh[_i15];
5280
+ for (var _i16 = c2Length - 1; _i16 >= 0; _i16 -= 1) {
5281
+ var n1 = c1[_i16];
5282
+ var n2 = c2[_i16];
5137
5283
 
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;
5284
+ if (n2 !== n1) {
5285
+ if (isVNode(n1)) {
5286
+ if (isVNode(n2)) {
5287
+ // both vnodes are equivalent, and we just need to patch them
5288
+ patch(n1, n2);
5289
+ anchor = n2.elm;
5144
5290
  } else {
5145
5291
  // removing the old vnode since the new one is null
5146
- oldVNode.hook.remove(oldVNode, parentElm);
5292
+ unmount(n1, parent, true);
5147
5293
  }
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;
5294
+ } else if (isVNode(n2)) {
5295
+ mount(n2, parent, anchor);
5296
+ anchor = n2.elm;
5154
5297
  }
5155
5298
  }
5156
5299
  }
5157
5300
  }
5158
-
5159
- function patchVnode(oldVnode, vnode) {
5160
- if (oldVnode !== vnode) {
5161
- vnode.elm = oldVnode.elm;
5162
- vnode.hook.update(oldVnode, vnode);
5163
- }
5164
- }
5165
5301
  /*
5166
5302
  * Copyright (c) 2018, salesforce.com, inc.
5167
5303
  * All rights reserved.
@@ -5177,7 +5313,8 @@ var LWC = (function (exports) {
5177
5313
  } // [h]tml node
5178
5314
 
5179
5315
 
5180
- function h(sel, data, children) {
5316
+ function h(sel, data) {
5317
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EmptyArray;
5181
5318
  var vmBeingRendered = getVMBeingRendered();
5182
5319
 
5183
5320
  if (process.env.NODE_ENV !== 'production') {
@@ -5211,7 +5348,6 @@ var LWC = (function (exports) {
5211
5348
  children: children,
5212
5349
  elm: elm,
5213
5350
  key: key,
5214
- hook: ElementHook,
5215
5351
  owner: vmBeingRendered
5216
5352
  };
5217
5353
  } // [t]ab[i]ndex function
@@ -5295,7 +5431,7 @@ var LWC = (function (exports) {
5295
5431
  }
5296
5432
 
5297
5433
  var key = data.key;
5298
- var elm;
5434
+ var elm, aChildren, vm;
5299
5435
  var vnode = {
5300
5436
  type: 3
5301
5437
  /* CustomElement */
@@ -5305,11 +5441,11 @@ var LWC = (function (exports) {
5305
5441
  children: children,
5306
5442
  elm: elm,
5307
5443
  key: key,
5308
- hook: CustomElementHook,
5309
5444
  ctor: Ctor,
5310
5445
  owner: vmBeingRendered,
5311
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5312
-
5446
+ mode: 'open',
5447
+ aChildren: aChildren,
5448
+ vm: vm
5313
5449
  };
5314
5450
  addVNodeToChildLWC(vnode);
5315
5451
  return vnode;
@@ -5436,7 +5572,6 @@ var LWC = (function (exports) {
5436
5572
  text: text,
5437
5573
  elm: elm,
5438
5574
  key: key,
5439
- hook: TextHook,
5440
5575
  owner: getVMBeingRendered()
5441
5576
  };
5442
5577
  } // [co]mment node
@@ -5452,7 +5587,6 @@ var LWC = (function (exports) {
5452
5587
  text: text,
5453
5588
  elm: elm,
5454
5589
  key: key,
5455
- hook: CommentHook,
5456
5590
  owner: getVMBeingRendered()
5457
5591
  };
5458
5592
  } // [d]ynamic text
@@ -5565,7 +5699,9 @@ var LWC = (function (exports) {
5565
5699
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5566
5700
  */
5567
5701
 
5568
- function dc(sel, Ctor, data, children) {
5702
+ function dc(sel, Ctor, data) {
5703
+ var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : EmptyArray;
5704
+
5569
5705
  if (process.env.NODE_ENV !== 'production') {
5570
5706
  assert.isTrue(isString(sel), "dc() 1st argument sel must be a string.");
5571
5707
  assert.isTrue(isObject(data), "dc() 3nd argument data must be an object.");
@@ -5589,10 +5725,14 @@ var LWC = (function (exports) {
5589
5725
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
5590
5726
  // to identify different constructors as vnodes with different keys to avoid reusing the
5591
5727
  // element used for previous constructors.
5728
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
5729
+ // hoisting optimization.
5592
5730
 
5593
5731
 
5594
- data.key = "dc:".concat(idx, ":").concat(data.key);
5595
- return c(sel, Ctor, data, children);
5732
+ var newData = Object.assign(Object.assign({}, data), {
5733
+ key: "dc:".concat(idx, ":").concat(data.key)
5734
+ });
5735
+ return c(sel, Ctor, newData, children);
5596
5736
  }
5597
5737
  /**
5598
5738
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5704,12 +5844,14 @@ var LWC = (function (exports) {
5704
5844
  oldHasTokenInClass = context.hasTokenInClass,
5705
5845
  oldHasTokenInAttribute = context.hasTokenInAttribute;
5706
5846
 
5707
- if (oldHasTokenInClass) {
5708
- getClassList$1(elm).remove(makeHostToken(oldToken));
5709
- }
5847
+ if (!isUndefined$1(oldToken)) {
5848
+ if (oldHasTokenInClass) {
5849
+ getClassList$1(elm).remove(makeHostToken(oldToken));
5850
+ }
5710
5851
 
5711
- if (oldHasTokenInAttribute) {
5712
- removeAttribute$1(elm, makeHostToken(oldToken));
5852
+ if (oldHasTokenInAttribute) {
5853
+ removeAttribute$1(elm, makeHostToken(oldToken));
5854
+ }
5713
5855
  } // Apply the new template styling token to the host element, if the new template has any
5714
5856
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
5715
5857
 
@@ -5741,16 +5883,18 @@ var LWC = (function (exports) {
5741
5883
  var content = [];
5742
5884
  var root;
5743
5885
 
5744
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5745
- var stylesheet = stylesheets[_i16];
5886
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5887
+ var stylesheet = stylesheets[_i17];
5746
5888
 
5747
5889
  if (isArray$1(stylesheet)) {
5748
5890
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
5749
5891
  } else {
5750
5892
  if (process.env.NODE_ENV !== 'production') {
5751
- // in dev-mode, we support hot swapping of stylesheet, which means that
5893
+ // Check for compiler version mismatch in dev mode only
5894
+ checkVersionMismatch(stylesheet, 'stylesheet'); // in dev-mode, we support hot swapping of stylesheet, which means that
5752
5895
  // the component instance might be attempting to use an old version of
5753
5896
  // the stylesheet, while internally, we have a replacement for it.
5897
+
5754
5898
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5755
5899
  }
5756
5900
 
@@ -5852,8 +5996,8 @@ var LWC = (function (exports) {
5852
5996
  && shadowMode === 1
5853
5997
  /* Synthetic */
5854
5998
  ) {
5855
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5856
- insertGlobalStylesheet$1(stylesheets[_i17]);
5999
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
6000
+ insertGlobalStylesheet$1(stylesheets[_i18]);
5857
6001
  }
5858
6002
  } else if (ssr$1 || isHydrating$1()) {
5859
6003
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -5867,12 +6011,12 @@ var LWC = (function (exports) {
5867
6011
  var root = getNearestNativeShadowComponent(vm);
5868
6012
  var isGlobal = isNull(root);
5869
6013
 
5870
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
6014
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
5871
6015
  if (isGlobal) {
5872
- insertGlobalStylesheet$1(stylesheets[_i18]);
6016
+ insertGlobalStylesheet$1(stylesheets[_i19]);
5873
6017
  } else {
5874
6018
  // local level
5875
- insertStylesheet$1(stylesheets[_i18], root.shadowRoot);
6019
+ insertStylesheet$1(stylesheets[_i19], root.shadowRoot);
5876
6020
  }
5877
6021
  }
5878
6022
  }
@@ -6149,8 +6293,8 @@ var LWC = (function (exports) {
6149
6293
  var stylesheets = template.stylesheets;
6150
6294
 
6151
6295
  if (!isUndefined$1(stylesheets)) {
6152
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6153
- if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
6296
+ for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
6297
+ if (isTrue(stylesheets[_i20][KEY__SCOPED_CSS])) {
6154
6298
  return true;
6155
6299
  }
6156
6300
  }
@@ -6277,6 +6421,11 @@ var LWC = (function (exports) {
6277
6421
 
6278
6422
  function registerComponent(Ctor, _ref2) {
6279
6423
  var tmpl = _ref2.tmpl;
6424
+
6425
+ if (process.env.NODE_ENV !== 'production') {
6426
+ checkVersionMismatch(Ctor, 'component');
6427
+ }
6428
+
6280
6429
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6281
6430
  // without too much transformation
6282
6431
 
@@ -6362,8 +6511,8 @@ var LWC = (function (exports) {
6362
6511
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6363
6512
  }
6364
6513
 
6365
- for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6366
- var hookName = hooks[_i20];
6514
+ for (var _i21 = 0; _i21 < hooks.length; ++_i21) {
6515
+ var hookName = hooks[_i21];
6367
6516
 
6368
6517
  if (hookName in service) {
6369
6518
  var l = Services[hookName];
@@ -6386,8 +6535,8 @@ var LWC = (function (exports) {
6386
6535
  def = vm.def,
6387
6536
  context = vm.context;
6388
6537
 
6389
- for (var _i21 = 0, _len8 = cbs.length; _i21 < _len8; ++_i21) {
6390
- cbs[_i21].call(undefined, component, {}, def, context);
6538
+ for (var _i22 = 0, _len7 = cbs.length; _i22 < _len7; ++_i22) {
6539
+ cbs[_i22].call(undefined, component, {}, def, context);
6391
6540
  }
6392
6541
  }
6393
6542
  /*
@@ -6398,7 +6547,7 @@ var LWC = (function (exports) {
6398
6547
  */
6399
6548
 
6400
6549
 
6401
- function hydrate$1(vnode, node) {
6550
+ function hydrate(vnode, node) {
6402
6551
  switch (vnode.type) {
6403
6552
  case 0
6404
6553
  /* Text */
@@ -6430,16 +6579,18 @@ var LWC = (function (exports) {
6430
6579
  var _a;
6431
6580
 
6432
6581
  if (process.env.NODE_ENV !== 'production') {
6433
- // eslint-disable-next-line lwc-internal/no-global-node
6434
- validateNodeType(vnode, node, Node.TEXT_NODE);
6582
+ validateNodeType(vnode, node, 3
6583
+ /* TEXT */
6584
+ );
6585
+ var nodeValue = getProperty$1(node, 'nodeValue');
6435
6586
 
6436
- if (node.nodeValue !== vnode.text && !(node.nodeValue === "\u200D" && vnode.text === '')) {
6587
+ if (nodeValue !== vnode.text && !(nodeValue === "\u200D" && vnode.text === '')) {
6437
6588
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6438
6589
  }
6439
6590
  } // always set the text value to the one from the vnode.
6440
6591
 
6441
6592
 
6442
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6593
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6443
6594
  vnode.elm = node;
6444
6595
  }
6445
6596
 
@@ -6447,23 +6598,25 @@ var LWC = (function (exports) {
6447
6598
  var _a;
6448
6599
 
6449
6600
  if (process.env.NODE_ENV !== 'production') {
6450
- // eslint-disable-next-line lwc-internal/no-global-node
6451
- validateNodeType(vnode, node, Node.COMMENT_NODE);
6601
+ validateNodeType(vnode, node, 8
6602
+ /* COMMENT */
6603
+ );
6452
6604
 
6453
- if (node.nodeValue !== vnode.text) {
6605
+ if (getProperty$1(node, 'nodeValue') !== vnode.text) {
6454
6606
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6455
6607
  }
6456
6608
  } // always set the text value to the one from the vnode.
6457
6609
 
6458
6610
 
6459
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6611
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6460
6612
  vnode.elm = node;
6461
6613
  }
6462
6614
 
6463
6615
  function hydrateElement(vnode, node) {
6464
6616
  if (process.env.NODE_ENV !== 'production') {
6465
- // eslint-disable-next-line lwc-internal/no-global-node
6466
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6617
+ validateNodeType(vnode, node, 1
6618
+ /* ELEMENT */
6619
+ );
6467
6620
  validateElement(vnode, node);
6468
6621
  }
6469
6622
 
@@ -6480,10 +6633,13 @@ var LWC = (function (exports) {
6480
6633
  var props = vnode.data.props;
6481
6634
 
6482
6635
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6483
- if (elm.innerHTML === props.innerHTML) {
6484
- delete props.innerHTML;
6636
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6637
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6638
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
6639
+ props: cloneAndOmitKey(props, 'innerHTML')
6640
+ });
6485
6641
  } else {
6486
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6642
+ 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
6643
  }
6488
6644
  }
6489
6645
  }
@@ -6491,19 +6647,19 @@ var LWC = (function (exports) {
6491
6647
  patchElementPropsAndAttrs(vnode);
6492
6648
 
6493
6649
  if (!isDomManual) {
6494
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
6650
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
6495
6651
  }
6496
6652
  }
6497
6653
 
6498
6654
  function hydrateCustomElement(vnode, node) {
6499
6655
  if (process.env.NODE_ENV !== 'production') {
6500
- // eslint-disable-next-line lwc-internal/no-global-node
6501
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6656
+ validateNodeType(vnode, node, 1
6657
+ /* ELEMENT */
6658
+ );
6502
6659
  validateElement(vnode, node);
6503
6660
  }
6504
6661
 
6505
6662
  var elm = node;
6506
- vnode.elm = elm;
6507
6663
  var sel = vnode.sel,
6508
6664
  mode = vnode.mode,
6509
6665
  ctor = vnode.ctor,
@@ -6513,6 +6669,8 @@ var LWC = (function (exports) {
6513
6669
  owner: owner,
6514
6670
  tagName: sel
6515
6671
  });
6672
+ vnode.elm = elm;
6673
+ vnode.vm = vm;
6516
6674
  allocateChildren(vnode, vm);
6517
6675
  patchElementPropsAndAttrs(vnode); // Insert hook section:
6518
6676
 
@@ -6529,7 +6687,7 @@ var LWC = (function (exports) {
6529
6687
  ) {
6530
6688
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6531
6689
  // Note: for Light DOM, this is handled while hydrating the VM
6532
- hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
6690
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vm);
6533
6691
  }
6534
6692
 
6535
6693
  hydrateVM(vm);
@@ -6549,12 +6707,12 @@ var LWC = (function (exports) {
6549
6707
 
6550
6708
  var childNodeIndex = 0;
6551
6709
 
6552
- for (var _i22 = 0; _i22 < children.length; _i22++) {
6553
- var childVnode = children[_i22];
6710
+ for (var _i23 = 0; _i23 < children.length; _i23++) {
6711
+ var childVnode = children[_i23];
6554
6712
 
6555
6713
  if (!isNull(childVnode)) {
6556
6714
  var childNode = elmChildren[childNodeIndex];
6557
- hydrate$1(childVnode, childNode);
6715
+ hydrate(childVnode, childNode);
6558
6716
  childNodeIndex++;
6559
6717
  }
6560
6718
  }
@@ -6570,15 +6728,15 @@ var LWC = (function (exports) {
6570
6728
  }
6571
6729
 
6572
6730
  function validateNodeType(vnode, node, nodeType) {
6573
- if (node.nodeType !== nodeType) {
6731
+ if (getProperty$1(node, 'nodeType') !== nodeType) {
6574
6732
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
6575
6733
  assert.fail('Hydration mismatch: incorrect node type received.');
6576
6734
  }
6577
6735
  }
6578
6736
 
6579
6737
  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);
6738
+ if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
6739
+ logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(getProperty$1(elm, 'tagName').toLowerCase(), "\"."), vnode.owner);
6582
6740
  throwHydrationError();
6583
6741
  }
6584
6742
 
@@ -6598,15 +6756,15 @@ var LWC = (function (exports) {
6598
6756
  var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
6599
6757
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6600
6758
 
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),
6759
+ for (var _i24 = 0, _Object$entries = Object.entries(attrs); _i24 < _Object$entries.length; _i24++) {
6760
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i24], 2),
6603
6761
  attrName = _Object$entries$_i[0],
6604
6762
  attrValue = _Object$entries$_i[1];
6605
6763
 
6606
6764
  var elmAttrValue = getAttribute$1(elm, attrName);
6607
6765
 
6608
6766
  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);
6767
+ 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
6768
  nodesAreCompatible = false;
6611
6769
  }
6612
6770
  }
@@ -6621,7 +6779,7 @@ var LWC = (function (exports) {
6621
6779
  var nodesAreCompatible = true;
6622
6780
  var vnodeClassName;
6623
6781
 
6624
- if (!isUndefined$1(className) && String(className) !== elm.className) {
6782
+ if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6625
6783
  // className is used when class is bound to an expr.
6626
6784
  nodesAreCompatible = false;
6627
6785
  vnodeClassName = className;
@@ -6646,7 +6804,7 @@ var LWC = (function (exports) {
6646
6804
  }
6647
6805
 
6648
6806
  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);
6807
+ 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
6808
  }
6651
6809
 
6652
6810
  return nodesAreCompatible;
@@ -6667,8 +6825,8 @@ var LWC = (function (exports) {
6667
6825
  var parsedVnodeStyle = parseStyleText(elmStyle);
6668
6826
  var expectedStyle = []; // styleMap is used when style is set to static value.
6669
6827
 
6670
- for (var _i24 = 0, n = styleDecls.length; _i24 < n; _i24++) {
6671
- var _styleDecls$_i2 = _slicedToArray(styleDecls[_i24], 3),
6828
+ for (var _i25 = 0, n = styleDecls.length; _i25 < n; _i25++) {
6829
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i25], 3),
6672
6830
  prop = _styleDecls$_i2[0],
6673
6831
  value = _styleDecls$_i2[1],
6674
6832
  important = _styleDecls$_i2[2];
@@ -6694,7 +6852,7 @@ var LWC = (function (exports) {
6694
6852
 
6695
6853
  if (!nodesAreCompatible) {
6696
6854
  // 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);
6855
+ 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
6856
  }
6699
6857
 
6700
6858
  return nodesAreCompatible;
@@ -6765,7 +6923,19 @@ var LWC = (function (exports) {
6765
6923
  }
6766
6924
 
6767
6925
  function hydrateVM(vm) {
6768
- hydrate(vm);
6926
+ if (isTrue(vm.isDirty)) {
6927
+ // manually diffing/patching here.
6928
+ // This routine is:
6929
+ // patchShadowRoot(vm, children);
6930
+ // -> addVnodes.
6931
+ var children = renderComponent(vm);
6932
+ vm.children = children;
6933
+ var vmChildren = vm.renderMode === 0
6934
+ /* Light */
6935
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
6936
+ hydrateChildren(vmChildren, children, vm);
6937
+ runRenderedCallback(vm);
6938
+ }
6769
6939
  } // just in case the component comes back, with this we guarantee re-rendering it
6770
6940
  // while preventing any attempt to rehydration until after reinsertion.
6771
6941
 
@@ -6908,30 +7078,38 @@ var LWC = (function (exports) {
6908
7078
  /* Native */
6909
7079
  ;
6910
7080
  } else if (isNativeShadowDefined$1) {
6911
- if (def.shadowSupportMode === "any"
6912
- /* Any */
6913
- ) {
6914
- shadowMode = 0
6915
- /* Native */
6916
- ;
6917
- } else {
6918
- var shadowAncestor = getNearestShadowAncestor(vm);
6919
-
6920
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
6921
- /* Native */
7081
+ // Not combined with above condition because @lwc/features only supports identifiers in
7082
+ // the if-condition.
7083
+ if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
7084
+ if (def.shadowSupportMode === "any"
7085
+ /* Any */
6922
7086
  ) {
6923
- // Transitive support for native Shadow DOM. A component in native mode
6924
- // transitively opts all of its descendants into native.
6925
7087
  shadowMode = 0
6926
7088
  /* Native */
6927
7089
  ;
6928
7090
  } else {
6929
- // Synthetic if neither this component nor any of its ancestors are configured
6930
- // to be native.
6931
- shadowMode = 1
6932
- /* Synthetic */
6933
- ;
7091
+ var shadowAncestor = getNearestShadowAncestor(vm);
7092
+
7093
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
7094
+ /* Native */
7095
+ ) {
7096
+ // Transitive support for native Shadow DOM. A component in native mode
7097
+ // transitively opts all of its descendants into native.
7098
+ shadowMode = 0
7099
+ /* Native */
7100
+ ;
7101
+ } else {
7102
+ // Synthetic if neither this component nor any of its ancestors are configured
7103
+ // to be native.
7104
+ shadowMode = 1
7105
+ /* Synthetic */
7106
+ ;
7107
+ }
6934
7108
  }
7109
+ } else {
7110
+ shadowMode = 1
7111
+ /* Synthetic */
7112
+ ;
6935
7113
  }
6936
7114
  } else {
6937
7115
  // Synthetic if there is no native Shadow DOM support.
@@ -6988,22 +7166,6 @@ var LWC = (function (exports) {
6988
7166
  }
6989
7167
  }
6990
7168
 
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
7169
  function patchShadowRoot(vm, newCh) {
7008
7170
  var renderRoot = vm.renderRoot,
7009
7171
  oldCh = vm.children; // caching the new children collection
@@ -7021,7 +7183,7 @@ var LWC = (function (exports) {
7021
7183
  , vm);
7022
7184
  }, function () {
7023
7185
  // job
7024
- patchChildren(renderRoot, oldCh, newCh);
7186
+ patchChildren(oldCh, newCh, renderRoot);
7025
7187
  }, function () {
7026
7188
  // post
7027
7189
  logOperationEnd(2
@@ -7082,19 +7244,19 @@ var LWC = (function (exports) {
7082
7244
  });
7083
7245
  rehydrateQueue = []; // reset to a new queue
7084
7246
 
7085
- for (var _i25 = 0, _len9 = vms.length; _i25 < _len9; _i25 += 1) {
7086
- var vm = vms[_i25];
7247
+ for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
7248
+ var vm = vms[_i26];
7087
7249
 
7088
7250
  try {
7089
7251
  rehydrate(vm);
7090
7252
  } catch (error) {
7091
- if (_i25 + 1 < _len9) {
7253
+ if (_i26 + 1 < _len8) {
7092
7254
  // pieces of the queue are still pending to be rehydrated, those should have priority
7093
7255
  if (rehydrateQueue.length === 0) {
7094
7256
  addCallbackToNextTick(flushRehydrationQueue);
7095
7257
  }
7096
7258
 
7097
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i25 + 1));
7259
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i26 + 1));
7098
7260
  } // we need to end the measure before throwing.
7099
7261
 
7100
7262
 
@@ -7198,8 +7360,8 @@ var LWC = (function (exports) {
7198
7360
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
7199
7361
  // inserted in reserved order.
7200
7362
 
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:
7363
+ for (var _i27 = vCustomElementCollection.length - 1; _i27 >= 0; _i27 -= 1) {
7364
+ var elm = vCustomElementCollection[_i27].elm; // There are two cases where the element could be undefined:
7203
7365
  // * when there is an error during the construction phase, and an error
7204
7366
  // boundary picks it, there is a possibility that the VCustomElement
7205
7367
  // is not properly initialized, and therefore is should be ignored.
@@ -7233,8 +7395,8 @@ var LWC = (function (exports) {
7233
7395
 
7234
7396
 
7235
7397
  function recursivelyDisconnectChildren(vnodes) {
7236
- for (var _i27 = 0, _len10 = vnodes.length; _i27 < _len10; _i27 += 1) {
7237
- var vnode = vnodes[_i27];
7398
+ for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
7399
+ var vnode = vnodes[_i28];
7238
7400
 
7239
7401
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
7240
7402
  switch (vnode.type) {
@@ -7265,8 +7427,8 @@ var LWC = (function (exports) {
7265
7427
  var children = vm.children,
7266
7428
  renderRoot = vm.renderRoot;
7267
7429
 
7268
- for (var _i28 = 0, _len11 = children.length; _i28 < _len11; _i28++) {
7269
- var child = children[_i28];
7430
+ for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
7431
+ var child = children[_i29];
7270
7432
 
7271
7433
  if (!isNull(child) && !isUndefined$1(child.elm)) {
7272
7434
  remove$1(child.elm, renderRoot);
@@ -7640,8 +7802,8 @@ var LWC = (function (exports) {
7640
7802
  function connectWireAdapters(vm) {
7641
7803
  var wiredConnecting = vm.context.wiredConnecting;
7642
7804
 
7643
- for (var _i29 = 0, _len12 = wiredConnecting.length; _i29 < _len12; _i29 += 1) {
7644
- wiredConnecting[_i29]();
7805
+ for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
7806
+ wiredConnecting[_i30]();
7645
7807
  }
7646
7808
  }
7647
7809
 
@@ -7649,8 +7811,8 @@ var LWC = (function (exports) {
7649
7811
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7650
7812
  runWithBoundaryProtection(vm, vm, noop, function () {
7651
7813
  // job
7652
- for (var _i30 = 0, _len13 = wiredDisconnecting.length; _i30 < _len13; _i30 += 1) {
7653
- wiredDisconnecting[_i30]();
7814
+ for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
7815
+ wiredDisconnecting[_i31]();
7654
7816
  }
7655
7817
  }, noop);
7656
7818
  }
@@ -7660,6 +7822,7 @@ var LWC = (function (exports) {
7660
7822
  * SPDX-License-Identifier: MIT
7661
7823
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7662
7824
  */
7825
+ // this is lwc internal implementation
7663
7826
 
7664
7827
 
7665
7828
  function createContextProvider(adapter) {
@@ -7740,7 +7903,7 @@ var LWC = (function (exports) {
7740
7903
  hooksAreSet = true;
7741
7904
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7742
7905
  }
7743
- /* version: 2.8.0 */
7906
+ /* version: 2.11.0 */
7744
7907
 
7745
7908
  /*
7746
7909
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7755,8 +7918,8 @@ var LWC = (function (exports) {
7755
7918
  if (process.env.NODE_ENV === 'development') {
7756
7919
  // @ts-ignore
7757
7920
  window.__lwcResetGlobalStylesheets = function () {
7758
- for (var _i31 = 0, _Object$keys = Object.keys(globalStylesheets); _i31 < _Object$keys.length; _i31++) {
7759
- var key = _Object$keys[_i31];
7921
+ for (var _i32 = 0, _Object$keys2 = Object.keys(globalStylesheets); _i32 < _Object$keys2.length; _i32++) {
7922
+ var key = _Object$keys2[_i32];
7760
7923
  delete globalStylesheets[key];
7761
7924
  }
7762
7925
  };
@@ -7767,9 +7930,10 @@ var LWC = (function (exports) {
7767
7930
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7768
7931
 
7769
7932
  var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7933
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
7770
7934
  var styleElements = create(null);
7771
7935
  var styleSheets = create(null);
7772
- var nodesToStyleSheets = new WeakMap();
7936
+ var shadowRootsToStyleSheets = new WeakMap();
7773
7937
  var getCustomElement;
7774
7938
  var defineCustomElement;
7775
7939
  var HTMLElementConstructor;
@@ -7821,18 +7985,26 @@ var LWC = (function (exports) {
7821
7985
  styleSheets[content] = styleSheet;
7822
7986
  }
7823
7987
 
7824
- if (!target.adoptedStyleSheets.includes(styleSheet)) {
7825
- target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
7988
+ var adoptedStyleSheets = target.adoptedStyleSheets;
7989
+
7990
+ if (!adoptedStyleSheets.includes(styleSheet)) {
7991
+ if (supportsMutableAdoptedStyleSheets) {
7992
+ // This is only supported in later versions of Chromium:
7993
+ // https://chromestatus.com/feature/5638996492288000
7994
+ adoptedStyleSheets.push(styleSheet);
7995
+ } else {
7996
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(adoptedStyleSheets), [styleSheet]);
7997
+ }
7826
7998
  }
7827
7999
  }
7828
8000
 
7829
8001
  function insertStyleElement(content, target) {
7830
8002
  // Avoid inserting duplicate `<style>`s
7831
- var sheets = nodesToStyleSheets.get(target);
8003
+ var sheets = shadowRootsToStyleSheets.get(target);
7832
8004
 
7833
8005
  if (isUndefined$1(sheets)) {
7834
8006
  sheets = create(null);
7835
- nodesToStyleSheets.set(target, sheets);
8007
+ shadowRootsToStyleSheets.set(target, sheets);
7836
8008
  }
7837
8009
 
7838
8010
  if (sheets[content]) {
@@ -8122,6 +8294,177 @@ var LWC = (function (exports) {
8122
8294
  setSetText(setText);
8123
8295
  setSsr(ssr);
8124
8296
  setAddEventListener(addEventListener);
8297
+ /*
8298
+ * Copyright (c) 2018, salesforce.com, inc.
8299
+ * All rights reserved.
8300
+ * SPDX-License-Identifier: MIT
8301
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8302
+ */
8303
+
8304
+ function resetShadowRootAndLightDom(element, Ctor) {
8305
+ if (element.shadowRoot) {
8306
+ var shadowRoot = element.shadowRoot;
8307
+
8308
+ while (!isNull(shadowRoot.firstChild)) {
8309
+ shadowRoot.removeChild(shadowRoot.firstChild);
8310
+ }
8311
+ }
8312
+
8313
+ if (Ctor.renderMode === 'light') {
8314
+ while (!isNull(element.firstChild)) {
8315
+ element.removeChild(element.firstChild);
8316
+ }
8317
+ }
8318
+ }
8319
+
8320
+ function createVMWithProps(element, Ctor, props) {
8321
+ createVM(element, Ctor, {
8322
+ mode: 'open',
8323
+ owner: null,
8324
+ tagName: element.tagName.toLowerCase()
8325
+ });
8326
+
8327
+ for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
8328
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
8329
+ key = _Object$entries2$_i[0],
8330
+ value = _Object$entries2$_i[1];
8331
+
8332
+ element[key] = value;
8333
+ }
8334
+ }
8335
+
8336
+ function hydrateComponent(element, Ctor) {
8337
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8338
+
8339
+ if (!(element instanceof Element)) {
8340
+ throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
8341
+ }
8342
+
8343
+ if (!isFunction$1(Ctor)) {
8344
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8345
+ }
8346
+
8347
+ if (!isObject(props) || isNull(props)) {
8348
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8349
+ }
8350
+
8351
+ if (getAssociatedVMIfPresent(element)) {
8352
+ /* eslint-disable-next-line no-console */
8353
+ console.warn("\"hydrateComponent\" expects an element that is not hydrated.", element);
8354
+ return;
8355
+ }
8356
+
8357
+ try {
8358
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8359
+ // and uses the same algo to create the stylesheets as in SSR.
8360
+ setIsHydrating(true);
8361
+ createVMWithProps(element, Ctor, props);
8362
+ hydrateRootElement(element); // set it back since now we finished hydration.
8363
+
8364
+ setIsHydrating(false);
8365
+ } catch (e) {
8366
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
8367
+ // with the client generated DOM.
8368
+
8369
+ /* eslint-disable-next-line no-console */
8370
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
8371
+
8372
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
8373
+
8374
+ createVMWithProps(element, Ctor, props);
8375
+ setIsHydrating(false);
8376
+ connectRootElement(element);
8377
+ } finally {
8378
+ // in case there's an error during recovery
8379
+ setIsHydrating(false);
8380
+ }
8381
+ }
8382
+ /*
8383
+ * Copyright (c) 2018, salesforce.com, inc.
8384
+ * All rights reserved.
8385
+ * SPDX-License-Identifier: MIT
8386
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8387
+ */
8388
+
8389
+ /**
8390
+ * This function builds a Web Component class from a LWC constructor so it can be
8391
+ * registered as a new element via customElements.define() at any given time.
8392
+ *
8393
+ * @deprecated since version 1.3.11
8394
+ *
8395
+ * @example
8396
+ * ```
8397
+ * import { buildCustomElementConstructor } from 'lwc';
8398
+ * import Foo from 'ns/foo';
8399
+ * const WC = buildCustomElementConstructor(Foo);
8400
+ * customElements.define('x-foo', WC);
8401
+ * const elm = document.createElement('x-foo');
8402
+ * ```
8403
+ */
8404
+
8405
+
8406
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8407
+ if (process.env.NODE_ENV !== 'production') {
8408
+ /* eslint-disable-next-line no-console */
8409
+ 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."));
8410
+ }
8411
+
8412
+ return Ctor.CustomElementConstructor;
8413
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
8414
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
8415
+
8416
+
8417
+ var hydratedCustomElements = new WeakSet();
8418
+
8419
+ function buildCustomElementConstructor(Ctor) {
8420
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8421
+ return /*#__PURE__*/function (_HtmlPrototype) {
8422
+ _inherits(_class, _HtmlPrototype);
8423
+
8424
+ var _super8 = _createSuper(_class);
8425
+
8426
+ function _class() {
8427
+ var _this6;
8428
+
8429
+ _classCallCheck(this, _class);
8430
+
8431
+ _this6 = _super8.call(this);
8432
+
8433
+ if (_this6.isConnected) {
8434
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
8435
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
8436
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
8437
+ } else {
8438
+ createVM(_assertThisInitialized(_this6), Ctor, {
8439
+ mode: 'open',
8440
+ owner: null,
8441
+ tagName: _this6.tagName
8442
+ });
8443
+ }
8444
+
8445
+ return _this6;
8446
+ }
8447
+
8448
+ _createClass(_class, [{
8449
+ key: "connectedCallback",
8450
+ value: function connectedCallback() {
8451
+ if (hydratedCustomElements.has(this)) {
8452
+ // This is an un-upgraded element that was hydrated in the constructor.
8453
+ hydratedCustomElements.delete(this);
8454
+ } else {
8455
+ connectRootElement(this);
8456
+ }
8457
+ }
8458
+ }, {
8459
+ key: "disconnectedCallback",
8460
+ value: function disconnectedCallback() {
8461
+ disconnectRootElement(this);
8462
+ }
8463
+ }]);
8464
+
8465
+ return _class;
8466
+ }(HtmlPrototype);
8467
+ }
8125
8468
  /*
8126
8469
  * Copyright (c) 2018, salesforce.com, inc.
8127
8470
  * All rights reserved.
@@ -8131,6 +8474,7 @@ var LWC = (function (exports) {
8131
8474
  // TODO [#2472]: Remove this workaround when appropriate.
8132
8475
  // eslint-disable-next-line lwc-internal/no-global-node
8133
8476
 
8477
+
8134
8478
  var _Node$1 = Node;
8135
8479
  var ConnectingSlot = new WeakMap();
8136
8480
  var DisconnectingSlot = new WeakMap();
@@ -8238,142 +8582,6 @@ var LWC = (function (exports) {
8238
8582
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8239
8583
  */
8240
8584
 
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
8585
  /**
8378
8586
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
8379
8587
  * This API is subject to change or being removed.
@@ -8405,30 +8613,31 @@ var LWC = (function (exports) {
8405
8613
 
8406
8614
  var _Node = Node;
8407
8615
  /**
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.
8616
+ * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
8617
+ * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
8410
8618
  */
8411
8619
 
8412
- function isNodeFromTemplate(node) {
8620
+ function isNodeShadowed(node) {
8413
8621
  if (isFalse(node instanceof _Node)) {
8414
8622
  return false;
8415
- } // TODO [#1250]: skipping the shadowRoot instances itself makes no sense, we need to revisit
8416
- // this with locker
8623
+ } // It's debatable whether shadow root instances should be considered as shadowed, but we keep
8624
+ // this unchanged for legacy reasons (#1250).
8417
8625
 
8418
8626
 
8419
8627
  if (node instanceof ShadowRoot) {
8420
8628
  return false;
8421
8629
  }
8422
8630
 
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
- }
8631
+ var rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
8632
+ // synthetic roots cannot be descendants of native roots.
8633
+
8634
+ if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
8635
+ return true;
8636
+ } // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
8637
+ // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
8638
+
8429
8639
 
8430
- var root = node.getRootNode();
8431
- return root instanceof ShadowRoot;
8640
+ return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
8432
8641
  }
8433
8642
  /*
8434
8643
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8472,7 +8681,7 @@ var LWC = (function (exports) {
8472
8681
  });
8473
8682
  freeze(LightningElement);
8474
8683
  seal(LightningElement.prototype);
8475
- /* version: 2.8.0 */
8684
+ /* version: 2.11.0 */
8476
8685
 
8477
8686
  exports.LightningElement = LightningElement;
8478
8687
  exports.__unstable__ProfilerControl = profilerControl;
@@ -8484,7 +8693,7 @@ var LWC = (function (exports) {
8484
8693
  exports.getComponentDef = getComponentDef;
8485
8694
  exports.hydrateComponent = hydrateComponent;
8486
8695
  exports.isComponentConstructor = isComponentConstructor;
8487
- exports.isNodeFromTemplate = isNodeFromTemplate;
8696
+ exports.isNodeFromTemplate = isNodeShadowed;
8488
8697
  exports.readonly = readonly;
8489
8698
  exports.register = register;
8490
8699
  exports.registerComponent = registerComponent;