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
@@ -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.7.4 */
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.7.4 */
478
+ /** version: 2.10.0 */
478
479
 
479
480
  /* proxy-compat-disable */
480
481
 
@@ -517,6 +518,19 @@
517
518
 
518
519
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
519
520
  } // Borrowed from Vue template compiler.
521
+
522
+
523
+ function cloneAndOmitKey(object, keyToOmit) {
524
+ const result = {};
525
+
526
+ for (const key of Object.keys(object)) {
527
+ if (key !== keyToOmit) {
528
+ result[key] = object[key];
529
+ }
530
+ }
531
+
532
+ return result;
533
+ }
520
534
  // Primitives
521
535
  //
522
536
 
@@ -2537,6 +2551,13 @@
2537
2551
  const meta = signedDecoratorToMetaMap.get(Ctor);
2538
2552
  return isUndefined$1(meta) ? defaultMeta : meta;
2539
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
+
2540
2561
 
2541
2562
  const signedTemplateSet = new Set();
2542
2563
 
@@ -2556,6 +2577,7 @@
2556
2577
 
2557
2578
 
2558
2579
  function registerTemplate(tpl) {
2580
+
2559
2581
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
2560
2582
  // assignment of templates easily, without too much transformation
2561
2583
 
@@ -3388,148 +3410,251 @@
3388
3410
  */
3389
3411
 
3390
3412
 
3391
- const TextHook = {
3392
- create: vnode => {
3393
- const {
3394
- owner
3395
- } = vnode;
3396
- const elm = createText$1(vnode.text);
3397
- linkNodeToShadow(elm, owner);
3398
- vnode.elm = elm;
3399
- },
3400
- update: updateNodeHook,
3401
- insert: insertNode,
3402
- move: insertNode,
3403
- remove: removeNode
3404
- };
3405
- const CommentHook = {
3406
- create: vnode => {
3407
- const {
3408
- owner,
3409
- text
3410
- } = vnode;
3411
- const elm = createComment$1(text);
3412
- linkNodeToShadow(elm, owner);
3413
- vnode.elm = elm;
3414
- },
3415
- update: updateNodeHook,
3416
- insert: insertNode,
3417
- move: insertNode,
3418
- remove: removeNode
3419
- }; // insert is called after update, which is used somewhere else (via a module)
3420
- // to mark the vm as inserted, that means we cannot use update as the main channel
3421
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
3422
- // which breaks some invariants. For that reason, we have the following for any
3423
- // Custom Element that is inserted via a template.
3424
-
3425
- const ElementHook = {
3426
- create: vnode => {
3427
- const {
3428
- sel,
3429
- owner,
3430
- data: {
3431
- svg
3432
- }
3433
- } = vnode;
3434
- const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3435
- const elm = createElement$2(sel, namespace);
3436
- linkNodeToShadow(elm, owner);
3437
- fallbackElmHook(elm, vnode);
3438
- vnode.elm = elm;
3439
- patchElementPropsAndAttrs$1(null, vnode);
3440
- },
3441
- update: (oldVnode, vnode) => {
3442
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3443
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3444
- },
3445
- insert: (vnode, parentNode, referenceNode) => {
3446
- insertNode(vnode, parentNode, referenceNode);
3447
- createChildrenHook(vnode);
3448
- },
3449
- move: insertNode,
3450
- remove: (vnode, parentNode) => {
3451
- removeNode(vnode, parentNode);
3452
- removeChildren(vnode);
3413
+ function patchChildren(c1, c2, parent) {
3414
+ if (hasDynamicChildren(c2)) {
3415
+ updateDynamicChildren(c1, c2, parent);
3416
+ } else {
3417
+ updateStaticChildren(c1, c2, parent);
3453
3418
  }
3454
- };
3455
- const CustomElementHook = {
3456
- create: vnode => {
3457
- const {
3458
- sel,
3459
- owner
3460
- } = vnode;
3461
- const UpgradableConstructor = getUpgradableConstructor(sel);
3462
- /**
3463
- * Note: if the upgradable constructor does not expect, or throw when we new it
3464
- * with a callback as the first argument, we could implement a more advanced
3465
- * mechanism that only passes that argument if the constructor is known to be
3466
- * an upgradable custom element.
3467
- */
3468
-
3469
- let vm;
3470
- const elm = new UpgradableConstructor(elm => {
3471
- // the custom element from the registry is expecting an upgrade callback
3472
- vm = createViewModelHook(elm, vnode);
3473
- });
3474
- linkNodeToShadow(elm, owner);
3475
- vnode.elm = elm;
3419
+ }
3476
3420
 
3477
- if (vm) {
3478
- allocateChildren(vnode, vm);
3479
- } else if (vnode.ctor !== UpgradableConstructor) {
3480
- throw new TypeError(`Incorrect Component Constructor`);
3481
- }
3421
+ function patch(n1, n2) {
3422
+ if (n1 === n2) {
3423
+ return;
3424
+ }
3482
3425
 
3483
- patchElementPropsAndAttrs$1(null, vnode);
3484
- },
3485
- update: (oldVnode, vnode) => {
3486
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3487
- const vm = getAssociatedVMIfPresent(vnode.elm);
3426
+ switch (n2.type) {
3427
+ case 0
3428
+ /* Text */
3429
+ :
3430
+ patchText(n1, n2);
3431
+ break;
3488
3432
 
3489
- if (vm) {
3490
- // in fallback mode, the allocation will always set children to
3491
- // empty and delegate the real allocation to the slot elements
3492
- allocateChildren(vnode, vm);
3493
- } // in fallback mode, the children will be always empty, so, nothing
3494
- // will happen, but in native, it does allocate the light dom
3433
+ case 1
3434
+ /* Comment */
3435
+ :
3436
+ patchComment(n1, n2);
3437
+ break;
3495
3438
 
3439
+ case 2
3440
+ /* Element */
3441
+ :
3442
+ patchElement(n1, n2);
3443
+ break;
3496
3444
 
3497
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3445
+ case 3
3446
+ /* CustomElement */
3447
+ :
3448
+ patchCustomElement(n1, n2);
3449
+ break;
3450
+ }
3451
+ }
3498
3452
 
3499
- if (vm) {
3500
- // 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;
3501
3460
 
3461
+ case 1
3462
+ /* Comment */
3463
+ :
3464
+ mountComment(node, parent, anchor);
3465
+ break;
3502
3466
 
3503
- rerenderVM(vm);
3504
- }
3505
- },
3506
- insert: (vnode, parentNode, referenceNode) => {
3507
- insertNode(vnode, parentNode, referenceNode);
3508
- 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
+ }
3509
3480
 
3510
- if (vm) {
3481
+ function patchText(n1, n2) {
3482
+ n2.elm = n1.elm;
3511
3483
 
3512
- runConnectedCallback(vm);
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.
3501
+
3502
+ if (n2.text !== n1.text) {
3503
+ updateTextContent(n2);
3504
+ }
3505
+ }
3506
+
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
3513
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) {
3572
+
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
+ }
3514
3604
 
3515
- createChildrenHook(vnode);
3605
+ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
3606
+ for (; start < end; ++start) {
3607
+ const vnode = vnodes[start];
3516
3608
 
3517
- if (vm) {
3518
- appendVM(vm);
3609
+ if (isVNode(vnode)) {
3610
+ mount(vnode, parent, anchor);
3519
3611
  }
3520
- },
3521
- move: insertNode,
3522
- remove: (vnode, parentNode) => {
3523
- removeNode(vnode, parentNode);
3524
- const vm = getAssociatedVMIfPresent(vnode.elm);
3525
-
3526
- if (vm) {
3527
- // for custom elements we don't have to go recursively because the removeVM routine
3528
- // will take care of disconnecting any child VM attached to its shadow as well.
3529
- 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);
3530
3655
  }
3531
3656
  }
3532
- };
3657
+ }
3533
3658
 
3534
3659
  function isVNode(vnode) {
3535
3660
  return vnode != null;
@@ -3574,26 +3699,23 @@
3574
3699
  }
3575
3700
  }
