lwc 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +603 -449
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +603 -449
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +477 -398
  5. package/dist/engine-dom/iife/es5/engine-dom.js +657 -479
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +509 -425
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +603 -449
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +477 -398
  11. package/dist/engine-dom/umd/es5/engine-dom.js +657 -479
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +509 -425
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +391 -285
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +391 -285
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +7 -7
@@ -305,7 +305,7 @@
305
305
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
306
306
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
307
307
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
308
- /** version: 2.9.0 */
308
+ /** version: 2.10.0 */
309
309
 
310
310
  /*
311
311
  * Copyright (c) 2018, salesforce.com, inc.
@@ -372,7 +372,7 @@
372
372
  };
373
373
  }
374
374
 
375
- function patch(propName) {
375
+ function patch$1(propName) {
376
376
  // Typescript is inferring the wrong function type for this particular
377
377
  // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
378
378
  // @ts-ignore type-mismatch
@@ -394,7 +394,7 @@
394
394
  const propName = ElementPrototypeAriaPropertyNames[i];
395
395
 
396
396
  if (detect(propName)) {
397
- patch(propName);
397
+ patch$1(propName);
398
398
  }
399
399
  }
400
400
  /**
@@ -410,14 +410,15 @@
410
410
 
411
411
 
412
412
  const features = {
413
- ENABLE_REACTIVE_SETTER: null,
414
- ENABLE_HMR: null,
415
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
413
+ DISABLE_MIXED_SHADOW_MODE: null,
416
414
  ENABLE_ELEMENT_PATCH: null,
417
415
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
418
- ENABLE_NODE_LIST_PATCH: null,
416
+ ENABLE_HMR: null,
419
417
  ENABLE_HTML_COLLECTIONS_PATCH: null,
418
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
419
+ ENABLE_NODE_LIST_PATCH: null,
420
420
  ENABLE_NODE_PATCH: null,
421
+ ENABLE_REACTIVE_SETTER: null,
421
422
  ENABLE_WIRE_SYNC_EMIT: null
422
423
  };
423
424
 
@@ -474,7 +475,7 @@
474
475
 
475
476
  function setFeatureFlagForTest(name, value) {
476
477
  }
477
- /** version: 2.9.0 */
478
+ /** version: 2.10.0 */
478
479
 
479
480
  /* proxy-compat-disable */
480
481
 
@@ -529,7 +530,7 @@
529
530
  }
530
531
 
531
532
  return result;
532
- } //
533
+ }
533
534
  // Primitives
534
535
  //
535
536
 
@@ -2550,6 +2551,13 @@
2550
2551
  const meta = signedDecoratorToMetaMap.get(Ctor);
2551
2552
  return isUndefined$1(meta) ? defaultMeta : meta;
2552
2553
  }
2554
+ /*
2555
+ * Copyright (c) 2018, salesforce.com, inc.
2556
+ * All rights reserved.
2557
+ * SPDX-License-Identifier: MIT
2558
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2559
+ */
2560
+
2553
2561
 
2554
2562
  const signedTemplateSet = new Set();
2555
2563
 
@@ -2569,6 +2577,7 @@
2569
2577
 
2570
2578
 
