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
@@ -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.9.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.1";
367
+ var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
368
+ /** version: 2.11.1 */
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.9.0 */
546
+ /** version: 2.11.1 */
536
547
 
537
548
  /* proxy-compat-disable */
538
549
 
@@ -635,6 +646,31 @@
635
646
  }
636
647
 
637
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;
638
674
  } //
639
675
  // Primitives
640
676
  //
@@ -1130,6 +1166,7 @@
1130
1166
  * SPDX-License-Identifier: MIT
1131
1167
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1132
1168
  */
1169
+ // These properties get added to LWCElement.prototype publicProps automatically
1133
1170
 
1134
1171
  var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
1135
1172
 
@@ -3395,6 +3432,48 @@
3395
3432
  var meta = signedDecoratorToMetaMap.get(Ctor);
3396
3433
  return isUndefined$1(meta) ? defaultMeta : meta;
3397
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
+ }
3398
3477
 
3399
3478
  var signedTemplateSet = new Set();
3400
3479
 
@@ -3414,6 +3493,10 @@
3414
3493
 
3415
3494
 
3416
3495
  function registerTemplate(tpl) {
3496
+ if (process.env.NODE_ENV !== 'production') {
3497
+ checkVersionMismatch(tpl, 'template');
3498
+ }
3499
+
3417
3500
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
3418
3501
  // assignment of templates easily, without too much transformation
3419
3502
 
@@ -3436,6 +3519,7 @@
3436
3519
  * SPDX-License-Identifier: MIT
3437
3520
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3438
3521
  */
3522
+ // A bridge descriptor is a descriptor whose job is just to get the component instance
3439
3523
  // from the element instance, and get the value or set a new value on the component.
3440
3524
  // This means that across different elements, similar names can get the exact same
3441
3525
  // descriptor, so we can cache them:
@@ -3709,31 +3793,6 @@
3709
3793
  return canRefreshAllInstances;
3710
3794
  }
3711
3795
 
3712
- function flattenStylesheets(stylesheets) {
3713
- var list = [];
3714
-
3715
- var _iterator2 = _createForOfIteratorHelper(stylesheets),
3716
- _step2;
3717
-
3718
- try {
3719
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3720
- var stylesheet = _step2.value;
3721
-
3722
- if (!Array.isArray(stylesheet)) {
3723
- list.push(stylesheet);
3724
- } else {
3725
- list.push.apply(list, _toConsumableArray(flattenStylesheets(stylesheet)));
3726
- }
3727
- }
3728
- } catch (err) {
3729
- _iterator2.e(err);
3730
- } finally {
3731
- _iterator2.f();
3732
- }
3733
-
3734
- return list;
3735
- }
3736
-
3737
3796
  function getTemplateOrSwappedTemplate(tpl) {
3738
3797
  if (process.env.NODE_ENV === 'production') {
3739
3798
  // this method should never leak to prod
@@ -4445,6 +4504,7 @@
4445
4504
  * SPDX-License-Identifier: MIT
4446
4505
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4447
4506
  */
4507
+ // The style property is a string when defined via an expression in the template.
4448
4508
 
4449
4509
 
4450
4510
  function patchStyleAttribute(oldVnode, vnode) {
@@ -4489,6 +4549,7 @@
4489
4549
  * SPDX-License-Identifier: MIT
4490
4550
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4491
4551
  */
4552
+ // The HTML class property becomes the vnode.data.classMap object when defined as a string in the template.
4492
4553
  // The compiler takes care of transforming the inline classnames into an object. It's faster to set the
4493
4554
  // different classnames properties individually instead of via a string.
4494
4555
 
@@ -4513,6 +4574,7 @@
4513
4574
  * SPDX-License-Identifier: MIT
4514
4575
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4515
4576
  */
4577
+ // The HTML style property becomes the vnode.data.styleDecls object when defined as a string in the template.
4516
4578
  // The compiler takes care of transforming the inline style into an object. It's faster to set the
4517
4579
  // different style properties individually instead of via a string.
4518
4580
 
@@ -4542,146 +4604,262 @@
4542
4604
  */
4543
4605
 
4544
4606
 
4545
- var TextHook = {
4546
- create: function create(vnode) {
4547
- var owner = vnode.owner;
4548
- var elm = createText$1(vnode.text);
4549
- linkNodeToShadow(elm, owner);
4550
- vnode.elm = elm;
4551
- },
4552
- update: updateNodeHook,
4553
- insert: insertNode,
4554
- move: insertNode,
4555
- remove: removeNode
4556
- };
4557
- var CommentHook = {
4558
- create: function create(vnode) {
4559
- var owner = vnode.owner,
4560
- text = vnode.text;
4561
- var elm = createComment$1(text);
4562
- linkNodeToShadow(elm, owner);
4563
- vnode.elm = elm;
4564
- },
4565
- update: updateNodeHook,
4566
- insert: insertNode,
4567
- move: insertNode,
4568
- remove: removeNode
4569
- }; // insert is called after update, which is used somewhere else (via a module)
4570
- // to mark the vm as inserted, that means we cannot use update as the main channel
4571
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
4572
- // which breaks some invariants. For that reason, we have the following for any
4573
- // Custom Element that is inserted via a template.
4574
-
4575
- var ElementHook = {
4576
- create: function create(vnode) {
4577
- var sel = vnode.sel,
4578
- owner = vnode.owner,
4579
- svg = vnode.data.svg;
4580
- var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
4581
- var elm = createElement$2(sel, namespace);
4582
- linkNodeToShadow(elm, owner);
4583
- fallbackElmHook(elm, vnode);
4584
- vnode.elm = elm;
4585
- patchElementPropsAndAttrs$1(null, vnode);
4586
- },
4587
- update: function update(oldVnode, vnode) {
4588
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4589
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4590
- },
4591
- insert: function insert(vnode, parentNode, referenceNode) {
4592
- insertNode(vnode, parentNode, referenceNode);
4593
- createChildrenHook(vnode);
4594
- },
4595
- move: insertNode,
4596
- remove: function remove(vnode, parentNode) {
4597
- removeNode(vnode, parentNode);
4598
- removeChildren(vnode);
4607
+ function patchChildren(c1, c2, parent) {
4608
+ if (hasDynamicChildren(c2)) {
4609
+ updateDynamicChildren(c1, c2, parent);
4610
+ } else {
4611
+ updateStaticChildren(c1, c2, parent);
4599
4612
  }
4600
- };
4601
- var CustomElementHook = {
4602
- create: function create(vnode) {
4603
- var sel = vnode.sel,
4604
- owner = vnode.owner;
4605
- var UpgradableConstructor = getUpgradableConstructor(sel);
4606
- /**
4607
- * Note: if the upgradable constructor does not expect, or throw when we new it
4608
- * with a callback as the first argument, we could implement a more advanced
4609
- * mechanism that only passes that argument if the constructor is known to be
4610
- * an upgradable custom element.
4611
- */
4613
+ }
4612
4614
 
4613
- var vm;
4614
- var elm = new UpgradableConstructor(function (elm) {
4615
- // the custom element from the registry is expecting an upgrade callback
4616
- vm = createViewModelHook(elm, vnode);
4617
- });
4618
- linkNodeToShadow(elm, owner);
4619
- vnode.elm = elm;
4615
+ function patch(n1, n2) {
4616
+ if (n1 === n2) {
4617
+ return;
4618
+ }
4620
4619
 
4621
- if (vm) {
4622
- allocateChildren(vnode, vm);
4623
- } else if (vnode.ctor !== UpgradableConstructor) {
4624
- 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
+ }));
4625
4629
  }
4630
+ }
4626
4631
 
4627
- patchElementPropsAndAttrs$1(null, vnode);
4628
- },
4629
- update: function update(oldVnode, vnode) {
4630
- patchElementPropsAndAttrs$1(oldVnode, vnode);
4631
- var vm = getAssociatedVMIfPresent(vnode.elm);
4632
+ switch (n2.type) {
4633
+ case 0
4634
+ /* Text */
4635
+ :
4636
+ patchText(n1, n2);
4637
+ break;
4638
+
4639
+ case 1
4640
+ /* Comment */
4641
+ :
4642
+ patchComment(n1, n2);
4643
+ break;
4632
4644
 
4633
- if (vm) {
4634
- // in fallback mode, the allocation will always set children to
4635
- // empty and delegate the real allocation to the slot elements
4636
- allocateChildren(vnode, vm);
4637
- } // in fallback mode, the children will be always empty, so, nothing
4638
- // will happen, but in native, it does allocate the light dom
4645
+ case 2
4646
+ /* Element */
4647
+ :
4648
+ patchElement(n1, n2);
4649
+ break;
4639
4650
 
4651
+ case 3
4652
+ /* CustomElement */
4653
+ :
4654
+ patchCustomElement(n1, n2);
4655
+ break;
4656
+ }
4657
+ }
4640
4658
 
4641
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
4659
+ function mount(node, parent, anchor) {
4660
+ switch (node.type) {
4661
+ case 0
4662
+ /* Text */
4663
+ :
4664
+ mountText(node, parent, anchor);
4665
+ break;
4642
4666
 
4643
- if (vm) {
4644
- if (process.env.NODE_ENV !== 'production') {
4645
- assert.isTrue(isArray$1(vnode.children), "Invalid vnode for a custom element, it must have children defined.");
4646
- } // this will probably update the shadowRoot, but only if the vm is in a dirty state
4647
- // this is important to preserve the top to bottom synchronous rendering phase.
4667
+ case 1
4668
+ /* Comment */
4669
+ :
4670
+ mountComment(node, parent, anchor);
4671
+ break;
4648
4672
 
4673
+ case 2
4674
+ /* Element */
4675
+ :
4676
+ mountElement(node, parent, anchor);
4677
+ break;
4649
4678
 
4650
- rerenderVM(vm);
4651
- }
4652
- },
4653
- insert: function insert(vnode, parentNode, referenceNode) {
4654
- insertNode(vnode, parentNode, referenceNode);
4655
- var vm = getAssociatedVMIfPresent(vnode.elm);
4679
+ case 3
4680
+ /* CustomElement */
4681
+ :
4682
+ mountCustomElement(node, parent, anchor);
4683
+ break;
4684
+ }
4685
+ }
4656
4686
 
4657
- if (vm) {
4658
- if (process.env.NODE_ENV !== 'production') {
4659
- assert.isTrue(vm.state === 0
4660
- /* created */
4661
- , "".concat(vm, " cannot be recycled."));
4662
- }
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
+ */
4663
4748
 
4664
- runConnectedCallback(vm);
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
+ }
4763
+
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."));
4665
4772
  }
4666
4773
 
4667
- createChildrenHook(vnode);
4774
+ runConnectedCallback(vm);
4775
+ }
4776
+
4777
+ mountVNodes(vnode.children, elm, null);
4778
+
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
+
4668
4796
 
