lwc 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +603 -449
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +603 -449
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +477 -398
  5. package/dist/engine-dom/iife/es5/engine-dom.js +657 -479
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +509 -425
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +603 -449
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +477 -398
  11. package/dist/engine-dom/umd/es5/engine-dom.js +657 -479
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +509 -425
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +391 -285
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +391 -285
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +7 -7
@@ -10,14 +10,6 @@
10
10
 
11
11
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
12
12
 
13
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
14
-
15
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
-
17
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
-
19
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
-
21
13
  function _get2() { if (typeof Reflect !== "undefined" && Reflect.get) { _get2 = Reflect.get; } else { _get2 = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get2.apply(this, arguments); }
22
14
 
23
15
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf2(object); if (object === null) break; } return object; }
@@ -44,6 +36,14 @@
44
36
 
45
37
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
46
38
 
39
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
40
+
41
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
42
+
43
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
44
+
45
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
46
+
47
47
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
48
48
 
49
49
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -348,7 +348,7 @@
348
348
  var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
349
349
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
350
350
  var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
351
- /** version: 2.9.0 */
351
+ /** version: 2.10.0 */
352
352
 
353
353
  /*
354
354
  * Copyright (c) 2018, salesforce.com, inc.
@@ -413,7 +413,7 @@
413
413
  };
414
414
  }
415
415
 
416
- function patch(propName) {
416
+ function patch$1(propName) {
417
417
  // Typescript is inferring the wrong function type for this particular
418
418
  // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
419
419
  // @ts-ignore type-mismatch
@@ -435,7 +435,7 @@
435
435
  var propName = ElementPrototypeAriaPropertyNames[_i2];
436
436
 
437
437
  if (detect(propName)) {
438
- patch(propName);
438
+ patch$1(propName);
439
439
  }
440
440
  }
441
441
  /**
@@ -451,14 +451,15 @@
451
451
 
452
452
 
453
453
  var features = {
454
- ENABLE_REACTIVE_SETTER: null,
455
- ENABLE_HMR: null,
456
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
454
+ DISABLE_MIXED_SHADOW_MODE: null,
457
455
  ENABLE_ELEMENT_PATCH: null,
458
456
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
459
- ENABLE_NODE_LIST_PATCH: null,
457
+ ENABLE_HMR: null,
460
458
  ENABLE_HTML_COLLECTIONS_PATCH: null,
459
+ ENABLE_INNER_OUTER_TEXT_PATCH: null,
460
+ ENABLE_NODE_LIST_PATCH: null,
461
461
  ENABLE_NODE_PATCH: null,
462
+ ENABLE_REACTIVE_SETTER: null,
462
463
  ENABLE_WIRE_SYNC_EMIT: null
463
464
  };
464
465
 
@@ -517,7 +518,7 @@
517
518
 
518
519
  function setFeatureFlagForTest(name, value) {
519
520
  }
520
- /** version: 2.9.0 */
521
+ /** version: 2.10.0 */
521
522
 
522
523
  /* proxy-compat-disable */
523
524
 
@@ -574,7 +575,7 @@
574
575
  }
575
576
 
576
577
  return result;
577
- } //
578
+ }
578
579
  // Primitives
579
580
  //
580
581
 
@@ -2592,6 +2593,13 @@
2592
2593
  var meta = signedDecoratorToMetaMap.get(Ctor);
2593
2594
  return isUndefined$1(meta) ? defaultMeta : meta;
2594
2595
  }
2596
+ /*
2597
+ * Copyright (c) 2018, salesforce.com, inc.
2598
+ * All rights reserved.
2599
+ * SPDX-License-Identifier: MIT
2600
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2601
+ */
2602
+
2595
2603
 
2596
2604
  var signedTemplateSet = new Set();
2597
2605
 
@@ -2611,6 +2619,7 @@
2611
2619
 
2612
2620
 
