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
@@ -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.8.0 */
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.11.0";
367
+ var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
368
+ /** version: 2.11.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,
464
471
  ENABLE_ELEMENT_PATCH: null,
465
472
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
466
- ENABLE_NODE_LIST_PATCH: null,
473
+ ENABLE_HMR: null,
467
474
  ENABLE_HTML_COLLECTIONS_PATCH: null,
475
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
476
+ ENABLE_MIXED_SHADOW_MODE: 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.8.0 */
546
+ /** version: 2.11.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
 
@@ -1115,6 +1166,7 @@
1115
1166
  * SPDX-License-Identifier: MIT
1116
1167
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1117
1168
  */
1169
+ // These properties get added to LWCElement.prototype publicProps automatically
1118
1170
 
1119
1171
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1120
1172
 
@@ -2749,7 +2801,7 @@
2749
2801
 
2750
2802
 
2751
2803
  var _loop = function _loop() {
2752
- var childGetter = _childGetters[_i6];
2804
+ var childGetter = _childGetters[_i7];
2753
2805
  queryAndChildGetterDescriptors[childGetter] = {
2754
2806
  get: function get() {
2755
2807
  var vm = getAssociatedVM(this);
@@ -2766,7 +2818,7 @@
2766
2818
  };
2767
2819
  };
2768
2820
 
2769
- for (var _i6 = 0, _childGetters = childGetters; _i6 < _childGetters.length; _i6++) {
2821
+ for (var _i7 = 0, _childGetters = childGetters; _i7 < _childGetters.length; _i7++) {
2770
2822
  _loop();
2771
2823
  }
2772
2824
 
@@ -2790,7 +2842,7 @@
2790
2842
 
2791
2843
 
2792
2844
  var _loop2 = function _loop2() {
2793
- var queryMethod = _queryMethods[_i7];
2845
+ var queryMethod = _queryMethods[_i8];
2794
2846
  queryAndChildGetterDescriptors[queryMethod] = {
2795
2847
  value: function value(arg) {
2796
2848
  var vm = getAssociatedVM(this);
@@ -2808,7 +2860,7 @@
2808
2860
  };
2809
2861
  };
2810
2862
 
2811
- for (var _i7 = 0, _queryMethods = queryMethods; _i7 < _queryMethods.length; _i7++) {
2863
+ for (var _i8 = 0, _queryMethods = queryMethods; _i8 < _queryMethods.length; _i8++) {
2812
2864
  _loop2();
2813
2865
  }
2814
2866
 
@@ -3331,8 +3383,8 @@
3331
3383
  }
3332
3384
 
3333
3385
  if (!isUndefined$1(fields)) {
3334
- for (var _i8 = 0, n = fields.length; _i8 < n; _i8++) {
3335
- var _fieldName2 = fields[_i8];
3386
+ for (var _i9 = 0, n = fields.length; _i9 < n; _i9++) {
3387
+ var _fieldName2 = fields[_i9];
3336
3388
  descriptor = getOwnPropertyDescriptor$1(proto, _fieldName2);
3337
3389
 
3338
3390
  if (process.env.NODE_ENV !== 'production') {
@@ -3380,6 +3432,48 @@
3380
3432
  var meta = signedDecoratorToMetaMap.get(Ctor);
3381
3433
  return isUndefined$1(meta) ? defaultMeta : meta;
3382
3434
  }
3435
+ /*
3436
+ * Copyright (c) 2018, salesforce.com, inc.
3437
+ * All rights reserved.
3438
+ * SPDX-License-Identifier: MIT
3439
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3440
+ */
3441
+
3442
+
3443
+ var warned = false;
3444
+
3445
+ if (process.env.NODE_ENV === 'development') {
3446
+ // @ts-ignore
3447
+ window.__lwcResetWarnedOnVersionMismatch = function () {
3448
+ warned = false;
3449
+ };
3450
+ }
3451
+
3452
+ function checkVersionMismatch(func, type) {
3453
+ var versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
3454
+
3455
+ if (!isNull(versionMatcher) && !warned) {
3456
+ var version = versionMatcher[1];
3457
+
3458
+ var _version$split = version.split('.'),
3459
+ _version$split2 = _slicedToArray(_version$split, 2),
3460
+ major = _version$split2[0],
3461
+ minor = _version$split2[1];
3462
+
3463
+ var _LWC_VERSION$split = LWC_VERSION.split('.'),
3464
+ _LWC_VERSION$split2 = _slicedToArray(_LWC_VERSION$split, 2),
3465
+ expectedMajor = _LWC_VERSION$split2[0],
3466
+ expectedMinor = _LWC_VERSION$split2[1];
3467
+
3468
+ if (major !== expectedMajor || minor !== expectedMinor) {
3469
+ warned = true; // only warn once to avoid flooding the console
3470
+ // stylesheets and templates do not have user-meaningful names, but components do
3471
+
3472
+ var friendlyName = type === 'component' ? "".concat(type, " ").concat(func.name) : type;
3473
+ 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."));
3474
+ }
3475
+ }
3476
+ }
3383
3477
 
3384
3478
  var signedTemplateSet = new Set();
3385
3479
 
@@ -3399,6 +3493,10 @@
3399
3493
 
3400
3494
 
3401
3495
  function registerTemplate(tpl) {
3496
+ if (process.env.NODE_ENV !== 'production') {
3497
+ checkVersionMismatch(tpl, 'template');
3498
+ }
3499
+
3402
3500
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3403
3501
  // assignment of templates easily, without too much transformation
3404
3502
 
@@ -3421,6 +3519,7 @@
3421
3519
  * SPDX-License-Identifier: MIT
3422
3520
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3423
3521
  */
3522
+ // A bridge descriptor is a descriptor whose job is just to get the component instance
3424
3523
  // from the element instance, and get the value or set a new value on the component.
3425
3524
  // This means that across different elements, similar names can get the exact same
3426
3525
  // descriptor, so we can cache them:
@@ -3553,8 +3652,8 @@
3553
3652
  superObservedAttributes = _SuperClass$observedA === void 0 ? [] : _SuperClass$observedA;
3554
3653
  var descriptors = create(null); // expose getters and setters for each public props on the new Element Bridge
3555
3654
 
3556
- for (var _i9 = 0, _len3 = props.length; _i9 < _len3; _i9 += 1) {
3557
- var _propName2 = props[_i9];
3655
+ for (var _i10 = 0, _len3 = props.length; _i10 < _len3; _i10 += 1) {
3656
+ var _propName2 = props[_i10];
3558
3657
  attributeToPropMap[htmlPropertyToAttribute(_propName2)] = _propName2;
3559
3658
  descriptors[_propName2] = {
3560
3659
  get: createGetter(_propName2),
@@ -3565,8 +3664,8 @@
3565
3664
  } // expose public methods as props on the new Element Bridge
3566
3665
 
3567
3666
 
3568
- for (var _i10 = 0, _len4 = methods.length; _i10 < _len4; _i10 += 1) {
3569
- var methodName = methods[_i10];
3667
+ for (var _i11 = 0, _len4 = methods.length; _i11 < _len4; _i11 += 1) {
3668
+ var methodName = methods[_i11];
3570
3669
  descriptors[methodName] = {
3571
3670
  value: createMethodCaller(methodName),
3572
3671
  writable: true,
@@ -3694,31 +3793,6 @@
3694
3793
  return canRefreshAllInstances;
3695
3794
  }
3696
3795
 
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
3796
  function getTemplateOrSwappedTemplate(tpl) {
3723
3797
  if (process.env.NODE_ENV === 'production') {
3724
3798
  // this method should never leak to prod
@@ -4430,6 +4504,7 @@
4430
4504
  * SPDX-License-Identifier: MIT
4431
4505
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4432
4506
  */
4507
+ // The style property is a string when defined via an expression in the template.
4433
4508
 
4434
4509
 
4435
4510
  function patchStyleAttribute(oldVnode, vnode) {
@@ -4474,6 +4549,7 @@
4474
4549
  * SPDX-License-Identifier: MIT
4475
4550
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4476
4551
  */
4552
+ // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
4477
4553
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
4478
4554
  // different classnames properties individually instead of via a string.
4479
4555
 
@@ -4498,6 +4574,7 @@
4498
4574
  * SPDX-License-Identifier: MIT
4499
4575
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4500
4576
  */
4577
+ // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
4501
4578
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
4502
4579
  // different style properties individually instead of via a string.
4503
4580
 
@@ -4510,8 +4587,8 @@
4510
4587
  return;
4511
4588
  }
4512
4589
 
4513
- for (var _i11 = 0; _i11 < styleDecls.length; _i11++) {
4514
- var _styleDecls$_i = _slicedToArray(styleDecls[_i11], 3),
4590
+ for (var _i12 = 0; _i12 < styleDecls.length; _i12++) {
4591
+ var _styleDecls$_i = _slicedToArray(styleDecls[_i12], 3),
4515
4592
  prop = _styleDecls$_i[0],
4516
4593
  value = _styleDecls$_i[1],
4517
4594
  important = _styleDecls$_i[2];
@@ -4527,146 +4604,262 @@
4527
4604
  */
4528
4605
 
4529
4606
 
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);
4607
+ function patchChildren(c1, c2, parent) {
4608
+ if (hasDynamicChildren(c2)) {
4609
+ updateDynamicChildren(c1, c2, parent);
4610
+ } else {
4611
+ updateStaticChildren(c1, c2, parent);
4584
4612
  }
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
- */
4613
+ }
4597
4614
 
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;
4615
+ function patch(n1, n2) {
4616
+ if (n1 === n2) {
4617
+ return;
4618
+ }
4605
4619
 
4606
- if (vm) {
4607
- allocateChildren(vnode, vm);
4608
- } else if (vnode.ctor !== UpgradableConstructor) {
4609
- throw new TypeError("Incorrect Component Constructor");
4620
+ if (process.env.NODE_ENV !== 'production') {
4621
+ if (!isSameVnode(n1, n2)) {
4622
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
4623
+ sel: n1.sel,
4624
+ key: n1.key
4625
+ }) + ', ' + JSON.stringify({
4626
+ sel: n2.sel,
4627
+ key: n2.key
4628
+ }));
4610
4629
  }
4630
+ }
4611
4631
 
4612
- patchElementPropsAndAttrs$1(null, vnode);
4613
- },
4614
- update: function update(oldVnode, vnode) {
4615
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4616
- var vm = getAssociatedVMIfPresent(vnode.elm);
4632
+ switch (n2.type) {
4633
+ case 0
4634
+ /* Text */
4635
+ :
4636
+ patchText(n1, n2);
4637
+ break;
4617
4638
 
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
4639
+ case 1
4640
+ /* Comment */
4641
+ :
4642
+ patchComment(n1, n2);
4643
+ break;
4624
4644
 
4645
+ case 2
4646
+ /* Element */
4647
+ :
4648
+ patchElement(n1, n2);
4649
+ break;
4625
4650
 
4626
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4651
+ case 3
4652
+ /* CustomElement */
4653
+ :
4654
+ patchCustomElement(n1, n2);
4655
+ break;
4656
+ }
4657
+ }
4627
4658
 
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.
4659
+ function mount(node, parent, anchor) {
4660
+ switch (node.type) {
4661
+ case 0
4662
+ /* Text */
4663
+ :
4664
+ mountText(node, parent, anchor);
4665
+ break;
4633
4666
 
4667
+ case 1
4668
+ /* Comment */
4669
+ :
4670
+ mountComment(node, parent, anchor);
4671
+ break;
4634
4672
 
4635
- rerenderVM(vm);
4636
- }
4637
- },
4638
- insert: function insert(vnode, parentNode, referenceNode) {
4639
- insertNode(vnode, parentNode, referenceNode);
4640
- var vm = getAssociatedVMIfPresent(vnode.elm);
4673
+ case 2
4674
+ /* Element */
4675
+ :
4676
+ mountElement(node, parent, anchor);
4677
+ break;
4641
4678
 
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
- }
4679
+ case 3
4680
+ /* CustomElement */
4681
+ :
4682
+ mountCustomElement(node, parent, anchor);
4683
+ break;
4684
+ }
4685
+ }
4686
+
4687
+ function patchText(n1, n2) {
4688
+ n2.elm = n1.elm;
4689
+
4690
+ if (n2.text !== n1.text) {
4691
+ updateTextContent(n2);
4692
+ }
4693
+ }
4694
+
4695
+ function mountText(node, parent, anchor) {
4696
+ var owner = node.owner;
4697
+ var textNode = node.elm = createText$1(node.text);
4698
+ linkNodeToShadow(textNode, owner);
4699
+ insertNode(textNode, parent, anchor);
4700
+ }
4701
+
4702
+ function patchComment(n1, n2) {
4703
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
4704
+ // it is the case today.
4705
+
4706
+ if (n2.text !== n1.text) {
4707
+ updateTextContent(n2);
4708
+ }
4709
+ }
4710
+
4711
+ function mountComment(node, parent, anchor) {
4712
+ var owner = node.owner;
4713
+ var commentNode = node.elm = createComment$1(node.text);
4714
+ linkNodeToShadow(commentNode, owner);
4715
+ insertNode(commentNode, parent, anchor);
4716
+ }
4717
+
4718
+ function mountElement(vnode, parent, anchor) {
4719
+ var sel = vnode.sel,
4720
+ owner = vnode.owner,
4721
+ svg = vnode.data.svg;
4722
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4723
+ var elm = createElement$2(sel, namespace);
4724
+ linkNodeToShadow(elm, owner);
4725
+ fallbackElmHook(elm, vnode);
4726
+ vnode.elm = elm;
4727
+ patchElementPropsAndAttrs$1(null, vnode);
4728
+ insertNode(elm, parent, anchor);
4729
+ mountVNodes(vnode.children, elm, null);
4730
+ }
4731
+
4732
+ function patchElement(n1, n2) {
4733
+ var elm = n2.elm = n1.elm;
4734
+ patchElementPropsAndAttrs$1(n1, n2);
4735
+ patchChildren(n1.children, n2.children, elm);
4736
+ }
4737
+
4738
+ function mountCustomElement(vnode, parent, anchor) {
4739
+ var sel = vnode.sel,
4740
+ owner = vnode.owner;
4741
+ var UpgradableConstructor = getUpgradableConstructor(sel);
4742
+ /**
4743
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4744
+ * with a callback as the first argument, we could implement a more advanced
4745
+ * mechanism that only passes that argument if the constructor is known to be
4746
+ * an upgradable custom element.
4747
+ */
4748
+
4749
+ var vm;
4750
+ var elm = new UpgradableConstructor(function (elm) {
4751
+ // the custom element from the registry is expecting an upgrade callback
4752
+ vm = createViewModelHook(elm, vnode);
4753
+ });
4754
+ linkNodeToShadow(elm, owner);
4755
+ vnode.elm = elm;
4756
+ vnode.vm = vm;
4757
+
4758
+ if (vm) {
4759
+ allocateChildren(vnode, vm);
4760
+ } else if (vnode.ctor !== UpgradableConstructor) {
4761
+ throw new TypeError("Incorrect Component Constructor");
4762
+ }
4648
4763
 
4649
- runConnectedCallback(vm);
4764
+ patchElementPropsAndAttrs$1(null, vnode);
4765
+ insertNode(elm, parent, anchor);
4766
+
4767
+ if (vm) {
4768
+ if (process.env.NODE_ENV !== 'production') {
4769
+ assert.isTrue(vm.state === 0
4770
+ /* created */
4771
+ , "".concat(vm, " cannot be recycled."));
4650
4772
  }
4651
4773
 
4652
- createChildrenHook(vnode);
4774
+ runConnectedCallback(vm);
4775
+ }
4776
+
4777
+ mountVNodes(vnode.children, elm, null);
4653
4778
 
4654
- if (vm) {
4655
- appendVM(vm);
4779
+ if (vm) {
4780
+ appendVM(vm);
4781
+ }
4782
+ }
4783
+
4784
+ function patchCustomElement(n1, n2) {
4785
+ var elm = n2.elm = n1.elm;
4786
+ var vm = n2.vm = n1.vm;
4787
+ patchElementPropsAndAttrs$1(n1, n2);
4788
+
4789
+ if (!isUndefined$1(vm)) {
4790
+ // in fallback mode, the allocation will always set children to
4791
+ // empty and delegate the real allocation to the slot elements
4792
+ allocateChildren(n2, vm);
4793
+ } // in fallback mode, the children will be always empty, so, nothing
4794
+ // will happen, but in native, it does allocate the light dom
4795
+
4796
+
4797
+ patchChildren(n1.children, n2.children, elm);
4798
+
4799
+ if (!isUndefined$1(vm)) {
4800
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4801
+ // this is important to preserve the top to bottom synchronous rendering phase.
4802
+ rerenderVM(vm);
4803
+ }
4804
+ }
4805
+
4806
+ function mountVNodes(vnodes, parent, anchor) {
4807
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4808
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
4809
+
4810
+ for (; start < end; ++start) {
4811
+ var vnode = vnodes[start];
4812
+
4813
+ if (isVNode(vnode)) {
4814
+ mount(vnode, parent, anchor);
4656
4815
  }
4657
- },
4658
- move: insertNode,
4659
- remove: function remove(vnode, parentNode) {
4660
- removeNode(vnode, parentNode);
4661
- var vm = getAssociatedVMIfPresent(vnode.elm);
4816
+ }
4817
+ }
4818
+
4819
+ function unmount(vnode, parent) {
4820
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4821
+ var type = vnode.type,
4822
+ elm = vnode.elm; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4823
+ // subtree root, is the only element worth unmounting from the subtree.
4824
+
4825
+ if (doRemove) {
4826
+ removeNode(elm, parent);
4827
+ }
4828
+
4829
+ switch (type) {
4830
+ case 2
4831
+ /* Element */
4832
+ :
4833
+ unmountVNodes(vnode.children, elm);
4834
+ break;
4835
+
4836
+ case 3
4837
+ /* CustomElement */
4838
+ :
4839
+ {
4840
+ var vm = vnode.vm; // No need to unmount the children here, `removeVM` will take care of removing the
4841
+ // children.
4842
+
4843
+ if (!isUndefined$1(vm)) {
4844
+ removeVM(vm);
4845
+ }
4846
+ }
4847
+ }
4848
+ }
4849
+
4850
+ function unmountVNodes(vnodes, parent) {
4851
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4852
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4853
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
4854
+
4855
+ for (; start < end; ++start) {
4856
+ var ch = vnodes[start];
4662
4857
 
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);
4858
+ if (isVNode(ch)) {
4859
+ unmount(ch, parent, doRemove);
4667
4860
  }
4668
4861
  }
4669
- };
4862
+ }
4670
4863
 
4671
4864
  function isVNode(vnode) {
4672
4865
  return vnode != null;
@@ -4707,41 +4900,39 @@
4707
4900
  }
4708
4901
  }
4709
4902
 
4710
- function updateNodeHook(oldVnode, vnode) {
4903
+ function updateTextContent(vnode) {
4711
4904
  var elm = vnode.elm,
4712
4905
  text = vnode.text;
4713
4906
 
4714
- if (oldVnode.text !== text) {
4715
- if (process.env.NODE_ENV !== 'production') {
4716
- unlockDomMutation();
4717
- }
4907
+ if (process.env.NODE_ENV !== 'production') {
4908
+ unlockDomMutation();
4909
+ }
4718
4910
 
4719
- setText$1(elm, text);
4911
+ setText$1(elm, text);
4720
4912
 
4721
- if (process.env.NODE_ENV !== 'production') {
4722
- lockDomMutation();
4723
- }
4913
+ if (process.env.NODE_ENV !== 'production') {
4914
+ lockDomMutation();
4724
4915
  }
4725
4916
  }
4726
4917
 
4727
- function insertNode(vnode, parentNode, referenceNode) {
4918
+ function insertNode(node, parent, anchor) {
4728
4919
  if (process.env.NODE_ENV !== 'production') {
4729
4920
  unlockDomMutation();
4730
4921
  }
4731
4922
 
4732
- insert$1(vnode.elm, parentNode, referenceNode);
4923
+ insert$1(node, parent, anchor);
4733
4924
 
4734
4925
  if (process.env.NODE_ENV !== 'production') {
4735
4926
  lockDomMutation();
4736
4927
  }
4737
4928
  }
4738
4929
 
4739
- function removeNode(vnode, parentNode) {
4930
+ function removeNode(node, parent) {
4740
4931
  if (process.env.NODE_ENV !== 'production') {
4741
4932
  unlockDomMutation();
4742
4933
  }
4743
4934
 
4744
- remove$1(vnode.elm, parentNode);
4935
+ remove$1(node, parent);
4745
4936
 
4746
4937
  if (process.env.NODE_ENV !== 'production') {
4747
4938
  lockDomMutation();
@@ -4778,11 +4969,13 @@
4778
4969
  ) {
4779
4970
  // this element will now accept any manual content inserted into it
4780
4971
  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
-
4972
+ }
4784
4973
 
4785
- setElementShadowToken(elm, stylesheetToken);
4974
+ if (!isUndefined$1(stylesheetToken)) {
4975
+ // when running in synthetic shadow mode, we need to set the shadowToken value
4976
+ // into each element from the template, so they can be styled accordingly.
4977
+ setElementShadowToken(elm, stylesheetToken);
4978
+ }
4786
4979
  }
4787
4980
 
4788
4981
  if (process.env.NODE_ENV !== 'production') {
@@ -4800,14 +4993,6 @@
4800
4993
  }
4801
4994
  }
4802
4995
 
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
4996
  function allocateChildren(vnode, vm) {
4812
4997
  // A component with slots will re-render because:
4813
4998
  // 1- There is a change of the internal state.
@@ -4859,7 +5044,9 @@
4859
5044
  var stylesheetToken = owner.context.stylesheetToken; // when running in synthetic shadow mode, we need to set the shadowToken value
4860
5045
  // into each element from the template, so they can be styled accordingly.
4861
5046
 
4862
- setElementShadowToken(elm, stylesheetToken);
5047
+ if (!isUndefined$1(stylesheetToken)) {
5048
+ setElementShadowToken(elm, stylesheetToken);
5049
+ }
4863
5050
  }
4864
5051
 
4865
5052
  vm = createVM(elm, ctor, {
@@ -4875,44 +5062,14 @@
4875
5062
  return vm;
4876
5063
  }
4877
5064
 
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
5065
  function allocateInSlot(vm, children) {
4909
5066
  var _a;
4910
5067
 
4911
5068
  var oldSlots = vm.cmpSlots;
4912
5069
  var cmpSlots = vm.cmpSlots = create(null);
4913
5070
 
4914
- for (var _i12 = 0, _len6 = children.length; _i12 < _len6; _i12 += 1) {
4915
- var vnode = children[_i12];
5071
+ for (var _i13 = 0, _len5 = children.length; _i13 < _len5; _i13 += 1) {
5072
+ var vnode = children[_i13];
4916
5073
 
4917
5074
  if (isNull(vnode)) {
4918
5075
  continue;
@@ -4946,8 +5103,8 @@
4946
5103
  return;
4947
5104
  }
4948
5105
 
4949
- for (var _i13 = 0, _len7 = oldKeys.length; _i13 < _len7; _i13 += 1) {
4950
- var key = oldKeys[_i13];
5106
+ for (var _i14 = 0, _len6 = oldKeys.length; _i14 < _len6; _i14 += 1) {
5107
+ var key = oldKeys[_i14];
4951
5108
 
4952
5109
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
4953
5110
  markComponentAsDirty(vm);
@@ -4997,28 +5154,7 @@
4997
5154
  return map;
4998
5155
  }
4999
5156
 
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) {
5157
+ function updateDynamicChildren(oldCh, newCh, parent) {
5022
5158
  var oldStartIdx = 0;
5023
5159
  var newStartIdx = 0;
5024
5160
  var oldEndIdx = oldCh.length - 1;
@@ -5032,6 +5168,7 @@
5032
5168
  var idxInOld;
5033
5169
  var elmToMove;
5034
5170
  var before;
5171
+ var clonedOldCh = false;
5035
5172
 
5036
5173
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
5037
5174
  if (!isVNode(oldStartVnode)) {
@@ -5043,23 +5180,23 @@
5043
5180
  } else if (!isVNode(newEndVnode)) {
5044
5181
  newEndVnode = newCh[--newEndIdx];
5045
5182
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
5046
- patchVnode(oldStartVnode, newStartVnode);
5183
+ patch(oldStartVnode, newStartVnode);
5047
5184
  oldStartVnode = oldCh[++oldStartIdx];
5048
5185
  newStartVnode = newCh[++newStartIdx];
5049
5186
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
5050
- patchVnode(oldEndVnode, newEndVnode);
5187
+ patch(oldEndVnode, newEndVnode);
5051
5188
  oldEndVnode = oldCh[--oldEndIdx];
5052
5189
  newEndVnode = newCh[--newEndIdx];
5053
5190
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
5054
5191
  // Vnode moved right
5055
- patchVnode(oldStartVnode, newEndVnode);
5056
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5192
+ patch(oldStartVnode, newEndVnode);
5193
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
5057
5194
  oldStartVnode = oldCh[++oldStartIdx];
5058
5195
  newEndVnode = newCh[--newEndIdx];
5059
5196
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
5060
5197
  // Vnode moved left
5061
- patchVnode(oldEndVnode, newStartVnode);
5062
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5198
+ patch(oldEndVnode, newStartVnode);
5199
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
5063
5200
  oldEndVnode = oldCh[--oldEndIdx];
5064
5201
  newStartVnode = newCh[++newStartIdx];
5065
5202
  } else {
@@ -5071,8 +5208,7 @@
5071
5208
 
5072
5209
  if (isUndefined$1(idxInOld)) {
5073
5210
  // New element
5074
- newStartVnode.hook.create(newStartVnode);
5075
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5211
+ mount(newStartVnode, parent, oldStartVnode.elm);
5076
5212
  newStartVnode = newCh[++newStartIdx];
5077
5213
  } else {
5078
5214
  elmToMove = oldCh[idxInOld];
@@ -5080,12 +5216,22 @@
5080
5216
  if (isVNode(elmToMove)) {
5081
5217
  if (elmToMove.sel !== newStartVnode.sel) {
5082
5218
  // New element
5083
- newStartVnode.hook.create(newStartVnode);
5084
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5219
+ mount(newStartVnode, parent, oldStartVnode.elm);
5085
5220
  } else {
5086
- patchVnode(elmToMove, newStartVnode);
5221
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5222
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
5223
+ // so we only care about the `oldCh` object inside this function.
5224
+ // To avoid cloning over and over again, we check `clonedOldCh`
5225
+ // and only clone once.
5226
+
5227
+ if (!clonedOldCh) {
5228
+ clonedOldCh = true;
5229
+ oldCh = _toConsumableArray(oldCh);
5230
+ } // We've already cloned at least once, so it's no longer read-only
5231
+
5232
+
5087
5233
  oldCh[idxInOld] = undefined;
5088
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5234
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
5089
5235
  }
5090
5236
  }
5091
5237
 
@@ -5098,73 +5244,63 @@
5098
5244
  if (oldStartIdx > oldEndIdx) {
5099
5245
  // There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
5100
5246
  // already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
5101
- var _i14 = newEndIdx;
5247
+ var _i15 = newEndIdx;
5102
5248
  var n;
5103
5249
 
5104
5250
  do {
5105
- n = newCh[++_i14];
5106
- } while (!isVNode(n) && _i14 < newChEnd);
5251
+ n = newCh[++_i15];
5252
+ } while (!isVNode(n) && _i15 < newChEnd);
5107
5253
 
5108
5254
  before = isVNode(n) ? n.elm : null;
5109
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5255
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
5110
5256
  } else {
5111
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5257
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
5112
5258
  }
5113
5259
  }
5114
5260
  }
5115
5261
 
5116
- function updateStaticChildren(parentElm, oldCh, newCh) {
5117
- var oldChLength = oldCh.length;
5118
- var newChLength = newCh.length;
5262
+ function updateStaticChildren(c1, c2, parent) {
5263
+ var c1Length = c1.length;
5264
+ var c2Length = c2.length;
5119
5265
 
5120
- if (oldChLength === 0) {
5266
+ if (c1Length === 0) {
5121
5267
  // the old list is empty, we can directly insert anything new
5122
- addVnodes(parentElm, null, newCh, 0, newChLength);
5268
+ mountVNodes(c2, parent, null);
5123
5269
  return;
5124
5270
  }
5125
5271
 
5126
- if (newChLength === 0) {
5272
+ if (c2Length === 0) {
5127
5273
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5128
5274
  // this is the case in which the dynamic children of an if-directive should be removed
5129
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5275
+ unmountVNodes(c1, parent, true);
5130
5276
  return;
5131
5277
  } // if the old list is not empty, the new list MUST have the same
5132
5278
  // amount of nodes, that's why we call this static children
5133
5279
 
5134
5280
 
5135
- var referenceElm = null;
5281
+ var anchor = null;
5136
5282
 
5137
- for (var _i15 = newChLength - 1; _i15 >= 0; _i15 -= 1) {
5138
- var vnode = newCh[_i15];
5139
- var oldVNode = oldCh[_i15];
5283
+ for (var _i16 = c2Length - 1; _i16 >= 0; _i16 -= 1) {
5284
+ var n1 = c1[_i16];
5285
+ var n2 = c2[_i16];
5140
5286
 
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;
5287
+ if (n2 !== n1) {
5288
+ if (isVNode(n1)) {
5289
+ if (isVNode(n2)) {
5290
+ // both vnodes are equivalent, and we just need to patch them
5291
+ patch(n1, n2);
5292
+ anchor = n2.elm;
5147
5293
  } else {
5148
5294
  // removing the old vnode since the new one is null
5149
- oldVNode.hook.remove(oldVNode, parentElm);
5295
+ unmount(n1, parent, true);
5150
5296
  }
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;
5297
+ } else if (isVNode(n2)) {
5298
+ mount(n2, parent, anchor);
5299
+ anchor = n2.elm;
5157
5300
  }
5158
5301
  }
5159
5302
  }
5160
5303
  }
5161
-
5162
- function patchVnode(oldVnode, vnode) {
5163
- if (oldVnode !== vnode) {
5164
- vnode.elm = oldVnode.elm;
5165
- vnode.hook.update(oldVnode, vnode);
5166
- }
5167
- }
5168
5304
  /*
5169
5305
  * Copyright (c) 2018, salesforce.com, inc.
5170
5306
  * All rights reserved.
@@ -5180,7 +5316,8 @@
5180
5316
  } // [h]tml node
5181
5317
 
5182
5318
 
5183
- function h(sel, data, children) {
5319
+ function h(sel, data) {
5320
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EmptyArray;
5184
5321
  var vmBeingRendered = getVMBeingRendered();
5185
5322
 
5186
5323
  if (process.env.NODE_ENV !== 'production') {
@@ -5214,7 +5351,6 @@
5214
5351
  children: children,
5215
5352
  elm: elm,
5216
5353
  key: key,
5217
- hook: ElementHook,
5218
5354
  owner: vmBeingRendered
5219
5355
  };
5220
5356
  } // [t]ab[i]ndex function
@@ -5298,7 +5434,7 @@
5298
5434
  }
5299
5435
 
5300
5436
  var key = data.key;
5301
- var elm;
5437
+ var elm, aChildren, vm;
5302
5438
  var vnode = {
5303
5439
  type: 3
5304
5440
  /* CustomElement */
@@ -5308,11 +5444,11 @@
5308
5444
  children: children,
5309
5445
  elm: elm,
5310
5446
  key: key,
5311
- hook: CustomElementHook,
5312
5447
  ctor: Ctor,
5313
5448
  owner: vmBeingRendered,
5314
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5315
-
5449
+ mode: 'open',
5450
+ aChildren: aChildren,
5451
+ vm: vm
5316
5452
  };
5317
5453
  addVNodeToChildLWC(vnode);
5318
5454
  return vnode;
@@ -5439,7 +5575,6 @@
5439
5575
  text: text,
5440
5576
  elm: elm,
5441
5577
  key: key,
5442
- hook: TextHook,
5443
5578
  owner: getVMBeingRendered()
5444
5579
  };
5445
5580
  } // [co]mment node
@@ -5455,7 +5590,6 @@
5455
5590
  text: text,
5456
5591
  elm: elm,
5457
5592
  key: key,
5458
- hook: CommentHook,
5459
5593
  owner: getVMBeingRendered()
5460
5594
  };
5461
5595
  } // [d]ynamic text
@@ -5568,7 +5702,9 @@
5568
5702
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
5569
5703
  */
5570
5704
 
5571
- function dc(sel, Ctor, data, children) {
5705
+ function dc(sel, Ctor, data) {
5706
+ var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : EmptyArray;
5707
+
5572
5708
  if (process.env.NODE_ENV !== 'production') {
5573
5709
  assert.isTrue(isString(sel), "dc() 1st argument sel must be a string.");
5574
5710
  assert.isTrue(isObject(data), "dc() 3nd argument data must be an object.");
@@ -5592,10 +5728,14 @@
5592
5728
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
5593
5729
  // to identify different constructors as vnodes with different keys to avoid reusing the
5594
5730
  // element used for previous constructors.
5731
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
5732
+ // hoisting optimization.
5595
5733
 
5596
5734
 
5597
- data.key = "dc:".concat(idx, ":").concat(data.key);
5598
- return c(sel, Ctor, data, children);
5735
+ var newData = Object.assign(Object.assign({}, data), {
5736
+ key: "dc:".concat(idx, ":").concat(data.key)
5737
+ });
5738
+ return c(sel, Ctor, newData, children);
5599
5739
  }
5600
5740
  /**
5601
5741
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5707,12 +5847,14 @@
5707
5847
  oldHasTokenInClass = context.hasTokenInClass,
5708
5848
  oldHasTokenInAttribute = context.hasTokenInAttribute;
5709
5849
 
5710
- if (oldHasTokenInClass) {
5711
- getClassList$1(elm).remove(makeHostToken(oldToken));
5712
- }
5850
+ if (!isUndefined$1(oldToken)) {
5851
+ if (oldHasTokenInClass) {
5852
+ getClassList$1(elm).remove(makeHostToken(oldToken));
5853
+ }
5713
5854
 
5714
- if (oldHasTokenInAttribute) {
5715
- removeAttribute$1(elm, makeHostToken(oldToken));
5855
+ if (oldHasTokenInAttribute) {
5856
+ removeAttribute$1(elm, makeHostToken(oldToken));
5857
+ }
5716
5858
  } // Apply the new template styling token to the host element, if the new template has any
5717
5859
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
5718
5860
 
@@ -5744,16 +5886,18 @@
5744
5886
  var content = [];
5745
5887
  var root;
5746
5888
 
5747
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5748
- var stylesheet = stylesheets[_i16];
5889
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5890
+ var stylesheet = stylesheets[_i17];
5749
5891
 
5750
5892
  if (isArray$1(stylesheet)) {
5751
5893
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
5752
5894
  } else {
5753
5895
  if (process.env.NODE_ENV !== 'production') {
5754
- // in dev-mode, we support hot swapping of stylesheet, which means that
5896
+ // Check for compiler version mismatch in dev mode only
5897
+ checkVersionMismatch(stylesheet, 'stylesheet'); // in dev-mode, we support hot swapping of stylesheet, which means that
5755
5898
  // the component instance might be attempting to use an old version of
5756
5899
  // the stylesheet, while internally, we have a replacement for it.
5900
+
5757
5901
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5758
5902
  }
5759
5903
 
@@ -5855,8 +5999,8 @@
5855
5999
  && shadowMode === 1
5856
6000
  /* Synthetic */
5857
6001
  ) {
5858
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5859
- insertGlobalStylesheet$1(stylesheets[_i17]);
6002
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
6003
+ insertGlobalStylesheet$1(stylesheets[_i18]);
5860
6004
  }
5861
6005
  } else if (ssr$1 || isHydrating$1()) {
5862
6006
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
@@ -5870,12 +6014,12 @@
5870
6014
  var root = getNearestNativeShadowComponent(vm);
5871
6015
  var isGlobal = isNull(root);
5872
6016
 
5873
- for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
6017
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
5874
6018
  if (isGlobal) {
5875
- insertGlobalStylesheet$1(stylesheets[_i18]);
6019
+ insertGlobalStylesheet$1(stylesheets[_i19]);
5876
6020
  } else {
5877
6021
  // local level
5878
- insertStylesheet$1(stylesheets[_i18], root.shadowRoot);
6022
+ insertStylesheet$1(stylesheets[_i19], root.shadowRoot);
5879
6023
  }
5880
6024
  }
5881
6025
  }
@@ -6152,8 +6296,8 @@
6152
6296
  var stylesheets = template.stylesheets;
6153
6297
 
6154
6298
  if (!isUndefined$1(stylesheets)) {
6155
- for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6156
- if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
6299
+ for (var _i20 = 0; _i20 < stylesheets.length; _i20++) {
6300
+ if (isTrue(stylesheets[_i20][KEY__SCOPED_CSS])) {
6157
6301
  return true;
6158
6302
  }
6159
6303
  }
@@ -6280,6 +6424,11 @@
6280
6424
 
6281
6425
  function registerComponent(Ctor, _ref2) {
6282
6426
  var tmpl = _ref2.tmpl;
6427
+
6428
+ if (process.env.NODE_ENV !== 'production') {
6429
+ checkVersionMismatch(Ctor, 'component');
6430
+ }
6431
+
6283
6432
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6284
6433
  // without too much transformation
6285
6434
 
@@ -6365,8 +6514,8 @@
6365
6514
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6366
6515
  }
6367
6516
 
6368
- for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6369
- var hookName = hooks[_i20];
6517
+ for (var _i21 = 0; _i21 < hooks.length; ++_i21) {
6518
+ var hookName = hooks[_i21];
6370
6519
 
6371
6520
  if (hookName in service) {
6372
6521
  var l = Services[hookName];
@@ -6389,8 +6538,8 @@
6389
6538
  def = vm.def,
6390
6539
  context = vm.context;
6391
6540
 
6392
- for (var _i21 = 0, _len8 = cbs.length; _i21 < _len8; ++_i21) {
6393
- cbs[_i21].call(undefined, component, {}, def, context);
6541
+ for (var _i22 = 0, _len7 = cbs.length; _i22 < _len7; ++_i22) {
6542
+ cbs[_i22].call(undefined, component, {}, def, context);
6394
6543
  }
6395
6544
  }
6396
6545
  /*
@@ -6401,7 +6550,7 @@
6401
6550
  */
6402
6551
 
6403
6552
 
6404
- function hydrate$1(vnode, node) {
6553
+ function hydrate(vnode, node) {
6405
6554
  switch (vnode.type) {
6406
6555
  case 0
6407
6556
  /* Text */
@@ -6433,16 +6582,18 @@
6433
6582
  var _a;
6434
6583
 
6435
6584
  if (process.env.NODE_ENV !== 'production') {
6436
- // eslint-disable-next-line lwc-internal/no-global-node
6437
- validateNodeType(vnode, node, Node.TEXT_NODE);
6585
+ validateNodeType(vnode, node, 3
6586
+ /* TEXT */
6587
+ );
6588
+ var nodeValue = getProperty$1(node, 'nodeValue');
6438
6589
 
6439
- if (node.nodeValue !== vnode.text && !(node.nodeValue === "\u200D" && vnode.text === '')) {
6590
+ if (nodeValue !== vnode.text && !(nodeValue === "\u200D" && vnode.text === '')) {
6440
6591
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6441
6592
  }
6442
6593
  } // always set the text value to the one from the vnode.
6443
6594
 
6444
6595
 
6445
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6596
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6446
6597
  vnode.elm = node;
6447
6598
  }
6448
6599
 
@@ -6450,23 +6601,25 @@
6450
6601
  var _a;
6451
6602
 
6452
6603
  if (process.env.NODE_ENV !== 'production') {
6453
- // eslint-disable-next-line lwc-internal/no-global-node
6454
- validateNodeType(vnode, node, Node.COMMENT_NODE);
6604
+ validateNodeType(vnode, node, 8
6605
+ /* COMMENT */
6606
+ );
6455
6607
 
6456
- if (node.nodeValue !== vnode.text) {
6608
+ if (getProperty$1(node, 'nodeValue') !== vnode.text) {
6457
6609
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6458
6610
  }
6459
6611
  } // always set the text value to the one from the vnode.
6460
6612
 
6461
6613
 
6462
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6614
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6463
6615
  vnode.elm = node;
6464
6616
  }
6465
6617
 
6466
6618
  function hydrateElement(vnode, node) {
6467
6619
  if (process.env.NODE_ENV !== 'production') {
6468
- // eslint-disable-next-line lwc-internal/no-global-node
6469
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6620
+ validateNodeType(vnode, node, 1
6621
+ /* ELEMENT */
6622
+ );
6470
6623
  validateElement(vnode, node);
6471
6624
  }
6472
6625
 
@@ -6483,10 +6636,13 @@
6483
6636
  var props = vnode.data.props;
6484
6637
 
6485
6638
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6486
- if (elm.innerHTML === props.innerHTML) {
6487
- delete props.innerHTML;
6639
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6640
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6641
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
6642
+ props: cloneAndOmitKey(props, 'innerHTML')
6643
+ });
6488
6644
  } else {
6489
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6645
+ 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
6646
  }
6491
6647
  }
6492
6648
  }
@@ -6494,19 +6650,19 @@
6494
6650
  patchElementPropsAndAttrs(vnode);
6495
6651
 
6496
6652
  if (!isDomManual) {
6497
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
6653
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
6498
6654
  }
6499
6655
  }
6500
6656
 
6501
6657
  function hydrateCustomElement(vnode, node) {
6502
6658
  if (process.env.NODE_ENV !== 'production') {
6503
- // eslint-disable-next-line lwc-internal/no-global-node
6504
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6659
+ validateNodeType(vnode, node, 1
6660
+ /* ELEMENT */
6661
+ );
6505
6662
  validateElement(vnode, node);
6506
6663
  }
6507
6664
 
6508
6665
  var elm = node;
6509
- vnode.elm = elm;
6510
6666
  var sel = vnode.sel,
6511
6667
  mode = vnode.mode,
6512
6668
  ctor = vnode.ctor,
@@ -6516,6 +6672,8 @@
6516
6672
  owner: owner,
6517
6673
  tagName: sel
6518
6674
  });
6675
+ vnode.elm = elm;
6676
+ vnode.vm = vm;
6519
6677
  allocateChildren(vnode, vm);
6520
6678
  patchElementPropsAndAttrs(vnode); // Insert hook section:
6521
6679
 
@@ -6532,7 +6690,7 @@
6532
6690
  ) {
6533
6691
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6534
6692
  // Note: for Light DOM, this is handled while hydrating the VM
6535
- hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
6693
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vm);
6536
6694
  }
6537
6695
 
6538
6696
  hydrateVM(vm);
@@ -6552,12 +6710,12 @@
6552
6710
 
6553
6711
  var childNodeIndex = 0;
6554
6712
 
6555
- for (var _i22 = 0; _i22 < children.length; _i22++) {
6556
- var childVnode = children[_i22];
6713
+ for (var _i23 = 0; _i23 < children.length; _i23++) {
6714
+ var childVnode = children[_i23];
6557
6715
 
6558
6716
  if (!isNull(childVnode)) {
6559
6717
  var childNode = elmChildren[childNodeIndex];
6560
- hydrate$1(childVnode, childNode);
6718
+ hydrate(childVnode, childNode);
6561
6719
  childNodeIndex++;
6562
6720
  }
6563
6721
  }
@@ -6573,15 +6731,15 @@
6573
6731
  }
6574
6732
 
6575
6733
  function validateNodeType(vnode, node, nodeType) {
6576
- if (node.nodeType !== nodeType) {
6734
+ if (getProperty$1(node, 'nodeType') !== nodeType) {
6577
6735
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
6578
6736
  assert.fail('Hydration mismatch: incorrect node type received.');
6579
6737
  }
6580
6738
  }
6581
6739
 
6582
6740
  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);
6741
+ if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
6742
+ logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(getProperty$1(elm, 'tagName').toLowerCase(), "\"."), vnode.owner);
6585
6743
  throwHydrationError();
6586
6744
  }
6587
6745
 
@@ -6601,15 +6759,15 @@
6601
6759
  var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
6602
6760
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6603
6761
 
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),
6762
+ for (var _i24 = 0, _Object$entries = Object.entries(attrs); _i24 < _Object$entries.length; _i24++) {
6763
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i24], 2),
6606
6764
  attrName = _Object$entries$_i[0],
6607
6765
  attrValue = _Object$entries$_i[1];
6608
6766
 
6609
6767
  var elmAttrValue = getAttribute$1(elm, attrName);
6610
6768
 
6611
6769
  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);
6770
+ 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
6771
  nodesAreCompatible = false;
6614
6772
  }
6615
6773
  }
@@ -6624,7 +6782,7 @@
6624
6782
  var nodesAreCompatible = true;
6625
6783
  var vnodeClassName;
6626
6784
 
6627
- if (!isUndefined$1(className) && String(className) !== elm.className) {
6785
+ if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6628
6786
  // className is used when class is bound to an expr.
6629
6787
  nodesAreCompatible = false;
6630
6788
  vnodeClassName = className;
@@ -6649,7 +6807,7 @@
6649
6807
  }
6650
6808
 
6651
6809
  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);
6810
+ 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
6811
  }
6654
6812
 
6655
6813
  return nodesAreCompatible;
@@ -6670,8 +6828,8 @@
6670
6828
  var parsedVnodeStyle = parseStyleText(elmStyle);
6671
6829
  var expectedStyle = []; // styleMap is used when style is set to static value.
6672
6830
 
6673
- for (var _i24 = 0, n = styleDecls.length; _i24 < n; _i24++) {
6674
- var _styleDecls$_i2 = _slicedToArray(styleDecls[_i24], 3),
6831
+ for (var _i25 = 0, n = styleDecls.length; _i25 < n; _i25++) {
6832
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i25], 3),
6675
6833
  prop = _styleDecls$_i2[0],
6676
6834
  value = _styleDecls$_i2[1],
6677
6835
  important = _styleDecls$_i2[2];
@@ -6697,7 +6855,7 @@
6697
6855
 
6698
6856
  if (!nodesAreCompatible) {
6699
6857
  // 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);
6858
+ 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
6859
  }
6702
6860
 
6703
6861
  return nodesAreCompatible;
@@ -6768,7 +6926,19 @@
6768
6926
  }
6769
6927
 
6770
6928
  function hydrateVM(vm) {
6771
- hydrate(vm);
6929
+ if (isTrue(vm.isDirty)) {
6930
+ // manually diffing/patching here.
6931
+ // This routine is:
6932
+ // patchShadowRoot(vm, children);
6933
+ // -> addVnodes.
6934
+ var children = renderComponent(vm);
6935
+ vm.children = children;
6936
+ var vmChildren = vm.renderMode === 0
6937
+ /* Light */
6938
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
6939
+ hydrateChildren(vmChildren, children, vm);
6940
+ runRenderedCallback(vm);
6941
+ }
6772
6942
  } // just in case the component comes back, with this we guarantee re-rendering it
6773
6943
  // while preventing any attempt to rehydration until after reinsertion.
6774
6944
 
@@ -6911,30 +7081,38 @@
6911
7081
  /* Native */
6912
7082
  ;
6913
7083
  } else if (isNativeShadowDefined$1) {
6914
- if (def.shadowSupportMode === "any"
6915
- /* Any */
6916
- ) {
6917
- shadowMode = 0
6918
- /* Native */
6919
- ;
6920
- } else {
6921
- var shadowAncestor = getNearestShadowAncestor(vm);
6922
-
6923
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
6924
- /* Native */
7084
+ // Not combined with above condition because @lwc/features only supports identifiers in
7085
+ // the if-condition.
7086
+ if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
7087
+ if (def.shadowSupportMode === "any"
7088
+ /* Any */
6925
7089
  ) {
6926
- // Transitive support for native Shadow DOM. A component in native mode
6927
- // transitively opts all of its descendants into native.
6928
7090
  shadowMode = 0
6929
7091
  /* Native */
6930
7092
  ;
6931
7093
  } else {
6932
- // Synthetic if neither this component nor any of its ancestors are configured
6933
- // to be native.
6934
- shadowMode = 1
6935
- /* Synthetic */
6936
- ;
7094
+ var shadowAncestor = getNearestShadowAncestor(vm);
7095
+
7096
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
7097
+ /* Native */
7098
+ ) {
7099
+ // Transitive support for native Shadow DOM. A component in native mode
7100
+ // transitively opts all of its descendants into native.
7101
+ shadowMode = 0
7102
+ /* Native */
7103
+ ;
7104
+ } else {
7105
+ // Synthetic if neither this component nor any of its ancestors are configured
7106
+ // to be native.
7107
+ shadowMode = 1
7108
+ /* Synthetic */
7109
+ ;
7110
+ }
6937
7111
  }
7112
+ } else {
7113
+ shadowMode = 1
7114
+ /* Synthetic */
7115
+ ;
6938
7116
  }
6939
7117
  } else {
6940
7118
  // Synthetic if there is no native Shadow DOM support.
@@ -6991,22 +7169,6 @@
6991
7169
  }
6992
7170
  }