4669
- if (vm) {
4670
- appendVM(vm);
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);
4671
4815
  }
4672
- },
4673
- move: insertNode,
4674
- remove: function remove(vnode, parentNode) {
4675
- removeNode(vnode, parentNode);
4676
- 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;
4677
4854
 
4678
- if (vm) {
4679
- // for custom elements we don't have to go recursively because the removeVM routine
4680
- // will take care of disconnecting any child VM attached to its shadow as well.
4681
- removeVM(vm);
4855
+ for (; start < end; ++start) {
4856
+ var ch = vnodes[start];
4857
+
4858
+ if (isVNode(ch)) {
4859
+ unmount(ch, parent, doRemove);
4682
4860
  }
4683
4861
  }
4684
- };
4862
+ }
4685
4863
 
4686
4864
  function isVNode(vnode) {
4687
4865
  return vnode != null;
@@ -4722,41 +4900,39 @@
4722
4900
  }
4723
4901
  }
4724
4902
 
4725
- function updateNodeHook(oldVnode, vnode) {
4903
+ function updateTextContent(vnode) {
4726
4904
  var elm = vnode.elm,
4727
4905
  text = vnode.text;
4728
4906
 
4729
- if (oldVnode.text !== text) {
4730
- if (process.env.NODE_ENV !== 'production') {
4731
- unlockDomMutation();
4732
- }
4907
+ if (process.env.NODE_ENV !== 'production') {
4908
+ unlockDomMutation();
4909
+ }
4733
4910
 
4734
- setText$1(elm, text);
4911
+ setText$1(elm, text);
4735
4912
 
4736
- if (process.env.NODE_ENV !== 'production') {
4737
- lockDomMutation();
4738
- }
4913
+ if (process.env.NODE_ENV !== 'production') {
4914
+ lockDomMutation();
4739
4915
  }
4740
4916
  }
4741
4917
 
4742
- function insertNode(vnode, parentNode, referenceNode) {
4918
+ function insertNode(node, parent, anchor) {
4743
4919
  if (process.env.NODE_ENV !== 'production') {
4744
4920
  unlockDomMutation();
4745
4921
  }
4746
4922
 
4747
- insert$1(vnode.elm, parentNode, referenceNode);
4923
+ insert$1(node, parent, anchor);
4748
4924
 
4749
4925
  if (process.env.NODE_ENV !== 'production') {
4750
4926
  lockDomMutation();
4751
4927
  }
4752
4928
  }
4753
4929
 
4754
- function removeNode(vnode, parentNode) {
4930
+ function removeNode(node, parent) {
4755
4931
  if (process.env.NODE_ENV !== 'production') {
4756
4932
  unlockDomMutation();
4757
4933
  }
4758
4934
 
4759
- remove$1(vnode.elm, parentNode);
4935
+ remove$1(node, parent);
4760
4936
 
4761
4937
  if (process.env.NODE_ENV !== 'production') {
4762
4938
  lockDomMutation();
@@ -4817,14 +4993,6 @@
4817
4993
  }
4818
4994
  }
4819
4995
 
4820
- function patchChildren(parent, oldCh, newCh) {
4821
- if (hasDynamicChildren(newCh)) {
4822
- updateDynamicChildren(parent, oldCh, newCh);
4823
- } else {
4824
- updateStaticChildren(parent, oldCh, newCh);
4825
- }
4826
- }
4827
-
4828
4996
  function allocateChildren(vnode, vm) {
4829
4997
  // A component with slots will re-render because:
4830
4998
  // 1- There is a change of the internal state.
@@ -4894,43 +5062,13 @@
4894
5062
  return vm;
4895
5063
  }
4896
5064
 
4897
- function createChildrenHook(vnode) {
4898
- var elm = vnode.elm,
4899
- children = vnode.children;
4900
-
4901
- for (var j = 0; j < children.length; ++j) {
4902
- var ch = children[j];
4903
-
4904
- if (ch != null) {
4905
- ch.hook.create(ch);
4906
- ch.hook.insert(ch, elm, null);
4907
- }
4908
- }
4909
- }
4910
-
4911
- function removeChildren(vnode) {
4912
- // this method only needs to search on child vnodes from template
4913
- // to trigger the remove hook just in case some of those children
4914
- // are custom elements.
4915
- var children = vnode.children,
4916
- elm = vnode.elm;
4917
-
4918
- for (var j = 0, _len5 = children.length; j < _len5; ++j) {
4919
- var ch = children[j];
4920
-
4921
- if (!isNull(ch)) {
4922
- ch.hook.remove(ch, elm);
4923
- }
4924
- }
4925
- }
4926
-
4927
- function allocateInSlot(vm, children) {
4928
- var _a;
5065
+ function allocateInSlot(vm, children) {
5066
+ var _a;
4929
5067
 
4930
5068
  var oldSlots = vm.cmpSlots;
4931
5069
  var cmpSlots = vm.cmpSlots = create(null);
4932
5070
 
4933
- for (var _i13 = 0, _len6 = children.length; _i13 < _len6; _i13 += 1) {
5071
+ for (var _i13 = 0, _len5 = children.length; _i13 < _len5; _i13 += 1) {
4934
5072
  var vnode = children[_i13];
4935
5073
 
4936
5074
  if (isNull(vnode)) {
@@ -4965,7 +5103,7 @@
4965
5103
  return;
4966
5104
  }
4967
5105
 
4968
- for (var _i14 = 0, _len7 = oldKeys.length; _i14 < _len7; _i14 += 1) {
5106
+ for (var _i14 = 0, _len6 = oldKeys.length; _i14 < _len6; _i14 += 1) {
4969
5107
  var key = oldKeys[_i14];
4970
5108
 
4971
5109
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
@@ -5016,28 +5154,7 @@
5016
5154
  return map;
5017
5155
  }
5018
5156
 
5019
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
5020
- for (; startIdx <= endIdx; ++startIdx) {
5021
- var ch = vnodes[startIdx];
5022
-
5023
- if (isVNode(ch)) {
5024
- ch.hook.create(ch);
5025
- ch.hook.insert(ch, parentElm, before);
5026
- }
5027
- }
5028
- }
5029
-
5030
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
5031
- for (; startIdx <= endIdx; ++startIdx) {
5032
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
5033
-
5034
- if (isVNode(ch)) {
5035
- ch.hook.remove(ch, parentElm);
5036
- }
5037
- }
5038
- }
5039
-
5040
- function updateDynamicChildren(parentElm, oldCh, newCh) {
5157
+ function updateDynamicChildren(oldCh, newCh, parent) {
5041
5158
  var oldStartIdx = 0;
5042
5159
  var newStartIdx = 0;
5043
5160
  var oldEndIdx = oldCh.length - 1;
@@ -5063,23 +5180,23 @@
5063
5180
  } else if (!isVNode(newEndVnode)) {
5064
5181
  newEndVnode = newCh[--newEndIdx];
5065
5182
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
5066
- patchVnode(oldStartVnode, newStartVnode);
5183
+ patch(oldStartVnode, newStartVnode);
5067
5184
  oldStartVnode = oldCh[++oldStartIdx];
5068
5185
  newStartVnode = newCh[++newStartIdx];
5069
5186
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
5070
- patchVnode(oldEndVnode, newEndVnode);
5187
+ patch(oldEndVnode, newEndVnode);
5071
5188
  oldEndVnode = oldCh[--oldEndIdx];
5072
5189
  newEndVnode = newCh[--newEndIdx];
5073
5190
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
5074
5191
  // Vnode moved right
5075
- patchVnode(oldStartVnode, newEndVnode);
5076
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
5192
+ patch(oldStartVnode, newEndVnode);
5193
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
5077
5194
  oldStartVnode = oldCh[++oldStartIdx];
5078
5195
  newEndVnode = newCh[--newEndIdx];
5079
5196
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
5080
5197
  // Vnode moved left
5081
- patchVnode(oldEndVnode, newStartVnode);
5082
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
5198
+ patch(oldEndVnode, newStartVnode);
5199
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
5083
5200
  oldEndVnode = oldCh[--oldEndIdx];
5084
5201
  newStartVnode = newCh[++newStartIdx];
5085
5202
  } else {
@@ -5091,8 +5208,7 @@
5091
5208
 
5092
5209
  if (isUndefined$1(idxInOld)) {
5093
5210
  // New element
5094
- newStartVnode.hook.create(newStartVnode);
5095
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5211
+ mount(newStartVnode, parent, oldStartVnode.elm);
5096
5212
  newStartVnode = newCh[++newStartIdx];
5097
5213
  } else {
5098
5214
  elmToMove = oldCh[idxInOld];
@@ -5100,10 +5216,9 @@
5100
5216
  if (isVNode(elmToMove)) {
5101
5217
  if (elmToMove.sel !== newStartVnode.sel) {
5102
5218
  // New element
5103
- newStartVnode.hook.create(newStartVnode);
5104
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
5219
+ mount(newStartVnode, parent, oldStartVnode.elm);
5105
5220
  } else {
5106
- patchVnode(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5221
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
5107
5222
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
5108
5223
  // so we only care about the `oldCh` object inside this function.
5109
5224
  // To avoid cloning over and over again, we check `clonedOldCh`
@@ -5116,7 +5231,7 @@
5116
5231
 
5117
5232
 
5118
5233
  oldCh[idxInOld] = undefined;
5119
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
5234
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
5120
5235
  }
5121
5236
  }
5122
5237
 
@@ -5137,65 +5252,55 @@
5137
5252
  } while (!isVNode(n) && _i15 < newChEnd);
5138
5253
 
5139
5254
  before = isVNode(n) ? n.elm : null;
5140
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
5255
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
5141
5256
  } else {
5142
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
5257
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
5143
5258
  }
5144
5259
  }
5145
5260
  }
5146
5261
 
5147
- function updateStaticChildren(parentElm, oldCh, newCh) {
5148
- var oldChLength = oldCh.length;
5149
- var newChLength = newCh.length;
5262
+ function updateStaticChildren(c1, c2, parent) {
5263
+ var c1Length = c1.length;
5264
+ var c2Length = c2.length;
5150
5265
 
5151
- if (oldChLength === 0) {
5266
+ if (c1Length === 0) {
5152
5267
  // the old list is empty, we can directly insert anything new
5153
- addVnodes(parentElm, null, newCh, 0, newChLength);
5268
+ mountVNodes(c2, parent, null);
5154
5269
  return;
5155
5270
  }
5156
5271
 
5157
- if (newChLength === 0) {
5272
+ if (c2Length === 0) {
5158
5273
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
5159
5274
  // this is the case in which the dynamic children of an if-directive should be removed
5160
- removeVnodes(parentElm, oldCh, 0, oldChLength);
5275
+ unmountVNodes(c1, parent, true);
5161
5276
  return;
5162
5277
  } // if the old list is not empty, the new list MUST have the same
5163
5278
  // amount of nodes, that's why we call this static children
5164
5279
 
5165
5280
 
5166
- var referenceElm = null;
5281
+ var anchor = null;
5167
5282
 
5168
- for (var _i16 = newChLength - 1; _i16 >= 0; _i16 -= 1) {
5169
- var vnode = newCh[_i16];
5170
- var oldVNode = oldCh[_i16];
5283
+ for (var _i16 = c2Length - 1; _i16 >= 0; _i16 -= 1) {
5284
+ var n1 = c1[_i16];
5285
+ var n2 = c2[_i16];
5171
5286
 
5172
- if (vnode !== oldVNode) {
5173
- if (isVNode(oldVNode)) {
5174
- if (isVNode(vnode)) {
5175
- // both vnodes must be equivalent, and se just need to patch them
5176
- patchVnode(oldVNode, vnode);
5177
- 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;
5178
5293
  } else {
5179
5294
  // removing the old vnode since the new one is null
5180
- oldVNode.hook.remove(oldVNode, parentElm);
5295
+ unmount(n1, parent, true);
5181
5296
  }
5182
- } else if (isVNode(vnode)) {
5183
- // this condition is unnecessary
5184
- vnode.hook.create(vnode); // insert the new node one since the old one is null
5185
-
5186
- vnode.hook.insert(vnode, parentElm, referenceElm);
5187
- referenceElm = vnode.elm;
5297
+ } else if (isVNode(n2)) {
5298
+ mount(n2, parent, anchor);
5299
+ anchor = n2.elm;
5188
5300
  }
5189
5301
  }
5190
5302
  }
5191
5303
  }
5192
-
5193
- function patchVnode(oldVnode, vnode) {
5194
- if (oldVnode !== vnode) {
5195
- vnode.elm = oldVnode.elm;
5196
- vnode.hook.update(oldVnode, vnode);
5197
- }
5198
- }
5199
5304
  /*
5200
5305
  * Copyright (c) 2018, salesforce.com, inc.
5201
5306
  * All rights reserved.
@@ -5246,7 +5351,6 @@
5246
5351
  children: children,
5247
5352
  elm: elm,
5248
5353
  key: key,
5249
- hook: ElementHook,
5250
5354
  owner: vmBeingRendered
5251
5355
  };
5252
5356
  } // [t]ab[i]ndex function
@@ -5330,7 +5434,7 @@
5330
5434
  }
5331
5435
 
5332
5436
  var key = data.key;
5333
- var elm;
5437
+ var elm, aChildren, vm;
5334
5438
  var vnode = {
5335
5439
  type: 3
5336
5440
  /* CustomElement */
@@ -5340,11 +5444,11 @@
5340
5444
  children: children,
5341
5445
  elm: elm,
5342
5446
  key: key,
5343
- hook: CustomElementHook,
5344
5447
  ctor: Ctor,
5345
5448
  owner: vmBeingRendered,
5346
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
5347
-
5449
+ mode: 'open',
5450
+ aChildren: aChildren,
5451
+ vm: vm
5348
5452
  };
5349
5453
  addVNodeToChildLWC(vnode);
5350
5454
  return vnode;
@@ -5471,7 +5575,6 @@
5471
5575
  text: text,
5472
5576
  elm: elm,
5473
5577
  key: key,
5474
- hook: TextHook,
5475
5578
  owner: getVMBeingRendered()
5476
5579
  };
5477
5580
  } // [co]mment node
@@ -5487,7 +5590,6 @@
5487
5590
  text: text,
5488
5591
  elm: elm,
5489
5592
  key: key,
5490
- hook: CommentHook,
5491
5593
  owner: getVMBeingRendered()
5492
5594
  };
5493
5595
  } // [d]ynamic text
@@ -5791,9 +5893,11 @@
5791
5893
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
5792
5894
  } else {
5793
5895
  if (process.env.NODE_ENV !== 'production') {
5794
- // 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
5795
5898
  // the component instance might be attempting to use an old version of
5796
5899
  // the stylesheet, while internally, we have a replacement for it.
5900
+
5797
5901
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5798
5902
  }
5799
5903
 
@@ -6318,11 +6422,20 @@
6318
6422
  * will prevent this function from being imported by userland code.
6319
6423
  */
6320
6424
 
6321
- function registerComponent(Ctor, _ref2) {
6425
+ function registerComponent( // We typically expect a LightningElementConstructor, but technically you can call this with anything
6426
+ Ctor, _ref2) {
6322
6427
  var tmpl = _ref2.tmpl;
6323
- signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
6428
+
6429
+ if (isFunction$1(Ctor)) {
6430
+ if (process.env.NODE_ENV !== 'production') {
6431
+ checkVersionMismatch(Ctor, 'component');
6432
+ }
6433
+
6434
+ signedTemplateMap.set(Ctor, tmpl);
6435
+ } // chaining this method as a way to wrap existing assignment of component constructor easily,
6324
6436
  // without too much transformation
6325
6437
 
6438
+
6326
6439
  return Ctor;
6327
6440
  }
6328
6441
 
@@ -6429,7 +6542,7 @@
6429
6542
  def = vm.def,
6430
6543
  context = vm.context;
6431
6544
 
6432
- for (var _i22 = 0, _len8 = cbs.length; _i22 < _len8; ++_i22) {
6545
+ for (var _i22 = 0, _len7 = cbs.length; _i22 < _len7; ++_i22) {
6433
6546
  cbs[_i22].call(undefined, component, {}, def, context);
6434
6547
  }
6435
6548
  }
@@ -6441,7 +6554,7 @@
6441
6554
  */
6442
6555
 
6443
6556
 
6444
- function hydrate$1(vnode, node) {
6557
+ function hydrate(vnode, node) {
6445
6558
  switch (vnode.type) {
6446
6559
  case 0
6447
6560
  /* Text */
@@ -6473,16 +6586,18 @@
6473
6586
  var _a;
6474
6587
 
6475
6588
  if (process.env.NODE_ENV !== 'production') {
6476
- // eslint-disable-next-line lwc-internal/no-global-node
6477
- validateNodeType(vnode, node, Node.TEXT_NODE);
6589
+ validateNodeType(vnode, node, 3
6590
+ /* TEXT */
6591
+ );
6592
+ var nodeValue = getProperty$1(node, 'nodeValue');
6478
6593
 
6479
- if (node.nodeValue !== vnode.text && !(node.nodeValue === "\u200D" && vnode.text === '')) {
6594
+ if (nodeValue !== vnode.text && !(nodeValue === "\u200D" && vnode.text === '')) {
6480
6595
  logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
6481
6596
  }
6482
6597
  } // always set the text value to the one from the vnode.
6483
6598
 
6484
6599
 
6485
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6600
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6486
6601
  vnode.elm = node;
6487
6602
  }
6488
6603
 
@@ -6490,23 +6605,25 @@
6490
6605
  var _a;
6491
6606
 
6492
6607
  if (process.env.NODE_ENV !== 'production') {
6493
- // eslint-disable-next-line lwc-internal/no-global-node
6494
- validateNodeType(vnode, node, Node.COMMENT_NODE);
6608
+ validateNodeType(vnode, node, 8
6609
+ /* COMMENT */
6610
+ );
6495
6611
 
6496
- if (node.nodeValue !== vnode.text) {
6612
+ if (getProperty$1(node, 'nodeValue') !== vnode.text) {
6497
6613
  logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
6498
6614
  }
6499
6615
  } // always set the text value to the one from the vnode.
6500
6616
 
6501
6617
 
6502
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
6618
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
6503
6619
  vnode.elm = node;
6504
6620
  }
6505
6621
 
6506
6622
  function hydrateElement(vnode, node) {
6507
6623
  if (process.env.NODE_ENV !== 'production') {
6508
- // eslint-disable-next-line lwc-internal/no-global-node
6509
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6624
+ validateNodeType(vnode, node, 1
6625
+ /* ELEMENT */
6626
+ );
6510
6627
  validateElement(vnode, node);
6511
6628
  }
6512
6629
 
@@ -6523,13 +6640,13 @@
6523
6640
  var props = vnode.data.props;
6524
6641
 
6525
6642
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
6526
- if (elm.innerHTML === props.innerHTML) {
6643
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
6527
6644
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
6528
6645
  vnode.data = Object.assign(Object.assign({}, vnode.data), {
6529
6646
  props: cloneAndOmitKey(props, 'innerHTML')
6530
6647
  });
6531
6648
  } else {
6532
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6649
+ logWarn("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
6533
6650
  }
6534
6651
  }
6535
6652
  }
@@ -6537,19 +6654,19 @@
6537
6654
  patchElementPropsAndAttrs(vnode);
6538
6655
 
6539
6656
  if (!isDomManual) {
6540
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
6657
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
6541
6658
  }
6542
6659
  }
6543
6660
 
6544
6661
  function hydrateCustomElement(vnode, node) {
6545
6662
  if (process.env.NODE_ENV !== 'production') {
6546
- // eslint-disable-next-line lwc-internal/no-global-node
6547
- validateNodeType(vnode, node, Node.ELEMENT_NODE);
6663
+ validateNodeType(vnode, node, 1
6664
+ /* ELEMENT */
6665
+ );
6548
6666
  validateElement(vnode, node);
6549
6667
  }
6550
6668
 
6551
6669
  var elm = node;
6552
- vnode.elm = elm;
6553
6670
  var sel = vnode.sel,
6554
6671
  mode = vnode.mode,
6555
6672
  ctor = vnode.ctor,
@@ -6559,6 +6676,8 @@
6559
6676
  owner: owner,
6560
6677
  tagName: sel
6561
6678
  });
6679
+ vnode.elm = elm;
6680
+ vnode.vm = vm;
6562
6681
  allocateChildren(vnode, vm);
6563
6682
  patchElementPropsAndAttrs(vnode); // Insert hook section:
6564
6683
 
@@ -6575,7 +6694,7 @@
6575
6694
  ) {
6576
6695
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
6577
6696
  // Note: for Light DOM, this is handled while hydrating the VM
6578
- hydrateChildren(vnode.elm.childNodes, vnode.children, vm);
6697
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vm);
6579
6698
  }
6580
6699
 
6581
6700
  hydrateVM(vm);
@@ -6600,7 +6719,7 @@
6600
6719
 
6601
6720
  if (!isNull(childVnode)) {
6602
6721
  var childNode = elmChildren[childNodeIndex];
6603
- hydrate$1(childVnode, childNode);
6722
+ hydrate(childVnode, childNode);
6604
6723
  childNodeIndex++;
6605
6724
  }
6606
6725
  }
@@ -6616,15 +6735,15 @@
6616
6735
  }
6617
6736
 
6618
6737
  function validateNodeType(vnode, node, nodeType) {
6619
- if (node.nodeType !== nodeType) {
6738
+ if (getProperty$1(node, 'nodeType') !== nodeType) {
6620
6739
  logError('Hydration mismatch: incorrect node type received', vnode.owner);
6621
6740
  assert.fail('Hydration mismatch: incorrect node type received.');
6622
6741
  }
6623
6742
  }
6624
6743
 
6625
6744
  function validateElement(vnode, elm) {
6626
- if (vnode.sel.toLowerCase() !== elm.tagName.toLowerCase()) {
6627
- logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(elm.tagName.toLowerCase(), "\"."), vnode.owner);
6745
+ if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
6746
+ logError("Hydration mismatch: expecting element with tag \"".concat(vnode.sel.toLowerCase(), "\" but found \"").concat(getProperty$1(elm, 'tagName').toLowerCase(), "\"."), vnode.owner);
6628
6747
  throwHydrationError();
6629
6748
  }
6630
6749
 
@@ -6652,7 +6771,7 @@
6652
6771
  var elmAttrValue = getAttribute$1(elm, attrName);
6653
6772
 
6654
6773
  if (String(attrValue) !== elmAttrValue) {
6655
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
6774
+ 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);
6656
6775
  nodesAreCompatible = false;
6657
6776
  }
6658
6777
  }
@@ -6667,7 +6786,7 @@
6667
6786
  var nodesAreCompatible = true;
6668
6787
  var vnodeClassName;
6669
6788
 
6670
- if (!isUndefined$1(className) && String(className) !== elm.className) {
6789
+ if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
6671
6790
  // className is used when class is bound to an expr.
6672
6791
  nodesAreCompatible = false;
6673
6792
  vnodeClassName = className;
@@ -6692,7 +6811,7 @@
6692
6811
  }
6693
6812
 
6694
6813
  if (!nodesAreCompatible) {
6695
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(elm.className, "\""), vnode.owner);
6814
+ 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);
6696
6815
  }
6697
6816
 
6698
6817
  return nodesAreCompatible;
@@ -6740,7 +6859,7 @@
6740
6859
 
6741
6860
  if (!nodesAreCompatible) {
6742
6861
  // style is used when class is bound to an expr.
6743
- logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
6862
+ logError("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
6744
6863
  }
6745
6864
 
6746
6865
  return nodesAreCompatible;
@@ -6811,7 +6930,19 @@
6811
6930
  }
6812
6931
 
6813
6932
  function hydrateVM(vm) {
6814
- hydrate(vm);
6933
+ if (isTrue(vm.isDirty)) {
6934
+ // manually diffing/patching here.
6935
+ // This routine is:
6936
+ // patchShadowRoot(vm, children);
6937
+ // -> addVnodes.
6938
+ var children = renderComponent(vm);
6939
+ vm.children = children;
6940
+ var vmChildren = vm.renderMode === 0
6941
+ /* Light */
6942
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
6943
+ hydrateChildren(vmChildren, children, vm);
6944
+ runRenderedCallback(vm);
6945
+ }
6815
6946
  } // just in case the component comes back, with this we guarantee re-rendering it
6816
6947
  // while preventing any attempt to rehydration until after reinsertion.
6817
6948
 
@@ -6954,30 +7085,38 @@
6954
7085
  /* Native */
6955
7086
  ;
6956
7087
  } else if (isNativeShadowDefined$1) {
6957
- if (def.shadowSupportMode === "any"
6958
- /* Any */
6959
- ) {
6960
- shadowMode = 0
6961
- /* Native */
6962
- ;
6963
- } else {
6964
- var shadowAncestor = getNearestShadowAncestor(vm);
6965
-
6966
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
6967
- /* Native */
7088
+ // Not combined with above condition because @lwc/features only supports identifiers in
7089
+ // the if-condition.
7090
+ if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
7091
+ if (def.shadowSupportMode === "any"
7092
+ /* Any */
6968
7093
  ) {
6969
- // Transitive support for native Shadow DOM. A component in native mode
6970
- // transitively opts all of its descendants into native.
6971
7094
  shadowMode = 0
6972
7095
  /* Native */
6973
7096
  ;
6974
7097
  } else {
6975
- // Synthetic if neither this component nor any of its ancestors are configured
6976
- // to be native.
6977
- shadowMode = 1
6978
- /* Synthetic */
6979
- ;
7098
+ var shadowAncestor = getNearestShadowAncestor(vm);
7099
+
7100
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
7101
+ /* Native */
7102
+ ) {
7103
+ // Transitive support for native Shadow DOM. A component in native mode
7104
+ // transitively opts all of its descendants into native.
7105
+ shadowMode = 0
7106
+ /* Native */
7107
+ ;
7108
+ } else {
7109
+ // Synthetic if neither this component nor any of its ancestors are configured
7110
+ // to be native.
7111
+ shadowMode = 1
7112
+ /* Synthetic */
7113
+ ;
7114
+ }
6980
7115
  }
7116
+ } else {
7117
+ shadowMode = 1
7118
+ /* Synthetic */
7119
+ ;
6981
7120
  }