3576
3701
 
3577
- function updateNodeHook(oldVnode, vnode) {
3702
+ function updateTextContent(vnode) {
3578
3703
  const {
3579
3704
  elm,
3580
3705
  text
3581
3706
  } = vnode;
3582
3707
 
3583
- if (oldVnode.text !== text) {
3584
-
3585
- setText$1(elm, text);
3586
- }
3708
+ setText$1(elm, text);
3587
3709
  }
3588
3710
 
3589
- function insertNode(vnode, parentNode, referenceNode) {
3711
+ function insertNode(node, parent, anchor) {
3590
3712
 
3591
- insert$1(vnode.elm, parentNode, referenceNode);
3713
+ insert$1(node, parent, anchor);
3592
3714
  }
3593
3715
 
3594
- function removeNode(vnode, parentNode) {
3716
+ function removeNode(node, parent) {
3595
3717
 
3596
- remove$1(vnode.elm, parentNode);
3718
+ remove$1(node, parent);
3597
3719
  }
3598
3720
 
3599
3721
  function patchElementPropsAndAttrs$1(oldVnode, vnode) {
@@ -3634,19 +3756,13 @@
3634
3756
  ) {
3635
3757
  // this element will now accept any manual content inserted into it
3636
3758
  observeElementChildNodes(elm);
3637
- } // when running in synthetic shadow mode, we need to set the shadowToken value
3638
- // into each element from the template, so they can be styled accordingly.
3639
-
3640
-
3641
- setElementShadowToken(elm, stylesheetToken);
3642
- }
3643
- }
3759
+ }
3644
3760
 