6993
7171
 
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
7172
  function patchShadowRoot(vm, newCh) {
7011
7173
  var renderRoot = vm.renderRoot,
7012
7174
  oldCh = vm.children; // caching the new children collection
@@ -7024,7 +7186,7 @@
7024
7186
  , vm);
7025
7187
  }, function () {
7026
7188
  // job
7027
- patchChildren(renderRoot, oldCh, newCh);
7189
+ patchChildren(oldCh, newCh, renderRoot);
7028
7190
  }, function () {
7029
7191
  // post
7030
7192
  logOperationEnd(2
@@ -7085,19 +7247,19 @@
7085
7247
  });
7086
7248
  rehydrateQueue = []; // reset to a new queue
7087
7249
 
7088
- for (var _i25 = 0, _len9 = vms.length; _i25 < _len9; _i25 += 1) {
7089
- var vm = vms[_i25];
7250
+ for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
7251
+ var vm = vms[_i26];
7090
7252
 
7091
7253
  try {
7092
7254
  rehydrate(vm);
7093
7255
  } catch (error) {
7094
- if (_i25 + 1 < _len9) {
7256
+ if (_i26 + 1 < _len8) {
7095
7257
  // pieces of the queue are still pending to be rehydrated, those should have priority
7096
7258
  if (rehydrateQueue.length === 0) {
7097
7259
  addCallbackToNextTick(flushRehydrationQueue);
7098
7260
  }
7099
7261
 
7100
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i25 + 1));
7262
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i26 + 1));
7101
7263
  } // we need to end the measure before throwing.