2571
2579
  function registerTemplate(tpl) {
2580
+
2572
2581
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
2573
2582
  // assignment of templates easily, without too much transformation
2574
2583
 
@@ -3401,148 +3410,251 @@
3401
3410
  */
3402
3411
 
3403
3412
 
3404
- const TextHook = {
3405
- create: vnode => {
3406
- const {
3407
- owner
3408
- } = vnode;
3409
- const elm = createText$1(vnode.text);
3410
- linkNodeToShadow(elm, owner);
3411
- vnode.elm = elm;
3412
- },
3413
- update: updateNodeHook,
3414
- insert: insertNode,
3415
- move: insertNode,
3416
- remove: removeNode
3417
- };
3418
- const CommentHook = {
3419
- create: vnode => {
3420
- const {
3421
- owner,
3422
- text
3423
- } = vnode;
3424
- const elm = createComment$1(text);
3425
- linkNodeToShadow(elm, owner);
3426
- vnode.elm = elm;
3427
- },
3428
- update: updateNodeHook,
3429
- insert: insertNode,
3430
- move: insertNode,
3431
- remove: removeNode
3432
- }; // insert is called after update, which is used somewhere else (via a module)
3433
- // to mark the vm as inserted, that means we cannot use update as the main channel
3434
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
3435
- // which breaks some invariants. For that reason, we have the following for any
3436
- // Custom Element that is inserted via a template.
3437
-
3438
- const ElementHook = {
3439
- create: vnode => {
3440
- const {
3441
- sel,
3442
- owner,
3443
- data: {
3444
- svg
3445
- }
3446
- } = vnode;
3447
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3448
- const elm = createElement$2(sel, namespace);
3449
- linkNodeToShadow(elm, owner);
3450
- fallbackElmHook(elm, vnode);
3451
- vnode.elm = elm;
3452
- patchElementPropsAndAttrs$1(null, vnode);
3453
- },
3454
- update: (oldVnode, vnode) => {
3455
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3456
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3457
- },
3458
- insert: (vnode, parentNode, referenceNode) => {
3459
- insertNode(vnode, parentNode, referenceNode);
3460
- createChildrenHook(vnode);
3461
- },
3462
- move: insertNode,
3463
- remove: (vnode, parentNode) => {
3464
- removeNode(vnode, parentNode);
3465
- removeChildren(vnode);
3413
+ function patchChildren(c1, c2, parent) {
3414
+ if (hasDynamicChildren(c2)) {
3415
+ updateDynamicChildren(c1, c2, parent);
3416
+ } else {
3417
+ updateStaticChildren(c1, c2, parent);
3466
3418
  }
3467
- };
3468
- const CustomElementHook = {
3469
- create: vnode => {
3470
- const {
3471
- sel,
3472
- owner
3473
- } = vnode;
3474
- const UpgradableConstructor = getUpgradableConstructor(sel);
3475
- /**
3476
- * Note: if the upgradable constructor does not expect, or throw when we new it
3477
- * with a callback as the first argument, we could implement a more advanced
3478
- * mechanism that only passes that argument if the constructor is known to be
3479
- * an upgradable custom element.
3480
- */
3481
-
3482
- let vm;
3483
- const elm = new UpgradableConstructor(elm => {
3484
- // the custom element from the registry is expecting an upgrade callback
3485
- vm = createViewModelHook(elm, vnode);
3486
- });
3487
- linkNodeToShadow(elm, owner);
3488
- vnode.elm = elm;
3419
+ }
3489
3420
 
3490
- if (vm) {
3491
- allocateChildren(vnode, vm);
3492
- } else if (vnode.ctor !== UpgradableConstructor) {
3493
- throw new TypeError(`Incorrect Component Constructor`);
3494
- }
3421
+ function patch(n1, n2) {
3422
+ if (n1 === n2) {
3423
+ return;
3424
+ }
3495
3425
 
3496
- patchElementPropsAndAttrs$1(null, vnode);
3497
- },
3498
- update: (oldVnode, vnode) => {
3499
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3500
- const vm = getAssociatedVMIfPresent(vnode.elm);
3426
+ switch (n2.type) {
3427
+ case 0
3428
+ /* Text */
3429
+ :
3430
+ patchText(n1, n2);
3431
+ break;
3501
3432
 
3502
- if (vm) {
3503
- // in fallback mode, the allocation will always set children to
3504
- // empty and delegate the real allocation to the slot elements
3505
- allocateChildren(vnode, vm);
3506
- } // in fallback mode, the children will be always empty, so, nothing
3507
- // will happen, but in native, it does allocate the light dom
3433
+ case 1
3434
+ /* Comment */
3435
+ :
3436
+ patchComment(n1, n2);
3437
+ break;
3508
3438
 
3439
+ case 2
3440
+ /* Element */
3441
+ :
3442
+ patchElement(n1, n2);
3443
+ break;
3509
3444
 
3510
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3445
+ case 3
3446
+ /* CustomElement */
3447
+ :
3448
+ patchCustomElement(n1, n2);
3449
+ break;
3450
+ }
3451
+ }
3511
3452
 
3512
- if (vm) {
3513
- // this is important to preserve the top to bottom synchronous rendering phase.
3453
+ function mount(node, parent, anchor) {
3454
+ switch (node.type) {
3455
+ case 0
3456
+ /* Text */
3457
+ :
3458
+ mountText(node, parent, anchor);
3459
+ break;
3514
3460
 
3461
+ case 1
3462
+ /* Comment */
3463
+ :
3464
+ mountComment(node, parent, anchor);
3465
+ break;
3515
3466
 
3516
- rerenderVM(vm);
3517
- }
3518
- },
3519
- insert: (vnode, parentNode, referenceNode) => {
3520
- insertNode(vnode, parentNode, referenceNode);
3521
- const vm = getAssociatedVMIfPresent(vnode.elm);
3467
+ case 2
3468
+ /* Element */
3469
+ :
3470
+ mountElement(node, parent, anchor);
3471
+ break;
3472
+
3473
+ case 3
3474
+ /* CustomElement */
3475
+ :
3476
+ mountCustomElement(node, parent, anchor);
3477
+ break;
3478
+ }
3479
+ }
3480
+
3481
+ function patchText(n1, n2) {
3482
+ n2.elm = n1.elm;
3483
+
3484
+ if (n2.text !== n1.text) {
3485
+ updateTextContent(n2);
3486
+ }
3487
+ }
3488
+
3489
+ function mountText(node, parent, anchor) {
3490
+ const {
3491
+ owner
3492
+ } = node;
3493
+ const textNode = node.elm = createText$1(node.text);
3494
+ linkNodeToShadow(textNode, owner);
3495
+ insertNode(textNode, parent, anchor);
3496
+ }
3497
+
3498
+ function patchComment(n1, n2) {
3499
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3500
+ // it is the case today.
3522
3501
 
3523
- if (vm) {
3502
+ if (n2.text !== n1.text) {
3503
+ updateTextContent(n2);
3504
+ }
3505
+ }
3524
3506
 
3525
- runConnectedCallback(vm);
3507
+ function mountComment(node, parent, anchor) {
3508
+ const {
3509
+ owner
3510
+ } = node;
3511
+ const commentNode = node.elm = createComment$1(node.text);
3512
+ linkNodeToShadow(commentNode, owner);
3513
+ insertNode(commentNode, parent, anchor);
3514
+ }
3515
+
3516
+ function mountElement(vnode, parent, anchor) {
3517
+ const {
3518
+ sel,
3519
+ owner,
3520
+ data: {
3521
+ svg
3526
3522
  }
3523
+ } = vnode;
3524
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3525
+ const elm = createElement$2(sel, namespace);
3526
+ linkNodeToShadow(elm, owner);
3527
+ fallbackElmHook(elm, vnode);
3528
+ vnode.elm = elm;
3529
+ patchElementPropsAndAttrs$1(null, vnode);
3530
+ insertNode(elm, parent, anchor);
3531
+ mountVNodes(vnode.children, elm, null);
3532
+ }
3533
+
3534
+ function patchElement(n1, n2) {
3535
+ const elm = n2.elm = n1.elm;
3536
+ patchElementPropsAndAttrs$1(n1, n2);
3537
+ patchChildren(n1.children, n2.children, elm);
3538
+ }
3539
+
3540
+ function mountCustomElement(vnode, parent, anchor) {
3541
+ const {
3542
+ sel,
3543
+ owner
3544
+ } = vnode;
3545
+ const UpgradableConstructor = getUpgradableConstructor(sel);
3546
+ /**
3547
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3548
+ * with a callback as the first argument, we could implement a more advanced
3549
+ * mechanism that only passes that argument if the constructor is known to be
3550
+ * an upgradable custom element.
3551
+ */
3552
+
3553
+ let vm;
3554
+ const elm = new UpgradableConstructor(elm => {
3555
+ // the custom element from the registry is expecting an upgrade callback
3556
+ vm = createViewModelHook(elm, vnode);
3557
+ });
3558
+ linkNodeToShadow(elm, owner);
3559
+ vnode.elm = elm;
3560
+ vnode.vm = vm;
3561
+
3562
+ if (vm) {
3563
+ allocateChildren(vnode, vm);
3564
+ } else if (vnode.ctor !== UpgradableConstructor) {
3565
+ throw new TypeError(`Incorrect Component Constructor`);
3566
+ }
3567
+
3568
+ patchElementPropsAndAttrs$1(null, vnode);
3569
+ insertNode(elm, parent, anchor);
3570
+
3571
+ if (vm) {
3527
3572
 
3528
- createChildrenHook(vnode);
3573
+ runConnectedCallback(vm);
3574
+ }
3575
+
3576
+ mountVNodes(vnode.children, elm, null);
3577
+
3578
+ if (vm) {
3579
+ appendVM(vm);
3580
+ }
3581
+ }
3582
+
3583
+ function patchCustomElement(n1, n2) {
3584
+ const elm = n2.elm = n1.elm;
3585
+ const vm = n2.vm = n1.vm;
3586
+ patchElementPropsAndAttrs$1(n1, n2);
3587
+
3588
+ if (!isUndefined$1(vm)) {
3589
+ // in fallback mode, the allocation will always set children to
3590
+ // empty and delegate the real allocation to the slot elements
3591
+ allocateChildren(n2, vm);
3592
+ } // in fallback mode, the children will be always empty, so, nothing
3593
+ // will happen, but in native, it does allocate the light dom
3594
+
3595
+
3596
+ patchChildren(n1.children, n2.children, elm);
3597
+
3598
+ if (!isUndefined$1(vm)) {
3599
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3600
+ // this is important to preserve the top to bottom synchronous rendering phase.
3601
+ rerenderVM(vm);
3602
+ }
3603
+ }
3529
3604
 
3530
- if (vm) {
3531
- appendVM(vm);
3605
+ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
3606
+ for (; start < end; ++start) {
3607
+ const vnode = vnodes[start];
3608
+
3609
+ if (isVNode(vnode)) {
3610
+ mount(vnode, parent, anchor);
3532
3611
  }
3533
- },
3534
- move: insertNode,
3535
- remove: (vnode, parentNode) => {
3536
- removeNode(vnode, parentNode);
3537
- const vm = getAssociatedVMIfPresent(vnode.elm);
3538
-
3539
- if (vm) {
3540
- // for custom elements we don't have to go recursively because the removeVM routine
3541
- // will take care of disconnecting any child VM attached to its shadow as well.
3542
- removeVM(vm);
3612
+ }
3613
+ }
3614
+
3615
+ function unmount(vnode, parent, doRemove = false) {
3616
+ const {
3617
+ type,
3618
+ elm
3619
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3620
+ // subtree root, is the only element worth unmounting from the subtree.
3621
+
3622
+ if (doRemove) {
3623
+ removeNode(elm, parent);
3624
+ }
3625
+
3626
+ switch (type) {
3627
+ case 2
3628
+ /* Element */
3629
+ :
3630
+ unmountVNodes(vnode.children, elm);
3631
+ break;
3632
+
3633
+ case 3
3634
+ /* CustomElement */
3635
+ :
3636
+ {
3637
+ const {
3638
+ vm
3639
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
3640
+ // children.
3641
+
3642
+ if (!isUndefined$1(vm)) {
3643
+ removeVM(vm);
3644
+ }
3645
+ }
3646
+ }
3647
+ }
3648
+
3649
+ function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
3650
+ for (; start < end; ++start) {
3651
+ const ch = vnodes[start];
3652
+
3653
+ if (isVNode(ch)) {
3654
+ unmount(ch, parent, doRemove);
3543
3655
  }
3544
3656
  }
3545
- };
3657
+ }
3546
3658
 
3547
3659
  function isVNode(vnode) {
3548
3660
  return vnode != null;
@@ -3587,26 +3699,23 @@
3587
3699
  }
3588
3700
  }
3589
3701
 
3590
- function updateNodeHook(oldVnode, vnode) {
3702
+ function updateTextContent(vnode) {
3591
3703
  const {
3592
3704
  elm,
3593
3705
  text
3594
3706
  } = vnode;
3595
3707
 
3596
- if (oldVnode.text !== text) {
3597
-
3598
- setText$1(elm, text);
3599
- }
3708
+ setText$1(elm, text);
3600
3709
  }
3601
3710
 
3602
- function insertNode(vnode, parentNode, referenceNode) {
3711
+ function insertNode(node, parent, anchor) {
3603
3712
 
3604
- insert$1(vnode.elm, parentNode, referenceNode);
3713
+ insert$1(node, parent, anchor);
3605
3714
  }
3606
3715
 
3607
- function removeNode(vnode, parentNode) {
3716
+ function removeNode(node, parent) {
3608
3717
 
3609
- remove$1(vnode.elm, parentNode);
3718
+ remove$1(node, parent);
3610
3719
  }
3611
3720
 
3612
3721
  function patchElementPropsAndAttrs$1(oldVnode, vnode) {
@@ -3657,14 +3766,6 @@
3657
3766
  }
3658
3767
  }
3659
3768
 
3660
- function patchChildren(parent, oldCh, newCh) {
3661
- if (hasDynamicChildren(newCh)) {
3662
- updateDynamicChildren(parent, oldCh, newCh);
3663
- } else {
3664
- updateStaticChildren(parent, oldCh, newCh);
3665
- }
3666
- }
3667
-
3668
3769
  function allocateChildren(vnode, vm) {
3669
3770
  // A component with slots will re-render because:
3670
3771
  // 1- There is a change of the internal state.
@@ -3736,40 +3837,6 @@
3736
3837
  return vm;
3737
3838
  }
3738
3839
 
3739
- function createChildrenHook(vnode) {
3740
- const {
3741
- elm,
3742
- children
3743
- } = vnode;
3744
-
3745
- for (let j = 0; j < children.length; ++j) {
3746
- const ch = children[j];
3747
-
3748
- if (ch != null) {
3749
- ch.hook.create(ch);
3750
- ch.hook.insert(ch, elm, null);
3751
- }
3752
- }
3753
- }
3754
-
3755
- function removeChildren(vnode) {
3756
- // this method only needs to search on child vnodes from template
3757
- // to trigger the remove hook just in case some of those children
3758
- // are custom elements.
3759
- const {
3760
- children,
3761
- elm
3762
- } = vnode;
3763
-
3764
- for (let j = 0, len = children.length; j < len; ++j) {
3765
- const ch = children[j];
3766
-
3767
- if (!isNull(ch)) {
3768
- ch.hook.remove(ch, elm);
3769
- }
3770
- }
3771
- }
3772
-
3773
3840
  function allocateInSlot(vm, children) {
3774
3841
  var _a;
3775
3842
 
@@ -3866,28 +3933,7 @@
3866
3933
  return map;
3867
3934
  }
3868
3935
 
3869
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
3870
- for (; startIdx <= endIdx; ++startIdx) {
3871
- const ch = vnodes[startIdx];
3872
-
3873
- if (isVNode(ch)) {
3874
- ch.hook.create(ch);
3875
- ch.hook.insert(ch, parentElm, before);
3876
- }
3877
- }
3878
- }
3879
-
3880
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
3881
- for (; startIdx <= endIdx; ++startIdx) {
3882
- const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
3883
-
3884
- if (isVNode(ch)) {
3885
- ch.hook.remove(ch, parentElm);
3886
- }
3887
- }
3888
- }
3889
-
3890
- function updateDynamicChildren(parentElm, oldCh, newCh) {
3936
+ function updateDynamicChildren(oldCh, newCh, parent) {
3891
3937
  let oldStartIdx = 0;
3892
3938
  let newStartIdx = 0;
3893
3939
  let oldEndIdx = oldCh.length - 1;
@@ -3913,23 +3959,23 @@
3913
3959
  } else if (!isVNode(newEndVnode)) {
3914
3960
  newEndVnode = newCh[--newEndIdx];
3915
3961
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
3916
- patchVnode(oldStartVnode, newStartVnode);
3962
+ patch(oldStartVnode, newStartVnode);
3917
3963
  oldStartVnode = oldCh[++oldStartIdx];
3918
3964
  newStartVnode = newCh[++newStartIdx];
3919
3965
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
3920
- patchVnode(oldEndVnode, newEndVnode);
3966
+ patch(oldEndVnode, newEndVnode);
3921
3967
  oldEndVnode = oldCh[--oldEndIdx];
3922
3968
  newEndVnode = newCh[--newEndIdx];
3923
3969
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
3924
3970
  // Vnode moved right
3925
- patchVnode(oldStartVnode, newEndVnode);
3926
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
3971
+ patch(oldStartVnode, newEndVnode);
3972
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
3927
3973
  oldStartVnode = oldCh[++oldStartIdx];
3928
3974
  newEndVnode = newCh[--newEndIdx];
3929
3975
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
3930
3976
  // Vnode moved left
3931
- patchVnode(oldEndVnode, newStartVnode);
3932
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
3977
+ patch(oldEndVnode, newStartVnode);
3978
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
3933
3979
  oldEndVnode = oldCh[--oldEndIdx];
3934
3980
  newStartVnode = newCh[++newStartIdx];
3935
3981
  } else {
@@ -3941,8 +3987,7 @@
3941
3987
 
3942
3988
  if (isUndefined$1(idxInOld)) {
3943
3989
  // New element
3944
- newStartVnode.hook.create(newStartVnode);
3945
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3990
+ mount(newStartVnode, parent, oldStartVnode.elm);
3946
3991
  newStartVnode = newCh[++newStartIdx];
3947
3992
  } else {
3948
3993
  elmToMove = oldCh[idxInOld];
@@ -3950,10 +3995,9 @@
3950
3995
  if (isVNode(elmToMove)) {
3951
3996
  if (elmToMove.sel !== newStartVnode.sel) {
3952
3997
  // New element
3953
- newStartVnode.hook.create(newStartVnode);
3954
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3998
+ mount(newStartVnode, parent, oldStartVnode.elm);
3955
3999
  } else {
3956
- patchVnode(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
4000
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
3957
4001
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3958
4002
  // so we only care about the `oldCh` object inside this function.
3959
4003
  // To avoid cloning over and over again, we check `clonedOldCh`
@@ -3966,7 +4010,7 @@
3966
4010
 
3967
4011
 
3968
4012
  oldCh[idxInOld] = undefined;
3969
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
4013
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
3970
4014
  }
3971
4015
  }
3972
4016
 
@@ -3987,65 +4031,55 @@
3987
4031
  } while (!isVNode(n) && i < newChEnd);
3988
4032
 
3989
4033
  before = isVNode(n) ? n.elm : null;
3990
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
4034
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
3991
4035
  } else {
3992
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
4036
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
3993
4037
  }
3994
4038
  }
3995
4039
  }
3996
4040
 
3997
- function updateStaticChildren(parentElm, oldCh, newCh) {
3998
- const oldChLength = oldCh.length;
3999
- const newChLength = newCh.length;
4041
+ function updateStaticChildren(c1, c2, parent) {
4042
+ const c1Length = c1.length;
4043
+ const c2Length = c2.length;
4000
4044
 
4001
- if (oldChLength === 0) {
4045
+ if (c1Length === 0) {
4002
4046
  // the old list is empty, we can directly insert anything new
4003
- addVnodes(parentElm, null, newCh, 0, newChLength);
4047
+ mountVNodes(c2, parent, null);
4004
4048
  return;
4005
4049
  }
4006
4050
 
4007
- if (newChLength === 0) {
4051
+ if (c2Length === 0) {
4008
4052
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
4009
4053
  // this is the case in which the dynamic children of an if-directive should be removed
4010
- removeVnodes(parentElm, oldCh, 0, oldChLength);
4054
+ unmountVNodes(c1, parent, true);
4011
4055
  return;
4012
4056
  } // if the old list is not empty, the new list MUST have the same
4013
4057
  // amount of nodes, that's why we call this static children
4014
4058
 
4015
4059
 
4016
- let referenceElm = null;
4060
+ let anchor = null;
4017
4061
 
4018
- for (let i = newChLength - 1; i >= 0; i -= 1) {
4019
- const vnode = newCh[i];
4020
- const oldVNode = oldCh[i];
4062
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
4063
+ const n1 = c1[i];
4064
+ const n2 = c2[i];
4021
4065
 
4022
- if (vnode !== oldVNode) {
4023
- if (isVNode(oldVNode)) {
4024
- if (isVNode(vnode)) {
4025
- // both vnodes must be equivalent, and se just need to patch them
4026
- patchVnode(oldVNode, vnode);
4027
- referenceElm = vnode.elm;
4066
+ if (n2 !== n1) {
4067
+ if (isVNode(n1)) {
4068
+ if (isVNode(n2)) {
4069
+ // both vnodes are equivalent, and we just need to patch them
4070
+ patch(n1, n2);
4071
+ anchor = n2.elm;
4028
4072
  } else {
4029
4073
  // removing the old vnode since the new one is null
4030
- oldVNode.hook.remove(oldVNode, parentElm);
4074
+ unmount(n1, parent, true);
4031
4075
  }
4032
- } else if (isVNode(vnode)) {
4033
- // this condition is unnecessary
4034
- vnode.hook.create(vnode); // insert the new node one since the old one is null
4035
-
4036
- vnode.hook.insert(vnode, parentElm, referenceElm);
4037
- referenceElm = vnode.elm;
4076
+ } else if (isVNode(n2)) {
4077
+ mount(n2, parent, anchor);
4078
+ anchor = n2.elm;
4038
4079
  }
4039
4080
  }
4040
4081
  }
4041
4082
  }
4042
-
4043
- function patchVnode(oldVnode, vnode) {
4044
- if (oldVnode !== vnode) {
4045
- vnode.elm = oldVnode.elm;
4046
- vnode.hook.update(oldVnode, vnode);
4047
- }
4048
- }
4049
4083
  /*
4050
4084
  * Copyright (c) 2018, salesforce.com, inc.
4051
4085
  * All rights reserved.
@@ -4077,7 +4111,6 @@
4077
4111
  children,
4078
4112
  elm,
4079
4113
  key,
4080
- hook: ElementHook,
4081
4114
  owner: vmBeingRendered
4082
4115
  };
4083
4116
  } // [t]ab[i]ndex function
@@ -4129,7 +4162,7 @@
4129
4162
  const {
4130
4163
  key
4131
4164
  } = data;
4132
- let elm;
4165
+ let elm, aChildren, vm;
4133
4166
  const vnode = {
4134
4167
  type: 3
4135
4168
  /* CustomElement */
@@ -4139,11 +4172,11 @@
4139
4172
  children,
4140
4173
  elm,
4141
4174
  key,
4142
- hook: CustomElementHook,
4143
4175
  ctor: Ctor,
4144
4176
  owner: vmBeingRendered,
4145
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
4146
-
4177
+ mode: 'open',
4178
+ aChildren,
4179
+ vm
4147
4180
  };
4148
4181
  addVNodeToChildLWC(vnode);
4149
4182
  return vnode;
@@ -4225,7 +4258,6 @@
4225
4258
  text,
4226
4259
  elm,
4227
4260
  key,
4228
- hook: TextHook,
4229
4261
  owner: getVMBeingRendered()
4230
4262
  };
4231
4263
  } // [co]mment node
@@ -4241,7 +4273,6 @@
4241
4273
  text,
4242
4274
  elm,
4243
4275
  key,
4244
- hook: CommentHook,
4245
4276
  owner: getVMBeingRendered()
4246
4277
  };
4247
4278
  } // [d]ynamic text
@@ -4970,6 +5001,7 @@
4970
5001
  function registerComponent(Ctor, {
4971
5002
  tmpl
4972
5003
  }) {
5004
+
4973
5005
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
4974
5006
  // without too much transformation
4975
5007
 
@@ -5079,7 +5111,7 @@
5079
5111
  */
5080
5112
 
5081
5113
 
5082
- function hydrate$1(vnode, node) {
5114
+ function hydrate(vnode, node) {
5083
5115
  switch (vnode.type) {
5084
5116
  case 0
5085
5117
  /* Text */
@@ -5111,7 +5143,7 @@
5111
5143
  var _a;
5112
5144
 
5113
5145
 
5114
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5146
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5115
5147
  vnode.elm = node;
5116
5148
  }
5117
5149
 
@@ -5119,7 +5151,7 @@
5119
5151
  var _a;
5120
5152
 
5121
5153
 
5122
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5154
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5123
5155
  vnode.elm = node;
5124
5156
  }
5125
5157
 
@@ -5142,13 +5174,13 @@
5142
5174
  } = vnode.data;
5143
5175
 
5144
5176
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5145
- if (elm.innerHTML === props.innerHTML) {
5177
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
5146
5178
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5147
5179
  vnode.data = Object.assign(Object.assign({}, vnode.data), {
5148
5180
  props: cloneAndOmitKey(props, 'innerHTML')
5149
5181
  });
5150
5182
  } else {
5151
- logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5183
+ logWarn(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5152
5184
  }
5153
5185
  }
5154
5186
  }
@@ -5156,14 +5188,13 @@
5156
5188
  patchElementPropsAndAttrs(vnode);
5157
5189
 
5158
5190
  if (!isDomManual) {
5159
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
5191
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
5160
5192
  }
5161
5193
  }
5162
5194
 
5163
5195
  function hydrateCustomElement(vnode, node) {
5164
5196
 
5165
5197
  const elm = node;
5166
- vnode.elm = elm;
5167
5198
  const {
5168
5199
  sel,
5169
5200
  mode,
@@ -5175,6 +5206,8 @@
5175
5206
  owner,
5176
5207
  tagName: sel
5177
5208
  });
5209
+ vnode.elm = elm;
5210
+ vnode.vm = vm;
5178
5211
  allocateChildren(vnode, vm);
5179
5212
  patchElementPropsAndAttrs(vnode); // Insert hook section:
5180
5213
 
@@ -5185,7 +5218,7 @@
5185
5218
  ) {
5186
5219
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5187
5220
  // Note: for Light DOM, this is handled while hydrating the VM
5188
- hydrateChildren(vnode.elm.childNodes, vnode.children);
5221
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children);
5189
5222
  }
5190
5223
 
5191
5224
  hydrateVM(vm);
@@ -5200,7 +5233,7 @@
5200
5233
 
5201
5234
  if (!isNull(childVnode)) {
5202
5235
  const childNode = elmChildren[childNodeIndex];
5203
- hydrate$1(childVnode, childNode);
5236
+ hydrate(childVnode, childNode);
5204
5237
  childNodeIndex++;
5205
5238
  }
5206
5239
  }
@@ -5275,7 +5308,19 @@
5275
5308
  }
5276
5309
 
5277
5310
  function hydrateVM(vm) {
5278
- hydrate(vm);
5311
+ if (isTrue(vm.isDirty)) {
5312
+ // manually diffing/patching here.
5313
+ // This routine is:
5314
+ // patchShadowRoot(vm, children);
5315
+ // -> addVnodes.
5316
+ const children = renderComponent(vm);
5317
+ vm.children = children;
5318
+ const vmChildren = vm.renderMode === 0
5319
+ /* Light */
5320
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
5321
+ hydrateChildren(vmChildren, children);
5322
+ runRenderedCallback(vm);
5323
+ }
5279
5324
  } // just in case the component comes back, with this we guarantee re-rendering it
5280
5325
  // while preventing any attempt to rehydration until after reinsertion.
5281
5326
 
@@ -5403,7 +5448,11 @@
5403
5448
  /* Native */
5404
5449
  ;
5405
5450
  } else if (isNativeShadowDefined$1) {
5406
- if (def.shadowSupportMode === "any"
5451
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
5452
+ shadowMode = 1
5453
+ /* Synthetic */
5454
+ ;
5455
+ } else if (def.shadowSupportMode === "any"
5407
5456
  /* Any */
5408
5457
  ) {
5409
5458
  shadowMode = 0
@@ -5467,22 +5516,6 @@
5467
5516
  }
5468
5517
  }