3645
- function patchChildren(parent, oldCh, newCh) {
3646
- if (hasDynamicChildren(newCh)) {
3647
- updateDynamicChildren(parent, oldCh, newCh);
3648
- } else {
3649
- updateStaticChildren(parent, oldCh, newCh);
3761
+ if (!isUndefined$1(stylesheetToken)) {
3762
+ // when running in synthetic shadow mode, we need to set the shadowToken value
3763
+ // into each element from the template, so they can be styled accordingly.
3764
+ setElementShadowToken(elm, stylesheetToken);
3765
+ }
3650
3766
  }
3651
3767
  }
3652
3768
 
@@ -3707,7 +3823,9 @@
3707
3823
  } = owner.context; // when running in synthetic shadow mode, we need to set the shadowToken value
3708
3824
  // into each element from the template, so they can be styled accordingly.
3709
3825
 
3710
- setElementShadowToken(elm, stylesheetToken);
3826
+ if (!isUndefined$1(stylesheetToken)) {
3827
+ setElementShadowToken(elm, stylesheetToken);
3828
+ }
3711
3829
  }
3712
3830
 
3713
3831
  vm = createVM(elm, ctor, {
@@ -3719,40 +3837,6 @@
3719
3837
  return vm;
3720
3838
  }
3721
3839
 
3722
- function createChildrenHook(vnode) {
3723
- const {
3724
- elm,
3725
- children
3726
- } = vnode;
3727
-
3728
- for (let j = 0; j < children.length; ++j) {
3729
- const ch = children[j];
3730
-
3731
- if (ch != null) {
3732
- ch.hook.create(ch);
3733
- ch.hook.insert(ch, elm, null);
3734
- }
3735
- }
3736
- }
3737
-
3738
- function removeChildren(vnode) {
3739
- // this method only needs to search on child vnodes from template
3740
- // to trigger the remove hook just in case some of those children
3741
- // are custom elements.
3742
- const {
3743
- children,
3744
- elm
3745
- } = vnode;
3746
-
3747
- for (let j = 0, len = children.length; j < len; ++j) {
3748
- const ch = children[j];
3749
-
3750
- if (!isNull(ch)) {
3751
- ch.hook.remove(ch, elm);
3752
- }
3753
- }
3754
- }
3755
-
3756
3840
  function allocateInSlot(vm, children) {
3757
3841
  var _a;
3758
3842
 
@@ -3849,28 +3933,7 @@
3849
3933
  return map;
3850
3934
  }
3851
3935
 
3852
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
3853
- for (; startIdx <= endIdx; ++startIdx) {
3854
- const ch = vnodes[startIdx];
3855
-
3856
- if (isVNode(ch)) {
3857
- ch.hook.create(ch);
3858
- ch.hook.insert(ch, parentElm, before);
3859
- }
3860
- }
3861
- }
3862
-
3863
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
3864
- for (; startIdx <= endIdx; ++startIdx) {
3865
- const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
3866
-
3867
- if (isVNode(ch)) {
3868
- ch.hook.remove(ch, parentElm);
3869
- }
3870
- }
3871
- }
3872
-
3873
- function updateDynamicChildren(parentElm, oldCh, newCh) {
3936
+ function updateDynamicChildren(oldCh, newCh, parent) {
3874
3937
  let oldStartIdx = 0;
3875
3938
  let newStartIdx = 0;
3876
3939
  let oldEndIdx = oldCh.length - 1;
@@ -3884,6 +3947,7 @@
3884
3947
  let idxInOld;
3885
3948
  let elmToMove;
3886
3949
  let before;
3950
+ let clonedOldCh = false;
3887
3951
 
3888
3952
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
3889
3953
  if (!isVNode(oldStartVnode)) {
@@ -3895,23 +3959,23 @@
3895
3959
  } else if (!isVNode(newEndVnode)) {
3896
3960
  newEndVnode = newCh[--newEndIdx];
3897
3961
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
3898
- patchVnode(oldStartVnode, newStartVnode);
3962
+ patch(oldStartVnode, newStartVnode);
3899
3963
  oldStartVnode = oldCh[++oldStartIdx];
3900
3964
  newStartVnode = newCh[++newStartIdx];
3901
3965
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
3902
- patchVnode(oldEndVnode, newEndVnode);
3966
+ patch(oldEndVnode, newEndVnode);
3903
3967
  oldEndVnode = oldCh[--oldEndIdx];
3904
3968
  newEndVnode = newCh[--newEndIdx];
3905
3969
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
3906
3970
  // Vnode moved right
3907
- patchVnode(oldStartVnode, newEndVnode);
3908
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
3971
+ patch(oldStartVnode, newEndVnode);
3972
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
3909
3973
  oldStartVnode = oldCh[++oldStartIdx];
3910
3974
  newEndVnode = newCh[--newEndIdx];
3911
3975
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
3912
3976
  // Vnode moved left
3913
- patchVnode(oldEndVnode, newStartVnode);
3914
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
3977
+ patch(oldEndVnode, newStartVnode);
3978
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
3915
3979
  oldEndVnode = oldCh[--oldEndIdx];
3916
3980
  newStartVnode = newCh[++newStartIdx];
3917
3981
  } else {
@@ -3923,8 +3987,7 @@
3923
3987
 
3924
3988
  if (isUndefined$1(idxInOld)) {
3925
3989
  // New element
3926
- newStartVnode.hook.create(newStartVnode);
3927
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3990
+ mount(newStartVnode, parent, oldStartVnode.elm);
3928
3991
  newStartVnode = newCh[++newStartIdx];
3929
3992
  } else {
3930
3993
  elmToMove = oldCh[idxInOld];
@@ -3932,12 +3995,22 @@
3932
3995
  if (isVNode(elmToMove)) {
3933
3996
  if (elmToMove.sel !== newStartVnode.sel) {
3934
3997
  // New element
3935
- newStartVnode.hook.create(newStartVnode);
3936
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3998
+ mount(newStartVnode, parent, oldStartVnode.elm);
3937
3999
  } else {
3938
- patchVnode(elmToMove, newStartVnode);
4000
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
4001
+ // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4002
+ // so we only care about the `oldCh` object inside this function.
4003
+ // To avoid cloning over and over again, we check `clonedOldCh`
4004
+ // and only clone once.
4005
+
4006
+ if (!clonedOldCh) {
4007
+ clonedOldCh = true;
4008
+ oldCh = [...oldCh];
4009
+ } // We've already cloned at least once, so it's no longer read-only
4010
+
4011
+
3939
4012
  oldCh[idxInOld] = undefined;
3940
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
4013
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
3941
4014
  }
3942
4015
  }
3943
4016
 
@@ -3958,65 +4031,55 @@
3958
4031
  } while (!isVNode(n) && i < newChEnd);
3959
4032
 
3960
4033
  before = isVNode(n) ? n.elm : null;
3961
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
4034
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
3962
4035
  } else {
3963
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
4036
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
3964
4037
  }
3965
4038
  }
3966
4039
  }