6982
7121
  } else {
6983
7122
  // Synthetic if there is no native Shadow DOM support.
@@ -7034,22 +7173,6 @@
7034
7173
  }
7035
7174
  }
7036
7175
 
7037
- function hydrate(vm) {
7038
- if (isTrue(vm.isDirty)) {
7039
- // manually diffing/patching here.
7040
- // This routine is:
7041
- // patchShadowRoot(vm, children);
7042
- // -> addVnodes.
7043
- var children = renderComponent(vm);
7044
- vm.children = children;
7045
- var vmChildren = vm.renderMode === 0
7046
- /* Light */
7047
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
7048
- hydrateChildren(vmChildren, children, vm);
7049
- runRenderedCallback(vm);
7050
- }
7051
- }
7052
-
7053
7176
  function patchShadowRoot(vm, newCh) {
7054
7177
  var renderRoot = vm.renderRoot,
7055
7178
  oldCh = vm.children; // caching the new children collection
@@ -7067,7 +7190,7 @@
7067
7190
  , vm);
7068
7191
  }, function () {
7069
7192
  // job
7070
- patchChildren(renderRoot, oldCh, newCh);
7193
+ patchChildren(oldCh, newCh, renderRoot);
7071
7194
  }, function () {
7072
7195
  // post
7073
7196
  logOperationEnd(2
@@ -7128,13 +7251,13 @@
7128
7251
  });