2613
2621
  function registerTemplate(tpl) {
2622
+
2614
2623
  signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
2615
2624
  // assignment of templates easily, without too much transformation
2616
2625
 
@@ -3423,138 +3432,245 @@
3423
3432
  */
3424
3433
 
3425
3434
 
3426
- var TextHook = {
3427
- create: function create(vnode) {
3428
- var owner = vnode.owner;
3429
- var elm = createText$1(vnode.text);
3430
- linkNodeToShadow(elm, owner);
3431
- vnode.elm = elm;
3432
- },
3433
- update: updateNodeHook,
3434
- insert: insertNode,
3435
- move: insertNode,
3436
- remove: removeNode
3437
- };
3438
- var CommentHook = {
3439
- create: function create(vnode) {
3440
- var owner = vnode.owner,
3441
- text = vnode.text;
3442
- var elm = createComment$1(text);
3443
- linkNodeToShadow(elm, owner);
3444
- vnode.elm = elm;
3445
- },
3446
- update: updateNodeHook,
3447
- insert: insertNode,
3448
- move: insertNode,
3449
- remove: removeNode
3450
- }; // insert is called after update, which is used somewhere else (via a module)
3451
- // to mark the vm as inserted, that means we cannot use update as the main channel
3452
- // to rehydrate when dirty, because sometimes the element is not inserted just yet,
3453
- // which breaks some invariants. For that reason, we have the following for any
3454
- // Custom Element that is inserted via a template.
3455
-
3456
- var ElementHook = {
3457
- create: function create(vnode) {
3458
- var sel = vnode.sel,
3459
- owner = vnode.owner,
3460
- svg = vnode.data.svg;
3461
- var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3462
- var elm = createElement$2(sel, namespace);
3463
- linkNodeToShadow(elm, owner);
3464
- fallbackElmHook(elm, vnode);
3465
- vnode.elm = elm;
3466
- patchElementPropsAndAttrs$1(null, vnode);
3467
- },
3468
- update: function update(oldVnode, vnode) {
3469
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3470
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3471
- },
3472
- insert: function insert(vnode, parentNode, referenceNode) {
3473
- insertNode(vnode, parentNode, referenceNode);
3474
- createChildrenHook(vnode);
3475
- },
3476
- move: insertNode,
3477
- remove: function remove(vnode, parentNode) {
3478
- removeNode(vnode, parentNode);
3479
- removeChildren(vnode);
3435
+ function patchChildren(c1, c2, parent) {
3436
+ if (hasDynamicChildren(c2)) {
3437
+ updateDynamicChildren(c1, c2, parent);
3438
+ } else {
3439
+ updateStaticChildren(c1, c2, parent);
3480
3440
  }
3481
- };
3482
- var CustomElementHook = {
3483
- create: function create(vnode) {
3484
- var sel = vnode.sel,
3485
- owner = vnode.owner;
3486
- var UpgradableConstructor = getUpgradableConstructor(sel);
3487
- /**
3488
- * Note: if the upgradable constructor does not expect, or throw when we new it
3489
- * with a callback as the first argument, we could implement a more advanced
3490
- * mechanism that only passes that argument if the constructor is known to be
3491
- * an upgradable custom element.
3492
- */
3441
+ }
3493
3442
 
3494
- var vm;
3495
- var elm = new UpgradableConstructor(function (elm) {
3496
- // the custom element from the registry is expecting an upgrade callback
3497
- vm = createViewModelHook(elm, vnode);
3498
- });
3499
- linkNodeToShadow(elm, owner);
3500
- vnode.elm = elm;
3443
+ function patch(n1, n2) {
3444
+ if (n1 === n2) {
3445
+ return;
3446
+ }
3501
3447
 
3502
- if (vm) {
3503
- allocateChildren(vnode, vm);
3504
- } else if (vnode.ctor !== UpgradableConstructor) {
3505
- throw new TypeError("Incorrect Component Constructor");
3506
- }
3448
+ switch (n2.type) {
3449
+ case 0
3450
+ /* Text */
3451
+ :
3452
+ patchText(n1, n2);
3453
+ break;
3507
3454
 
3508
- patchElementPropsAndAttrs$1(null, vnode);
3509
- },
3510
- update: function update(oldVnode, vnode) {
3511
- patchElementPropsAndAttrs$1(oldVnode, vnode);
3512
- var vm = getAssociatedVMIfPresent(vnode.elm);
3455
+ case 1
3456
+ /* Comment */
3457
+ :
3458
+ patchComment(n1, n2);
3459
+ break;
3513
3460
 
3514
- if (vm) {
3515
- // in fallback mode, the allocation will always set children to
3516
- // empty and delegate the real allocation to the slot elements
3517
- allocateChildren(vnode, vm);
3518
- } // in fallback mode, the children will be always empty, so, nothing
3519
- // will happen, but in native, it does allocate the light dom
3461
+ case 2
3462
+ /* Element */
3463
+ :
3464
+ patchElement(n1, n2);
3465
+ break;
3520
3466
 
3467
+ case 3
3468
+ /* CustomElement */
3469
+ :
3470
+ patchCustomElement(n1, n2);
3471
+ break;
3472
+ }
3473
+ }
3521
3474
 
3522
- patchChildren(vnode.elm, oldVnode.children, vnode.children);
3475
+ function mount(node, parent, anchor) {
3476
+ switch (node.type) {
3477
+ case 0
3478
+ /* Text */
3479
+ :
3480
+ mountText(node, parent, anchor);
3481
+ break;
3523
3482
 
3524
- if (vm) {
3525
- // this is important to preserve the top to bottom synchronous rendering phase.
3483
+ case 1
3484
+ /* Comment */
3485
+ :
3486
+ mountComment(node, parent, anchor);
3487
+ break;
3526
3488
 
3489
+ case 2
3490
+ /* Element */
3491
+ :
3492
+ mountElement(node, parent, anchor);
3493
+ break;
3527
3494
 
3528
- rerenderVM(vm);
3529
- }
3530
- },
3531
- insert: function insert(vnode, parentNode, referenceNode) {
3532
- insertNode(vnode, parentNode, referenceNode);
3533
- var vm = getAssociatedVMIfPresent(vnode.elm);
3495
+ case 3
3496
+ /* CustomElement */
3497
+ :
3498
+ mountCustomElement(node, parent, anchor);
3499
+ break;
3500
+ }
3501
+ }
3534
3502
 
3535
- if (vm) {
3503
+ function patchText(n1, n2) {
3504
+ n2.elm = n1.elm;
3536
3505
 
3537
- runConnectedCallback(vm);
3538
- }
3506
+ if (n2.text !== n1.text) {
3507
+ updateTextContent(n2);
3508
+ }
3509
+ }
3510
+
3511
+ function mountText(node, parent, anchor) {
3512
+ var owner = node.owner;
3513
+ var textNode = node.elm = createText$1(node.text);
3514
+ linkNodeToShadow(textNode, owner);
3515
+ insertNode(textNode, parent, anchor);
3516
+ }
3517
+
3518
+ function patchComment(n1, n2) {
3519
+ n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
3520
+ // it is the case today.
3521
+
3522
+ if (n2.text !== n1.text) {
3523
+ updateTextContent(n2);
3524
+ }
3525
+ }
3539
3526
 
3540
- createChildrenHook(vnode);
3527
+ function mountComment(node, parent, anchor) {
3528
+ var owner = node.owner;
3529
+ var commentNode = node.elm = createComment$1(node.text);
3530
+ linkNodeToShadow(commentNode, owner);
3531
+ insertNode(commentNode, parent, anchor);
3532
+ }
3533
+
3534
+ function mountElement(vnode, parent, anchor) {
3535
+ var sel = vnode.sel,
3536
+ owner = vnode.owner,
3537
+ svg = vnode.data.svg;
3538
+ var namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3539
+ var elm = createElement$2(sel, namespace);
3540
+ linkNodeToShadow(elm, owner);
3541
+ fallbackElmHook(elm, vnode);
3542
+ vnode.elm = elm;
3543
+ patchElementPropsAndAttrs$1(null, vnode);
3544
+ insertNode(elm, parent, anchor);
3545
+ mountVNodes(vnode.children, elm, null);
3546
+ }
3547
+
3548
+ function patchElement(n1, n2) {
3549
+ var elm = n2.elm = n1.elm;
3550
+ patchElementPropsAndAttrs$1(n1, n2);
3551
+ patchChildren(n1.children, n2.children, elm);
3552
+ }
3541
3553
 
3542
- if (vm) {
3543
- appendVM(vm);
3554
+ function mountCustomElement(vnode, parent, anchor) {
3555
+ var sel = vnode.sel,
3556
+ owner = vnode.owner;
3557
+ var UpgradableConstructor = getUpgradableConstructor(sel);
3558
+ /**
3559
+ * Note: if the upgradable constructor does not expect, or throw when we new it
3560
+ * with a callback as the first argument, we could implement a more advanced
3561
+ * mechanism that only passes that argument if the constructor is known to be
3562
+ * an upgradable custom element.
3563
+ */
3564
+
3565
+ var vm;
3566
+ var elm = new UpgradableConstructor(function (elm) {
3567
+ // the custom element from the registry is expecting an upgrade callback
3568
+ vm = createViewModelHook(elm, vnode);
3569
+ });
3570
+ linkNodeToShadow(elm, owner);
3571
+ vnode.elm = elm;
3572
+ vnode.vm = vm;
3573
+
3574
+ if (vm) {
3575
+ allocateChildren(vnode, vm);
3576
+ } else if (vnode.ctor !== UpgradableConstructor) {
3577
+ throw new TypeError("Incorrect Component Constructor");
3578
+ }
3579
+
3580
+ patchElementPropsAndAttrs$1(null, vnode);
3581
+ insertNode(elm, parent, anchor);
3582
+
3583
+ if (vm) {
3584
+
3585
+ runConnectedCallback(vm);
3586
+ }
3587
+
3588
+ mountVNodes(vnode.children, elm, null);
3589
+
3590
+ if (vm) {
3591
+ appendVM(vm);
3592
+ }
3593
+ }
3594
+
3595
+ function patchCustomElement(n1, n2) {
3596
+ var elm = n2.elm = n1.elm;
3597
+ var vm = n2.vm = n1.vm;
3598
+ patchElementPropsAndAttrs$1(n1, n2);
3599
+
3600
+ if (!isUndefined$1(vm)) {
3601
+ // in fallback mode, the allocation will always set children to
3602
+ // empty and delegate the real allocation to the slot elements
3603
+ allocateChildren(n2, vm);
3604
+ } // in fallback mode, the children will be always empty, so, nothing
3605
+ // will happen, but in native, it does allocate the light dom
3606
+
3607
+
3608
+ patchChildren(n1.children, n2.children, elm);
3609
+
3610
+ if (!isUndefined$1(vm)) {
3611
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3612
+ // this is important to preserve the top to bottom synchronous rendering phase.
3613
+ rerenderVM(vm);
3614
+ }
3615
+ }
3616
+
3617
+ function mountVNodes(vnodes, parent, anchor) {
3618
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
3619
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
3620
+
3621
+ for (; start < end; ++start) {
3622
+ var vnode = vnodes[start];
3623
+
3624
+ if (isVNode(vnode)) {
3625
+ mount(vnode, parent, anchor);
3544
3626
  }
3545
- },
3546
- move: insertNode,
3547
- remove: function remove(vnode, parentNode) {
3548
- removeNode(vnode, parentNode);
3549
- var vm = getAssociatedVMIfPresent(vnode.elm);
3550
-
3551
- if (vm) {
3552
- // for custom elements we don't have to go recursively because the removeVM routine
3553
- // will take care of disconnecting any child VM attached to its shadow as well.
3554
- removeVM(vm);
3627
+ }
3628
+ }
3629
+
3630
+ function unmount(vnode, parent) {
3631
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3632
+ var type = vnode.type,
3633
+ elm = vnode.elm; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
3634
+ // subtree root, is the only element worth unmounting from the subtree.
3635
+
3636
+ if (doRemove) {
3637
+ removeNode(elm, parent);
3638
+ }
3639
+
3640
+ switch (type) {
3641
+ case 2
3642
+ /* Element */
3643
+ :
3644
+ unmountVNodes(vnode.children, elm);
3645
+ break;
3646
+
3647
+ case 3
3648
+ /* CustomElement */
3649
+ :
3650
+ {
3651
+ var vm = vnode.vm; // No need to unmount the children here, `removeVM` will take care of removing the
3652
+ // children.
3653
+
3654
+ if (!isUndefined$1(vm)) {
3655
+ removeVM(vm);
3656
+ }
3657
+ }
3658
+ }
3659
+ }
3660
+
3661
+ function unmountVNodes(vnodes, parent) {
3662
+ var doRemove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3663
+ var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
3664
+ var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : vnodes.length;
3665
+
3666
+ for (; start < end; ++start) {
3667
+ var ch = vnodes[start];
3668
+
3669
+ if (isVNode(ch)) {
3670
+ unmount(ch, parent, doRemove);
3555
3671
  }
3556
3672
  }
3557
- };
3673
+ }
3558
3674
 
3559
3675
  function isVNode(vnode) {
3560
3676
  return vnode != null;
@@ -3595,24 +3711,21 @@
3595
3711
  }
3596
3712
  }
3597
3713
 
3598
- function updateNodeHook(oldVnode, vnode) {
3714
+ function updateTextContent(vnode) {
3599
3715
  var elm = vnode.elm,
3600
3716
  text = vnode.text;
3601
3717
 
3602
- if (oldVnode.text !== text) {
3603
-
3604
- setText$1(elm, text);
3605
- }
3718
+ setText$1(elm, text);
3606
3719
  }
3607
3720
 
3608
- function insertNode(vnode, parentNode, referenceNode) {
3721
+ function insertNode(node, parent, anchor) {
3609
3722
 
3610
- insert$1(vnode.elm, parentNode, referenceNode);
3723
+ insert$1(node, parent, anchor);
3611
3724
  }
3612
3725
 
3613
- function removeNode(vnode, parentNode) {
3726
+ function removeNode(node, parent) {
3614
3727
 
3615
- remove$1(vnode.elm, parentNode);
3728
+ remove$1(node, parent);
3616
3729
  }
3617
3730
 
3618
3731
  function patchElementPropsAndAttrs$1(oldVnode, vnode) {
@@ -3655,14 +3768,6 @@
3655
3768
  }
3656
3769
  }
3657
3770
 
3658
- function patchChildren(parent, oldCh, newCh) {
3659
- if (hasDynamicChildren(newCh)) {
3660
- updateDynamicChildren(parent, oldCh, newCh);
3661
- } else {
3662
- updateStaticChildren(parent, oldCh, newCh);
3663
- }
3664
- }
3665
-
3666
3771
  function allocateChildren(vnode, vm) {
3667
3772
  // A component with slots will re-render because:
3668
3773
  // 1- There is a change of the internal state.
@@ -3728,43 +3833,13 @@
3728
3833
  return vm;
3729
3834
  }
3730
3835
 
3731
- function createChildrenHook(vnode) {
3732
- var elm = vnode.elm,
3733
- children = vnode.children;
3734
-
3735
- for (var j = 0; j < children.length; ++j) {
3736
- var ch = children[j];
3737
-
3738
- if (ch != null) {
3739
- ch.hook.create(ch);
3740
- ch.hook.insert(ch, elm, null);
3741
- }
3742
- }
3743
- }
3744
-
3745
- function removeChildren(vnode) {
3746
- // this method only needs to search on child vnodes from template
3747
- // to trigger the remove hook just in case some of those children
3748
- // are custom elements.
3749
- var children = vnode.children,
3750
- elm = vnode.elm;
3751
-
3752
- for (var j = 0, _len5 = children.length; j < _len5; ++j) {
3753
- var ch = children[j];
3754
-
3755
- if (!isNull(ch)) {
3756
- ch.hook.remove(ch, elm);
3757
- }
3758
- }
3759
- }
3760
-
3761
3836
  function allocateInSlot(vm, children) {
3762
3837
  var _a;
3763
3838
 
3764
3839
  var oldSlots = vm.cmpSlots;
3765
3840
  var cmpSlots = vm.cmpSlots = create(null);
3766
3841
 
3767
- for (var _i13 = 0, _len6 = children.length; _i13 < _len6; _i13 += 1) {
3842
+ for (var _i13 = 0, _len5 = children.length; _i13 < _len5; _i13 += 1) {
3768
3843
  var vnode = children[_i13];
3769
3844
 
3770
3845
  if (isNull(vnode)) {
@@ -3799,7 +3874,7 @@
3799
3874
  return;
3800
3875
  }
3801
3876
 
3802
- for (var _i14 = 0, _len7 = oldKeys.length; _i14 < _len7; _i14 += 1) {
3877
+ for (var _i14 = 0, _len6 = oldKeys.length; _i14 < _len6; _i14 += 1) {
3803
3878
  var key = oldKeys[_i14];
3804
3879
 
3805
3880
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
@@ -3850,28 +3925,7 @@
3850
3925
  return map;
3851
3926
  }
3852
3927
 
3853
- function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
3854
- for (; startIdx <= endIdx; ++startIdx) {
3855
- var ch = vnodes[startIdx];
3856
-
3857
- if (isVNode(ch)) {
3858
- ch.hook.create(ch);
3859
- ch.hook.insert(ch, parentElm, before);
3860
- }
3861
- }
3862
- }
3863
-
3864
- function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
3865
- for (; startIdx <= endIdx; ++startIdx) {
3866
- var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
3867
-
3868
- if (isVNode(ch)) {
3869
- ch.hook.remove(ch, parentElm);
3870
- }
3871
- }
3872
- }
3873
-
3874
- function updateDynamicChildren(parentElm, oldCh, newCh) {
3928
+ function updateDynamicChildren(oldCh, newCh, parent) {
3875
3929
  var oldStartIdx = 0;
3876
3930
  var newStartIdx = 0;
3877
3931
  var oldEndIdx = oldCh.length - 1;
@@ -3897,23 +3951,23 @@
3897
3951
  } else if (!isVNode(newEndVnode)) {
3898
3952
  newEndVnode = newCh[--newEndIdx];
3899
3953
  } else if (isSameVnode(oldStartVnode, newStartVnode)) {
3900
- patchVnode(oldStartVnode, newStartVnode);
3954
+ patch(oldStartVnode, newStartVnode);
3901
3955
  oldStartVnode = oldCh[++oldStartIdx];
3902
3956
  newStartVnode = newCh[++newStartIdx];
3903
3957
  } else if (isSameVnode(oldEndVnode, newEndVnode)) {
3904
- patchVnode(oldEndVnode, newEndVnode);
3958
+ patch(oldEndVnode, newEndVnode);
3905
3959
  oldEndVnode = oldCh[--oldEndIdx];
3906
3960
  newEndVnode = newCh[--newEndIdx];
3907
3961
  } else if (isSameVnode(oldStartVnode, newEndVnode)) {
3908
3962
  // Vnode moved right
3909
- patchVnode(oldStartVnode, newEndVnode);
3910
- newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling$1(oldEndVnode.elm));
3963
+ patch(oldStartVnode, newEndVnode);
3964
+ insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
3911
3965
  oldStartVnode = oldCh[++oldStartIdx];
3912
3966
  newEndVnode = newCh[--newEndIdx];
3913
3967
  } else if (isSameVnode(oldEndVnode, newStartVnode)) {
3914
3968
  // Vnode moved left
3915
- patchVnode(oldEndVnode, newStartVnode);
3916
- newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
3969
+ patch(oldEndVnode, newStartVnode);
3970
+ insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
3917
3971
  oldEndVnode = oldCh[--oldEndIdx];
3918
3972
  newStartVnode = newCh[++newStartIdx];
3919
3973
  } else {
@@ -3925,8 +3979,7 @@
3925
3979
 
3926
3980
  if (isUndefined$1(idxInOld)) {
3927
3981
  // New element
3928
- newStartVnode.hook.create(newStartVnode);
3929
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3982
+ mount(newStartVnode, parent, oldStartVnode.elm);
3930
3983
  newStartVnode = newCh[++newStartIdx];
3931
3984
  } else {
3932
3985
  elmToMove = oldCh[idxInOld];
@@ -3934,10 +3987,9 @@
3934
3987
  if (isVNode(elmToMove)) {
3935
3988
  if (elmToMove.sel !== newStartVnode.sel) {
3936
3989
  // New element
3937
- newStartVnode.hook.create(newStartVnode);
3938
- newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
3990
+ mount(newStartVnode, parent, oldStartVnode.elm);
3939
3991
  } else {
3940
- patchVnode(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
3992
+ patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
3941
3993
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3942
3994
  // so we only care about the `oldCh` object inside this function.
3943
3995
  // To avoid cloning over and over again, we check `clonedOldCh`
@@ -3950,7 +4002,7 @@
3950
4002
 
3951
4003
 
3952
4004
  oldCh[idxInOld] = undefined;
3953
- newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
4005
+ insertNode(elmToMove.elm, parent, oldStartVnode.elm);
3954
4006
  }
3955
4007
  }
3956
4008
 
@@ -3971,65 +4023,55 @@
3971
4023
  } while (!isVNode(n) && _i15 < newChEnd);
3972
4024
 
3973
4025
  before = isVNode(n) ? n.elm : null;
3974
- addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
4026
+ mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
3975
4027
  } else {
3976
- removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
4028
+ unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
3977
4029
  }
3978
4030
  }
3979
4031
  }
3980
4032
 
3981
- function updateStaticChildren(parentElm, oldCh, newCh) {
3982
- var oldChLength = oldCh.length;
3983
- var newChLength = newCh.length;
4033
+ function updateStaticChildren(c1, c2, parent) {
4034
+ var c1Length = c1.length;
4035
+ var c2Length = c2.length;
3984
4036
 
3985
- if (oldChLength === 0) {
4037
+ if (c1Length === 0) {
3986
4038
  // the old list is empty, we can directly insert anything new
3987
- addVnodes(parentElm, null, newCh, 0, newChLength);
4039
+ mountVNodes(c2, parent, null);
3988
4040
  return;
3989
4041
  }
3990
4042
 
3991
- if (newChLength === 0) {
4043
+ if (c2Length === 0) {
3992
4044
  // the old list is nonempty and the new list is empty so we can directly remove all old nodes
3993
4045
  // this is the case in which the dynamic children of an if-directive should be removed
3994
- removeVnodes(parentElm, oldCh, 0, oldChLength);
4046
+ unmountVNodes(c1, parent, true);
3995
4047
  return;
3996
4048
  } // if the old list is not empty, the new list MUST have the same
3997
4049
  // amount of nodes, that's why we call this static children
3998
4050
 
3999
4051
 
4000
- var referenceElm = null;
4052
+ var anchor = null;
4001
4053
 
4002
- for (var _i16 = newChLength - 1; _i16 >= 0; _i16 -= 1) {
4003
- var vnode = newCh[_i16];
4004
- var oldVNode = oldCh[_i16];
4054
+ for (var _i16 = c2Length - 1; _i16 >= 0; _i16 -= 1) {
4055
+ var n1 = c1[_i16];
4056
+ var n2 = c2[_i16];
4005
4057
 
4006
- if (vnode !== oldVNode) {
4007
- if (isVNode(oldVNode)) {
4008
- if (isVNode(vnode)) {
4009
- // both vnodes must be equivalent, and se just need to patch them
4010
- patchVnode(oldVNode, vnode);
4011
- referenceElm = vnode.elm;
4058
+ if (n2 !== n1) {
4059
+ if (isVNode(n1)) {
4060
+ if (isVNode(n2)) {
4061
+ // both vnodes are equivalent, and we just need to patch them
4062
+ patch(n1, n2);
4063
+ anchor = n2.elm;
4012
4064
  } else {
4013
4065
  // removing the old vnode since the new one is null
4014
- oldVNode.hook.remove(oldVNode, parentElm);
4066
+ unmount(n1, parent, true);
4015
4067
  }
4016
- } else if (isVNode(vnode)) {
4017
- // this condition is unnecessary
4018
- vnode.hook.create(vnode); // insert the new node one since the old one is null
4019
-
4020
- vnode.hook.insert(vnode, parentElm, referenceElm);
4021
- referenceElm = vnode.elm;
4068
+ } else if (isVNode(n2)) {
4069
+ mount(n2, parent, anchor);
4070
+ anchor = n2.elm;
4022
4071
  }
4023
4072
  }
4024
4073
  }
4025
4074
  }
4026
-
4027
- function patchVnode(oldVnode, vnode) {
4028
- if (oldVnode !== vnode) {
4029
- vnode.elm = oldVnode.elm;
4030
- vnode.hook.update(oldVnode, vnode);
4031
- }
4032
- }
4033
4075
  /*
4034
4076
  * Copyright (c) 2018, salesforce.com, inc.
4035
4077
  * All rights reserved.
@@ -4060,7 +4102,6 @@
4060
4102
  children: children,
4061
4103
  elm: elm,
4062
4104
  key: key,
4063
- hook: ElementHook,
4064
4105
  owner: vmBeingRendered
4065
4106
  };
4066
4107
  } // [t]ab[i]ndex function
@@ -4109,7 +4150,7 @@
4109
4150
  var vmBeingRendered = getVMBeingRendered();
4110
4151
 
4111
4152
  var key = data.key;
4112
- var elm;
4153
+ var elm, aChildren, vm;
4113
4154
  var vnode = {
4114
4155
  type: 3
4115
4156
  /* CustomElement */
@@ -4119,11 +4160,11 @@
4119
4160
  children: children,
4120
4161
  elm: elm,
4121
4162
  key: key,
4122
- hook: CustomElementHook,
4123
4163
  ctor: Ctor,
4124
4164
  owner: vmBeingRendered,
4125
- mode: 'open' // TODO [#1294]: this should be defined in Ctor
4126
-
4165
+ mode: 'open',
4166
+ aChildren: aChildren,
4167
+ vm: vm
4127
4168
  };
4128
4169
  addVNodeToChildLWC(vnode);
4129
4170
  return vnode;
@@ -4204,7 +4245,6 @@
4204
4245
  text: text,
4205
4246
  elm: elm,
4206
4247
  key: key,
4207
- hook: TextHook,
4208
4248
  owner: getVMBeingRendered()
4209
4249
  };
4210
4250
  } // [co]mment node
@@ -4220,7 +4260,6 @@
4220
4260
  text: text,
4221
4261
  elm: elm,
4222
4262
  key: key,
4223
- hook: CommentHook,
4224
4263
  owner: getVMBeingRendered()
4225
4264
  };
4226
4265
  } // [d]ynamic text
@@ -4917,6 +4956,7 @@
4917
4956
 
4918
4957
  function registerComponent(Ctor, _ref2) {
4919
4958
  var tmpl = _ref2.tmpl;
4959
+
4920
4960
  signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
4921
4961
  // without too much transformation
4922
4962
 
@@ -5010,7 +5050,7 @@
5010
5050
  def = vm.def,
5011
5051
  context = vm.context;
5012
5052
 
5013
- for (var _i22 = 0, _len8 = cbs.length; _i22 < _len8; ++_i22) {
5053
+ for (var _i22 = 0, _len7 = cbs.length; _i22 < _len7; ++_i22) {
5014
5054
  cbs[_i22].call(undefined, component, {}, def, context);
5015
5055
  }
5016
5056
  }
@@ -5022,7 +5062,7 @@
5022
5062
  */
5023
5063
 
5024
5064
 
5025
- function hydrate$1(vnode, node) {
5065
+ function hydrate(vnode, node) {
5026
5066
  switch (vnode.type) {
5027
5067
  case 0
5028
5068
  /* Text */
@@ -5054,7 +5094,7 @@
5054
5094
  var _a;
5055
5095
 
5056
5096
 
5057
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5097
+ setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5058
5098
  vnode.elm = node;
5059
5099
  }
5060
5100
 
@@ -5062,7 +5102,7 @@
5062
5102
  var _a;
5063
5103
 
5064
5104
 
5065
- node.nodeValue = (_a = vnode.text) !== null && _a !== void 0 ? _a : null;
5105
+ setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
5066
5106
  vnode.elm = node;
5067
5107
  }
5068
5108
 
@@ -5081,13 +5121,13 @@
5081
5121
  var props = vnode.data.props;
5082
5122
 
5083
5123
  if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5084
- if (elm.innerHTML === props.innerHTML) {
5124
+ if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
5085
5125
  // Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
5086
5126
  vnode.data = Object.assign(Object.assign({}, vnode.data), {
5087
5127
  props: cloneAndOmitKey(props, 'innerHTML')
5088
5128
  });
5089
5129
  } else {
5090
- logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5130
+ logWarn("Mismatch hydrating element <".concat(getProperty$1(elm, 'tagName').toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5091
5131
  }
5092
5132
  }
5093
5133
  }
@@ -5095,14 +5135,13 @@
5095
5135
  patchElementPropsAndAttrs(vnode);
5096
5136
 
5097
5137
  if (!isDomManual) {
5098
- hydrateChildren(vnode.elm.childNodes, vnode.children, vnode.owner);
5138
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
5099
5139
  }
5100
5140
  }
5101
5141
 
5102
5142
  function hydrateCustomElement(vnode, node) {
5103
5143
 
5104
5144
  var elm = node;
5105
- vnode.elm = elm;
5106
5145
  var sel = vnode.sel,
5107
5146
  mode = vnode.mode,
5108
5147
  ctor = vnode.ctor,
@@ -5112,6 +5151,8 @@
5112
5151
  owner: owner,
5113
5152
  tagName: sel
5114
5153
  });
5154
+ vnode.elm = elm;
5155
+ vnode.vm = vm;
5115
5156
  allocateChildren(vnode, vm);
5116
5157
  patchElementPropsAndAttrs(vnode); // Insert hook section:
5117
5158
 
@@ -5122,7 +5163,7 @@
5122
5163
  ) {
5123
5164
  // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5124
5165
  // Note: for Light DOM, this is handled while hydrating the VM
5125
- hydrateChildren(vnode.elm.childNodes, vnode.children);
5166
+ hydrateChildren(getChildNodes$1(vnode.elm), vnode.children);
5126
5167
  }
5127
5168
 
5128
5169
  hydrateVM(vm);
@@ -5137,7 +5178,7 @@
5137
5178
 
5138
5179
  if (!isNull(childVnode)) {
5139
5180
  var childNode = elmChildren[childNodeIndex];
5140
- hydrate$1(childVnode, childNode);
5181
+ hydrate(childVnode, childNode);
5141
5182
  childNodeIndex++;
5142
5183
  }
5143
5184
  }
@@ -5213,7 +5254,19 @@
5213
5254
  }
5214
5255
 
5215
5256
  function hydrateVM(vm) {
5216
- hydrate(vm);
5257
+ if (isTrue(vm.isDirty)) {
5258
+ // manually diffing/patching here.
5259
+ // This routine is:
5260
+ // patchShadowRoot(vm, children);
5261
+ // -> addVnodes.
5262
+ var children = renderComponent(vm);
5263
+ vm.children = children;
5264
+ var vmChildren = vm.renderMode === 0
5265
+ /* Light */
5266
+ ? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
5267
+ hydrateChildren(vmChildren, children);
5268
+ runRenderedCallback(vm);
5269
+ }
5217
5270
  } // just in case the component comes back, with this we guarantee re-rendering it
5218
5271
  // while preventing any attempt to rehydration until after reinsertion.
5219
5272
 
@@ -5333,7 +5386,11 @@
5333
5386
  /* Native */
5334
5387
  ;
5335
5388
  } else if (isNativeShadowDefined$1) {
5336
- if (def.shadowSupportMode === "any"
5389
+ if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
5390
+ shadowMode = 1
5391
+ /* Synthetic */
5392
+ ;
5393
+ } else if (def.shadowSupportMode === "any"
5337
5394
  /* Any */
5338
5395
  ) {
5339
5396
  shadowMode = 0
@@ -5397,22 +5454,6 @@
5397
5454
  }
5398
5455
  }
5399
5456
 
5400
- function hydrate(vm) {
5401
- if (isTrue(vm.isDirty)) {
5402
- // manually diffing/patching here.
5403
- // This routine is:
5404
- // patchShadowRoot(vm, children);
5405
- // -> addVnodes.
5406
- var children = renderComponent(vm);
5407
- vm.children = children;
5408
- var vmChildren = vm.renderMode === 0
5409
- /* Light */
5410
- ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5411
- hydrateChildren(vmChildren, children);
5412
- runRenderedCallback(vm);
5413
- }
5414
- }
5415
-
5416
5457
  function patchShadowRoot(vm, newCh) {
5417
5458
  var renderRoot = vm.renderRoot,
5418
5459
  oldCh = vm.children; // caching the new children collection
@@ -5430,7 +5471,7 @@
5430
5471
  , vm);
5431
5472
  }, function () {
5432
5473
  // job
5433
- patchChildren(renderRoot, oldCh, newCh);
5474
+ patchChildren(oldCh, newCh, renderRoot);
5434
5475
  }, function () {
5435
5476
  // post
5436
5477
  logOperationEnd(2
@@ -5487,13 +5528,13 @@
5487
5528
  });
5488
5529
  rehydrateQueue = []; // reset to a new queue
5489
5530
 
5490
- for (var _i26 = 0, _len9 = vms.length; _i26 < _len9; _i26 += 1) {
5531
+ for (var _i26 = 0, _len8 = vms.length; _i26 < _len8; _i26 += 1) {
5491
5532
  var vm = vms[_i26];
5492
5533
 
5493
5534
  try {
5494
5535
  rehydrate(vm);
5495
5536
  } catch (error) {
5496
- if (_i26 + 1 < _len9) {
5537
+ if (_i26 + 1 < _len8) {
5497
5538
  // pieces of the queue are still pending to be rehydrated, those should have priority
5498
5539
  if (rehydrateQueue.length === 0) {
5499
5540
  addCallbackToNextTick(flushRehydrationQueue);
@@ -5633,7 +5674,7 @@
5633
5674
 
5634
5675
 
5635
5676
  function recursivelyDisconnectChildren(vnodes) {
5636
- for (var _i28 = 0, _len10 = vnodes.length; _i28 < _len10; _i28 += 1) {
5677
+ for (var _i28 = 0, _len9 = vnodes.length; _i28 < _len9; _i28 += 1) {
5637
5678
  var vnode = vnodes[_i28];
5638
5679
 
5639
5680
  if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
@@ -5665,7 +5706,7 @@
5665
5706
  var children = vm.children,
5666
5707
  renderRoot = vm.renderRoot;
5667
5708
 
5668
- for (var _i29 = 0, _len11 = children.length; _i29 < _len11; _i29++) {
5709
+ for (var _i29 = 0, _len10 = children.length; _i29 < _len10; _i29++) {
5669
5710
  var child = children[_i29];
5670
5711
 
5671
5712
  if (!isNull(child) && !isUndefined$1(child.elm)) {
@@ -6016,7 +6057,7 @@
6016
6057
  function connectWireAdapters(vm) {
6017
6058
  var wiredConnecting = vm.context.wiredConnecting;
6018
6059
 
6019
- for (var _i30 = 0, _len12 = wiredConnecting.length; _i30 < _len12; _i30 += 1) {
6060
+ for (var _i30 = 0, _len11 = wiredConnecting.length; _i30 < _len11; _i30 += 1) {
6020
6061
  wiredConnecting[_i30]();
6021
6062
  }
6022
6063
  }
@@ -6025,7 +6066,7 @@
6025
6066
  var wiredDisconnecting = vm.context.wiredDisconnecting;
6026
6067
  runWithBoundaryProtection(vm, vm, noop, function () {
6027
6068
  // job
6028
- for (var _i31 = 0, _len13 = wiredDisconnecting.length; _i31 < _len13; _i31 += 1) {
6069
+ for (var _i31 = 0, _len12 = wiredDisconnecting.length; _i31 < _len12; _i31 += 1) {
6029
6070
  wiredDisconnecting[_i31]();
6030
6071
  }
6031
6072
  }, noop);
@@ -6110,7 +6151,7 @@
6110
6151
  hooksAreSet = true;
6111
6152
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6112
6153
  }
6113
- /* version: 2.9.0 */
6154
+ /* version: 2.10.0 */
6114
6155
 
6115
6156
  /*
6116
6157
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6127,6 +6168,7 @@
6127
6168
  // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
6128
6169
 
6129
6170
  var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
6171
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
6130
6172
  var styleElements = create(null);
6131
6173
  var styleSheets = create(null);
6132
6174
  var nodesToStyleSheets = new WeakMap();
@@ -6182,7 +6224,13 @@
6182
6224
  }
6183
6225
 
6184
6226
  if (!target.adoptedStyleSheets.includes(styleSheet)) {
6185
- target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
6227
+ if (supportsMutableAdoptedStyleSheets) {
6228
+ // This is only supported in later versions of Chromium:
6229
+ // https://chromestatus.com/feature/5638996492288000
6230
+ target.adoptedStyleSheets.push(styleSheet);
6231
+ } else {
6232
+ target.adoptedStyleSheets = [].concat(_toConsumableArray(target.adoptedStyleSheets), [styleSheet]);
6233
+ }
6186
6234
  }
6187
6235
  }
6188
6236
 
@@ -6464,6 +6512,173 @@
6464
6512
  setSetText(setText);
6465
6513
  setSsr(ssr);
6466
6514
  setAddEventListener(addEventListener);
6515
+ /*
6516
+ * Copyright (c) 2018, salesforce.com, inc.
6517
+ * All rights reserved.
6518
+ * SPDX-License-Identifier: MIT
6519
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6520
+ */
6521
+
6522
+ function resetShadowRootAndLightDom(element, Ctor) {
6523
+ if (element.shadowRoot) {
6524
+ var shadowRoot = element.shadowRoot;
6525
+
6526
+ while (!isNull(shadowRoot.firstChild)) {
6527
+ shadowRoot.removeChild(shadowRoot.firstChild);
6528
+ }
6529
+ }
6530
+
6531
+ if (Ctor.renderMode === 'light') {
6532
+ while (!isNull(element.firstChild)) {
6533
+ element.removeChild(element.firstChild);
6534
+ }
6535
+ }
6536
+ }
6537
+
6538
+ function createVMWithProps(element, Ctor, props) {
6539
+ createVM(element, Ctor, {
6540
+ mode: 'open',
6541
+ owner: null,
6542
+ tagName: element.tagName.toLowerCase()
6543
+ });
6544
+
6545
+ for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
6546
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
6547
+ key = _Object$entries2$_i[0],
6548
+ value = _Object$entries2$_i[1];
6549
+
6550
+ element[key] = value;
6551
+ }
6552
+ }
6553
+
6554
+ function hydrateComponent(element, Ctor) {
6555
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6556
+
6557
+ if (!(element instanceof Element)) {
6558
+ throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
6559
+ }
6560
+
6561
+ if (!isFunction$1(Ctor)) {
6562
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6563
+ }
6564
+
6565
+ if (!isObject(props) || isNull(props)) {
6566
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6567
+ }
6568
+
6569
+ if (getAssociatedVMIfPresent(element)) {
6570
+ /* eslint-disable-next-line no-console */
6571
+ console.warn("\"hydrateComponent\" expects an element that is not hydrated.", element);
6572
+ return;
6573
+ }
6574
+
6575
+ try {
6576
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6577
+ // and uses the same algo to create the stylesheets as in SSR.
6578
+ setIsHydrating(true);
6579
+ createVMWithProps(element, Ctor, props);
6580
+ hydrateRootElement(element); // set it back since now we finished hydration.
6581
+
6582
+ setIsHydrating(false);
6583
+ } catch (e) {
6584
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
6585
+ // with the client generated DOM.
6586
+
6587
+ /* eslint-disable-next-line no-console */
6588
+ console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
6589
+
6590
+ resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
6591
+
6592
+ createVMWithProps(element, Ctor, props);
6593
+ setIsHydrating(false);
6594
+ connectRootElement(element);
6595
+ } finally {
6596
+ // in case there's an error during recovery
6597
+ setIsHydrating(false);
6598
+ }
6599
+ }
6600
+ /*
6601
+ * Copyright (c) 2018, salesforce.com, inc.
6602
+ * All rights reserved.
6603
+ * SPDX-License-Identifier: MIT
6604
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6605
+ */
6606
+
6607
+ /**
6608
+ * This function builds a Web Component class from a LWC constructor so it can be
6609
+ * registered as a new element via customElements.define() at any given time.
6610
+ *
6611
+ * @deprecated since version 1.3.11
6612
+ *
6613
+ * @example
6614
+ * ```
6615
+ * import { buildCustomElementConstructor } from 'lwc';
6616
+ * import Foo from 'ns/foo';
6617
+ * const WC = buildCustomElementConstructor(Foo);
6618
+ * customElements.define('x-foo', WC);
6619
+ * const elm = document.createElement('x-foo');
6620
+ * ```
6621
+ */
6622
+
6623
+
6624
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6625
+
6626
+ return Ctor.CustomElementConstructor;
6627
+ } // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
6628
+ // This WeakSet usage is valid because this functionality is not meant to run in IE11.
6629
+
6630
+
6631
+ var hydratedCustomElements = new WeakSet();
6632
+
6633
+ function buildCustomElementConstructor(Ctor) {
6634
+ var HtmlPrototype = getComponentHtmlPrototype(Ctor);
6635
+ return /*#__PURE__*/function (_HtmlPrototype) {
6636
+ _inherits(_class, _HtmlPrototype);
6637
+
6638
+ var _super8 = _createSuper(_class);
6639
+
6640
+ function _class() {
6641
+ var _this6;
6642
+
6643
+ _classCallCheck(this, _class);
6644
+
6645
+ _this6 = _super8.call(this);
6646
+
6647
+ if (_this6.isConnected) {
6648
+ // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
6649
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
6650
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
6651
+ } else {
6652
+ createVM(_assertThisInitialized(_this6), Ctor, {
6653
+ mode: 'open',
6654
+ owner: null,
6655
+ tagName: _this6.tagName
6656
+ });
6657
+ }
6658
+
6659
+ return _this6;
6660
+ }
6661
+
6662
+ _createClass(_class, [{
6663
+ key: "connectedCallback",
6664
+ value: function connectedCallback() {
6665
+ if (hydratedCustomElements.has(this)) {
6666
+ // This is an un-upgraded element that was hydrated in the constructor.
6667
+ hydratedCustomElements.delete(this);
6668
+ } else {
6669
+ connectRootElement(this);
6670
+ }
6671
+ }
6672
+ }, {
6673
+ key: "disconnectedCallback",
6674
+ value: function disconnectedCallback() {
6675
+ disconnectRootElement(this);
6676
+ }
6677
+ }]);
6678
+
6679
+ return _class;
6680
+ }(HtmlPrototype);
6681
+ }
6467
6682
  /*
6468
6683
  * Copyright (c) 2018, salesforce.com, inc.
6469
6684
  * All rights reserved.
@@ -6473,6 +6688,7 @@
6473
6688
  // TODO [#2472]: Remove this workaround when appropriate.
6474
6689
  // eslint-disable-next-line lwc-internal/no-global-node
6475
6690
 
6691
+
6476
6692
  var _Node$1 = Node;
6477
6693
  var ConnectingSlot = new WeakMap();
6478
6694
  var DisconnectingSlot = new WeakMap();
@@ -6577,138 +6793,6 @@
6577
6793
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6578
6794
  */
6579
6795
 
6580
-
6581
- function hydrateComponent(element, Ctor) {
6582
- var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6583
-
6584
- if (!(element instanceof Element)) {
6585
- throw new TypeError("\"hydrateComponent\" expects a valid DOM element as the first parameter but instead received ".concat(element, "."));
6586
- }
6587
-
6588
- if (!isFunction$1(Ctor)) {
6589
- throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6590
- }
6591
-
6592
- if (!isObject(props) || isNull(props)) {
6593
- throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6594
- }
6595
-
6596
- try {
6597
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6598
- // and uses the same algo to create the stylesheets as in SSR.
6599
- setIsHydrating(true);
6600
- createVM(element, Ctor, {
6601
- mode: 'open',
6602
- owner: null,
6603
- tagName: element.tagName.toLowerCase()
6604
- });
6605
-
6606
- for (var _i33 = 0, _Object$entries2 = Object.entries(props); _i33 < _Object$entries2.length; _i33++) {
6607
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i33], 2),
6608
- key = _Object$entries2$_i[0],
6609
- value = _Object$entries2$_i[1];
6610
-
6611
- element[key] = value;
6612
- }
6613
-
6614
- hydrateRootElement(element); // set it back since now we finished hydration.
6615
-
6616
- setIsHydrating(false);
6617
- } catch (e) {
6618
- // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6619
- // the client generated DOM.
6620
-
6621
- /* eslint-disable-next-line no-console */
6622
- console.error('Recovering from error while hydrating: ', e);
6623
- setIsHydrating(false);
6624
- var newElem = createElement(element.tagName, {
6625
- is: Ctor,
6626
- mode: 'open'
6627
- });
6628
-
6629
- for (var _i34 = 0, _Object$entries3 = Object.entries(props); _i34 < _Object$entries3.length; _i34++) {
6630
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i34], 2),
6631
- _key3 = _Object$entries3$_i[0],
6632
- _value2 = _Object$entries3$_i[1];
6633
-
6634
- newElem[_key3] = _value2;
6635
- }
6636
-
6637
- element.parentNode.replaceChild(newElem, element);
6638
- }
6639
- }
6640
- /*
6641
- * Copyright (c) 2018, salesforce.com, inc.
6642
- * All rights reserved.
6643
- * SPDX-License-Identifier: MIT
6644
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6645
- */
6646
-
6647
- /**
6648
- * This function builds a Web Component class from a LWC constructor so it can be
6649
- * registered as a new element via customElements.define() at any given time.
6650
- *
6651
- * @deprecated since version 1.3.11
6652
- *
6653
- * @example
6654
- * ```
6655
- * import { buildCustomElementConstructor } from 'lwc';
6656
- * import Foo from 'ns/foo';
6657
- * const WC = buildCustomElementConstructor(Foo);
6658
- * customElements.define('x-foo', WC);
6659
- * const elm = document.createElement('x-foo');
6660
- * ```
6661
- */
6662
-
6663
-
6664
- function deprecatedBuildCustomElementConstructor(Ctor) {
6665
-
6666
- return Ctor.CustomElementConstructor;
6667
- }
6668
-
6669
- function buildCustomElementConstructor(Ctor) {
6670
- var HtmlPrototype = getComponentHtmlPrototype(Ctor);
6671
- return /*#__PURE__*/function (_HtmlPrototype) {
6672
- _inherits(_class, _HtmlPrototype);
6673
-
6674
- var _super8 = _createSuper(_class);
6675
-
6676
- function _class() {
6677
- var _this6;
6678
-
6679
- _classCallCheck(this, _class);
6680
-
6681
- _this6 = _super8.call(this);
6682
- createVM(_assertThisInitialized(_this6), Ctor, {
6683
- mode: 'open',
6684
- owner: null,
6685
- tagName: _this6.tagName
6686
- });
6687
- return _this6;
6688
- }
6689
-
6690
- _createClass(_class, [{
6691
- key: "connectedCallback",
6692
- value: function connectedCallback() {
6693
- connectRootElement(this);
6694
- }
6695
- }, {
6696
- key: "disconnectedCallback",
6697
- value: function disconnectedCallback() {
6698
- disconnectRootElement(this);
6699
- }
6700
- }]);
6701
-
6702
- return _class;
6703
- }(HtmlPrototype);
6704
- }
6705
- /*
6706
- * Copyright (c) 2018, salesforce.com, inc.
6707
- * All rights reserved.
6708
- * SPDX-License-Identifier: MIT
6709
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6710
- */
6711
-
6712
6796
  /**
6713
6797
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6714
6798
  * This API is subject to change or being removed.
@@ -6808,7 +6892,7 @@
6808
6892
  });
6809
6893
  freeze(LightningElement);
6810
6894
  seal(LightningElement.prototype);
6811
- /* version: 2.9.0 */
6895
+ /* version: 2.10.0 */
6812
6896
 
6813
6897
  exports.LightningElement = LightningElement;
6814
6898
  exports.__unstable__ProfilerControl = profilerControl;