3967
4040
 
3968
- function updateStaticChildren(parentElm, oldCh, newCh) {
3969
- const oldChLength = oldCh.length;
3970
- const newChLength = newCh.length;
4041
+ function updateStaticChildren(c1, c2, parent) {
4042
+ const c1Length = c1.length;
4043
+ const c2Length = c2.length;
3971
4044
 
3972
- if (oldChLength === 0) {
4045
+ if (c1Length === 0) {
3973
4046
  // the old list is empty, we can directly insert anything new
3974
- addVnodes(parentElm, null, newCh, 0, newChLength);
4047
+ mountVNodes(c2, parent, null);
3975
4048
  return;
3976
4049
  }
3977
4050
 
3978
- if (newChLength === 0) {
4051
+ if (c2Length === 0) {
3979
4052
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3980
4053
  // this is the case in which the dynamic children of an if-directive should be removed
3981
- removeVnodes(parentElm, oldCh, 0, oldChLength);
4054
+ unmountVNodes(c1, parent, true);
3982
4055
  return;
3983
4056
  } // if the old list is not empty, the new list MUST have the same
3984
4057
  // amount of nodes, that's why we call this static children
3985
4058
 
3986
4059
 
3987
- let referenceElm = null;
4060
+ let anchor = null;
3988
4061
 
3989
- for (let i = newChLength - 1; i >= 0; i -= 1) {
3990
- const vnode = newCh[i];
3991
- const oldVNode = oldCh[i];
4062
+ for (let i = c2Length - 1; i >= 0; i -= 1) {
4063
+ const n1 = c1[i];
4064
+ const n2 = c2[i];
3992
4065
 
3993
- if (vnode !== oldVNode) {
3994
- if (isVNode(oldVNode)) {
3995
- if (isVNode(vnode)) {
3996
- // both vnodes must be equivalent, and se just need to patch them
3997
- patchVnode(oldVNode, vnode);
3998
- 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;
3999
4072
  } else {
4000
4073
  // removing the old vnode since the new one is null
4001
- oldVNode.hook.remove(oldVNode, parentElm);
4074
+ unmount(n1, parent, true);
4002
4075
  }
4003
- } else if (isVNode(vnode)) {
4004
- // this condition is unnecessary
4005
- vnode.hook.create(vnode); // insert the new node one since the old one is null
4006
-
4007
- vnode.hook.insert(vnode, parentElm, referenceElm);
4008
- referenceElm = vnode.elm;
4076
+ } else if (isVNode(n2)) {
4077
+ mount(n2, parent, anchor);
4078
+ anchor = n2.elm;
4009
4079
  }
4010
4080
  }
4011
4081
  }
4012
4082
  }
4013
-
4014
- function patchVnode(oldVnode, vnode) {
4015
- if (oldVnode !== vnode) {
4016
- vnode.elm = oldVnode.elm;
4017
- vnode.hook.update(oldVnode, vnode);
4018
- }
4019
- }
4020
4083
  /*
4021
4084
  * Copyright (c) 2018, salesforce.com, inc.
4022
4085
  * All rights reserved.
@@ -4032,7 +4095,7 @@
4032
4095
  } // [h]tml node
4033
4096
 
4034
4097
 
4035
- function h(sel, data, children) {
4098
+ function h(sel, data, children = EmptyArray) {
4036
4099
  const vmBeingRendered = getVMBeingRendered();
4037
4100
 
4038
4101
  let elm;
@@ -4048,7 +4111,6 @@
4048
4111
  children,
4049
4112
  elm,
4050
4113
  key,
4051
- hook: ElementHook,
4052
4114
  owner: vmBeingRendered
4053
4115
  };
4054
4116
  } // [t]ab[i]ndex function
@@ -4100,7 +4162,7 @@
4100
4162
  const {
4101
4163
  key
4102
4164
  } = data;
4103
- let elm;
4165
+ let elm, aChildren, vm;
4104
4166
  const vnode = {
4105
4167
  type: 3
4106
4168
  /* CustomElement */
@@ -4110,11 +4172,11 @@
4110
4172
  children,
4111
4173
  elm,
4112
4174
  key,
4113
- hook: CustomElementHook,
4114
4175
  ctor: Ctor,
4115
4176
  owner: vmBeingRendered,
4116
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
4117
-
4177
+ mode: 'open',
4178
+ aChildren,
4179
+ vm
4118
4180
  };
4119
4181
  addVNodeToChildLWC(vnode);
4120
4182
  return vnode;
@@ -4196,7 +4258,6 @@
4196
4258
  text,
4197
4259
  elm,
4198
4260
  key,
4199
- hook: TextHook,
4200
4261
  owner: getVMBeingRendered()
4201
4262
  };
4202
4263
  } // [co]mment node
@@ -4212,7 +4273,6 @@
4212
4273
  text,
4213
4274
  elm,
4214
4275
  key,
4215
- hook: CommentHook,
4216
4276
  owner: getVMBeingRendered()
4217
4277
  };
