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