lwc 2.7.4 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +663 -470
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +663 -470
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +544 -426
  5. package/dist/engine-dom/iife/es5/engine-dom.js +816 -594
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +624 -497
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +663 -470
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +544 -426
  11. package/dist/engine-dom/umd/es5/engine-dom.js +816 -594
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +624 -497
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +427 -299
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +427 -299
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +8 -8
  36. package/LICENSE +0 -10
@@ -302,7 +302,7 @@ var LWC = (function (exports) {
302
302
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
303
303
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
304
304
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
305
- /** version: 2.7.4 */
305
+ /** version: 2.10.0 */
306
306
 
307
307
  /*
308
308
  * Copyright (c) 2018, salesforce.com, inc.
@@ -369,7 +369,7 @@ var LWC = (function (exports) {
369
369
  };
370
370
  }
371
371
 
372
- function patch(propName) {
372
+ function patch$1(propName) {
373
373
  // Typescript is inferring the wrong function type for this particular
374
374
  // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
375
375
  // @ts-ignore type-mismatch
@@ -391,7 +391,7 @@ var LWC = (function (exports) {
391
391
  const propName = ElementPrototypeAriaPropertyNames[i];
392
392
 
393
393
  if (detect(propName)) {
394
- patch(propName);
394
+ patch$1(propName);
395
395
  }
396
396
  }
397
397
  /**
@@ -407,14 +407,15 @@ var LWC = (function (exports) {
407
407
 
408
408
 
409
409
  const features = {
410
- ENABLE_REACTIVE_SETTER: null,
411
- ENABLE_HMR: null,
412
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
410
+ DISABLE_MIXED_SHADOW_MODE: null,
413
411
  ENABLE_ELEMENT_PATCH: null,
414
412
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
415
- ENABLE_NODE_LIST_PATCH: null,
413
+ ENABLE_HMR: null,
416
414
  ENABLE_HTML_COLLECTIONS_PATCH: null,
415
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
416
+ ENABLE_NODE_LIST_PATCH: null,
417
417
  ENABLE_NODE_PATCH: null,
418
+ ENABLE_REACTIVE_SETTER: null,
418
419
  ENABLE_WIRE_SYNC_EMIT: null
419
420
  };
420
421
 
@@ -471,7 +472,7 @@ var LWC = (function (exports) {
471
472
 
472
473
  function setFeatureFlagForTest(name, value) {
473
474
  }
474
- /** version: 2.7.4 */
475
+ /** version: 2.10.0 */
475
476
 
476
477
  /* proxy-compat-disable */
477
478
 
@@ -514,6 +515,19 @@ var LWC = (function (exports) {
514
515
 
515
516
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
516
517
  } // Borrowed from Vue template compiler.
518
+
519
+
520
+ function cloneAndOmitKey(object, keyToOmit) {
521
+ const result = {};
522
+
523
+ for (const key of Object.keys(object)) {
524
+ if (key !== keyToOmit) {
525
+ result[key] = object[key];
526
+ }
527
+ }
528
+
529
+ return result;
530
+ }
517
531
  // Primitives
518
532
  //
519
533
 
@@ -2534,6 +2548,13 @@ var LWC = (function (exports) {
2534
2548
  const meta = signedDecoratorToMetaMap.get(Ctor);
2535
2549
  return isUndefined$1(meta) ? defaultMeta : meta;
2536
2550
  }
2551
+ /*
2552
+ * Copyright (c) 2018, salesforce.com, inc.
2553
+ * All rights reserved.
2554
+ * SPDX-License-Identifier: MIT
2555
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2556
+ */
2557
+
2537
2558
 
2538
2559
  const signedTemplateSet = new Set();
2539
2560
 
@@ -2553,6 +2574,7 @@ var LWC = (function (exports) {
2553
2574
 
2554
2575
 
2555
2576
  function registerTemplate(tpl) {
2577
+
2556
2578
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
2557
2579
  // assignment of templates easily, without too much transformation
2558
2580
 
@@ -3385,148 +3407,251 @@ var LWC = (function (exports) {
3385
3407
  */
3386
3408
 
3387
3409
 
3388
- const TextHook = {
3389
- create: vnode => {
3390
- const {
3391
- owner
3392
- } = vnode;
3393
- const elm = createText$1(vnode.text);
3394
- linkNodeToShadow(elm, owner);
3395
- vnode.elm = elm;
3396
- },
3397
- update: updateNodeHook,
3398
- insert: insertNode,
3399
- move: insertNode,
3400
- remove: removeNode
3401
- };
3402
- const CommentHook = {
3403
- create: vnode => {
3404
- const {
3405
- owner,
3406
- text
3407
- } = vnode;
3408
- const elm = createComment$1(text);
3409
- linkNodeToShadow(elm, owner);
3410
- vnode.elm = elm;
3411
- },
3412
- update: updateNodeHook,
3413
- insert: insertNode,
3414
- move: insertNode,
3415
- remove: removeNode
3416
- }; // insert is called after update, which is used somewhere else (via a module)
3417
- // to mark the vm as inserted, that means we cannot use update as the main channel
3418
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
3419
- // which breaks some invariants. For that reason, we have the following for any
3420
- // Custom Element that is inserted via a template.
3421
-
3422
- const ElementHook = {
3423
- create: vnode => {
3424
- const {
3425
- sel,
3426
- owner,
3427
- data: {
3428
- svg
3429
- }
3430
- } = vnode;
3431
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3432
- const elm = createElement$2(sel, namespace);
3433
- linkNodeToShadow(elm, owner);
3434
- fallbackElmHook(elm, vnode);
3435
- vnode.elm = elm;
3436
- patchElementPropsAndAttrs$1(null, vnode);
3437
- },
3438
- update: (oldVnode, vnode) => {
3439
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3440
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3441
- },
3442
- insert: (vnode, parentNode, referenceNode) => {
3443
- insertNode(vnode, parentNode, referenceNode);
3444
- createChildrenHook(vnode);
3445
- },
3446
- move: insertNode,
3447
- remove: (vnode, parentNode) => {
3448
- removeNode(vnode, parentNode);
3449
- removeChildren(vnode);
3410
+ function patchChildren(c1, c2, parent) {
3411
+ if (hasDynamicChildren(c2)) {
3412
+ updateDynamicChildren(c1, c2, parent);
3413
+ } else {
3414
+ updateStaticChildren(c1, c2, parent);
3450
3415
  }
3451
- };
3452
- const CustomElementHook = {
3453
- create: vnode => {
3454
- const {
3455
- sel,
3456
- owner
3457
- } = vnode;
3458
- const UpgradableConstructor = getUpgradableConstructor(sel);
3459
- /**
3460
- * Note: if the upgradable constructor does not expect, or throw when we new it
3461
- * with a callback as the first argument, we could implement a more advanced
3462
- * mechanism that only passes that argument if the constructor is known to be
3463
- * an upgradable custom element.
3464
- */
3465
-
3466
- let vm;
3467
- const elm = new UpgradableConstructor(elm => {
3468
- // the custom element from the registry is expecting an upgrade callback
3469
- vm = createViewModelHook(elm, vnode);
3470
- });
3471
- linkNodeToShadow(elm, owner);
3472
- vnode.elm = elm;
3416
+ }
3473
3417
 
3474
- if (vm) {
3475
- allocateChildren(vnode, vm);
3476
- } else if (vnode.ctor !== UpgradableConstructor) {
3477
- throw new TypeError(`Incorrect Component Constructor`);
3478
- }
3418
+ function patch(n1, n2) {
3419
+ if (n1 === n2) {
3420
+ return;
3421
+ }
3479
3422
 
3480
- patchElementPropsAndAttrs$1(null, vnode);
3481
- },
3482
- update: (oldVnode, vnode) => {
3483
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3484
- const vm = getAssociatedVMIfPresent(vnode.elm);
3423
+ switch (n2.type) {
3424
+ case 0
3425
+ /* Text */
3426
+ :
3427
+ patchText(n1, n2);
3428
+ break;
3485
3429
 
3486
- if (vm) {
3487
- // in fallback mode, the allocation will always set children to
3488
- // empty and delegate the real allocation to the slot elements
3489
- allocateChildren(vnode, vm);
3490
- } // in fallback mode, the children will be always empty, so, nothing
3491
- // will happen, but in native, it does allocate the light dom
3430
+ case 1
3431
+ /* Comment */
3432
+ :
3433
+ patchComment(n1, n2);
3434
+ break;
3492
3435
 
3436
+ case 2
3437
+ /* Element */
3438
+ :
3439
+ patchElement(n1, n2);
3440
+ break;
3493
3441
 
3494
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3442
+ case 3
3443
+ /* CustomElement */
3444
+ :
3445
+ patchCustomElement(n1, n2);
3446
+ break;
3447
+ }
3448
+ }
3495
3449
 
3496
- if (vm) {
3497
- // this is important to preserve the top to bottom synchronous rendering phase.
3450
+ function mount(node, parent, anchor) {
3451
+ switch (node.type) {
3452
+ case 0
3453
+ /* Text */
3454
+ :
3455
+ mountText(node, parent, anchor);
3456
+ break;
3498
3457
 
3458
+ case 1
3459
+ /* Comment */
3460
+ :
3461
+ mountComment(node, parent, anchor);
3462
+ break;
3499
3463
 
3500
- rerenderVM(vm);
3501
- }
3502
- },
3503
- insert: (vnode, parentNode, referenceNode) => {
3504
- insertNode(vnode, parentNode, referenceNode);
3505
- const vm = getAssociatedVMIfPresent(vnode.elm);
3464
+ case 2
3465
+ /* Element */
3466
+ :
3467
+ mountElement(node, parent, anchor);
3468
+ break;
3469
+
3470
+ case 3
3471
+ /* CustomElement */
3472
+ :
3473
+ mountCustomElement(node, parent, anchor);
3474
+ break;
3475
+ }
3476
+ }
3506
3477
 
3507
- if (vm) {
3478
+ function patchText(n1, n2) {
3479
+ n2.elm = n1.elm;
3508
3480
 
3509
- runConnectedCallback(vm);
3481
+ if (n2.text !== n1.text) {
3482
+ updateTextContent(n2);
3483
+ }
3484
+ }
3485
+
3486
+ function mountText(node, parent, anchor) {
3487
+ const {
3488
+ owner
3489
+ } = node;
3490
+ const textNode = node.elm = createText$1(node.text);
3491
+ linkNodeToShadow(textNode, owner);
3492
+ insertNode(textNode, parent, anchor);
3493
+ }
3494
+
3495
+ function patchComment(n1, n2) {
3496
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3497
+ // it is the case today.
3498
+
3499
+ if (n2.text !== n1.text) {
3500
+ updateTextContent(n2);
3501
+ }
3502
+ }
3503
+
3504
+ function mountComment(node, parent, anchor) {
3505
+ const {
3506
+ owner
3507
+ } = node;
3508
+ const commentNode = node.elm = createComment$1(node.text);
3509
+ linkNodeToShadow(commentNode, owner);
3510
+ insertNode(commentNode, parent, anchor);
3511
+ }
3512
+
3513
+ function mountElement(vnode, parent, anchor) {
3514
+ const {
3515
+ sel,
3516
+ owner,
3517
+ data: {
3518
+ svg
3510
3519
  }
3520
+ } = vnode;
3521
+ const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3522
+ const elm = createElement$2(sel, namespace);
3523
+ linkNodeToShadow(elm, owner);
3524
+ fallbackElmHook(elm, vnode);
3525
+ vnode.elm = elm;
3526
+ patchElementPropsAndAttrs$1(null, vnode);
3527
+ insertNode(elm, parent, anchor);
3528
+ mountVNodes(vnode.children, elm, null);
3529
+ }
3530
+
3531
+ function patchElement(n1, n2) {
3532
+ const elm = n2.elm = n1.elm;
3533
+ patchElementPropsAndAttrs$1(n1, n2);
3534
+ patchChildren(n1.children, n2.children, elm);
3535
+ }
3536
+
3537
+ function mountCustomElement(vnode, parent, anchor) {
3538
+ const {
3539
+ sel,
3540
+ owner
3541
+ } = vnode;
3542
+ const UpgradableConstructor = getUpgradableConstructor(sel);
3543
+ /**
3544
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3545
+ * with a callback as the first argument, we could implement a more advanced
3546
+ * mechanism that only passes that argument if the constructor is known to be
3547
+ * an upgradable custom element.
3548
+ */
3549
+
3550
+ let vm;
3551
+ const elm = new UpgradableConstructor(elm => {
3552
+ // the custom element from the registry is expecting an upgrade callback
3553
+ vm = createViewModelHook(elm, vnode);
3554
+ });
3555
+ linkNodeToShadow(elm, owner);
3556
+ vnode.elm = elm;
3557
+ vnode.vm = vm;
3558
+
3559
+ if (vm) {
3560
+ allocateChildren(vnode, vm);
3561
+ } else if (vnode.ctor !== UpgradableConstructor) {
3562
+ throw new TypeError(`Incorrect Component Constructor`);
3563
+ }
3564
+
3565
+ patchElementPropsAndAttrs$1(null, vnode);
3566
+ insertNode(elm, parent, anchor);
3567
+
3568
+ if (vm) {
3569
+
3570
+ runConnectedCallback(vm);
3571
+ }
3572
+
3573
+ mountVNodes(vnode.children, elm, null);
3574
+
3575
+ if (vm) {
3576
+ appendVM(vm);
3577
+ }
3578
+ }
3579
+
3580
+ function patchCustomElement(n1, n2) {
3581
+ const elm = n2.elm = n1.elm;
3582
+ const vm = n2.vm = n1.vm;
3583
+ patchElementPropsAndAttrs$1(n1, n2);
3584
+
3585
+ if (!isUndefined$1(vm)) {
3586
+ // in fallback mode, the allocation will always set children to
3587
+ // empty and delegate the real allocation to the slot elements
3588
+ allocateChildren(n2, vm);
3589
+ } // in fallback mode, the children will be always empty, so, nothing
3590
+ // will happen, but in native, it does allocate the light dom
3591
+
3592
+
3593
+ patchChildren(n1.children, n2.children, elm);
3594
+
3595
+ if (!isUndefined$1(vm)) {
3596
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3597
+ // this is important to preserve the top to bottom synchronous rendering phase.
3598
+ rerenderVM(vm);
3599
+ }
3600
+ }
3511
3601
 
3512
- createChildrenHook(vnode);
3602
+ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
3603
+ for (; start < end; ++start) {
3604
+ const vnode = vnodes[start];
3513
3605
 
3514
- if (vm) {
3515
- appendVM(vm);
3606
+ if (isVNode(vnode)) {
3607
+ mount(vnode, parent, anchor);
3516
3608
  }
3517
- },
3518
- move: insertNode,
3519
- remove: (vnode, parentNode) => {
3520
- removeNode(vnode, parentNode);
3521
- const vm = getAssociatedVMIfPresent(vnode.elm);
3522
-
3523
- if (vm) {
3524
- // for custom elements we don't have to go recursively because the removeVM routine
3525
- // will take care of disconnecting any child VM attached to its shadow as well.
3526
- removeVM(vm);
3609
+ }
3610
+ }
3611
+
3612
+ function unmount(vnode, parent, doRemove = false) {
3613
+ const {
3614
+ type,
3615
+ elm
3616
+ } = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3617
+ // subtree root, is the only element worth unmounting from the subtree.
3618
+
3619
+ if (doRemove) {
3620
+ removeNode(elm, parent);
3621
+ }
3622
+
3623
+ switch (type) {
3624
+ case 2
3625
+ /* Element */
3626
+ :
3627
+ unmountVNodes(vnode.children, elm);
3628
+ break;
3629
+
3630
+ case 3
3631
+ /* CustomElement */
3632
+ :
3633
+ {
3634
+ const {
3635
+ vm
3636
+ } = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
3637
+ // children.
3638
+
3639
+ if (!isUndefined$1(vm)) {
3640
+ removeVM(vm);
3641
+ }
3642
+ }
3643
+ }
3644
+ }
3645
+
3646
+ function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
3647
+ for (; start < end; ++start) {
3648
+ const ch = vnodes[start];
3649
+
3650
+ if (isVNode(ch)) {
3651
+ unmount(ch, parent, doRemove);
3527
3652
  }
3528
3653
  }
3529
- };
3654
+ }
3530
3655
 
3531
3656
  function isVNode(vnode) {
3532
3657
  return vnode != null;
@@ -3571,26 +3696,23 @@ var LWC = (function (exports) {
3571
3696
  }
3572
3697
  }
3573
3698
 
3574
- function updateNodeHook(oldVnode, vnode) {
3699
+ function updateTextContent(vnode) {
3575
3700
  const {
3576
3701
  elm,
3577
3702
  text
3578
3703
  } = vnode;
3579
3704
 
3580
- if (oldVnode.text !== text) {
3581
-
3582
- setText$1(elm, text);
3583
- }
3705
+ setText$1(elm, text);
3584
3706
  }
3585
3707
 
3586
- function insertNode(vnode, parentNode, referenceNode) {
3708
+ function insertNode(node, parent, anchor) {
3587
3709
 
3588
- insert$1(vnode.elm, parentNode, referenceNode);
3710
+ insert$1(node, parent, anchor);
3589
3711
  }
3590
3712
 
3591
- function removeNode(vnode, parentNode) {
3713
+ function removeNode(node, parent) {
3592
3714
 
3593
- remove$1(vnode.elm, parentNode);
3715
+ remove$1(node, parent);
3594
3716
  }
3595
3717
 
3596
3718
  function patchElementPropsAndAttrs$1(oldVnode, vnode) {
@@ -3631,19 +3753,13 @@ var LWC = (function (exports) {
3631
3753
  ) {
3632
3754
  // this element will now accept any manual content inserted into it
3633
3755
  observeElementChildNodes(elm);
3634
- } // when running in synthetic shadow mode, we need to set the shadowToken value
3635
- // into each element from the template, so they can be styled accordingly.
3636
-
3637
-
3638
- setElementShadowToken(elm, stylesheetToken);
3639
- }
3640
- }
3756
+ }
3641
3757
 
3642
- function patchChildren(parent, oldCh, newCh) {
3643
- if (hasDynamicChildren(newCh)) {
3644
- updateDynamicChildren(parent, oldCh, newCh);
3645
- } else {
3646
- updateStaticChildren(parent, oldCh, newCh);
3758
+ if (!isUndefined$1(stylesheetToken)) {
3759
+ // when running in synthetic shadow mode, we need to set the shadowToken value
3760
+ // into each element from the template, so they can be styled accordingly.
3761
+ setElementShadowToken(elm, stylesheetToken);
3762
+ }
3647
3763
  }
3648
3764
  }
3649
3765
 
@@ -3704,7 +3820,9 @@ var LWC = (function (exports) {
3704
3820
  } = owner.context; // when running in synthetic shadow mode, we need to set the shadowToken value
3705
3821
  // into each element from the template, so they can be styled accordingly.
3706
3822
 
3707
- setElementShadowToken(elm, stylesheetToken);
3823
+ if (!isUndefined$1(stylesheetToken)) {
3824
+ setElementShadowToken(elm, stylesheetToken);
3825
+ }
3708
3826
  }
3709
3827
 
3710
3828
  vm = createVM(elm, ctor, {
@@ -3716,40 +3834,6 @@ var LWC = (function (exports) {
3716
3834
  return vm;
3717
3835
  }
3718
3836
 
3719
- function createChildrenHook(vnode) {
3720
- const {
3721
- elm,
3722
- children
3723
- } = vnode;
3724
-
3725
- for (let j = 0; j < children.length; ++j) {
3726
- const ch = children[j];
3727
-
3728
- if (ch != null) {
3729
- ch.hook.create(ch);
3730
- ch.hook.insert(ch, elm, null);
3731
- }
3732
- }
3733
- }
3734
-
3735
- function removeChildren(vnode) {
3736
- // this method only needs to search on child vnodes from template
3737
- // to trigger the remove hook just in case some of those children
3738
- // are custom elements.
3739
- const {
3740
- children,
3741
- elm
3742
- } = vnode;
3743
-
3744
- for (let j = 0, len = children.length; j < len; ++j) {
3745
- const ch = children[j];
3746
-
3747
- if (!isNull(ch)) {
3748
- ch.hook.remove(ch, elm);
3749
- }
3750
- }
3751
- }
3752
-
3753
3837
  function allocateInSlot(vm, children) {
3754
3838
  var _a;
3755
3839
 
@@ -3846,28 +3930,7 @@ var LWC = (function (exports) {
3846
3930
  return map;
3847
3931
  }
3848
3932
 
3849
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
3850
- for (; startIdx <= endIdx; ++startIdx) {
3851
- const ch = vnodes[startIdx];
3852
-
3853
- if (isVNode(ch)) {
3854
- ch.hook.create(ch);
3855
- ch.hook.insert(ch, parentElm, before);
3856
- }
3857
- }
3858
- }
3859
-
3860
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
3861
- for (; startIdx <= endIdx; ++startIdx) {
3862
- const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
3863
-
3864
- if (isVNode(ch)) {
3865
- ch.hook.remove(ch, parentElm);
3866
- }
3867
- }
3868
- }
3869
-
3870
- function updateDynamicChildren(parentElm, oldCh, newCh) {
3933
+ function updateDynamicChildren(oldCh, newCh, parent) {
3871
3934
  let oldStartIdx = 0;
3872
3935
  let newStartIdx = 0;
3873
3936
  let oldEndIdx = oldCh.length - 1;
@@ -3881,6 +3944,7 @@ var LWC = (function (exports) {
3881
3944
  let idxInOld;
3882
3945
  let elmToMove;
3883
3946
  let before;
3947
+ let clonedOldCh = false;
3884
3948
 
3885
3949
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3886
3950
  if (!isVNode(oldStartVnode)) {
@@ -3892,23 +3956,23 @@ var LWC = (function (exports) {
3892
3956
  } else if (!isVNode(newEndVnode)) {
3893
3957
  newEndVnode = newCh[--newEndIdx];
3894
3958
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
3895
- patchVnode(oldStartVnode, newStartVnode);
3959
+ patch(oldStartVnode, newStartVnode);
3896
3960
  oldStartVnode = oldCh[++oldStartIdx];
3897
3961
  newStartVnode = newCh[++newStartIdx];
3898
3962
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
3899
- patchVnode(oldEndVnode, newEndVnode);
3963
+ patch(oldEndVnode, newEndVnode);
3900
3964
  oldEndVnode = oldCh[--oldEndIdx];
3901
3965
  newEndVnode = newCh[--newEndIdx];
3902
3966
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
3903
3967
  // Vnode moved right
3904
- patchVnode(oldStartVnode, newEndVnode);
3905
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
3968
+ patch(oldStartVnode, newEndVnode);
3969
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
3906
3970
  oldStartVnode = oldCh[++oldStartIdx];
3907
3971
  newEndVnode = newCh[--newEndIdx];
3908
3972
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
3909
3973
  // Vnode moved left
3910
- patchVnode(oldEndVnode, newStartVnode);
3911
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
3974
+ patch(oldEndVnode, newStartVnode);
3975
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
3912
3976
  oldEndVnode = oldCh[--oldEndIdx];
3913
3977
  newStartVnode = newCh[++newStartIdx];
3914
3978
  } else {
@@ -3920,8 +3984,7 @@ var LWC = (function (exports) {
3920
3984
 
3921
3985
  if (isUndefined$1(idxInOld)) {
3922
3986
  // New element
3923
- newStartVnode.hook.create(newStartVnode);
3924
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3987
+ mount(newStartVnode, parent, oldStartVnode.elm);
3925
3988
  newStartVnode = newCh[++newStartIdx];
3926
3989
  } else {
3927
3990
  elmToMove = oldCh[idxInOld];
@@ -3929,12 +3992,22 @@ var LWC = (function (exports) {
3929
3992
  if (isVNode(elmToMove)) {
3930
3993
  if (elmToMove.sel !== newStartVnode.sel) {
3931
3994
  // New element
3932
- newStartVnode.hook.create(newStartVnode);
3933
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3995
+ mount(newStartVnode, parent, oldStartVnode.elm);
3934
3996
  } else {
3935
- patchVnode(elmToMove, newStartVnode);
3997
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
3998
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3999
+ // so we only care about the `oldCh` object inside this function.
4000
+ // To avoid cloning over and over again, we check `clonedOldCh`
4001
+ // and only clone once.
4002
+
4003
+ if (!clonedOldCh) {
4004
+ clonedOldCh = true;
4005
+ oldCh = [...oldCh];
4006
+ } // We've already cloned at least once, so it's no longer read-only
4007
+
4008
+
3936
4009
  oldCh[idxInOld] = undefined;
3937
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
4010
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
3938
4011
  }
3939
4012
  }
3940
4013
 
@@ -3955,65 +4028,55 @@ var LWC = (function (exports) {
3955
4028
  } while (!isVNode(n) && i < newChEnd);
3956
4029
 
3957
4030
  before = isVNode(n) ? n.elm : null;
3958
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
4031
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
3959
4032
  } else {
3960
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
4033
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
3961
4034
  }
3962
4035
  }
3963
4036
  }
3964
4037
 
3965
- function updateStaticChildren(parentElm, oldCh, newCh) {
3966
- const oldChLength = oldCh.length;
3967
- const newChLength = newCh.length;
4038
+ function updateStaticChildren(c1, c2, parent) {
4039
+ const c1Length = c1.length;
4040
+ const c2Length = c2.length;
3968
4041
 
3969
- if (oldChLength === 0) {
4042
+ if (c1Length === 0) {
3970
4043
  // the old list is empty, we can directly insert anything new
3971
- addVnodes(parentElm, null, newCh, 0, newChLength);
4044
+ mountVNodes(c2, parent, null);
3972
4045
  return;
3973
4046
  }
3974
4047
 
3975
- if (newChLength === 0) {
4048
+ if (c2Length === 0) {
3976
4049
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3977
4050
  // this is the case in which the dynamic children of an if-directive should be removed
3978
- removeVnodes(parentElm, oldCh, 0, oldChLength);
4051
+ unmountVNodes(c1, parent, true);
3979
4052
  return;
3980
4053
  } // if the old list is not empty, the new list MUST have the same
3981
4054
  // amount of nodes, that's why we call this static children
3982
4055
 
3983
4056
 
3984
- let referenceElm = null;
4057
+ let anchor = null;
3985
4058
 
3986
- for (let i = newChLength - 1; i >= 0; i -= 1) {
3987
- const vnode = newCh[i];
3988
- const oldVNode = oldCh[i];
4059
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
4060
+ const n1 = c1[i];
4061
+ const n2 = c2[i];
3989
4062
 
3990
- if (vnode !== oldVNode) {
3991
- if (isVNode(oldVNode)) {
3992
- if (isVNode(vnode)) {
3993
- // both vnodes must be equivalent, and se just need to patch them
3994
- patchVnode(oldVNode, vnode);
3995
- referenceElm = vnode.elm;
4063
+ if (n2 !== n1) {
4064
+ if (isVNode(n1)) {
4065
+ if (isVNode(n2)) {
4066
+ // both vnodes are equivalent, and we just need to patch them
4067
+ patch(n1, n2);
4068
+ anchor = n2.elm;
3996
4069
  } else {
3997
4070
  // removing the old vnode since the new one is null
3998
- oldVNode.hook.remove(oldVNode, parentElm);
4071
+ unmount(n1, parent, true);
3999
4072
  }
4000
- } else if (isVNode(vnode)) {
4001
- // this condition is unnecessary
4002
- vnode.hook.create(vnode); // insert the new node one since the old one is null
4003
-
4004
- vnode.hook.insert(vnode, parentElm, referenceElm);
4005
- referenceElm = vnode.elm;
4073
+ } else if (isVNode(n2)) {
4074
+ mount(n2, parent, anchor);
4075
+ anchor = n2.elm;
4006
4076
  }
4007
4077
  }
4008
4078
  }
4009
4079
  }
4010
-
4011
- function patchVnode(oldVnode, vnode) {
4012
- if (oldVnode !== vnode) {
4013
- vnode.elm = oldVnode.elm;
4014
- vnode.hook.update(oldVnode, vnode);
4015
- }
4016
- }
4017
4080
  /*
4018
4081
  * Copyright (c) 2018, salesforce.com, inc.
4019
4082
  * All rights reserved.
@@ -4029,7 +4092,7 @@ var LWC = (function (exports) {
4029
4092
  } // [h]tml node
4030
4093
 
4031
4094
 
4032
- function h(sel, data, children) {
4095
+ function h(sel, data, children = EmptyArray) {
4033
4096
  const vmBeingRendered = getVMBeingRendered();
4034
4097
 
4035
4098
  let elm;
@@ -4045,7 +4108,6 @@ var LWC = (function (exports) {
4045
4108
  children,
4046
4109
  elm,
4047
4110
  key,
4048
- hook: ElementHook,
4049
4111
  owner: vmBeingRendered
4050
4112
  };
4051
4113
  } // [t]ab[i]ndex function
@@ -4097,7 +4159,7 @@ var LWC = (function (exports) {
4097
4159
  const {
4098
4160
  key
4099
4161
  } = data;
4100
- let elm;
4162
+ let elm, aChildren, vm;
4101
4163
  const vnode = {
4102
4164
  type: 3
4103
4165
  /* CustomElement */
@@ -4107,11 +4169,11 @@ var LWC = (function (exports) {
4107
4169
  children,
4108
4170
  elm,
4109
4171
  key,
4110
- hook: CustomElementHook,
4111
4172
  ctor: Ctor,
4112
4173
  owner: vmBeingRendered,
4113
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
4114
-
4174
+ mode: 'open',
4175
+ aChildren,
4176
+ vm
4115
4177
  };
4116
4178
  addVNodeToChildLWC(vnode);
4117
4179
  return vnode;
@@ -4193,7 +4255,6 @@ var LWC = (function (exports) {
4193
4255
  text,
4194
4256
  elm,
4195
4257
  key,
4196
- hook: TextHook,
4197
4258
  owner: getVMBeingRendered()
4198
4259
  };
4199
4260
  } // [co]mment node
@@ -4209,7 +4270,6 @@ var LWC = (function (exports) {
4209
4270
  text,
4210
4271
  elm,
4211
4272
  key,
4212
- hook: CommentHook,
4213
4273
  owner: getVMBeingRendered()
4214
4274
  };
4215
4275
  } // [d]ynamic text
@@ -4311,7 +4371,7 @@ var LWC = (function (exports) {
4311
4371
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4312
4372
  */
4313
4373
 
4314
- function dc(sel, Ctor, data, children) {
4374
+ function dc(sel, Ctor, data, children = EmptyArray) {
4315
4375
 
4316
4376
 
4317
4377
  if (Ctor == null) {
@@ -4330,10 +4390,14 @@ var LWC = (function (exports) {
4330
4390
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4331
4391
  // to identify different constructors as vnodes with different keys to avoid reusing the
4332
4392
  // element used for previous constructors.
4393
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4394
+ // hoisting optimization.
4333
4395
 
4334
4396
 
4335
- data.key = `dc:${idx}:${data.key}`;
4336
- return c(sel, Ctor, data, children);
4397
+ const newData = Object.assign(Object.assign({}, data), {
4398
+ key: `dc:${idx}:${data.key}`
4399
+ });
4400
+ return c(sel, Ctor, newData, children);
4337
4401
  }
4338
4402
  /**
4339
4403
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -4450,12 +4514,14 @@ var LWC = (function (exports) {
4450
4514
  hasTokenInAttribute: oldHasTokenInAttribute
4451
4515
  } = context;
4452
4516
 
4453
- if (oldHasTokenInClass) {
4454
- getClassList$1(elm).remove(makeHostToken(oldToken));
4455
- }
4517
+ if (!isUndefined$1(oldToken)) {
4518
+ if (oldHasTokenInClass) {
4519
+ getClassList$1(elm).remove(makeHostToken(oldToken));
4520
+ }
4456
4521
 
4457
- if (oldHasTokenInAttribute) {
4458
- removeAttribute$1(elm, makeHostToken(oldToken));
4522
+ if (oldHasTokenInAttribute) {
4523
+ removeAttribute$1(elm, makeHostToken(oldToken));
4524
+ }
4459
4525
  } // Apply the new template styling token to the host element, if the new template has any
4460
4526
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
4461
4527
 
@@ -4932,6 +4998,7 @@ var LWC = (function (exports) {
4932
4998
  function registerComponent(Ctor, {
4933
4999
  tmpl
4934
5000
  }) {
5001
+
4935
5002
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
4936
5003
  // without too much transformation
4937
5004
 
@@ -5041,7 +5108,7 @@ var LWC = (function (exports) {
5041
5108
  */
5042
5109
 
5043
5110
 
5044
- function hydrate$1(vnode, node) {
5111
+ function hydrate(vnode, node) {
5045
5112
  switch (vnode.type) {
5046
5113
  case 0
5047
5114
  /* Text */
@@ -5073,7 +5140,7 @@ var LWC = (function (exports) {
5073
5140
  var _a;
5074
5141
 
5075
5142
 
5076
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5143
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5077
5144
  vnode.elm = node;
5078
5145
  }
5079
5146
 
@@ -5081,7 +5148,7 @@ var LWC = (function (exports) {
5081
5148
  var _a;
5082
5149
 
5083
5150
 
5084
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5151
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5085
5152
  vnode.elm = node;
5086
5153
  }
5087
5154
 
@@ -5104,10 +5171,13 @@ var LWC = (function (exports) {
5104
5171
  } = vnode.data;
5105
5172
 
5106
5173
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5107
- if (elm.innerHTML === props.innerHTML) {
5108
- delete props.innerHTML;
5174
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
5175
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5176
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
5177
+ props: cloneAndOmitKey(props, 'innerHTML')
5178
+ });
5109
5179
  } else {
5110
- logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5180
+ logWarn(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5111
5181
  }
5112
5182
  }
5113
5183
  }
@@ -5115,14 +5185,13 @@ var LWC = (function (exports) {
5115
5185
  patchElementPropsAndAttrs(vnode);
5116
5186
 
5117
5187
  if (!isDomManual) {
5118
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
5188
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
5119
5189
  }
5120
5190
  }
5121
5191
 
5122
5192
  function hydrateCustomElement(vnode, node) {
5123
5193
 
5124
5194
  const elm = node;
5125
- vnode.elm = elm;
5126
5195
  const {
5127
5196
  sel,
5128
5197
  mode,
@@ -5134,6 +5203,8 @@ var LWC = (function (exports) {
5134
5203
  owner,
5135
5204
  tagName: sel
5136
5205
  });
5206
+ vnode.elm = elm;
5207
+ vnode.vm = vm;
5137
5208
  allocateChildren(vnode, vm);
5138
5209
  patchElementPropsAndAttrs(vnode); // Insert hook section:
5139
5210
 
@@ -5144,7 +5215,7 @@ var LWC = (function (exports) {
5144
5215
  ) {
5145
5216
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5146
5217
  // Note: for Light DOM, this is handled while hydrating the VM
5147
- hydrateChildren(vnode.elm.childNodes, vnode.children);
5218
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children);
5148
5219
  }
5149
5220
 
5150
5221
  hydrateVM(vm);
@@ -5159,7 +5230,7 @@ var LWC = (function (exports) {
5159
5230
 
5160
5231
  if (!isNull(childVnode)) {
5161
5232
  const childNode = elmChildren[childNodeIndex];
5162
- hydrate$1(childVnode, childNode);
5233
+ hydrate(childVnode, childNode);
5163
5234
  childNodeIndex++;
5164
5235
  }
5165
5236
  }
@@ -5234,7 +5305,19 @@ var LWC = (function (exports) {
5234
5305
  }
5235
5306
 
5236
5307
  function hydrateVM(vm) {
5237
- hydrate(vm);
5308
+ if (isTrue(vm.isDirty)) {
5309
+ // manually diffing/patching here.
5310
+ // This routine is:
5311
+ // patchShadowRoot(vm, children);
5312
+ // -> addVnodes.
5313
+ const children = renderComponent(vm);
5314
+ vm.children = children;
5315
+ const vmChildren = vm.renderMode === 0
5316
+ /* Light */
5317
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
5318
+ hydrateChildren(vmChildren, children);
5319
+ runRenderedCallback(vm);
5320
+ }
5238
5321
  } // just in case the component comes back, with this we guarantee re-rendering it
5239
5322
  // while preventing any attempt to rehydration until after reinsertion.
5240
5323
 
@@ -5362,7 +5445,11 @@ var LWC = (function (exports) {
5362
5445
  /* Native */
5363
5446
  ;
5364
5447
  } else if (isNativeShadowDefined$1) {
5365
- if (def.shadowSupportMode === "any"
5448
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
5449
+ shadowMode = 1
5450
+ /* Synthetic */
5451
+ ;
5452
+ } else if (def.shadowSupportMode === "any"
5366
5453
  /* Any */
5367
5454
  ) {
5368
5455
  shadowMode = 0
@@ -5426,22 +5513,6 @@ var LWC = (function (exports) {
5426
5513
  }
5427
5514
  }
5428
5515
 
5429
- function hydrate(vm) {
5430
- if (isTrue(vm.isDirty)) {
5431
- // manually diffing/patching here.
5432
- // This routine is:
5433
- // patchShadowRoot(vm, children);
5434
- // -> addVnodes.
5435
- const children = renderComponent(vm);
5436
- vm.children = children;
5437
- const vmChildren = vm.renderMode === 0
5438
- /* Light */
5439
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5440
- hydrateChildren(vmChildren, children);
5441
- runRenderedCallback(vm);
5442
- }
5443
- }
5444
-
5445
5516
  function patchShadowRoot(vm, newCh) {
5446
5517
  const {
5447
5518
  renderRoot,
@@ -5461,7 +5532,7 @@ var LWC = (function (exports) {
5461
5532
  , vm);
5462
5533
  }, () => {
5463
5534
  // job
5464
- patchChildren(renderRoot, oldCh, newCh);
5535
+ patchChildren(oldCh, newCh, renderRoot);
5465
5536
  }, () => {
5466
5537
  // post
5467
5538
  logOperationEnd(2
@@ -6171,7 +6242,7 @@ var LWC = (function (exports) {
6171
6242
  hooksAreSet = true;
6172
6243
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6173
6244
  }
6174
- /* version: 2.7.4 */
6245
+ /* version: 2.10.0 */
6175
6246
 
6176
6247
  /*
6177
6248
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6188,6 +6259,7 @@ var LWC = (function (exports) {
6188
6259
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6189
6260
 
6190
6261
  const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6262
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6191
6263
  const styleElements = create(null);
6192
6264
  const styleSheets = create(null);
6193
6265
  const nodesToStyleSheets = new WeakMap();
@@ -6231,7 +6303,13 @@ var LWC = (function (exports) {
6231
6303
  }
6232
6304
 
6233
6305
  if (!target.adoptedStyleSheets.includes(styleSheet)) {
6234
- target.adoptedStyleSheets = [...target.adoptedStyleSheets, styleSheet];
6306
+ if (supportsMutableAdoptedStyleSheets) {
6307
+ // This is only supported in later versions of Chromium:
6308
+ // https://chromestatus.com/feature/5638996492288000
6309
+ target.adoptedStyleSheets.push(styleSheet);
6310
+ } else {
6311
+ target.adoptedStyleSheets = [...target.adoptedStyleSheets, styleSheet];
6312
+ }
6235
6313
  }
6236
6314
  }
6237
6315
 
@@ -6515,6 +6593,152 @@ var LWC = (function (exports) {
6515
6593
  setSetText(setText);
6516
6594
  setSsr(ssr);
6517
6595
  setAddEventListener(addEventListener);
6596
+ /*
6597
+ * Copyright (c) 2018, salesforce.com, inc.
6598
+ * All rights reserved.
6599
+ * SPDX-License-Identifier: MIT
6600
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6601
+ */
6602
+
6603
+ function resetShadowRootAndLightDom(element, Ctor) {
6604
+ if (element.shadowRoot) {
6605
+ const shadowRoot = element.shadowRoot;
6606
+
6607
+ while (!isNull(shadowRoot.firstChild)) {
6608
+ shadowRoot.removeChild(shadowRoot.firstChild);
6609
+ }
6610
+ }
6611
+
6612
+ if (Ctor.renderMode === 'light') {
6613
+ while (!isNull(element.firstChild)) {
6614
+ element.removeChild(element.firstChild);
6615
+ }
6616
+ }
6617
+ }
6618
+
6619
+ function createVMWithProps(element, Ctor, props) {
6620
+ createVM(element, Ctor, {
6621
+ mode: 'open',
6622
+ owner: null,
6623
+ tagName: element.tagName.toLowerCase()
6624
+ });
6625
+
6626
+ for (const [key, value] of Object.entries(props)) {
6627
+ element[key] = value;
6628
+ }
6629
+ }
6630
+
6631
+ function hydrateComponent(element, Ctor, props = {}) {
6632
+ if (!(element instanceof Element)) {
6633
+ throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
6634
+ }
6635
+
6636
+ if (!isFunction$1(Ctor)) {
6637
+ throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
6638
+ }
6639
+
6640
+ if (!isObject(props) || isNull(props)) {
6641
+ throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
6642
+ }
6643
+
6644
+ if (getAssociatedVMIfPresent(element)) {
6645
+ /* eslint-disable-next-line no-console */
6646
+ console.warn(`"hydrateComponent" expects an element that is not hydrated.`, element);
6647
+ return;
6648
+ }
6649
+
6650
+ try {
6651
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6652
+ // and uses the same algo to create the stylesheets as in SSR.
6653
+ setIsHydrating(true);
6654
+ createVMWithProps(element, Ctor, props);
6655
+ hydrateRootElement(element); // set it back since now we finished hydration.
6656
+
6657
+ setIsHydrating(false);
6658
+ } catch (e) {
6659
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
6660
+ // with the client generated DOM.
6661
+
6662
+ /* eslint-disable-next-line no-console */
6663
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
6664
+
6665
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
6666
+
6667
+ createVMWithProps(element, Ctor, props);
6668
+ setIsHydrating(false);
6669
+ connectRootElement(element);
6670
+ } finally {
6671
+ // in case there's an error during recovery
6672
+ setIsHydrating(false);
6673
+ }
6674
+ }
6675
+ /*
6676
+ * Copyright (c) 2018, salesforce.com, inc.
6677
+ * All rights reserved.
6678
+ * SPDX-License-Identifier: MIT
6679
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6680
+ */
6681
+
6682
+ /**
6683
+ * This function builds a Web Component class from a LWC constructor so it can be
6684
+ * registered as a new element via customElements.define() at any given time.
6685
+ *
6686
+ * @deprecated since version 1.3.11
6687
+ *
6688
+ * @example
6689
+ * ```
6690
+ * import { buildCustomElementConstructor } from 'lwc';
6691
+ * import Foo from 'ns/foo';
6692
+ * const WC = buildCustomElementConstructor(Foo);
6693
+ * customElements.define('x-foo', WC);
6694
+ * const elm = document.createElement('x-foo');
6695
+ * ```
6696
+ */
6697
+
6698
+
6699
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6700
+
6701
+ return Ctor.CustomElementConstructor;
6702
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
6703
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
6704
+
6705
+
6706
+ const hydratedCustomElements = new WeakSet();
6707
+
6708
+ function buildCustomElementConstructor(Ctor) {
6709
+ const HtmlPrototype = getComponentHtmlPrototype(Ctor);
6710
+ return class extends HtmlPrototype {
6711
+ constructor() {
6712
+ super();
6713
+
6714
+ if (this.isConnected) {
6715
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
6716
+ hydrateComponent(this, Ctor, {});
6717
+ hydratedCustomElements.add(this);
6718
+ } else {
6719
+ createVM(this, Ctor, {
6720
+ mode: 'open',
6721
+ owner: null,
6722
+ tagName: this.tagName
6723
+ });
6724
+ }
6725
+ }
6726
+
6727
+ connectedCallback() {
6728
+ if (hydratedCustomElements.has(this)) {
6729
+ // This is an un-upgraded element that was hydrated in the constructor.
6730
+ hydratedCustomElements.delete(this);
6731
+ } else {
6732
+ connectRootElement(this);
6733
+ }
6734
+ }
6735
+
6736
+ disconnectedCallback() {
6737
+ disconnectRootElement(this);
6738
+ }
6739
+
6740
+ };
6741
+ }
6518
6742
  /*
6519
6743
  * Copyright (c) 2018, salesforce.com, inc.
6520
6744
  * All rights reserved.
@@ -6524,6 +6748,7 @@ var LWC = (function (exports) {
6524
6748
  // TODO [#2472]: Remove this workaround when appropriate.
6525
6749
  // eslint-disable-next-line lwc-internal/no-global-node
6526
6750
 
6751
+
6527
6752
  const _Node$1 = Node;
6528
6753
  const ConnectingSlot = new WeakMap();
6529
6754
  const DisconnectingSlot = new WeakMap();
@@ -6629,114 +6854,6 @@ var LWC = (function (exports) {
6629
6854
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6630
6855
  */
6631
6856
 
6632
-
6633
- function hydrateComponent(element, Ctor, props = {}) {
6634
- if (!(element instanceof Element)) {
6635
- throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
6636
- }
6637
-
6638
- if (!isFunction$1(Ctor)) {
6639
- throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
6640
- }
6641
-
6642
- if (!isObject(props) || isNull(props)) {
6643
- throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
6644
- }
6645
-
6646
- try {
6647
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6648
- // and uses the same algo to create the stylesheets as in SSR.
6649
- setIsHydrating(true);
6650
- createVM(element, Ctor, {
6651
- mode: 'open',
6652
- owner: null,
6653
- tagName: element.tagName.toLowerCase()
6654
- });
6655
-
6656
- for (const [key, value] of Object.entries(props)) {
6657
- element[key] = value;
6658
- }
6659
-
6660
- hydrateRootElement(element); // set it back since now we finished hydration.
6661
-
6662
- setIsHydrating(false);
6663
- } catch (e) {
6664
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6665
- // the client generated DOM.
6666
-
6667
- /* eslint-disable-next-line no-console */
6668
- console.error('Recovering from error while hydrating: ', e);
6669
- setIsHydrating(false);
6670
- const newElem = createElement(element.tagName, {
6671
- is: Ctor,
6672
- mode: 'open'
6673
- });
6674
-
6675
- for (const [key, value] of Object.entries(props)) {
6676
- newElem[key] = value;
6677
- }
6678
-
6679
- element.parentNode.replaceChild(newElem, element);
6680
- }
6681
- }
6682
- /*
6683
- * Copyright (c) 2018, salesforce.com, inc.
6684
- * All rights reserved.
6685
- * SPDX-License-Identifier: MIT
6686
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6687
- */
6688
-
6689
- /**
6690
- * This function builds a Web Component class from a LWC constructor so it can be
6691
- * registered as a new element via customElements.define() at any given time.
6692
- *
6693
- * @deprecated since version 1.3.11
6694
- *
6695
- * @example
6696
- * ```
6697
- * import { buildCustomElementConstructor } from 'lwc';
6698
- * import Foo from 'ns/foo';
6699
- * const WC = buildCustomElementConstructor(Foo);
6700
- * customElements.define('x-foo', WC);
6701
- * const elm = document.createElement('x-foo');
6702
- * ```
6703
- */
6704
-
6705
-
6706
- function deprecatedBuildCustomElementConstructor(Ctor) {
6707
-
6708
- return Ctor.CustomElementConstructor;
6709
- }
6710
-
6711
- function buildCustomElementConstructor(Ctor) {
6712
- const HtmlPrototype = getComponentHtmlPrototype(Ctor);
6713
- return class extends HtmlPrototype {
6714
- constructor() {
6715
- super();
6716
- createVM(this, Ctor, {
6717
- mode: 'open',
6718
- owner: null,
6719
- tagName: this.tagName
6720
- });
6721
- }
6722
-
6723
- connectedCallback() {
6724
- connectRootElement(this);
6725
- }
6726
-
6727
- disconnectedCallback() {
6728
- disconnectRootElement(this);
6729
- }
6730
-
6731
- };
6732
- }
6733
- /*
6734
- * Copyright (c) 2018, salesforce.com, inc.
6735
- * All rights reserved.
6736
- * SPDX-License-Identifier: MIT
6737
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6738
- */
6739
-
6740
6857
  /**
6741
6858
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6742
6859
  * This API is subject to change or being removed.
@@ -6768,30 +6885,31 @@ var LWC = (function (exports) {
6768
6885
 
6769
6886
  const _Node = Node;
6770
6887
  /**
6771
- * EXPERIMENTAL: This function detects whether or not a Node is controlled by a LWC template. This
6772
- * API is subject to change or being removed.
6888
+ * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
6889
+ * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
6773
6890
  */
6774
6891
 
6775
- function isNodeFromTemplate(node) {
6892
+ function isNodeShadowed(node) {
6776
6893
  if (isFalse(node instanceof _Node)) {
6777
6894
  return false;
6778
- } // TODO [#1250]: skipping the shadowRoot instances itself makes no sense, we need to revisit
6779
- // this with locker
6895
+ } // It's debatable whether shadow root instances should be considered as shadowed, but we keep
6896
+ // this unchanged for legacy reasons (#1250).
6780
6897
 
6781
6898
 
6782
6899
  if (node instanceof ShadowRoot) {
6783
6900
  return false;
6784
6901
  }
6785
6902
 
6786
- if (isSyntheticShadowDefined) {
6787
- // TODO [#1252]: old behavior that is still used by some pieces of the platform,
6788
- // specifically, nodes inserted manually on places where `lwc:dom="manual"` directive is not
6789
- // used, will be considered global elements.
6790
- return !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6791
- }
6903
+ const rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
6904
+ // synthetic roots cannot be descendants of native roots.
6905
+
6906
+ if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
6907
+ return true;
6908
+ } // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
6909
+ // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
6910
+
6792
6911
 
6793
- const root = node.getRootNode();
6794
- return root instanceof ShadowRoot;
6912
+ return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6795
6913
  }
6796
6914
  /*
6797
6915
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6836,7 +6954,7 @@ var LWC = (function (exports) {
6836
6954
  });
6837
6955
  freeze(LightningElement);
6838
6956
  seal(LightningElement.prototype);
6839
- /* version: 2.7.4 */
6957
+ /* version: 2.10.0 */
6840
6958
 
6841
6959
  exports.LightningElement = LightningElement;
6842
6960
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6848,7 +6966,7 @@ var LWC = (function (exports) {
6848
6966
  exports.getComponentDef = getComponentDef;
6849
6967
  exports.hydrateComponent = hydrateComponent;
6850
6968
  exports.isComponentConstructor = isComponentConstructor;
6851
- exports.isNodeFromTemplate = isNodeFromTemplate;
6969
+ exports.isNodeFromTemplate = isNodeShadowed;
6852
6970
  exports.readonly = readonly;
6853
6971
  exports.register = register;
6854
6972
  exports.registerComponent = registerComponent;