4218
4278
  } // [d]ynamic text
@@ -4314,7 +4374,7 @@
4314
4374
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4315
4375
  */
4316
4376
 
4317
- function dc(sel, Ctor, data, children) {
4377
+ function dc(sel, Ctor, data, children = EmptyArray) {
4318
4378
 
4319
4379
 
4320
4380
  if (Ctor == null) {
@@ -4333,10 +4393,14 @@
4333
4393
  } // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4334
4394
  // to identify different constructors as vnodes with different keys to avoid reusing the
4335
4395
  // element used for previous constructors.
4396
+ // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4397
+ // hoisting optimization.
4336
4398
 
4337
4399
 
4338
- data.key = `dc:${idx}:${data.key}`;
4339
- return c(sel, Ctor, data, children);
4400
+ const newData = Object.assign(Object.assign({}, data), {
4401
+ key: `dc:${idx}:${data.key}`
4402
+ });
4403
+ return c(sel, Ctor, newData, children);
4340
4404
  }
4341
4405
  /**
4342
4406
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -4453,12 +4517,14 @@
4453
4517
  hasTokenInAttribute: oldHasTokenInAttribute
4454
4518
  } = context;
4455
4519
 
4456
- if (oldHasTokenInClass) {
4457
- getClassList$1(elm).remove(makeHostToken(oldToken));
4458
- }
4520
+ if (!isUndefined$1(oldToken)) {
4521
+ if (oldHasTokenInClass) {
4522
+ getClassList$1(elm).remove(makeHostToken(oldToken));
4523
+ }
4459
4524
 
4460
- if (oldHasTokenInAttribute) {
4461
- removeAttribute$1(elm, makeHostToken(oldToken));
4525
+ if (oldHasTokenInAttribute) {
4526
+ removeAttribute$1(elm, makeHostToken(oldToken));
4527
+ }
4462
4528
  } // Apply the new template styling token to the host element, if the new template has any
4463
4529
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
4464
4530
 
@@ -4935,6 +5001,7 @@
4935
5001
  function registerComponent(Ctor, {
4936
5002
  tmpl
4937
5003
  }) {
5004
+
4938
5005
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
4939
5006
  // without too much transformation
4940
5007
 
@@ -5044,7 +5111,7 @@
5044
5111
  */
5045
5112
 
5046
5113
 
5047
- function hydrate$1(vnode, node) {
5114
+ function hydrate(vnode, node) {
5048
5115
  switch (vnode.type) {
5049
5116
  case 0
5050
5117
  /* Text */
@@ -5076,7 +5143,7 @@
5076
5143
  var _a;
5077
5144
 
5078
5145
 
5079
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5146
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5080
5147
  vnode.elm = node;
5081
5148
  }
5082
5149
 
@@ -5084,7 +5151,7 @@
5084
5151
  var _a;
5085
5152
 
5086
5153
 
5087
- 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);
5088
5155
  vnode.elm = node;
5089
5156
  }
5090
5157
 
@@ -5107,10 +5174,13 @@
5107
5174
  } = vnode.data;