5469
5518
 
5470
- function hydrate(vm) {
5471
- if (isTrue(vm.isDirty)) {
5472
- // manually diffing/patching here.
5473
- // This routine is:
5474
- // patchShadowRoot(vm, children);
5475
- // -> addVnodes.
5476
- const children = renderComponent(vm);
5477
- vm.children = children;
5478
- const vmChildren = vm.renderMode === 0
5479
- /* Light */
5480
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5481
- hydrateChildren(vmChildren, children);
5482
- runRenderedCallback(vm);
5483
- }
5484
- }
5485
-
5486
5519
  function patchShadowRoot(vm, newCh) {
5487
5520
  const {
5488
5521
  renderRoot,
@@ -5502,7 +5535,7 @@
5502
5535
  , vm);
5503
5536
  }, () => {
5504
5537
  // job
5505
- patchChildren(renderRoot, oldCh, newCh);
5538
+ patchChildren(oldCh, newCh, renderRoot);
5506
5539
  }, () => {
5507
5540
  // post
5508
5541
  logOperationEnd(2
@@ -6212,7 +6245,7 @@
6212
6245
  hooksAreSet = true;
6213
6246
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6214
6247
  }
6215
- /* version: 2.9.0 */
6248
+ /* version: 2.10.0 */
6216
6249
 
6217
6250
  /*
6218
6251
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6229,6 +6262,7 @@
6229
6262
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6230
6263
 
6231
6264
  const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6265
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6232
6266
  const styleElements = create(null);
6233
6267
  const styleSheets = create(null);
6234
6268
  const nodesToStyleSheets = new WeakMap();
@@ -6272,7 +6306,13 @@
6272
6306
  }
6273
6307
 
6274
6308
  if (!target.adoptedStyleSheets.includes(styleSheet)) {
6275
- target.adoptedStyleSheets = [...target.adoptedStyleSheets, styleSheet];
6309
+ if (supportsMutableAdoptedStyleSheets) {
6310
+ // This is only supported in later versions of Chromium:
6311
+ // https://chromestatus.com/feature/5638996492288000
6312
+ target.adoptedStyleSheets.push(styleSheet);
6313
+ } else {
6314
+ target.adoptedStyleSheets = [...target.adoptedStyleSheets, styleSheet];
6315
+ }
6276
6316
  }
6277
6317
  }
6278
6318
 
@@ -6556,6 +6596,152 @@
6556
6596
  setSetText(setText);
6557
6597
  setSsr(ssr);
6558
6598
  setAddEventListener(addEventListener);
6599
+ /*
6600
+ * Copyright (c) 2018, salesforce.com, inc.
6601
+ * All rights reserved.
6602
+ * SPDX-License-Identifier: MIT
6603
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6604
+ */
6605
+
6606
+ function resetShadowRootAndLightDom(element, Ctor) {
6607
+ if (element.shadowRoot) {
6608
+ const shadowRoot = element.shadowRoot;
6609
+
6610
+ while (!isNull(shadowRoot.firstChild)) {
6611
+ shadowRoot.removeChild(shadowRoot.firstChild);
6612
+ }
6613
+ }
6614
+
6615
+ if (Ctor.renderMode === 'light') {
6616
+ while (!isNull(element.firstChild)) {
6617
+ element.removeChild(element.firstChild);
6618
+ }
6619
+ }
6620
+ }
6621
+
6622
+ function createVMWithProps(element, Ctor, props) {
6623
+ createVM(element, Ctor, {
6624
+ mode: 'open',
6625
+ owner: null,
6626
+ tagName: element.tagName.toLowerCase()
6627
+ });
6628
+
6629
+ for (const [key, value] of Object.entries(props)) {
6630
+ element[key] = value;
6631
+ }
6632
+ }
6633
+
6634
+ function hydrateComponent(element, Ctor, props = {}) {
6635
+ if (!(element instanceof Element)) {
6636
+ throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
6637
+ }
6638
+
6639
+ if (!isFunction$1(Ctor)) {
6640
+ throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
6641
+ }
6642
+
6643
+ if (!isObject(props) || isNull(props)) {
6644
+ throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
6645
+ }
6646
+
6647
+ if (getAssociatedVMIfPresent(element)) {
6648
+ /* eslint-disable-next-line no-console */
6649
+ console.warn(`"hydrateComponent" expects an element that is not hydrated.`, element);
6650
+ return;
6651
+ }
6652
+
6653
+ try {
6654
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6655
+ // and uses the same algo to create the stylesheets as in SSR.
6656
+ setIsHydrating(true);
6657
+ createVMWithProps(element, Ctor, props);
6658
+ hydrateRootElement(element); // set it back since now we finished hydration.
6659
+
6660
+ setIsHydrating(false);
6661
+ } catch (e) {
6662
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
6663
+ // with the client generated DOM.
6664
+
6665
+ /* eslint-disable-next-line no-console */
6666
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
6667
+
6668
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
6669
+
6670
+ createVMWithProps(element, Ctor, props);
6671
+ setIsHydrating(false);
6672
+ connectRootElement(element);
6673
+ } finally {
6674
+ // in case there's an error during recovery
6675
+ setIsHydrating(false);
6676
+ }
6677
+ }
6678
+ /*
6679
+ * Copyright (c) 2018, salesforce.com, inc.
6680
+ * All rights reserved.
6681
+ * SPDX-License-Identifier: MIT
6682
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6683
+ */
6684
+
6685
+ /**
6686
+ * This function builds a Web Component class from a LWC constructor so it can be
6687
+ * registered as a new element via customElements.define() at any given time.
6688
+ *
6689
+ * @deprecated since version 1.3.11
6690
+ *
6691
+ * @example
6692
+ * ```
6693
+ * import { buildCustomElementConstructor } from 'lwc';
6694
+ * import Foo from 'ns/foo';
6695
+ * const WC = buildCustomElementConstructor(Foo);
6696
+ * customElements.define('x-foo', WC);
6697
+ * const elm = document.createElement('x-foo');
6698
+ * ```
6699
+ */
6700
+
6701
+
6702
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6703
+
6704
+ return Ctor.CustomElementConstructor;
6705
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
6706
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
6707
+
6708
+
6709
+ const hydratedCustomElements = new WeakSet();
6710
+
6711
+ function buildCustomElementConstructor(Ctor) {
6712
+ const HtmlPrototype = getComponentHtmlPrototype(Ctor);
6713
+ return class extends HtmlPrototype {
6714
+ constructor() {
6715
+ super();
6716
+
6717
+ if (this.isConnected) {
6718
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
6719
+ hydrateComponent(this, Ctor, {});
6720
+ hydratedCustomElements.add(this);
6721
+ } else {
6722
+ createVM(this, Ctor, {
6723
+ mode: 'open',
6724
+ owner: null,
6725
+ tagName: this.tagName
6726
+ });
6727
+ }
6728
+ }
6729
+
6730
+ connectedCallback() {
6731
+ if (hydratedCustomElements.has(this)) {
6732
+ // This is an un-upgraded element that was hydrated in the constructor.
6733
+ hydratedCustomElements.delete(this);
6734
+ } else {
6735
+ connectRootElement(this);
6736
+ }
6737
+ }
6738
+
6739
+ disconnectedCallback() {
6740
+ disconnectRootElement(this);
6741
+ }
6742
+
6743
+ };
6744
+ }
6559
6745
  /*
6560
6746
  * Copyright (c) 2018, salesforce.com, inc.
6561
6747
  * All rights reserved.
@@ -6565,6 +6751,7 @@
6565
6751
  // TODO [#2472]: Remove this workaround when appropriate.
6566
6752
  // eslint-disable-next-line lwc-internal/no-global-node
6567
6753
 
6754
+
6568
6755
  const _Node$1 = Node;
6569
6756
  const ConnectingSlot = new WeakMap();
6570
6757
  const DisconnectingSlot = new WeakMap();
@@ -6670,114 +6857,6 @@
6670
6857
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6671
6858
  */
6672
6859
 
6673
-
6674
- function hydrateComponent(element, Ctor, props = {}) {
6675
- if (!(element instanceof Element)) {
6676
- throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
6677
- }
6678
-
6679
- if (!isFunction$1(Ctor)) {
6680
- throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
6681
- }
6682
-
6683
- if (!isObject(props) || isNull(props)) {
6684
- throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
6685
- }
6686
-
6687
- try {
6688
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6689
- // and uses the same algo to create the stylesheets as in SSR.
6690
- setIsHydrating(true);
6691
- createVM(element, Ctor, {
6692
- mode: 'open',
6693
- owner: null,
6694
- tagName: element.tagName.toLowerCase()
6695
- });
6696
-
6697
- for (const [key, value] of Object.entries(props)) {
6698
- element[key] = value;
6699
- }
6700
-
6701
- hydrateRootElement(element); // set it back since now we finished hydration.
6702
-
6703
- setIsHydrating(false);
6704
- } catch (e) {
6705
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6706
- // the client generated DOM.
6707
-
6708
- /* eslint-disable-next-line no-console */
6709
- console.error('Recovering from error while hydrating: ', e);
6710
- setIsHydrating(false);
6711
- const newElem = createElement(element.tagName, {
6712
- is: Ctor,
6713
- mode: 'open'
6714
- });
6715
-
6716
- for (const [key, value] of Object.entries(props)) {
6717
- newElem[key] = value;
6718
- }
6719
-
6720
- element.parentNode.replaceChild(newElem, element);
6721
- }
6722
- }
6723
- /*
6724
- * Copyright (c) 2018, salesforce.com, inc.
6725
- * All rights reserved.
6726
- * SPDX-License-Identifier: MIT
6727
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6728
- */
6729
-
6730
- /**
6731
- * This function builds a Web Component class from a LWC constructor so it can be
6732
- * registered as a new element via customElements.define() at any given time.
6733
- *
6734
- * @deprecated since version 1.3.11
6735
- *
6736
- * @example
6737
- * ```
6738
- * import { buildCustomElementConstructor } from 'lwc';
6739
- * import Foo from 'ns/foo';
6740
- * const WC = buildCustomElementConstructor(Foo);
6741
- * customElements.define('x-foo', WC);
6742
- * const elm = document.createElement('x-foo');
6743
- * ```
6744
- */
6745
-
6746
-
6747
- function deprecatedBuildCustomElementConstructor(Ctor) {
6748
-
6749
- return Ctor.CustomElementConstructor;
6750
- }
6751
-
6752
- function buildCustomElementConstructor(Ctor) {
6753
- const HtmlPrototype = getComponentHtmlPrototype(Ctor);
6754
- return class extends HtmlPrototype {
6755
- constructor() {
6756
- super();
6757
- createVM(this, Ctor, {
6758
- mode: 'open',
6759
- owner: null,
6760
- tagName: this.tagName
6761
- });
6762
- }
6763
-
6764
- connectedCallback() {
6765
- connectRootElement(this);
6766
- }
6767
-
6768
- disconnectedCallback() {
6769
- disconnectRootElement(this);
6770
- }
6771
-
6772
- };
6773
- }
6774
- /*
6775
- * Copyright (c) 2018, salesforce.com, inc.
6776
- * All rights reserved.
6777
- * SPDX-License-Identifier: MIT
6778
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6779
- */
6780
-
6781
6860
  /**
6782
6861
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6783
6862
  * This API is subject to change or being removed.
@@ -6878,7 +6957,7 @@
6878
6957
  });
6879
6958
  freeze(LightningElement);
6880
6959
  seal(LightningElement.prototype);
6881
- /* version: 2.9.0 */
6960
+ /* version: 2.10.0 */
6882
6961
 
6883
6962
  exports.LightningElement = LightningElement;
6884
6963
  exports.__unstable__ProfilerControl = profilerControl;