7129
7252
  rehydrateQueue = []; // reset to a new queue
7130
7253
 
7131
- for (var _i26 = 0, _len9 = vms.length; _i26 < _len9; _i26 += 1) {
7254
+ for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
7132
7255
  var vm = vms[_i26];
7133
7256
 
7134
7257
  try {
7135
7258
  rehydrate(vm);
7136
7259
  } catch (error) {
7137
- if (_i26 + 1 < _len9) {
7260
+ if (_i26 + 1 < _len8) {
7138
7261
  // pieces of the queue are still pending to be rehydrated, those should have priority
7139
7262
  if (rehydrateQueue.length === 0) {
7140
7263
  addCallbackToNextTick(flushRehydrationQueue);
@@ -7279,7 +7402,7 @@
7279
7402
 
7280
7403
 
7281
7404
  function recursivelyDisconnectChildren(vnodes) {
7282
- for (var _i28 = 0, _len10 = vnodes.length; _i28 < _len10; _i28 += 1) {
7405
+ for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
7283
7406
  var vnode = vnodes[_i28];
7284
7407
 
7285
7408
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
@@ -7311,7 +7434,7 @@
7311
7434
  var children = vm.children,
7312
7435
  renderRoot = vm.renderRoot;
7313
7436
 
7314
- for (var _i29 = 0, _len11 = children.length; _i29 < _len11; _i29++) {
7437
+ for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
7315
7438
  var child = children[_i29];
7316
7439
 
7317
7440
  if (!isNull(child) && !isUndefined$1(child.elm)) {
@@ -7686,7 +7809,7 @@
7686
7809
  function connectWireAdapters(vm) {
7687
7810
  var wiredConnecting = vm.context.wiredConnecting;
7688
7811
 
7689
- for (var _i30 = 0, _len12 = wiredConnecting.length; _i30 < _len12; _i30 += 1) {
7812
+ for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
7690
7813
  wiredConnecting[_i30]();
7691
7814
  }
7692
7815
  }
@@ -7695,7 +7818,7 @@
7695
7818
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7696
7819
  runWithBoundaryProtection(vm, vm, noop, function () {
7697
7820
  // job
7698
- for (var _i31 = 0, _len13 = wiredDisconnecting.length; _i31 < _len13; _i31 += 1) {
7821
+ for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
7699
7822
  wiredDisconnecting[_i31]();
7700
7823
  }
7701
7824
  }, noop);
@@ -7706,6 +7829,7 @@
7706
7829
  * SPDX-License-Identifier: MIT
7707
7830
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7708
7831
  */
7832
+ // this is lwc internal implementation
7709
7833
 
7710
7834
 
7711
7835
  function createContextProvider(adapter) {
@@ -7786,7 +7910,7 @@
7786
7910
  hooksAreSet = true;
7787
7911
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7788
7912
  }
7789
- /* version: 2.9.0 */
7913
+ /* version: 2.11.1 */
7790
7914
 
7791
7915
  /*
7792
7916
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7813,9 +7937,10 @@
7813
7937
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7814
7938
 
7815
7939
  var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7940
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
7816
7941
  var styleElements = create(null);
7817
7942
  var styleSheets = create(null);
7818
- var nodesToStyleSheets = new WeakMap();
7943
+ var shadowRootsToStyleSheets = new WeakMap();
7819
7944
  var getCustomElement;
7820
7945
  var defineCustomElement;
7821
7946
  var HTMLElementConstructor;
@@ -7867,18 +7992,26 @@
7867
7992
  styleSheets[content] = styleSheet;
7868
7993
  }
7869
7994
 
7870
- if (!target.adoptedStyleSheets.includes(styleSheet)) {
7871
- target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
7995
+ var adoptedStyleSheets = target.adoptedStyleSheets;
7996
+
7997
+ if (!adoptedStyleSheets.includes(styleSheet)) {
7998
+ if (supportsMutableAdoptedStyleSheets) {
7999
+ // This is only supported in later versions of Chromium:
8000
+ // https://chromestatus.com/feature/5638996492288000
8001
+ adoptedStyleSheets.push(styleSheet);
8002
+ } else {
8003
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(adoptedStyleSheets), [styleSheet]);
8004
+ }
7872
8005
  }
7873
8006
  }
7874
8007
 
7875
8008
  function insertStyleElement(content, target) {
7876
8009
  // Avoid inserting duplicate `<style>`s
7877
- var sheets = nodesToStyleSheets.get(target);
8010
+ var sheets = shadowRootsToStyleSheets.get(target);
7878
8011
 
7879
8012
  if (isUndefined$1(sheets)) {
7880
8013
  sheets = create(null);
7881
- nodesToStyleSheets.set(target, sheets);
8014
+ shadowRootsToStyleSheets.set(target, sheets);
7882
8015
  }
7883
8016
 
7884
8017
  if (sheets[content]) {
@@ -8168,6 +8301,177 @@
8168
8301
  setSetText(setText);
8169
8302
  setSsr(ssr);
8170
8303
  setAddEventListener(addEventListener);
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
+ function resetShadowRootAndLightDom(element, Ctor) {
8312
+ if (element.shadowRoot) {
8313
+ var shadowRoot = element.shadowRoot;
8314
+
8315
+ while (!isNull(shadowRoot.firstChild)) {
8316
+ shadowRoot.removeChild(shadowRoot.firstChild);
8317
+ }
8318
+ }
8319
+
8320
+ if (Ctor.renderMode === 'light') {
8321
+ while (!isNull(element.firstChild)) {
8322
+ element.removeChild(element.firstChild);
8323
+ }
8324
+ }
8325
+ }
8326
+
8327
+ function createVMWithProps(element, Ctor, props) {
8328
+ createVM(element, Ctor, {
8329
+ mode: 'open',
8330
+ owner: null,
8331
+ tagName: element.tagName.toLowerCase()
8332
+ });
8333
+
8334
+ for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
8335
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
8336
+ key = _Object$entries2$_i[0],
8337
+ value = _Object$entries2$_i[1];
8338
+
8339
+ element[key] = value;
8340
+ }
8341
+ }
8342
+
8343
+ function hydrateComponent(element, Ctor) {
8344
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8345
+
8346
+ if (!(element instanceof Element)) {
8347
+ throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
8348
+ }
8349
+
8350
+ if (!isFunction$1(Ctor)) {
8351
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8352
+ }
8353
+
8354
+ if (!isObject(props) || isNull(props)) {
8355
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8356
+ }
8357
+
8358
+ if (getAssociatedVMIfPresent(element)) {
8359
+ /* eslint-disable-next-line no-console */
8360
+ console.warn("\"hydrateComponent\" expects an element that is not hydrated.", element);
8361
+ return;
8362
+ }
8363
+
8364
+ try {
8365
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8366
+ // and uses the same algo to create the stylesheets as in SSR.
8367
+ setIsHydrating(true);
8368
+ createVMWithProps(element, Ctor, props);
8369
+ hydrateRootElement(element); // set it back since now we finished hydration.
8370
+
8371
+ setIsHydrating(false);
8372
+ } catch (e) {
8373
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
8374
+ // with the client generated DOM.
8375
+
8376
+ /* eslint-disable-next-line no-console */
8377
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
8378
+
8379
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
8380
+
8381
+ createVMWithProps(element, Ctor, props);
8382
+ setIsHydrating(false);
8383
+ connectRootElement(element);
8384
+ } finally {
8385
+ // in case there's an error during recovery
8386
+ setIsHydrating(false);
8387
+ }
8388
+ }
8389
+ /*
8390
+ * Copyright (c) 2018, salesforce.com, inc.
8391
+ * All rights reserved.
8392
+ * SPDX-License-Identifier: MIT
8393
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8394
+ */
8395
+
8396
+ /**
8397
+ * This function builds a Web Component class from a LWC constructor so it can be
8398
+ * registered as a new element via customElements.define() at any given time.
8399
+ *
8400
+ * @deprecated since version 1.3.11
8401
+ *
8402
+ * @example
8403
+ * ```
8404
+ * import { buildCustomElementConstructor } from 'lwc';
8405
+ * import Foo from 'ns/foo';
8406
+ * const WC = buildCustomElementConstructor(Foo);
8407
+ * customElements.define('x-foo', WC);
8408
+ * const elm = document.createElement('x-foo');
8409
+ * ```
8410
+ */
8411
+
8412
+
8413
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8414
+ if (process.env.NODE_ENV !== 'production') {
8415
+ /* eslint-disable-next-line no-console */
8416
+ 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."));
8417
+ }
8418
+
8419
+ return Ctor.CustomElementConstructor;
8420
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
8421
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
8422
+
8423
+
8424
+ var hydratedCustomElements = new WeakSet();
8425
+
8426
+ function buildCustomElementConstructor(Ctor) {
8427
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8428
+ return /*#__PURE__*/function (_HtmlPrototype) {
8429
+ _inherits(_class, _HtmlPrototype);
8430
+
8431
+ var _super8 = _createSuper(_class);
8432
+
8433
+ function _class() {
8434
+ var _this6;
8435
+
8436
+ _classCallCheck(this, _class);
8437
+
8438
+ _this6 = _super8.call(this);
8439
+
8440
+ if (_this6.isConnected) {
8441
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
8442
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
8443
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
8444
+ } else {
8445
+ createVM(_assertThisInitialized(_this6), Ctor, {
8446
+ mode: 'open',
8447
+ owner: null,
8448
+ tagName: _this6.tagName
8449
+ });
8450
+ }
8451
+
8452
+ return _this6;
8453
+ }
8454
+
8455
+ _createClass(_class, [{
8456
+ key: "connectedCallback",
8457
+ value: function connectedCallback() {
8458
+ if (hydratedCustomElements.has(this)) {
8459
+ // This is an un-upgraded element that was hydrated in the constructor.
8460
+ hydratedCustomElements.delete(this);
8461
+ } else {
8462
+ connectRootElement(this);
8463
+ }
8464
+ }
8465
+ }, {
8466
+ key: "disconnectedCallback",
8467
+ value: function disconnectedCallback() {
8468
+ disconnectRootElement(this);
8469
+ }
8470
+ }]);
8471
+
8472
+ return _class;
8473
+ }(HtmlPrototype);
8474
+ }
8171
8475
  /*
8172
8476
  * Copyright (c) 2018, salesforce.com, inc.
8173
8477
  * All rights reserved.
@@ -8177,6 +8481,7 @@
8177
8481
  // TODO [#2472]: Remove this workaround when appropriate.
8178
8482
  // eslint-disable-next-line lwc-internal/no-global-node
8179
8483
 
8484
+
8180
8485
  var _Node$1 = Node;
8181
8486
  var ConnectingSlot = new WeakMap();
8182
8487
  var DisconnectingSlot = new WeakMap();
@@ -8284,142 +8589,6 @@
8284
8589
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8285
8590
  */
8286
8591
 
8287
-
8288
- function hydrateComponent(element, Ctor) {
8289
- var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8290
-
8291
- if (!(element instanceof Element)) {
8292
- throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
8293
- }
8294
-
8295
- if (!isFunction$1(Ctor)) {
8296
- throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8297
- }
8298
-
8299
- if (!isObject(props) || isNull(props)) {
8300
- throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8301
- }
8302
-
8303
- try {
8304
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8305
- // and uses the same algo to create the stylesheets as in SSR.
8306
- setIsHydrating(true);
8307
- createVM(element, Ctor, {
8308
- mode: 'open',
8309
- owner: null,
8310
- tagName: element.tagName.toLowerCase()
8311
- });
8312
-
8313
- for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
8314
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
8315
- key = _Object$entries2$_i[0],
8316
- value = _Object$entries2$_i[1];
8317
-
8318
- element[key] = value;
8319
- }
8320
-
8321
- hydrateRootElement(element); // set it back since now we finished hydration.
8322
-
8323
- setIsHydrating(false);
8324
- } catch (e) {
8325
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8326
- // the client generated DOM.
8327
-
8328
- /* eslint-disable-next-line no-console */
8329
- console.error('Recovering from error while hydrating: ', e);
8330
- setIsHydrating(false);
8331
- var newElem = createElement(element.tagName, {
8332
- is: Ctor,
8333
- mode: 'open'
8334
- });
8335
-
8336
- for (var _i34 = 0, _Object$entries3 = Object.entries(props); _i34 < _Object$entries3.length; _i34++) {
8337
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i34], 2),
8338
- _key3 = _Object$entries3$_i[0],
8339
- _value2 = _Object$entries3$_i[1];
8340
-
8341
- newElem[_key3] = _value2;
8342
- }
8343
-
8344
- element.parentNode.replaceChild(newElem, element);
8345
- }
8346
- }
8347
- /*
8348
- * Copyright (c) 2018, salesforce.com, inc.
8349
- * All rights reserved.
8350
- * SPDX-License-Identifier: MIT
8351
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8352
- */
8353
-
8354
- /**
8355
- * This function builds a Web Component class from a LWC constructor so it can be
8356
- * registered as a new element via customElements.define() at any given time.
8357
- *
8358
- * @deprecated since version 1.3.11
8359
- *
8360
- * @example
8361
- * ```
8362
- * import { buildCustomElementConstructor } from 'lwc';
8363
- * import Foo from 'ns/foo';
8364
- * const WC = buildCustomElementConstructor(Foo);
8365
- * customElements.define('x-foo', WC);
8366
- * const elm = document.createElement('x-foo');
8367
- * ```
8368
- */
8369
-
8370
-
8371
- function deprecatedBuildCustomElementConstructor(Ctor) {
8372
- if (process.env.NODE_ENV !== 'production') {
8373
- /* eslint-disable-next-line no-console */
8374
- 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."));
8375
- }
8376
-
8377
- return Ctor.CustomElementConstructor;
8378
- }
8379
-
8380
- function buildCustomElementConstructor(Ctor) {
8381
- var HtmlPrototype = getComponentHtmlPrototype(Ctor);
8382
- return /*#__PURE__*/function (_HtmlPrototype) {
8383
- _inherits(_class, _HtmlPrototype);
8384
-
8385
- var _super8 = _createSuper(_class);
8386
-
8387
- function _class() {
8388
- var _this6;
8389
-
8390
- _classCallCheck(this, _class);
8391
-
8392
- _this6 = _super8.call(this);
8393
- createVM(_assertThisInitialized(_this6), Ctor, {
8394
- mode: 'open',
8395
- owner: null,
8396
- tagName: _this6.tagName
8397
- });
8398
- return _this6;
8399
- }
8400
-
8401
- _createClass(_class, [{
8402
- key: "connectedCallback",
8403
- value: function connectedCallback() {
8404
- connectRootElement(this);
8405
- }
8406
- }, {
8407
- key: "disconnectedCallback",
8408
- value: function disconnectedCallback() {
8409
- disconnectRootElement(this);
8410
- }
8411
- }]);
8412
-
8413
- return _class;
8414
- }(HtmlPrototype);
8415
- }
8416
- /*
8417
- * Copyright (c) 2018, salesforce.com, inc.
8418
- * All rights reserved.
8419
- * SPDX-License-Identifier: MIT
8420
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8421
- */
8422
-
8423
8592
  /**
8424
8593
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
8425
8594
  * This API is subject to change or being removed.
@@ -8519,7 +8688,7 @@
8519
8688
  });
8520
8689
  freeze(LightningElement);
8521
8690
  seal(LightningElement.prototype);
8522
- /* version: 2.9.0 */
8691
+ /* version: 2.11.1 */
8523
8692
 
8524
8693
  exports.LightningElement = LightningElement;
8525
8694
  exports.__unstable__ProfilerControl = profilerControl;