5108
5175
 
5109
5176
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5110
- if (elm.innerHTML === props.innerHTML) {
5111
- delete props.innerHTML;
5177
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
5178
+ // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5179
+ vnode.data = Object.assign(Object.assign({}, vnode.data), {
5180
+ props: cloneAndOmitKey(props, 'innerHTML')
5181
+ });
5112
5182
  } else {
5113
- 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);
5114
5184
  }
5115
5185
  }
5116
5186
  }
@@ -5118,14 +5188,13 @@
5118
5188
  patchElementPropsAndAttrs(vnode);
5119
5189
 
5120
5190
  if (!isDomManual) {
5121
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
5191
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
5122
5192
  }
5123
5193
  }
5124
5194
 
5125
5195
  function hydrateCustomElement(vnode, node) {
5126
5196
 
5127
5197
  const elm = node;
5128
- vnode.elm = elm;
5129
5198
  const {
5130
5199
  sel,
5131
5200
  mode,
@@ -5137,6 +5206,8 @@
5137
5206
  owner,
5138
5207
  tagName: sel
5139
5208
  });
5209
+ vnode.elm = elm;
5210
+ vnode.vm = vm;
5140
5211
  allocateChildren(vnode, vm);
5141
5212
  patchElementPropsAndAttrs(vnode); // Insert hook section:
5142
5213
 
@@ -5147,7 +5218,7 @@
5147
5218
  ) {
5148
5219
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5149
5220
  // Note: for Light DOM, this is handled while hydrating the VM
5150
- hydrateChildren(vnode.elm.childNodes, vnode.children);
5221
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children);
5151
5222
  }
5152
5223
 
5153
5224
  hydrateVM(vm);
@@ -5162,7 +5233,7 @@
5162
5233
 
5163
5234
  if (!isNull(childVnode)) {
5164
5235
  const childNode = elmChildren[childNodeIndex];
5165
- hydrate$1(childVnode, childNode);
5236
+ hydrate(childVnode, childNode);
5166
5237
  childNodeIndex++;
5167
5238
  }
5168
5239
  }
@@ -5237,7 +5308,19 @@
5237
5308
  }
5238
5309
 
5239
5310
  function hydrateVM(vm) {
5240
- 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
+ }
5241
5324
  } // just in case the component comes back, with this we guarantee re-rendering it
5242
5325
  // while preventing any attempt to rehydration until after reinsertion.
5243
5326
 
@@ -5365,7 +5448,11 @@
5365
5448
  /* Native */
5366
5449
  ;
