lwc 2.9.0 → 2.11.1

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 +4353 -5789
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +4353 -5789
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +3299 -4566
  5. package/dist/engine-dom/iife/es5/engine-dom.js +674 -505
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +542 -448
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +4353 -5789
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +3299 -4566
  11. package/dist/engine-dom/umd/es5/engine-dom.js +674 -505
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +542 -448
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +4061 -5290
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +4061 -5290
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +2952 -3673
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +2952 -3673
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +2825 -3532
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +11 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +11 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +2952 -3673
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +2825 -3532
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +11 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +11 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +128 -174
  27. package/dist/wire-service/iife/es2017/wire-service.js +128 -174
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +128 -174
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +128 -174
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +128 -174
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +7 -7
@@ -7,14 +7,6 @@ var LWC = (function (exports) {
7
7
 
8
8
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
9
9
 
10
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
-
12
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
-
14
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
-
16
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
-
18
10
  function _get2() { if (typeof Reflect !== "undefined" && Reflect.get) { _get2 = Reflect.get; } else { _get2 = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get2.apply(this, arguments); }
19
11
 
20
12
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf2(object); if (object === null) break; } return object; }
@@ -41,6 +33,14 @@ var LWC = (function (exports) {
41
33
 
42
34
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
43
35
 
36
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
37
+
38
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
39
+
40
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
41
+
42
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
43
+
44
44
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
45
45
 
46
46
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -352,7 +352,17 @@ var LWC = (function (exports) {
352
352
  var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
353
353
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
354
354
  var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
355
- /** version: 2.9.0 */
355
+ /*
356
+ * Copyright (c) 2018, salesforce.com, inc.
357
+ * All rights reserved.
358
+ * SPDX-License-Identifier: MIT
359
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
360
+ */
361
+ // Increment whenever the LWC template compiler changes
362
+
363
+ var LWC_VERSION = "2.11.1";
364
+ var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
365
+ /** version: 2.11.1 */
356
366
 
357
367
  /*
358
368
  * Copyright (c) 2018, salesforce.com, inc.
@@ -417,7 +427,7 @@ var LWC = (function (exports) {
417
427
  };
418
428
  }
419
429
 
420
- function patch(propName) {
430
+ function patch$1(propName) {
421
431
  // Typescript is inferring the wrong function type for this particular
422
432
  // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
423
433
  // @ts-ignore type-mismatch
@@ -439,7 +449,7 @@ var LWC = (function (exports) {
439
449
  var propName = ElementPrototypeAriaPropertyNames[_i2];
440
450
 
441
451
  if (detect(propName)) {
442
- patch(propName);
452
+ patch$1(propName);
443
453
  }
444
454
  }
445
455
  /**
@@ -455,14 +465,15 @@ var LWC = (function (exports) {
455
465
 
456
466
 
457
467
  var features = {
458
- ENABLE_REACTIVE_SETTER: null,
459
- ENABLE_HMR: null,
460
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
461
468
  ENABLE_ELEMENT_PATCH: null,
462
469
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
463
- ENABLE_NODE_LIST_PATCH: null,
470
+ ENABLE_HMR: null,
464
471
  ENABLE_HTML_COLLECTIONS_PATCH: null,
472
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
473
+ ENABLE_MIXED_SHADOW_MODE: null,
474
+ ENABLE_NODE_LIST_PATCH: null,
465
475
  ENABLE_NODE_PATCH: null,
476
+ ENABLE_REACTIVE_SETTER: null,
466
477
  ENABLE_WIRE_SYNC_EMIT: null
467
478
  };
468
479
 
@@ -529,7 +540,7 @@ var LWC = (function (exports) {
529
540
  setFeatureFlag(name, value);
530
541
  }
531
542
  }
532
- /** version: 2.9.0 */
543
+ /** version: 2.11.1 */
533
544
 
534
545
  /* proxy-compat-disable */
535
546
 
@@ -632,6 +643,31 @@ var LWC = (function (exports) {
632
643
  }
633
644
 
634
645
  return result;
646
+ }
647
+
648
+ function flattenStylesheets(stylesheets) {
649
+ var list = [];
650
+
651
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
652
+ _step2;
653
+
654
+ try {
655
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
656
+ var stylesheet = _step2.value;
657
+
658
+ if (!Array.isArray(stylesheet)) {
659
+ list.push(stylesheet);
660
+ } else {
661
+ list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
662
+ }
663
+ }
664
+ } catch (err) {
665
+ _iterator2.e(err);
666
+ } finally {
667
+ _iterator2.f();
668
+ }
669
+
670
+ return list;
635
671
  } //
636
672
  // Primitives
637
673
  //
@@ -1127,6 +1163,7 @@ var LWC = (function (exports) {
1127
1163
  * SPDX-License-Identifier: MIT
1128
1164
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1129
1165
  */
1166
+ // These properties get added to LWCElement.prototype publicProps automatically
1130
1167
 
1131
1168
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1132
1169
 
@@ -3392,6 +3429,48 @@ var LWC = (function (exports) {
3392
3429
  var meta = signedDecoratorToMetaMap.get(Ctor);
3393
3430
  return isUndefined$1(meta) ? defaultMeta : meta;
3394
3431
  }
3432
+ /*
3433
+ * Copyright (c) 2018, salesforce.com, inc.
3434
+ * All rights reserved.
3435
+ * SPDX-License-Identifier: MIT
3436
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3437
+ */
3438
+
3439
+
3440
+ var warned = false;
3441
+
3442
+ if (process.env.NODE_ENV === 'development') {
3443
+ // @ts-ignore
3444
+ window.__lwcResetWarnedOnVersionMismatch = function () {
3445
+ warned = false;
3446
+ };
3447
+ }
3448
+
3449
+ function checkVersionMismatch(func, type) {
3450
+ var versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
3451
+
3452
+ if (!isNull(versionMatcher) && !warned) {
3453
+ var version = versionMatcher[1];
3454
+
3455
+ var _version$split = version.split('.'),
3456
+ _version$split2 = _slicedToArray(_version$split, 2),
3457
+ major = _version$split2[0],
3458
+ minor = _version$split2[1];
3459
+
3460
+ var _LWC_VERSION$split = LWC_VERSION.split('.'),
3461
+ _LWC_VERSION$split2 = _slicedToArray(_LWC_VERSION$split, 2),
3462
+ expectedMajor = _LWC_VERSION$split2[0],
3463
+ expectedMinor = _LWC_VERSION$split2[1];
3464
+
3465
+ if (major !== expectedMajor || minor !== expectedMinor) {
3466
+ warned = true; // only warn once to avoid flooding the console
3467
+ // stylesheets and templates do not have user-meaningful names, but components do
3468
+
3469
+ var friendlyName = type === 'component' ? "".concat(type, " ").concat(func.name) : type;
3470
+ logError("LWC WARNING: current engine is v".concat(LWC_VERSION, ", but ").concat(friendlyName, " was compiled with v").concat(version, ".\nPlease update your compiled code or LWC engine so that the versions match.\nNo further warnings will appear."));
3471
+ }
3472
+ }
3473
+ }
3395
3474
 
3396
3475
  var signedTemplateSet = new Set();
3397
3476
 
@@ -3411,6 +3490,10 @@ var LWC = (function (exports) {
3411
3490
 
3412
3491
 
3413
3492
  function registerTemplate(tpl) {
3493
+ if (process.env.NODE_ENV !== 'production') {
3494
+ checkVersionMismatch(tpl, 'template');
3495
+ }
3496
+
3414
3497
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3415
3498
  // assignment of templates easily, without too much transformation
3416
3499
 
@@ -3433,6 +3516,7 @@ var LWC = (function (exports) {
3433
3516
  * SPDX-License-Identifier: MIT
3434
3517
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3435
3518
  */
3519
+ // A bridge descriptor is a descriptor whose job is just to get the component instance
3436
3520
  // from the element instance, and get the value or set a new value on the component.
3437
3521
  // This means that across different elements, similar names can get the exact same
3438
3522
  // descriptor, so we can cache them:
@@ -3706,31 +3790,6 @@ var LWC = (function (exports) {
3706
3790
  return canRefreshAllInstances;
3707
3791
  }
3708
3792
 
3709
- function flattenStylesheets(stylesheets) {
3710
- var list = [];
3711
-
3712
- var _iterator2 = _createForOfIteratorHelper(stylesheets),
3713
- _step2;
3714
-
3715
- try {
3716
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3717
- var stylesheet = _step2.value;
3718
-
3719
- if (!Array.isArray(stylesheet)) {
3720
- list.push(stylesheet);
3721
- } else {
3722
- list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
3723
- }
3724
- }
3725
- } catch (err) {
3726
- _iterator2.e(err);
3727
- } finally {
3728
- _iterator2.f();
3729
- }
3730
-
3731
- return list;
3732
- }
3733
-
3734
3793
  function getTemplateOrSwappedTemplate(tpl) {
3735
3794
  if (process.env.NODE_ENV === 'production') {
3736
3795
  // this method should never leak to prod
@@ -4442,6 +4501,7 @@ var LWC = (function (exports) {
4442
4501
  * SPDX-License-Identifier: MIT
4443
4502
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4444
4503
  */
4504
+ // The style property is a string when defined via an expression in the template.
4445
4505
 
4446
4506
 
4447
4507
  function patchStyleAttribute(oldVnode, vnode) {
@@ -4486,6 +4546,7 @@ var LWC = (function (exports) {
4486
4546
  * SPDX-License-Identifier: MIT
4487
4547
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4488
4548
  */
4549
+ // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
4489
4550
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
4490
4551
  // different classnames properties individually instead of via a string.
4491
4552
 
@@ -4510,6 +4571,7 @@ var LWC = (function (exports) {
4510
4571
  * SPDX-License-Identifier: MIT
4511
4572
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4512
4573
  */
4574
+ // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
4513
4575
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
4514
4576
  // different style properties individually instead of via a string.
4515
4577
 
@@ -4539,146 +4601,262 @@ var LWC = (function (exports) {
4539
4601
  */
4540
4602
 
4541
4603
 
4542
- var TextHook = {
4543
- create: function create(vnode) {
4544
- var owner = vnode.owner;
4545
- var elm = createText$1(vnode.text);
4546
- linkNodeToShadow(elm, owner);
4547
- vnode.elm = elm;
4548
- },
4549
- update: updateNodeHook,
4550
- insert: insertNode,
4551
- move: insertNode,
4552
- remove: removeNode
4553
- };
4554
- var CommentHook = {
4555
- create: function create(vnode) {
4556
- var owner = vnode.owner,
4557
- text = vnode.text;
4558
- var elm = createComment$1(text);
4559
- linkNodeToShadow(elm, owner);
4560
- vnode.elm = elm;
4561
- },
4562
- update: updateNodeHook,
4563
- insert: insertNode,
4564
- move: insertNode,
4565
- remove: removeNode
4566
- }; // insert is called after update, which is used somewhere else (via a module)
4567
- // to mark the vm as inserted, that means we cannot use update as the main channel
4568
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
4569
- // which breaks some invariants. For that reason, we have the following for any
4570
- // Custom Element that is inserted via a template.
4571
-
4572
- var ElementHook = {
4573
- create: function create(vnode) {
4574
- var sel = vnode.sel,
4575
- owner = vnode.owner,
4576
- svg = vnode.data.svg;
4577
- var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4578
- var elm = createElement$2(sel, namespace);
4579
- linkNodeToShadow(elm, owner);
4580
- fallbackElmHook(elm, vnode);
4581
- vnode.elm = elm;
4582
- patchElementPropsAndAttrs$1(null, vnode);
4583
- },
4584
- update: function update(oldVnode, vnode) {
4585
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4586
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4587
- },
4588
- insert: function insert(vnode, parentNode, referenceNode) {
4589
- insertNode(vnode, parentNode, referenceNode);
4590
- createChildrenHook(vnode);
4591
- },
4592
- move: insertNode,
4593
- remove: function remove(vnode, parentNode) {
4594
- removeNode(vnode, parentNode);
4595
- removeChildren(vnode);
4604
+ function patchChildren(c1, c2, parent) {
4605
+ if (hasDynamicChildren(c2)) {
4606
+ updateDynamicChildren(c1, c2, parent);
4607
+ } else {
4608
+ updateStaticChildren(c1, c2, parent);
4596
4609
  }
4597
- };
4598
- var CustomElementHook = {
4599
- create: function create(vnode) {
4600
- var sel = vnode.sel,
4601
- owner = vnode.owner;
4602
- var UpgradableConstructor = getUpgradableConstructor(sel);
4603
- /**
4604
- * Note: if the upgradable constructor does not expect, or throw when we new it
4605
- * with a callback as the first argument, we could implement a more advanced
4606
- * mechanism that only passes that argument if the constructor is known to be
4607
- * an upgradable custom element.
4608
- */
4610
+ }
4609
4611
 
4610
- var vm;
4611
- var elm = new UpgradableConstructor(function (elm) {
4612
- // the custom element from the registry is expecting an upgrade callback
4613
- vm = createViewModelHook(elm, vnode);
4614
- });
4615
- linkNodeToShadow(elm, owner);
4616
- vnode.elm = elm;
4612
+ function patch(n1, n2) {
4613
+ if (n1 === n2) {
4614
+ return;
4615
+ }
4617
4616
 
4618
- if (vm) {
4619
- allocateChildren(vnode, vm);
4620
- } else if (vnode.ctor !== UpgradableConstructor) {
4621
- throw new TypeError("Incorrect Component Constructor");
4617
+ if (process.env.NODE_ENV !== 'production') {
4618
+ if (!isSameVnode(n1, n2)) {
4619
+ throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
4620
+ sel: n1.sel,
4621
+ key: n1.key
4622
+ }) + ', ' + JSON.stringify({
4623
+ sel: n2.sel,
4624
+ key: n2.key
4625
+ }));
4622
4626
  }
4627
+ }
4623
4628
 
4624
- patchElementPropsAndAttrs$1(null, vnode);
4625
- },
4626
- update: function update(oldVnode, vnode) {
4627
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4628
- var vm = getAssociatedVMIfPresent(vnode.elm);
4629
+ switch (n2.type) {
4630
+ case 0
4631
+ /* Text */
4632
+ :
4633
+ patchText(n1, n2);
4634
+ break;
4635
+
4636
+ case 1
4637
+ /* Comment */
4638
+ :
4639
+ patchComment(n1, n2);
4640
+ break;
4629
4641
 
4630
- if (vm) {
4631
- // in fallback mode, the allocation will always set children to
4632
- // empty and delegate the real allocation to the slot elements
4633
- allocateChildren(vnode, vm);
4634
- } // in fallback mode, the children will be always empty, so, nothing
4635
- // will happen, but in native, it does allocate the light dom
4642
+ case 2
4643
+ /* Element */
4644
+ :
4645
+ patchElement(n1, n2);
4646
+ break;
4636
4647
 
4648
+ case 3
4649
+ /* CustomElement */
4650
+ :
4651
+ patchCustomElement(n1, n2);
4652
+ break;
4653
+ }
4654
+ }
4637
4655
 
4638
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4656
+ function mount(node, parent, anchor) {
4657
+ switch (node.type) {
4658
+ case 0
4659
+ /* Text */
4660
+ :
4661
+ mountText(node, parent, anchor);
4662
+ break;
4639
4663
 
4640
- if (vm) {
4641
- if (process.env.NODE_ENV !== 'production') {
4642
- assert.isTrue(isArray$1(vnode.children), "Invalid vnode for a custom element, it must have children defined.");
4643
- } // this will probably update the shadowRoot, but only if the vm is in a dirty state
4644
- // this is important to preserve the top to bottom synchronous rendering phase.
4664
+ case 1
4665
+ /* Comment */
4666
+ :
4667
+ mountComment(node, parent, anchor);
4668
+ break;
4645
4669
 
4670
+ case 2
4671
+ /* Element */
4672
+ :
4673
+ mountElement(node, parent, anchor);
4674
+ break;
4646
4675
 
4647
- rerenderVM(vm);
4648
- }
4649
- },
4650
- insert: function insert(vnode, parentNode, referenceNode) {
4651
- insertNode(vnode, parentNode, referenceNode);
4652
- var vm = getAssociatedVMIfPresent(vnode.elm);
4676
+ case 3
4677
+ /* CustomElement */
4678
+ :
4679
+ mountCustomElement(node, parent, anchor);
4680
+ break;
4681
+ }
4682
+ }
4653
4683
 
4654
- if (vm) {
4655
- if (process.env.NODE_ENV !== 'production') {
4656
- assert.isTrue(vm.state === 0
4657
- /* created */
4658
- , "".concat(vm, " cannot be recycled."));
4659
- }
4684
+ function patchText(n1, n2) {
4685
+ n2.elm = n1.elm;
4686
+
4687
+ if (n2.text !== n1.text) {
4688
+ updateTextContent(n2);
4689
+ }
4690
+ }
4691
+
4692
+ function mountText(node, parent, anchor) {
4693
+ var owner = node.owner;
4694
+ var textNode = node.elm = createText$1(node.text);
4695
+ linkNodeToShadow(textNode, owner);
4696
+ insertNode(textNode, parent, anchor);
4697
+ }
4698
+
4699
+ function patchComment(n1, n2) {
4700
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
4701
+ // it is the case today.
4702
+
4703
+ if (n2.text !== n1.text) {
4704
+ updateTextContent(n2);
4705
+ }
4706
+ }
4707
+
4708
+ function mountComment(node, parent, anchor) {
4709
+ var owner = node.owner;
4710
+ var commentNode = node.elm = createComment$1(node.text);
4711
+ linkNodeToShadow(commentNode, owner);
4712
+ insertNode(commentNode, parent, anchor);
4713
+ }
4714
+
4715
+ function mountElement(vnode, parent, anchor) {
4716
+ var sel = vnode.sel,
4717
+ owner = vnode.owner,
4718
+ svg = vnode.data.svg;
4719
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4720
+ var elm = createElement$2(sel, namespace);
4721
+ linkNodeToShadow(elm, owner);
4722
+ fallbackElmHook(elm, vnode);
4723
+ vnode.elm = elm;
4724
+ patchElementPropsAndAttrs$1(null, vnode);
4725
+ insertNode(elm, parent, anchor);
4726
+ mountVNodes(vnode.children, elm, null);
4727
+ }
4728
+
4729
+ function patchElement(n1, n2) {
4730
+ var elm = n2.elm = n1.elm;
4731
+ patchElementPropsAndAttrs$1(n1, n2);
4732
+ patchChildren(n1.children, n2.children, elm);
4733
+ }
4734
+
4735
+ function mountCustomElement(vnode, parent, anchor) {
4736
+ var sel = vnode.sel,
4737
+ owner = vnode.owner;
4738
+ var UpgradableConstructor = getUpgradableConstructor(sel);
4739
+ /**
4740
+ * Note: if the upgradable constructor does not expect, or throw when we new it
4741
+ * with a callback as the first argument, we could implement a more advanced
4742
+ * mechanism that only passes that argument if the constructor is known to be
4743
+ * an upgradable custom element.
4744
+ */
4660
4745
 
4661
- runConnectedCallback(vm);
4746
+ var vm;
4747
+ var elm = new UpgradableConstructor(function (elm) {
4748
+ // the custom element from the registry is expecting an upgrade callback
4749
+ vm = createViewModelHook(elm, vnode);
4750
+ });
4751
+ linkNodeToShadow(elm, owner);
4752
+ vnode.elm = elm;
4753
+ vnode.vm = vm;
4754
+
4755
+ if (vm) {
4756
+ allocateChildren(vnode, vm);
4757
+ } else if (vnode.ctor !== UpgradableConstructor) {
4758
+ throw new TypeError("Incorrect Component Constructor");
4759
+ }
4760
+
4761
+ patchElementPropsAndAttrs$1(null, vnode);
4762
+ insertNode(elm, parent, anchor);
4763
+
4764
+ if (vm) {
4765
+ if (process.env.NODE_ENV !== 'production') {
4766
+ assert.isTrue(vm.state === 0
4767
+ /* created */
4768
+ , "".concat(vm, " cannot be recycled."));
4662
4769
  }
4663
4770
 
4664
- createChildrenHook(vnode);
4771
+ runConnectedCallback(vm);
4772
+ }
4773
+
4774
+ mountVNodes(vnode.children, elm, null);
4775
+
4776
+ if (vm) {
4777
+ appendVM(vm);
4778
+ }
4779
+ }
4780
+
4781
+ function patchCustomElement(n1, n2) {
4782
+ var elm = n2.elm = n1.elm;
4783
+ var vm = n2.vm = n1.vm;
4784
+ patchElementPropsAndAttrs$1(n1, n2);
4785
+
4786
+ if (!isUndefined$1(vm)) {
4787
+ // in fallback mode, the allocation will always set children to
4788
+ // empty and delegate the real allocation to the slot elements
4789
+ allocateChildren(n2, vm);
4790
+ } // in fallback mode, the children will be always empty, so, nothing
4791
+ // will happen, but in native, it does allocate the light dom
4792
+
4665
4793
 
4666
- if (vm) {
4667
- appendVM(vm);
4794
+ patchChildren(n1.children, n2.children, elm);
4795
+
4796
+ if (!isUndefined$1(vm)) {
4797
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4798
+ // this is important to preserve the top to bottom synchronous rendering phase.
4799
+ rerenderVM(vm);
4800
+ }
4801
+ }
4802
+
4803
+ function mountVNodes(vnodes, parent, anchor) {
4804
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4805
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
4806
+
4807
+ for (; start < end; ++start) {
4808
+ var vnode = vnodes[start];
4809
+
4810
+ if (isVNode(vnode)) {
4811
+ mount(vnode, parent, anchor);
4668
4812
  }
4669
- },
4670
- move: insertNode,
4671
- remove: function remove(vnode, parentNode) {
4672
- removeNode(vnode, parentNode);
4673
- var vm = getAssociatedVMIfPresent(vnode.elm);
4813
+ }
4814
+ }
4815
+
4816
+ function unmount(vnode, parent) {
4817
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4818
+ var type = vnode.type,
4819
+ elm = vnode.elm; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
4820
+ // subtree root, is the only element worth unmounting from the subtree.
4821
+
4822
+ if (doRemove) {
4823
+ removeNode(elm, parent);
4824
+ }
4825
+
4826
+ switch (type) {
4827
+ case 2
4828
+ /* Element */
4829
+ :
4830
+ unmountVNodes(vnode.children, elm);
4831
+ break;
4832
+
4833
+ case 3
4834
+ /* CustomElement */
4835
+ :
4836
+ {
4837
+ var vm = vnode.vm; // No need to unmount the children here, `removeVM` will take care of removing the
4838
+ // children.
4839
+
4840
+ if (!isUndefined$1(vm)) {
4841
+ removeVM(vm);
4842
+ }
4843
+ }
4844
+ }
4845
+ }
4846
+
4847
+ function unmountVNodes(vnodes, parent) {
4848
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4849
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4850
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
4674
4851
 
4675
- if (vm) {
4676
- // for custom elements we don't have to go recursively because the removeVM routine
4677
- // will take care of disconnecting any child VM attached to its shadow as well.
4678
- removeVM(vm);
4852
+ for (; start < end; ++start) {
4853
+ var ch = vnodes[start];
4854
+
4855
+ if (isVNode(ch)) {
4856
+ unmount(ch, parent, doRemove);
4679
4857
  }
4680
4858
  }
4681
- };
4859
+ }
4682
4860
 
4683
4861
  function isVNode(vnode) {
4684
4862
  return vnode != null;
@@ -4719,41 +4897,39 @@ var LWC = (function (exports) {
4719
4897
  }
4720
4898
  }
4721
4899
 
4722
- function updateNodeHook(oldVnode, vnode) {
4900
+ function updateTextContent(vnode) {
4723
4901
  var elm = vnode.elm,
4724
4902
  text = vnode.text;
4725
4903
 
4726
- if (oldVnode.text !== text) {
4727
- if (process.env.NODE_ENV !== 'production') {
4728
- unlockDomMutation();
4729
- }
4904
+ if (process.env.NODE_ENV !== 'production') {
4905
+ unlockDomMutation();
4906
+ }
4730
4907
 
4731
- setText$1(elm, text);
4908
+ setText$1(elm, text);
4732
4909
 
4733
- if (process.env.NODE_ENV !== 'production') {
4734
- lockDomMutation();
4735
- }
4910
+ if (process.env.NODE_ENV !== 'production') {
4911
+ lockDomMutation();
4736
4912
  }
4737
4913
  }
4738
4914
 
4739
- function insertNode(vnode, parentNode, referenceNode) {
4915
+ function insertNode(node, parent, anchor) {
4740
4916
  if (process.env.NODE_ENV !== 'production') {
4741
4917
  unlockDomMutation();
4742
4918
  }
4743
4919
 
4744
- insert$1(vnode.elm, parentNode, referenceNode);
4920
+ insert$1(node, parent, anchor);
4745
4921
 
4746
4922
  if (process.env.NODE_ENV !== 'production') {
4747
4923
  lockDomMutation();
4748
4924
  }
4749
4925
  }
4750
4926
 
4751
- function removeNode(vnode, parentNode) {
4927
+ function removeNode(node, parent) {
4752
4928
  if (process.env.NODE_ENV !== 'production') {
4753
4929
  unlockDomMutation();
4754
4930
  }
4755
4931
 
4756
- remove$1(vnode.elm, parentNode);
4932
+ remove$1(node, parent);
4757
4933
 
4758
4934
  if (process.env.NODE_ENV !== 'production') {
4759
4935
  lockDomMutation();
@@ -4814,14 +4990,6 @@ var LWC = (function (exports) {
4814
4990
  }
4815
4991
  }
4816
4992
 
4817
- function patchChildren(parent, oldCh, newCh) {
4818
- if (hasDynamicChildren(newCh)) {
4819
- updateDynamicChildren(parent, oldCh, newCh);
4820
- } else {
4821
- updateStaticChildren(parent, oldCh, newCh);
4822
- }
4823
- }
4824
-
4825
4993
  function allocateChildren(vnode, vm) {
4826
4994
  // A component with slots will re-render because:
4827
4995
  // 1- There is a change of the internal state.
@@ -4891,43 +5059,13 @@ var LWC = (function (exports) {
4891
5059
  return vm;
4892
5060
  }
4893
5061
 
4894
- function createChildrenHook(vnode) {
4895
- var elm = vnode.elm,
4896
- children = vnode.children;
4897
-
4898
- for (var j = 0; j < children.length; ++j) {
4899
- var ch = children[j];
4900
-
4901
- if (ch != null) {
4902
- ch.hook.create(ch);
4903
- ch.hook.insert(ch, elm, null);
4904
- }
4905
- }
4906
- }
4907
-
4908
- function removeChildren(vnode) {
4909
- // this method only needs to search on child vnodes from template
4910
- // to trigger the remove hook just in case some of those children
4911
- // are custom elements.
4912
- var children = vnode.children,
4913
- elm = vnode.elm;
4914
-
4915
- for (var j = 0, _len5 = children.length; j < _len5; ++j) {
4916
- var ch = children[j];
4917
-
4918
- if (!isNull(ch)) {
4919
- ch.hook.remove(ch, elm);
4920
- }
4921
- }
4922
- }
4923
-
4924
- function allocateInSlot(vm, children) {
4925
- var _a;
5062
+ function allocateInSlot(vm, children) {
5063
+ var _a;
4926
5064
 
4927
5065
  var oldSlots = vm.cmpSlots;
4928
5066
  var cmpSlots = vm.cmpSlots = create(null);
4929
5067
 
4930
- for (var _i13 = 0, _len6 = children.length; _i13 < _len6; _i13 += 1) {
5068
+ for (var _i13 = 0, _len5 = children.length; _i13 < _len5; _i13 += 1) {
4931
5069
  var vnode = children[_i13];
4932
5070
 
4933
5071
  if (isNull(vnode)) {
@@ -4962,7 +5100,7 @@ var LWC = (function (exports) {
4962
5100
  return;
4963
5101
  }
4964
5102
 
4965
- for (var _i14 = 0, _len7 = oldKeys.length; _i14 < _len7; _i14 += 1) {
5103
+ for (var _i14 = 0, _len6 = oldKeys.length; _i14 < _len6; _i14 += 1) {
4966
5104
  var key = oldKeys[_i14];
4967
5105
 
4968
5106
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
@@ -5013,28 +5151,7 @@ var LWC = (function (exports) {
5013
5151
  return map;
5014
5152
  }
5015
5153
 
5016
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
5017
- for (; startIdx <= endIdx; ++startIdx) {
5018
- var ch = vnodes[startIdx];
5019
-
5020
- if (isVNode(ch)) {
5021
- ch.hook.create(ch);
5022
- ch.hook.insert(ch, parentElm, before);
5023
- }
5024
- }
5025
- }
5026
-
5027
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
5028
- for (; startIdx <= endIdx; ++startIdx) {
5029
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
5030
-
5031
- if (isVNode(ch)) {
5032
- ch.hook.remove(ch, parentElm);
5033
- }
5034
- }
5035
- }
5036
-
5037
- function updateDynamicChildren(parentElm, oldCh, newCh) {
5154
+ function updateDynamicChildren(oldCh, newCh, parent) {
5038
5155
  var oldStartIdx = 0;
5039
5156
  var newStartIdx = 0;
5040
5157
  var oldEndIdx = oldCh.length - 1;
@@ -5060,23 +5177,23 @@ var LWC = (function (exports) {
5060
5177
  } else if (!isVNode(newEndVnode)) {
5061
5178
  newEndVnode = newCh[--newEndIdx];
5062
5179
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
5063
- patchVnode(oldStartVnode, newStartVnode);
5180
+ patch(oldStartVnode, newStartVnode);
5064
5181
  oldStartVnode = oldCh[++oldStartIdx];
5065
5182
  newStartVnode = newCh[++newStartIdx];
5066
5183
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
5067
- patchVnode(oldEndVnode, newEndVnode);
5184
+ patch(oldEndVnode, newEndVnode);
5068
5185
  oldEndVnode = oldCh[--oldEndIdx];
5069
5186
  newEndVnode = newCh[--newEndIdx];
5070
5187
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
5071
5188
  // Vnode moved right
5072
- patchVnode(oldStartVnode, newEndVnode);
5073
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5189
+ patch(oldStartVnode, newEndVnode);
5190
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
5074
5191
  oldStartVnode = oldCh[++oldStartIdx];
5075
5192
  newEndVnode = newCh[--newEndIdx];
5076
5193
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
5077
5194
  // Vnode moved left
5078
- patchVnode(oldEndVnode, newStartVnode);
5079
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5195
+ patch(oldEndVnode, newStartVnode);
5196
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
5080
5197
  oldEndVnode = oldCh[--oldEndIdx];
5081
5198
  newStartVnode = newCh[++newStartIdx];
5082
5199
  } else {
@@ -5088,8 +5205,7 @@ var LWC = (function (exports) {
5088
5205
 
5089
5206
  if (isUndefined$1(idxInOld)) {
5090
5207
  // New element
5091
- newStartVnode.hook.create(newStartVnode);
5092
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5208
+ mount(newStartVnode, parent, oldStartVnode.elm);
5093
5209
  newStartVnode = newCh[++newStartIdx];
5094
5210
  } else {
5095
5211
  elmToMove = oldCh[idxInOld];
@@ -5097,10 +5213,9 @@ var LWC = (function (exports) {
5097
5213
  if (isVNode(elmToMove)) {
5098
5214
  if (elmToMove.sel !== newStartVnode.sel) {
5099
5215
  // New element
5100
- newStartVnode.hook.create(newStartVnode);
5101
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5216
+ mount(newStartVnode, parent, oldStartVnode.elm);
5102
5217
  } else {
5103
- patchVnode(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5218
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5104
5219
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
5105
5220
  // so we only care about the `oldCh` object inside this function.
5106
5221
  // To avoid cloning over and over again, we check `clonedOldCh`
@@ -5113,7 +5228,7 @@ var LWC = (function (exports) {
5113
5228
 
5114
5229
 
5115
5230
  oldCh[idxInOld] = undefined;
5116
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5231
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
5117
5232
  }
5118
5233
  }
5119
5234
 
@@ -5134,65 +5249,55 @@ var LWC = (function (exports) {
5134
5249
  } while (!isVNode(n) && _i15 < newChEnd);
5135
5250
 
5136
5251
  before = isVNode(n) ? n.elm : null;
5137
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5252
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
5138
5253
  } else {
5139
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5254
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
5140
5255
  }
5141
5256
  }
5142
5257
  }
5143
5258
 
5144
- function updateStaticChildren(parentElm, oldCh, newCh) {
5145
- var oldChLength = oldCh.length;
5146
- var newChLength = newCh.length;
5259
+ function updateStaticChildren(c1, c2, parent) {
5260
+ var c1Length = c1.length;
5261
+ var c2Length = c2.length;
5147
5262
 
5148
- if (oldChLength === 0) {
5263
+ if (c1Length === 0) {
5149
5264
  // the old list is empty, we can directly insert anything new
5150
- addVnodes(parentElm, null, newCh, 0, newChLength);
5265
+ mountVNodes(c2, parent, null);
5151
5266
  return;
5152
5267
  }
5153
5268
 
5154
- if (newChLength === 0) {
5269
+ if (c2Length === 0) {
5155
5270
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5156
5271
  // this is the case in which the dynamic children of an if-directive should be removed
5157
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5272
+ unmountVNodes(c1, parent, true);
5158
5273
  return;
5159
5274
  } // if the old list is not empty, the new list MUST have the same
5160
5275
  // amount of nodes, that's why we call this static children
5161
5276
 
5162
5277
 
5163
- var referenceElm = null;
5278
+ var anchor = null;
5164
5279
 
5165
- for (var _i16 = newChLength - 1; _i16 >= 0; _i16 -= 1) {
5166
- var vnode = newCh[_i16];
5167
- var oldVNode = oldCh[_i16];
5280
+ for (var _i16 = c2Length - 1; _i16 >= 0; _i16 -= 1) {
5281
+ var n1 = c1[_i16];
5282
+ var n2 = c2[_i16];
5168
5283
 
5169
- if (vnode !== oldVNode) {
5170
- if (isVNode(oldVNode)) {
5171
- if (isVNode(vnode)) {
5172
- // both vnodes must be equivalent, and se just need to patch them
5173
- patchVnode(oldVNode, vnode);
5174
- referenceElm = vnode.elm;
5284
+ if (n2 !== n1) {
5285
+ if (isVNode(n1)) {
5286
+ if (isVNode(n2)) {
5287
+ // both vnodes are equivalent, and we just need to patch them
5288
+ patch(n1, n2);
5289
+ anchor = n2.elm;
5175
5290
  } else {
5176
5291
  // removing the old vnode since the new one is null
5177
- oldVNode.hook.remove(oldVNode, parentElm);
5292
+ unmount(n1, parent, true);
5178
5293
  }
5179
- } else if (isVNode(vnode)) {
5180
- // this condition is unnecessary
5181
- vnode.hook.create(vnode); // insert the new node one since the old one is null
5182
-
5183
- vnode.hook.insert(vnode, parentElm, referenceElm);
5184
- referenceElm = vnode.elm;
5294
+ } else if (isVNode(n2)) {
5295
+ mount(n2, parent, anchor);
5296
+ anchor = n2.elm;
5185
5297
  }
5186
5298
  }
5187
5299
  }
5188
5300
  }
5189
-
5190
- function patchVnode(oldVnode, vnode) {
5191
- if (oldVnode !== vnode) {
5192
- vnode.elm = oldVnode.elm;
5193
- vnode.hook.update(oldVnode, vnode);
5194
- }
5195
- }
5196
5301
  /*
5197
5302
  * Copyright (c) 2018, salesforce.com, inc.
5198
5303
  * All rights reserved.
@@ -5243,7 +5348,6 @@ var LWC = (function (exports) {
5243
5348
  children: children,
5244
5349
  elm: elm,
5245
5350
  key: key,
5246
- hook: ElementHook,
5247
5351
  owner: vmBeingRendered
5248
5352
  };
5249
5353
  } // [t]ab[i]ndex function
@@ -5327,7 +5431,7 @@ var LWC = (function (exports) {
5327
5431
  }
5328
5432
 
5329
5433
  var key = data.key;
5330
- var elm;
5434
+ var elm, aChildren, vm;
5331
5435
  var vnode = {
5332
5436
  type: 3
5333
5437
  /* CustomElement */
@@ -5337,11 +5441,11 @@ var LWC = (function (exports) {
5337
5441
  children: children,
5338
5442
  elm: elm,
5339
5443
  key: key,
5340
- hook: CustomElementHook,
5341
5444
  ctor: Ctor,
5342
5445
  owner: vmBeingRendered,
5343
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5344
-
5446
+ mode: 'open',
5447
+ aChildren: aChildren,
5448
+ vm: vm
5345
5449
  };
5346
5450
  addVNodeToChildLWC(vnode);
5347
5451
  return vnode;
@@ -5468,7 +5572,6 @@ var LWC = (function (exports) {
5468
5572
  text: text,
5469
5573
  elm: elm,
5470
5574
  key: key,
5471
- hook: TextHook,
5472
5575
  owner: getVMBeingRendered()
5473
5576
  };
5474
5577
  } // [co]mment node
@@ -5484,7 +5587,6 @@ var LWC = (function (exports) {
5484
5587
  text: text,
5485
5588
  elm: elm,
5486
5589
  key: key,
5487
- hook: CommentHook,
5488
5590
  owner: getVMBeingRendered()
5489
5591
  };
5490
5592
  } // [d]ynamic text
@@ -5788,9 +5890,11 @@ var LWC = (function (exports) {
5788
5890
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
5789
5891
  } else {
5790
5892
  if (process.env.NODE_ENV !== 'production') {
5791
- // in dev-mode, we support hot swapping of stylesheet, which means that
5893
+ // Check for compiler version mismatch in dev mode only
5894
+ checkVersionMismatch(stylesheet, 'stylesheet'); // in dev-mode, we support hot swapping of stylesheet, which means that
5792
5895
  // the component instance might be attempting to use an old version of
5793
5896
  // the stylesheet, while internally, we have a replacement for it.
5897
+
5794
5898
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5795
5899
  }
5796
5900
 
@@ -6315,11 +6419,20 @@ var LWC = (function (exports) {
6315
6419
  * will prevent this function from being imported by userland code.
6316
6420
  */
6317
6421
 
6318
- function registerComponent(Ctor, _ref2) {
6422
+ function registerComponent( // We typically expect a LightningElementConstructor, but technically you can call this with anything
6423
+ Ctor, _ref2) {
6319
6424
  var tmpl = _ref2.tmpl;
6320
- signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6425
+
6426
+ if (isFunction$1(Ctor)) {
6427
+ if (process.env.NODE_ENV !== 'production') {
6428
+ checkVersionMismatch(Ctor, 'component');
6429
+ }
6430
+
6431
+ signedTemplateMap.set(Ctor, tmpl);
6432
+ } // chaining this method as a way to wrap existing assignment of component constructor easily,
6321
6433
  // without too much transformation
6322
6434
 
6435
+
6323
6436
  return Ctor;
6324
6437
  }
6325
6438
 
@@ -6426,7 +6539,7 @@ var LWC = (function (exports) {
6426
6539
  def = vm.def,
6427
6540
  context = vm.context;
6428
6541
 
6429
- for (var _i22 = 0, _len8 = cbs.length; _i22 < _len8; ++_i22) {
6542
+ for (var _i22 = 0, _len7 = cbs.length; _i22 < _len7; ++_i22) {
6430
6543
  cbs[_i22].call(undefined, component, {}, def, context);
6431
6544
  }
6432
6545
  }
@@ -6438,7 +6551,7 @@ var LWC = (function (exports) {
6438
6551
  */
6439
6552
 
6440
6553
 
6441
- function hydrate$1(vnode, node) {
6554
+ function hydrate(vnode, node) {
6442
6555
  switch (vnode.type) {
6443
6556
  case 0
6444
6557
  /* Text */
@@ -6470,16 +6583,18 @@ var LWC = (function (exports) {
6470
6583
  var _a;
6471
6584
 
6472
6585
  if (process.env.NODE_ENV !== 'production') {
6473
- // eslint-disable-next-line lwc-internal/no-global-node
6474
- validateNodeType(vnode, node, Node.TEXT_NODE);
6586
+ validateNodeType(vnode, node, 3
6587
+ /* TEXT */
6588
+ );
6589
+ var nodeValue = getProperty$1(node, 'nodeValue');
6475
6590
 
6476
- if (node.nodeValue !== vnode.text && !(node.nodeValue === "\u200D" && vnode.text === '')) {
6591
+ if (nodeValue !== vnode.text && !(nodeValue === "\u200D" && vnode.text === '')) {
6477
6592
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6478
6593
  }
6479
6594
  } // always set the text value to the one from the vnode.
6480
6595
 
6481
6596
 
6482
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6597
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6483
6598
  vnode.elm = node;
6484
6599
  }
6485
6600
 
@@ -6487,23 +6602,25 @@ var LWC = (function (exports) {
6487
6602
  var _a;
6488
6603
 
6489
6604
  if (process.env.NODE_ENV !== 'production') {
6490
- // eslint-disable-next-line lwc-internal/no-global-node
6491
- validateNodeType(vnode, node, Node.COMMENT_NODE);
6605
+ validateNodeType(vnode, node, 8
6606
+ /* COMMENT */
6607
+ );
6492
6608
 
6493
- if (node.nodeValue !== vnode.text) {
6609
+ if (getProperty$1(node, 'nodeValue') !== vnode.text) {
6494
6610
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6495
6611
  }
6496
6612
  } // always set the text value to the one from the vnode.
6497
6613
 
6498
6614
 
6499
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6615
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6500
6616
  vnode.elm = node;
6501
6617
  }
6502
6618
 
6503
6619
  function hydrateElement(vnode, node) {
6504
6620
  if (process.env.NODE_ENV !== 'production') {
6505
- // eslint-disable-next-line lwc-internal/no-global-node
6506
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6621
+ validateNodeType(vnode, node, 1
6622
+ /* ELEMENT */
6623
+ );
6507
6624
  validateElement(vnode, node);
6508
6625
  }
6509
6626
 
@@ -6520,13 +6637,13 @@ var LWC = (function (exports) {
6520
6637
  var props = vnode.data.props;
6521
6638
 
6522
6639
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6523
- if (elm.innerHTML === props.innerHTML) {
6640
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6524
6641
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6525
6642
  vnode.data = Object.assign(Object.assign({}, vnode.data), {
6526
6643
  props: cloneAndOmitKey(props, 'innerHTML')
6527
6644
  });
6528
6645
  } else {
6529
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6646
+ logWarn("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6530
6647
  }
6531
6648
  }
6532
6649
  }
@@ -6534,19 +6651,19 @@ var LWC = (function (exports) {
6534
6651
  patchElementPropsAndAttrs(vnode);
6535
6652
 
6536
6653
  if (!isDomManual) {
6537
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
6654
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
6538
6655
  }
6539
6656
  }
6540
6657
 
6541
6658
  function hydrateCustomElement(vnode, node) {
6542
6659
  if (process.env.NODE_ENV !== 'production') {
6543
- // eslint-disable-next-line lwc-internal/no-global-node
6544
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6660
+ validateNodeType(vnode, node, 1
6661
+ /* ELEMENT */
6662
+ );
6545
6663
  validateElement(vnode, node);
6546
6664
  }
6547
6665
 
6548
6666
  var elm = node;
6549
- vnode.elm = elm;
6550
6667
  var sel = vnode.sel,
6551
6668
  mode = vnode.mode,
6552
6669
  ctor = vnode.ctor,
@@ -6556,6 +6673,8 @@ var LWC = (function (exports) {
6556
6673
  owner: owner,
6557
6674
  tagName: sel
6558
6675
  });
6676
+ vnode.elm = elm;
6677
+ vnode.vm = vm;
6559
6678
  allocateChildren(vnode, vm);
6560
6679
  patchElementPropsAndAttrs(vnode); // Insert hook section:
6561
6680
 
@@ -6572,7 +6691,7 @@ var LWC = (function (exports) {
6572
6691
  ) {
6573
6692
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6574
6693
  // Note: for Light DOM, this is handled while hydrating the VM
6575
- hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
6694
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vm);
6576
6695
  }
6577
6696
 
6578
6697
  hydrateVM(vm);
@@ -6597,7 +6716,7 @@ var LWC = (function (exports) {
6597
6716
 
6598
6717
  if (!isNull(childVnode)) {
6599
6718
  var childNode = elmChildren[childNodeIndex];
6600
- hydrate$1(childVnode, childNode);
6719
+ hydrate(childVnode, childNode);
6601
6720
  childNodeIndex++;
6602
6721
  }
6603
6722
  }
@@ -6613,15 +6732,15 @@ var LWC = (function (exports) {
6613
6732
  }
6614
6733
 
6615
6734
  function validateNodeType(vnode, node, nodeType) {
6616
- if (node.nodeType !== nodeType) {
6735
+ if (getProperty$1(node, 'nodeType') !== nodeType) {
6617
6736
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
6618
6737
  assert.fail('Hydration mismatch: incorrect node type received.');
6619
6738
  }
6620
6739
  }
6621
6740
 
6622
6741
  function validateElement(vnode, elm) {
6623
- if (vnode.sel.toLowerCase() !== elm.tagName.toLowerCase()) {
6624
- logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(elm.tagName.toLowerCase(), "\"."), vnode.owner);
6742
+ if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
6743
+ logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(getProperty$1(elm, 'tagName').toLowerCase(), "\"."), vnode.owner);
6625
6744
  throwHydrationError();
6626
6745
  }
6627
6746
 
@@ -6649,7 +6768,7 @@ var LWC = (function (exports) {
6649
6768
  var elmAttrValue = getAttribute$1(elm, attrName);
6650
6769
 
6651
6770
  if (String(attrValue) !== elmAttrValue) {
6652
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
6771
+ 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);
6653
6772
  nodesAreCompatible = false;
6654
6773
  }
6655
6774
  }
@@ -6664,7 +6783,7 @@ var LWC = (function (exports) {
6664
6783
  var nodesAreCompatible = true;
6665
6784
  var vnodeClassName;
6666
6785
 
6667
- if (!isUndefined$1(className) && String(className) !== elm.className) {
6786
+ if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6668
6787
  // className is used when class is bound to an expr.
6669
6788
  nodesAreCompatible = false;
6670
6789
  vnodeClassName = className;
@@ -6689,7 +6808,7 @@ var LWC = (function (exports) {
6689
6808
  }
6690
6809
 
6691
6810
  if (!nodesAreCompatible) {
6692
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(elm.className, "\""), vnode.owner);
6811
+ 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);
6693
6812
  }
6694
6813
 
6695
6814
  return nodesAreCompatible;
@@ -6737,7 +6856,7 @@ var LWC = (function (exports) {
6737
6856
 
6738
6857
  if (!nodesAreCompatible) {
6739
6858
  // style is used when class is bound to an expr.
6740
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
6859
+ logError("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
6741
6860
  }
6742
6861
 
6743
6862
  return nodesAreCompatible;
@@ -6808,7 +6927,19 @@ var LWC = (function (exports) {
6808
6927
  }
6809
6928
 
6810
6929
  function hydrateVM(vm) {
6811
- hydrate(vm);
6930
+ if (isTrue(vm.isDirty)) {
6931
+ // manually diffing/patching here.
6932
+ // This routine is:
6933
+ // patchShadowRoot(vm, children);
6934
+ // -> addVnodes.
6935
+ var children = renderComponent(vm);
6936
+ vm.children = children;
6937
+ var vmChildren = vm.renderMode === 0
6938
+ /* Light */
6939
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
6940
+ hydrateChildren(vmChildren, children, vm);
6941
+ runRenderedCallback(vm);
6942
+ }
6812
6943
  } // just in case the component comes back, with this we guarantee re-rendering it
6813
6944
  // while preventing any attempt to rehydration until after reinsertion.
6814
6945
 
@@ -6951,30 +7082,38 @@ var LWC = (function (exports) {
6951
7082
  /* Native */
6952
7083
  ;
6953
7084
  } else if (isNativeShadowDefined$1) {
6954
- if (def.shadowSupportMode === "any"
6955
- /* Any */
6956
- ) {
6957
- shadowMode = 0
6958
- /* Native */
6959
- ;
6960
- } else {
6961
- var shadowAncestor = getNearestShadowAncestor(vm);
6962
-
6963
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
6964
- /* Native */
7085
+ // Not combined with above condition because @lwc/features only supports identifiers in
7086
+ // the if-condition.
7087
+ if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
7088
+ if (def.shadowSupportMode === "any"
7089
+ /* Any */
6965
7090
  ) {
6966
- // Transitive support for native Shadow DOM. A component in native mode
6967
- // transitively opts all of its descendants into native.
6968
7091
  shadowMode = 0
6969
7092
  /* Native */
6970
7093
  ;
6971
7094
  } else {
6972
- // Synthetic if neither this component nor any of its ancestors are configured
6973
- // to be native.
6974
- shadowMode = 1
6975
- /* Synthetic */
6976
- ;
7095
+ var shadowAncestor = getNearestShadowAncestor(vm);
7096
+
7097
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
7098
+ /* Native */
7099
+ ) {
7100
+ // Transitive support for native Shadow DOM. A component in native mode
7101
+ // transitively opts all of its descendants into native.
7102
+ shadowMode = 0
7103
+ /* Native */
7104
+ ;
7105
+ } else {
7106
+ // Synthetic if neither this component nor any of its ancestors are configured
7107
+ // to be native.
7108
+ shadowMode = 1
7109
+ /* Synthetic */
7110
+ ;
7111
+ }
6977
7112
  }
7113
+ } else {
7114
+ shadowMode = 1
7115
+ /* Synthetic */
7116
+ ;
6978
7117
  }
6979
7118
  } else {
6980
7119
  // Synthetic if there is no native Shadow DOM support.
@@ -7031,22 +7170,6 @@ var LWC = (function (exports) {
7031
7170
  }
7032
7171
  }
7033
7172
 
7034
- function hydrate(vm) {
7035
- if (isTrue(vm.isDirty)) {
7036
- // manually diffing/patching here.
7037
- // This routine is:
7038
- // patchShadowRoot(vm, children);
7039
- // -> addVnodes.
7040
- var children = renderComponent(vm);
7041
- vm.children = children;
7042
- var vmChildren = vm.renderMode === 0
7043
- /* Light */
7044
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
7045
- hydrateChildren(vmChildren, children, vm);
7046
- runRenderedCallback(vm);
7047
- }
7048
- }
7049
-
7050
7173
  function patchShadowRoot(vm, newCh) {
7051
7174
  var renderRoot = vm.renderRoot,
7052
7175
  oldCh = vm.children; // caching the new children collection
@@ -7064,7 +7187,7 @@ var LWC = (function (exports) {
7064
7187
  , vm);
7065
7188
  }, function () {
7066
7189
  // job
7067
- patchChildren(renderRoot, oldCh, newCh);
7190
+ patchChildren(oldCh, newCh, renderRoot);
7068
7191
  }, function () {
7069
7192
  // post
7070
7193
  logOperationEnd(2
@@ -7125,13 +7248,13 @@ var LWC = (function (exports) {
7125
7248
  });
7126
7249
  rehydrateQueue = []; // reset to a new queue
7127
7250
 
7128
- for (var _i26 = 0, _len9 = vms.length; _i26 < _len9; _i26 += 1) {
7251
+ for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
7129
7252
  var vm = vms[_i26];
7130
7253
 
7131
7254
  try {
7132
7255
  rehydrate(vm);
7133
7256
  } catch (error) {
7134
- if (_i26 + 1 < _len9) {
7257
+ if (_i26 + 1 < _len8) {
7135
7258
  // pieces of the queue are still pending to be rehydrated, those should have priority
7136
7259
  if (rehydrateQueue.length === 0) {
7137
7260
  addCallbackToNextTick(flushRehydrationQueue);
@@ -7276,7 +7399,7 @@ var LWC = (function (exports) {
7276
7399
 
7277
7400
 
7278
7401
  function recursivelyDisconnectChildren(vnodes) {
7279
- for (var _i28 = 0, _len10 = vnodes.length; _i28 < _len10; _i28 += 1) {
7402
+ for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
7280
7403
  var vnode = vnodes[_i28];
7281
7404
 
7282
7405
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
@@ -7308,7 +7431,7 @@ var LWC = (function (exports) {
7308
7431
  var children = vm.children,
7309
7432
  renderRoot = vm.renderRoot;
7310
7433
 
7311
- for (var _i29 = 0, _len11 = children.length; _i29 < _len11; _i29++) {
7434
+ for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
7312
7435
  var child = children[_i29];
7313
7436
 
7314
7437
  if (!isNull(child) && !isUndefined$1(child.elm)) {
@@ -7683,7 +7806,7 @@ var LWC = (function (exports) {
7683
7806
  function connectWireAdapters(vm) {
7684
7807
  var wiredConnecting = vm.context.wiredConnecting;
7685
7808
 
7686
- for (var _i30 = 0, _len12 = wiredConnecting.length; _i30 < _len12; _i30 += 1) {
7809
+ for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
7687
7810
  wiredConnecting[_i30]();
7688
7811
  }
7689
7812
  }
@@ -7692,7 +7815,7 @@ var LWC = (function (exports) {
7692
7815
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7693
7816
  runWithBoundaryProtection(vm, vm, noop, function () {
7694
7817
  // job
7695
- for (var _i31 = 0, _len13 = wiredDisconnecting.length; _i31 < _len13; _i31 += 1) {
7818
+ for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
7696
7819
  wiredDisconnecting[_i31]();
7697
7820
  }
7698
7821
  }, noop);
@@ -7703,6 +7826,7 @@ var LWC = (function (exports) {
7703
7826
  * SPDX-License-Identifier: MIT
7704
7827
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7705
7828
  */
7829
+ // this is lwc internal implementation
7706
7830
 
7707
7831
 
7708
7832
  function createContextProvider(adapter) {
@@ -7783,7 +7907,7 @@ var LWC = (function (exports) {
7783
7907
  hooksAreSet = true;
7784
7908
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7785
7909
  }
7786
- /* version: 2.9.0 */
7910
+ /* version: 2.11.1 */
7787
7911
 
7788
7912
  /*
7789
7913
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7810,9 +7934,10 @@ var LWC = (function (exports) {
7810
7934
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7811
7935
 
7812
7936
  var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7937
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
7813
7938
  var styleElements = create(null);
7814
7939
  var styleSheets = create(null);
7815
- var nodesToStyleSheets = new WeakMap();
7940
+ var shadowRootsToStyleSheets = new WeakMap();
7816
7941
  var getCustomElement;
7817
7942
  var defineCustomElement;
7818
7943
  var HTMLElementConstructor;
@@ -7864,18 +7989,26 @@ var LWC = (function (exports) {
7864
7989
  styleSheets[content] = styleSheet;
7865
7990
  }
7866
7991
 
7867
- if (!target.adoptedStyleSheets.includes(styleSheet)) {
7868
- target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
7992
+ var adoptedStyleSheets = target.adoptedStyleSheets;
7993
+
7994
+ if (!adoptedStyleSheets.includes(styleSheet)) {
7995
+ if (supportsMutableAdoptedStyleSheets) {
7996
+ // This is only supported in later versions of Chromium:
7997
+ // https://chromestatus.com/feature/5638996492288000
7998
+ adoptedStyleSheets.push(styleSheet);
7999
+ } else {
8000
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(adoptedStyleSheets), [styleSheet]);
8001
+ }
7869
8002
  }
7870
8003
  }
7871
8004
 
7872
8005
  function insertStyleElement(content, target) {
7873
8006
  // Avoid inserting duplicate `<style>`s
7874
- var sheets = nodesToStyleSheets.get(target);
8007
+ var sheets = shadowRootsToStyleSheets.get(target);
7875
8008
 
7876
8009
  if (isUndefined$1(sheets)) {
7877
8010
  sheets = create(null);
7878
- nodesToStyleSheets.set(target, sheets);
8011
+ shadowRootsToStyleSheets.set(target, sheets);
7879
8012
  }
7880
8013
 
7881
8014
  if (sheets[content]) {
@@ -8165,6 +8298,177 @@ var LWC = (function (exports) {
8165
8298
  setSetText(setText);
8166
8299
  setSsr(ssr);
8167
8300
  setAddEventListener(addEventListener);
8301
+ /*
8302
+ * Copyright (c) 2018, salesforce.com, inc.
8303
+ * All rights reserved.
8304
+ * SPDX-License-Identifier: MIT
8305
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8306
+ */
8307
+
8308
+ function resetShadowRootAndLightDom(element, Ctor) {
8309
+ if (element.shadowRoot) {
8310
+ var shadowRoot = element.shadowRoot;
8311
+
8312
+ while (!isNull(shadowRoot.firstChild)) {
8313
+ shadowRoot.removeChild(shadowRoot.firstChild);
8314
+ }
8315
+ }
8316
+
8317
+ if (Ctor.renderMode === 'light') {
8318
+ while (!isNull(element.firstChild)) {
8319
+ element.removeChild(element.firstChild);
8320
+ }
8321
+ }
8322
+ }
8323
+
8324
+ function createVMWithProps(element, Ctor, props) {
8325
+ createVM(element, Ctor, {
8326
+ mode: 'open',
8327
+ owner: null,
8328
+ tagName: element.tagName.toLowerCase()
8329
+ });
8330
+
8331
+ for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
8332
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
8333
+ key = _Object$entries2$_i[0],
8334
+ value = _Object$entries2$_i[1];
8335
+
8336
+ element[key] = value;
8337
+ }
8338
+ }
8339
+
8340
+ function hydrateComponent(element, Ctor) {
8341
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8342
+
8343
+ if (!(element instanceof Element)) {
8344
+ throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
8345
+ }
8346
+
8347
+ if (!isFunction$1(Ctor)) {
8348
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8349
+ }
8350
+
8351
+ if (!isObject(props) || isNull(props)) {
8352
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8353
+ }
8354
+
8355
+ if (getAssociatedVMIfPresent(element)) {
8356
+ /* eslint-disable-next-line no-console */
8357
+ console.warn("\"hydrateComponent\" expects an element that is not hydrated.", element);
8358
+ return;
8359
+ }
8360
+
8361
+ try {
8362
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8363
+ // and uses the same algo to create the stylesheets as in SSR.
8364
+ setIsHydrating(true);
8365
+ createVMWithProps(element, Ctor, props);
8366
+ hydrateRootElement(element); // set it back since now we finished hydration.
8367
+
8368
+ setIsHydrating(false);
8369
+ } catch (e) {
8370
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
8371
+ // with the client generated DOM.
8372
+
8373
+ /* eslint-disable-next-line no-console */
8374
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
8375
+
8376
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
8377
+
8378
+ createVMWithProps(element, Ctor, props);
8379
+ setIsHydrating(false);
8380
+ connectRootElement(element);
8381
+ } finally {
8382
+ // in case there's an error during recovery
8383
+ setIsHydrating(false);
8384
+ }
8385
+ }
8386
+ /*
8387
+ * Copyright (c) 2018, salesforce.com, inc.
8388
+ * All rights reserved.
8389
+ * SPDX-License-Identifier: MIT
8390
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8391
+ */
8392
+
8393
+ /**
8394
+ * This function builds a Web Component class from a LWC constructor so it can be
8395
+ * registered as a new element via customElements.define() at any given time.
8396
+ *
8397
+ * @deprecated since version 1.3.11
8398
+ *
8399
+ * @example
8400
+ * ```
8401
+ * import { buildCustomElementConstructor } from 'lwc';
8402
+ * import Foo from 'ns/foo';
8403
+ * const WC = buildCustomElementConstructor(Foo);
8404
+ * customElements.define('x-foo', WC);
8405
+ * const elm = document.createElement('x-foo');
8406
+ * ```
8407
+ */
8408
+
8409
+
8410
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8411
+ if (process.env.NODE_ENV !== 'production') {
8412
+ /* eslint-disable-next-line no-console */
8413
+ 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."));
8414
+ }
8415
+
8416
+ return Ctor.CustomElementConstructor;
8417
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
8418
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
8419
+
8420
+
8421
+ var hydratedCustomElements = new WeakSet();
8422
+
8423
+ function buildCustomElementConstructor(Ctor) {
8424
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8425
+ return /*#__PURE__*/function (_HtmlPrototype) {
8426
+ _inherits(_class, _HtmlPrototype);
8427
+
8428
+ var _super8 = _createSuper(_class);
8429
+
8430
+ function _class() {
8431
+ var _this6;
8432
+
8433
+ _classCallCheck(this, _class);
8434
+
8435
+ _this6 = _super8.call(this);
8436
+
8437
+ if (_this6.isConnected) {
8438
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
8439
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
8440
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
8441
+ } else {
8442
+ createVM(_assertThisInitialized(_this6), Ctor, {
8443
+ mode: 'open',
8444
+ owner: null,
8445
+ tagName: _this6.tagName
8446
+ });
8447
+ }
8448
+
8449
+ return _this6;
8450
+ }
8451
+
8452
+ _createClass(_class, [{
8453
+ key: "connectedCallback",
8454
+ value: function connectedCallback() {
8455
+ if (hydratedCustomElements.has(this)) {
8456
+ // This is an un-upgraded element that was hydrated in the constructor.
8457
+ hydratedCustomElements.delete(this);
8458
+ } else {
8459
+ connectRootElement(this);
8460
+ }
8461
+ }
8462
+ }, {
8463
+ key: "disconnectedCallback",
8464
+ value: function disconnectedCallback() {
8465
+ disconnectRootElement(this);
8466
+ }
8467
+ }]);
8468
+
8469
+ return _class;
8470
+ }(HtmlPrototype);
8471
+ }
8168
8472
  /*
8169
8473
  * Copyright (c) 2018, salesforce.com, inc.
8170
8474
  * All rights reserved.
@@ -8174,6 +8478,7 @@ var LWC = (function (exports) {
8174
8478
  // TODO [#2472]: Remove this workaround when appropriate.
8175
8479
  // eslint-disable-next-line lwc-internal/no-global-node
8176
8480
 
8481
+
8177
8482
  var _Node$1 = Node;
8178
8483
  var ConnectingSlot = new WeakMap();
8179
8484
  var DisconnectingSlot = new WeakMap();
@@ -8281,142 +8586,6 @@ var LWC = (function (exports) {
8281
8586
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8282
8587
  */
8283
8588
 
8284
-
8285
- function hydrateComponent(element, Ctor) {
8286
- var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8287
-
8288
- if (!(element instanceof Element)) {
8289
- throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
8290
- }
8291
-
8292
- if (!isFunction$1(Ctor)) {
8293
- throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8294
- }
8295
-
8296
- if (!isObject(props) || isNull(props)) {
8297
- throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8298
- }
8299
-
8300
- try {
8301
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8302
- // and uses the same algo to create the stylesheets as in SSR.
8303
- setIsHydrating(true);
8304
- createVM(element, Ctor, {
8305
- mode: 'open',
8306
- owner: null,
8307
- tagName: element.tagName.toLowerCase()
8308
- });
8309
-
8310
- for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
8311
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
8312
- key = _Object$entries2$_i[0],
8313
- value = _Object$entries2$_i[1];
8314
-
8315
- element[key] = value;
8316
- }
8317
-
8318
- hydrateRootElement(element); // set it back since now we finished hydration.
8319
-
8320
- setIsHydrating(false);
8321
- } catch (e) {
8322
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8323
- // the client generated DOM.
8324
-
8325
- /* eslint-disable-next-line no-console */
8326
- console.error('Recovering from error while hydrating: ', e);
8327
- setIsHydrating(false);
8328
- var newElem = createElement(element.tagName, {
8329
- is: Ctor,
8330
- mode: 'open'
8331
- });
8332
-
8333
- for (var _i34 = 0, _Object$entries3 = Object.entries(props); _i34 < _Object$entries3.length; _i34++) {
8334
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i34], 2),
8335
- _key3 = _Object$entries3$_i[0],
8336
- _value2 = _Object$entries3$_i[1];
8337
-
8338
- newElem[_key3] = _value2;
8339
- }
8340
-
8341
- element.parentNode.replaceChild(newElem, element);
8342
- }
8343
- }
8344
- /*
8345
- * Copyright (c) 2018, salesforce.com, inc.
8346
- * All rights reserved.
8347
- * SPDX-License-Identifier: MIT
8348
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8349
- */
8350
-
8351
- /**
8352
- * This function builds a Web Component class from a LWC constructor so it can be
8353
- * registered as a new element via customElements.define() at any given time.
8354
- *
8355
- * @deprecated since version 1.3.11
8356
- *
8357
- * @example
8358
- * ```
8359
- * import { buildCustomElementConstructor } from 'lwc';
8360
- * import Foo from 'ns/foo';
8361
- * const WC = buildCustomElementConstructor(Foo);
8362
- * customElements.define('x-foo', WC);
8363
- * const elm = document.createElement('x-foo');
8364
- * ```
8365
- */
8366
-
8367
-
8368
- function deprecatedBuildCustomElementConstructor(Ctor) {
8369
- if (process.env.NODE_ENV !== 'production') {
8370
- /* eslint-disable-next-line no-console */
8371
- 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."));
8372
- }
8373
-
8374
- return Ctor.CustomElementConstructor;
8375
- }
8376
-
8377
- function buildCustomElementConstructor(Ctor) {
8378
- var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8379
- return /*#__PURE__*/function (_HtmlPrototype) {
8380
- _inherits(_class, _HtmlPrototype);
8381
-
8382
- var _super8 = _createSuper(_class);
8383
-
8384
- function _class() {
8385
- var _this6;
8386
-
8387
- _classCallCheck(this, _class);
8388
-
8389
- _this6 = _super8.call(this);
8390
- createVM(_assertThisInitialized(_this6), Ctor, {
8391
- mode: 'open',
8392
- owner: null,
8393
- tagName: _this6.tagName
8394
- });
8395
- return _this6;
8396
- }
8397
-
8398
- _createClass(_class, [{
8399
- key: "connectedCallback",
8400
- value: function connectedCallback() {
8401
- connectRootElement(this);
8402
- }
8403
- }, {
8404
- key: "disconnectedCallback",
8405
- value: function disconnectedCallback() {
8406
- disconnectRootElement(this);
8407
- }
8408
- }]);
8409
-
8410
- return _class;
8411
- }(HtmlPrototype);
8412
- }
8413
- /*
8414
- * Copyright (c) 2018, salesforce.com, inc.
8415
- * All rights reserved.
8416
- * SPDX-License-Identifier: MIT
8417
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8418
- */
8419
-
8420
8589
  /**
8421
8590
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
8422
8591
  * This API is subject to change or being removed.
@@ -8516,7 +8685,7 @@ var LWC = (function (exports) {
8516
8685
  });
8517
8686
  freeze(LightningElement);
8518
8687
  seal(LightningElement.prototype);
8519
- /* version: 2.9.0 */
8688
+ /* version: 2.11.1 */
8520
8689
 
8521
8690
  exports.LightningElement = LightningElement;
8522
8691
  exports.__unstable__ProfilerControl = profilerControl;