7102
7264
 
7103
7265
 
@@ -7201,8 +7363,8 @@
7201
7363
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
7202
7364
  // inserted in reserved order.
7203
7365
 
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:
7366
+ for (var _i27 = vCustomElementCollection.length - 1; _i27 >= 0; _i27 -= 1) {
7367
+ var elm = vCustomElementCollection[_i27].elm; // There are two cases where the element could be undefined:
7206
7368
  // * when there is an error during the construction phase, and an error
7207
7369
  // boundary picks it, there is a possibility that the VCustomElement
7208
7370
  // is not properly initialized, and therefore is should be ignored.
@@ -7236,8 +7398,8 @@
7236
7398
 
7237
7399
 
7238
7400
  function recursivelyDisconnectChildren(vnodes) {
7239
- for (var _i27 = 0, _len10 = vnodes.length; _i27 < _len10; _i27 += 1) {
7240
- var vnode = vnodes[_i27];
7401
+ for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
7402
+ var vnode = vnodes[_i28];
7241
7403
 
7242
7404
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
7243
7405
  switch (vnode.type) {
@@ -7268,8 +7430,8 @@
7268
7430
  var children = vm.children,
7269
7431
  renderRoot = vm.renderRoot;
7270
7432
 
7271
- for (var _i28 = 0, _len11 = children.length; _i28 < _len11; _i28++) {
7272
- var child = children[_i28];
7433
+ for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
7434
+ var child = children[_i29];
7273
7435
 
7274
7436
  if (!isNull(child) && !isUndefined$1(child.elm)) {
7275
7437
  remove$1(child.elm, renderRoot);
@@ -7643,8 +7805,8 @@
7643
7805
  function connectWireAdapters(vm) {
7644
7806
  var wiredConnecting = vm.context.wiredConnecting;
7645
7807
 
7646
- for (var _i29 = 0, _len12 = wiredConnecting.length; _i29 < _len12; _i29 += 1) {
7647
- wiredConnecting[_i29]();
7808
+ for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
7809
+ wiredConnecting[_i30]();
7648
7810
  }
7649
7811
  }
7650
7812
 
@@ -7652,8 +7814,8 @@
7652
7814
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7653
7815
  runWithBoundaryProtection(vm, vm, noop, function () {
7654
7816
  // job
7655
- for (var _i30 = 0, _len13 = wiredDisconnecting.length; _i30 < _len13; _i30 += 1) {
7656
- wiredDisconnecting[_i30]();
7817
+ for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
7818
+ wiredDisconnecting[_i31]();
7657
7819
  }
7658
7820
  }, noop);
7659
7821
  }
@@ -7663,6 +7825,7 @@
7663
7825
  * SPDX-License-Identifier: MIT
7664
7826
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7665
7827
  */
7828
+ // this is lwc internal implementation
7666
7829
 
7667
7830
 
7668
7831
  function createContextProvider(adapter) {
@@ -7743,7 +7906,7 @@
7743
7906
  hooksAreSet = true;
7744
7907
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7745
7908
  }
7746
- /* version: 2.8.0 */
7909
+ /* version: 2.11.0 */
7747
7910
 
7748
7911
  /*
7749
7912
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7758,8 +7921,8 @@
7758
7921
  if (process.env.NODE_ENV === 'development') {
7759
7922
  // @ts-ignore
7760
7923
  window.__lwcResetGlobalStylesheets = function () {
7761
- for (var _i31 = 0, _Object$keys = Object.keys(globalStylesheets); _i31 < _Object$keys.length; _i31++) {
7762
- var key = _Object$keys[_i31];
7924
+ for (var _i32 = 0, _Object$keys2 = Object.keys(globalStylesheets); _i32 < _Object$keys2.length; _i32++) {
7925
+ var key = _Object$keys2[_i32];
7763
7926
  delete globalStylesheets[key];
7764
7927
  }
7765
7928
  };
@@ -7770,9 +7933,10 @@
7770
7933
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7771
7934
 
7772
7935
  var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7936
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
7773
7937
  var styleElements = create(null);
7774
7938
  var styleSheets = create(null);
7775
- var nodesToStyleSheets = new WeakMap();
7939
+ var shadowRootsToStyleSheets = new WeakMap();
7776
7940
  var getCustomElement;
7777
7941
  var defineCustomElement;
7778
7942
  var HTMLElementConstructor;
@@ -7824,18 +7988,26 @@
7824
7988
  styleSheets[content] = styleSheet;
7825
7989
  }
7826
7990
 
7827
- if (!target.adoptedStyleSheets.includes(styleSheet)) {
7828
- target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
7991
+ var adoptedStyleSheets = target.adoptedStyleSheets;
7992
+
7993
+ if (!adoptedStyleSheets.includes(styleSheet)) {
7994
+ if (supportsMutableAdoptedStyleSheets) {
7995
+ // This is only supported in later versions of Chromium:
7996
+ // https://chromestatus.com/feature/5638996492288000
7997
+ adoptedStyleSheets.push(styleSheet);
7998
+ } else {
7999
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(adoptedStyleSheets), [styleSheet]);
8000
+ }
7829
8001
  }
7830
8002
  }
7831
8003
 
7832
8004
  function insertStyleElement(content, target) {
7833
8005
  // Avoid inserting duplicate `<style>`s
7834
- var sheets = nodesToStyleSheets.get(target);
8006
+ var sheets = shadowRootsToStyleSheets.get(target);
7835
8007
 
7836
8008
  if (isUndefined$1(sheets)) {
7837
8009
  sheets = create(null);
7838
- nodesToStyleSheets.set(target, sheets);
8010
+ shadowRootsToStyleSheets.set(target, sheets);
7839
8011
  }
7840
8012
 
7841
8013
  if (sheets[content]) {
@@ -8125,6 +8297,177 @@
8125
8297
  setSetText(setText);
8126
8298
  setSsr(ssr);
8127
8299
  setAddEventListener(addEventListener);
8300
+ /*
8301
+ * Copyright (c) 2018, salesforce.com, inc.
8302
+ * All rights reserved.
8303
+ * SPDX-License-Identifier: MIT
8304
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8305
+ */
8306
+
8307
+ function resetShadowRootAndLightDom(element, Ctor) {
8308
+ if (element.shadowRoot) {
8309
+ var shadowRoot = element.shadowRoot;
8310
+
8311
+ while (!isNull(shadowRoot.firstChild)) {
8312
+ shadowRoot.removeChild(shadowRoot.firstChild);
8313
+ }
8314
+ }
8315
+
8316
+ if (Ctor.renderMode === 'light') {
8317
+ while (!isNull(element.firstChild)) {
8318
+ element.removeChild(element.firstChild);
8319
+ }
8320
+ }
8321
+ }
8322
+
8323
+ function createVMWithProps(element, Ctor, props) {
8324
+ createVM(element, Ctor, {
8325
+ mode: 'open',
8326
+ owner: null,
8327
+ tagName: element.tagName.toLowerCase()
8328
+ });
8329
+
8330
+ for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
8331
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
8332
+ key = _Object$entries2$_i[0],
8333
+ value = _Object$entries2$_i[1];
8334
+
8335
+ element[key] = value;
8336
+ }
8337
+ }
8338
+
8339
+ function hydrateComponent(element, Ctor) {
8340
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8341
+
8342
+ if (!(element instanceof Element)) {
8343
+ throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
8344
+ }
8345
+
8346
+ if (!isFunction$1(Ctor)) {
8347
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8348
+ }
8349
+
8350
+ if (!isObject(props) || isNull(props)) {
8351
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8352
+ }
8353
+
8354
+ if (getAssociatedVMIfPresent(element)) {
8355
+ /* eslint-disable-next-line no-console */
8356
+ console.warn("\"hydrateComponent\" expects an element that is not hydrated.", element);
8357
+ return;
8358
+ }
8359
+
8360
+ try {
8361
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8362
+ // and uses the same algo to create the stylesheets as in SSR.
8363
+ setIsHydrating(true);
8364
+ createVMWithProps(element, Ctor, props);
8365
+ hydrateRootElement(element); // set it back since now we finished hydration.
8366
+
8367
+ setIsHydrating(false);
8368
+ } catch (e) {
8369
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
8370
+ // with the client generated DOM.
8371
+
8372
+ /* eslint-disable-next-line no-console */
8373
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
8374
+
8375
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
8376
+
8377
+ createVMWithProps(element, Ctor, props);
8378
+ setIsHydrating(false);
8379
+ connectRootElement(element);
8380
+ } finally {
8381
+ // in case there's an error during recovery
8382
+ setIsHydrating(false);
8383
+ }
8384
+ }
8385
+ /*
8386
+ * Copyright (c) 2018, salesforce.com, inc.
8387
+ * All rights reserved.
8388
+ * SPDX-License-Identifier: MIT
8389
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8390
+ */
8391
+
8392
+ /**
8393
+ * This function builds a Web Component class from a LWC constructor so it can be
8394
+ * registered as a new element via customElements.define() at any given time.
8395
+ *
8396
+ * @deprecated since version 1.3.11
8397
+ *
8398
+ * @example
8399
+ * ```
8400
+ * import { buildCustomElementConstructor } from 'lwc';
8401
+ * import Foo from 'ns/foo';
8402
+ * const WC = buildCustomElementConstructor(Foo);
8403
+ * customElements.define('x-foo', WC);
8404
+ * const elm = document.createElement('x-foo');
8405
+ * ```
8406
+ */
8407
+
8408
+
8409
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8410
+ if (process.env.NODE_ENV !== 'production') {
8411
+ /* eslint-disable-next-line no-console */
8412
+ 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."));
8413
+ }
8414
+
8415
+ return Ctor.CustomElementConstructor;
8416
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
8417
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
8418
+
8419
+
8420
+ var hydratedCustomElements = new WeakSet();
8421
+
8422
+ function buildCustomElementConstructor(Ctor) {
8423
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8424
+ return /*#__PURE__*/function (_HtmlPrototype) {
8425
+ _inherits(_class, _HtmlPrototype);
8426
+
8427
+ var _super8 = _createSuper(_class);
8428
+
8429
+ function _class() {
8430
+ var _this6;
8431
+
8432
+ _classCallCheck(this, _class);
8433
+
8434
+ _this6 = _super8.call(this);
8435
+
8436
+ if (_this6.isConnected) {
8437
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
8438
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
8439
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
8440
+ } else {
8441
+ createVM(_assertThisInitialized(_this6), Ctor, {
8442
+ mode: 'open',
8443
+ owner: null,
8444
+ tagName: _this6.tagName
8445
+ });
8446
+ }
8447
+
8448
+ return _this6;
8449
+ }
8450
+
8451
+ _createClass(_class, [{
8452
+ key: "connectedCallback",
8453
+ value: function connectedCallback() {
8454
+ if (hydratedCustomElements.has(this)) {
8455
+ // This is an un-upgraded element that was hydrated in the constructor.
8456
+ hydratedCustomElements.delete(this);
8457
+ } else {
8458
+ connectRootElement(this);
8459
+ }
8460
+ }
8461
+ }, {
8462
+ key: "disconnectedCallback",
8463
+ value: function disconnectedCallback() {
8464
+ disconnectRootElement(this);
8465
+ }
8466
+ }]);
8467
+
8468
+ return _class;
8469
+ }(HtmlPrototype);
8470
+ }
8128
8471
  /*
8129
8472
  * Copyright (c) 2018, salesforce.com, inc.
8130
8473
  * All rights reserved.
@@ -8134,6 +8477,7 @@
8134
8477
  // TODO [#2472]: Remove this workaround when appropriate.
8135
8478
  // eslint-disable-next-line lwc-internal/no-global-node
8136
8479
 
8480
+
8137
8481
  var _Node$1 = Node;
8138
8482
  var ConnectingSlot = new WeakMap();
8139
8483
  var DisconnectingSlot = new WeakMap();
@@ -8241,142 +8585,6 @@
8241
8585
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8242
8586
  */
8243
8587
 
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
8588
  /**
8381
8589
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
8382
8590
  * This API is subject to change or being removed.
@@ -8408,30 +8616,31 @@
8408
8616
 
8409
8617
  var _Node = Node;
8410
8618
  /**
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.
8619
+ * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
8620
+ * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
8413
8621
  */
8414
8622
 
8415
- function isNodeFromTemplate(node) {
8623
+ function isNodeShadowed(node) {
8416
8624
  if (isFalse(node instanceof _Node)) {
8417
8625
  return false;
8418
- } // TODO [#1250]: skipping the shadowRoot instances itself makes no sense, we need to revisit
8419
- // this with locker
8626
+ } // It's debatable whether shadow root instances should be considered as shadowed, but we keep
8627
+ // this unchanged for legacy reasons (#1250).
8420
8628
 
8421
8629
 
8422
8630
  if (node instanceof ShadowRoot) {
8423
8631
  return false;
8424
8632
  }
8425
8633
 
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
- }
8634
+ var rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
8635
+ // synthetic roots cannot be descendants of native roots.
8636
+
8637
+ if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
8638
+ return true;
8639
+ } // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
8640
+ // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
8641
+
8432
8642
 
8433
- var root = node.getRootNode();
8434
- return root instanceof ShadowRoot;
8643
+ return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
8435
8644
  }
8436
8645
  /*
8437
8646
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8475,7 +8684,7 @@
8475
8684
  });
8476
8685
  freeze(LightningElement);
8477
8686
  seal(LightningElement.prototype);
8478
- /* version: 2.8.0 */
8687
+ /* version: 2.11.0 */
8479
8688
 
8480
8689
  exports.LightningElement = LightningElement;
8481
8690
  exports.__unstable__ProfilerControl = profilerControl;
@@ -8487,7 +8696,7 @@
8487
8696
  exports.getComponentDef = getComponentDef;
8488
8697
  exports.hydrateComponent = hydrateComponent;
8489
8698
  exports.isComponentConstructor = isComponentConstructor;
8490
- exports.isNodeFromTemplate = isNodeFromTemplate;
8699
+ exports.isNodeFromTemplate = isNodeShadowed;
8491
8700
  exports.readonly = readonly;
8492
8701
  exports.register = register;
8493
8702
  exports.registerComponent = registerComponent;