5367
5450
  } else if (isNativeShadowDefined$1) {
5368
- if (def.shadowSupportMode === "any"
5451
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
5452
+ shadowMode = 1
5453
+ /* Synthetic */
5454
+ ;
5455
+ } else if (def.shadowSupportMode === "any"
5369
5456
  /* Any */
5370
5457
  ) {
5371
5458
  shadowMode = 0
@@ -5429,22 +5516,6 @@
5429
5516
  }
5430
5517
  }
5431
5518
 
5432
- function hydrate(vm) {
5433
- if (isTrue(vm.isDirty)) {
5434
- // manually diffing/patching here.
5435
- // This routine is:
5436
- // patchShadowRoot(vm, children);
5437
- // -> addVnodes.
5438
- const children = renderComponent(vm);
5439
- vm.children = children;
5440
- const vmChildren = vm.renderMode === 0
5441
- /* Light */
5442
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5443
- hydrateChildren(vmChildren, children);
5444
- runRenderedCallback(vm);
5445
- }
5446
- }
5447
-
5448
5519
  function patchShadowRoot(vm, newCh) {
5449
5520
  const {
5450
5521
  renderRoot,
@@ -5464,7 +5535,7 @@
5464
5535
  , vm);
5465
5536
  }, () => {
5466
5537
  // job
5467
- patchChildren(renderRoot, oldCh, newCh);
5538
+ patchChildren(oldCh, newCh, renderRoot);
5468
5539
  }, () => {
5469
5540
  // post
5470
5541
  logOperationEnd(2
@@ -6174,7 +6245,7 @@
6174
6245
  hooksAreSet = true;
6175
6246
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6176
6247
  }
6177
- /* version: 2.7.4 */
6248
+ /* version: 2.10.0 */
6178
6249
 
6179
6250
  /*
6180
6251
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6191,6 +6262,7 @@
6191
6262
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6192
6263
 
6193
6264
  const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6265
+ const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6194
6266
  const styleElements = create(null);
6195
6267
  const styleSheets = create(null);
6196
6268
  const nodesToStyleSheets = new WeakMap();
@@ -6234,7 +6306,13 @@
6234
6306
  }
6235
6307
 
6236
6308
  if (!target.adoptedStyleSheets.includes(styleSheet)) {
6237
- 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
+ }
6238
6316
  }
6239
6317
  }
6240
6318
 
@@ -6518,6 +6596,152 @@
6518
6596
  setSetText(setText);
6519
6597
  setSsr(ssr);
6520
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
+ }
6521
6745
  /*
6522
6746
  * Copyright (c) 2018, salesforce.com, inc.
6523
6747
  * All rights reserved.
@@ -6527,6 +6751,7 @@
6527
6751
  // TODO [#2472]: Remove this workaround when appropriate.
6528
6752
  // eslint-disable-next-line lwc-internal/no-global-node
6529
6753
 
6754
+
6530
6755
  const _Node$1 = Node;
6531
6756
  const ConnectingSlot = new WeakMap();
6532
6757
  const DisconnectingSlot = new WeakMap();
@@ -6632,114 +6857,6 @@
6632
6857
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6633
6858
  */
6634
6859
 
6635
-
6636
- function hydrateComponent(element, Ctor, props = {}) {
6637
- if (!(element instanceof Element)) {
6638
- throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
6639
- }
6640
-
6641
- if (!isFunction$1(Ctor)) {
6642
- throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
6643
- }
6644
-
6645
- if (!isObject(props) || isNull(props)) {
6646
- throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
6647
- }
6648
-
6649
- try {
6650
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6651
- // and uses the same algo to create the stylesheets as in SSR.
6652
- setIsHydrating(true);
6653
- createVM(element, Ctor, {
6654
- mode: 'open',
6655
- owner: null,
6656
- tagName: element.tagName.toLowerCase()
6657
- });
6658
-
6659
- for (const [key, value] of Object.entries(props)) {
6660
- element[key] = value;
6661
- }
6662
-
6663
- hydrateRootElement(element); // set it back since now we finished hydration.
6664
-
6665
- setIsHydrating(false);
6666
- } catch (e) {
6667
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6668
- // the client generated DOM.
6669
-
6670
- /* eslint-disable-next-line no-console */
6671
- console.error('Recovering from error while hydrating: ', e);
6672
- setIsHydrating(false);
6673
- const newElem = createElement(element.tagName, {
6674
- is: Ctor,
6675
- mode: 'open'
6676
- });
6677
-
6678
- for (const [key, value] of Object.entries(props)) {
6679
- newElem[key] = value;
6680
- }
6681
-
6682
- element.parentNode.replaceChild(newElem, element);
6683
- }
6684
- }
6685
- /*
6686
- * Copyright (c) 2018, salesforce.com, inc.
6687
- * All rights reserved.
6688
- * SPDX-License-Identifier: MIT
6689
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6690
- */
6691
-
6692
- /**
6693
- * This function builds a Web Component class from a LWC constructor so it can be
6694
- * registered as a new element via customElements.define() at any given time.
6695
- *
6696
- * @deprecated since version 1.3.11
6697
- *
6698
- * @example
6699
- * ```
6700
- * import { buildCustomElementConstructor } from 'lwc';
6701
- * import Foo from 'ns/foo';
6702
- * const WC = buildCustomElementConstructor(Foo);
6703
- * customElements.define('x-foo', WC);
6704
- * const elm = document.createElement('x-foo');
6705
- * ```
6706
- */
6707
-
6708
-
6709
- function deprecatedBuildCustomElementConstructor(Ctor) {
6710
-
6711
- return Ctor.CustomElementConstructor;
6712
- }
6713
-
6714
- function buildCustomElementConstructor(Ctor) {
6715
- const HtmlPrototype = getComponentHtmlPrototype(Ctor);
6716
- return class extends HtmlPrototype {
6717
- constructor() {
6718
- super();
6719
- createVM(this, Ctor, {
6720
- mode: 'open',
6721
- owner: null,
6722
- tagName: this.tagName
6723
- });
6724
- }
6725
-
6726
- connectedCallback() {
6727
- connectRootElement(this);
6728
- }
6729
-
6730
- disconnectedCallback() {
6731
- disconnectRootElement(this);
6732
- }
6733
-
6734
- };
6735
- }
6736
- /*
6737
- * Copyright (c) 2018, salesforce.com, inc.
6738
- * All rights reserved.
6739
- * SPDX-License-Identifier: MIT
6740
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6741
- */
6742
-
6743
6860
  /**
6744
6861
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6745
6862
  * This API is subject to change or being removed.
@@ -6771,30 +6888,31 @@
6771
6888
 
6772
6889
  const _Node = Node;
6773
6890
  /**
6774
- * EXPERIMENTAL: This function detects whether or not a Node is controlled by a LWC template. This
6775
- * API is subject to change or being removed.
6891
+ * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
6892
+ * ONCE LOCKER V1 IS NO LONGER SUPPORTED.
6776
6893
  */
6777
6894
 
6778
- function isNodeFromTemplate(node) {
6895
+ function isNodeShadowed(node) {
6779
6896
  if (isFalse(node instanceof _Node)) {
6780
6897
  return false;
6781
- } // TODO [#1250]: skipping the shadowRoot instances itself makes no sense, we need to revisit
6782
- // this with locker
6898
+ } // It's debatable whether shadow root instances should be considered as shadowed, but we keep
6899
+ // this unchanged for legacy reasons (#1250).
6783
6900
 
6784
6901
 
6785
6902
  if (node instanceof ShadowRoot) {
6786
6903
  return false;
6787
6904
  }
6788
6905
 
6789
- if (isSyntheticShadowDefined) {
6790
- // TODO [#1252]: old behavior that is still used by some pieces of the platform,
6791
- // specifically, nodes inserted manually on places where `lwc:dom="manual"` directive is not
6792
- // used, will be considered global elements.
6793
- return !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6794
- }
6906
+ const rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
6907
+ // synthetic roots cannot be descendants of native roots.
6908
+
6909
+ if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
6910
+ return true;
6911
+ } // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
6912
+ // inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
6913
+
6795
6914
 
6796
- const root = node.getRootNode();
6797
- return root instanceof ShadowRoot;
6915
+ return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
6798
6916
  }
6799
6917
  /*
6800
6918
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6839,7 +6957,7 @@
6839
6957
  });
6840
6958
  freeze(LightningElement);
6841
6959
  seal(LightningElement.prototype);
6842
- /* version: 2.7.4 */
6960
+ /* version: 2.10.0 */
6843
6961
 
6844
6962
  exports.LightningElement = LightningElement;
6845
6963
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6851,7 +6969,7 @@
6851
6969
  exports.getComponentDef = getComponentDef;
6852
6970
  exports.hydrateComponent = hydrateComponent;
6853
6971
  exports.isComponentConstructor = isComponentConstructor;
6854
- exports.isNodeFromTemplate = isNodeFromTemplate;
6972
+ exports.isNodeFromTemplate = isNodeShadowed;
6855
6973
  exports.readonly = readonly;
6856
6974
  exports.register = register;
6857
6975
  exports.registerComponent = registerComponent;