lwc 2.23.5 → 2.24.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 (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +216 -69
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +216 -69
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +194 -67
  5. package/dist/engine-dom/iife/es5/engine-dom.js +494 -313
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +463 -299
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +216 -69
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +194 -67
  11. package/dist/engine-dom/umd/es5/engine-dom.js +494 -313
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +463 -299
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +124 -16
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +124 -16
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +205 -168
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +205 -168
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +195 -158
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +25 -11
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +25 -11
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +205 -168
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +195 -158
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +25 -11
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +25 -11
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -151,7 +151,7 @@
151
151
  // We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
152
152
  // we can't use typeof since it will fail when transpiling.
153
153
  const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === 'Symbol(x)')();
154
- /** version: 2.23.5 */
154
+ /** version: 2.24.0 */
155
155
 
156
156
  /*
157
157
  * Copyright (c) 2018, salesforce.com, inc.
@@ -465,7 +465,7 @@
465
465
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
466
466
  }
467
467
  const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
468
- /** version: 2.23.5 */
468
+ /** version: 2.24.0 */
469
469
 
470
470
  /*
471
471
  * Copyright (c) 2018, salesforce.com, inc.
@@ -546,201 +546,238 @@
546
546
  * SPDX-License-Identifier: MIT
547
547
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
548
548
  */
549
- // when finding a slot in the DOM, we can fold it if it is contained
550
549
  // inside another slot.
550
+
551
551
  function foldSlotElement(slot) {
552
- let parent = parentElementGetter.call(slot);
553
- while (!isNull(parent) && isSlotElement(parent)) {
554
- slot = parent;
555
- parent = parentElementGetter.call(slot);
556
- }
557
- return slot;
552
+ let parent = parentElementGetter.call(slot);
553
+
554
+ while (!isNull(parent) && isSlotElement(parent)) {
555
+ slot = parent;
556
+ parent = parentElementGetter.call(slot);
557
+ }
558
+
559
+ return slot;
558
560
  }
561
+
559
562
  function isNodeSlotted(host, node) {
560
- if (process.env.NODE_ENV !== 'production') {
561
- assert.invariant(host instanceof HTMLElement, `isNodeSlotted() should be called with a host as the first argument instead of ${host}`);
562
- assert.invariant(node instanceof _Node, `isNodeSlotted() should be called with a node as the second argument instead of ${node}`);
563
- assert.invariant(compareDocumentPosition.call(node, host) & DOCUMENT_POSITION_CONTAINS, `isNodeSlotted() should never be called with a node that is not a child node of ${host}`);
564
- }
565
- const hostKey = getNodeKey(host);
566
- // this routine assumes that the node is coming from a different shadow (it is not owned by the host)
567
- // just in case the provided node is not an element
568
- let currentElement = node instanceof Element ? node : parentElementGetter.call(node);
569
- while (!isNull(currentElement) && currentElement !== host) {
570
- const elmOwnerKey = getNodeNearestOwnerKey(currentElement);
571
- const parent = parentElementGetter.call(currentElement);
572
- if (elmOwnerKey === hostKey) {
573
- // we have reached an element inside the host's template, and only if
574
- // that element is an slot, then the node is considered slotted
575
- return isSlotElement(currentElement);
576
- }
577
- else if (parent === host) {
578
- return false;
579
- }
580
- else if (!isNull(parent) && getNodeNearestOwnerKey(parent) !== elmOwnerKey) {
581
- // we are crossing a boundary of some sort since the elm and its parent
582
- // have different owner key. for slotted elements, this is possible
583
- // if the parent happens to be a slot.
584
- if (isSlotElement(parent)) {
585
- /**
586
- * the slot parent might be allocated inside another slot, think of:
587
- * <x-root> (<--- root element)
588
- * <x-parent> (<--- own by x-root)
589
- * <x-child> (<--- own by x-root)
590
- * <slot> (<--- own by x-child)
591
- * <slot> (<--- own by x-parent)
592
- * <div> (<--- own by x-root)
593
- *
594
- * while checking if x-parent has the div slotted, we need to traverse
595
- * up, but when finding the first slot, we skip that one in favor of the
596
- * most outer slot parent before jumping into its corresponding host.
597
- */
598
- currentElement = getNodeOwner(foldSlotElement(parent));
599
- if (!isNull(currentElement)) {
600
- if (currentElement === host) {
601
- // the slot element is a top level element inside the shadow
602
- // of a host that was allocated into host in question
603
- return true;
604
- }
605
- else if (getNodeNearestOwnerKey(currentElement) === hostKey) {
606
- // the slot element is an element inside the shadow
607
- // of a host that was allocated into host in question
608
- return true;
609
- }
610
- }
611
- }
612
- else {
613
- return false;
614
- }
615
- }
616
- else {
617
- currentElement = parent;
563
+ if (process.env.NODE_ENV !== 'production') {
564
+ assert.invariant(host instanceof HTMLElement, `isNodeSlotted() should be called with a host as the first argument instead of ${host}`);
565
+ assert.invariant(node instanceof _Node, `isNodeSlotted() should be called with a node as the second argument instead of ${node}`);
566
+ assert.invariant(compareDocumentPosition.call(node, host) & DOCUMENT_POSITION_CONTAINS, `isNodeSlotted() should never be called with a node that is not a child node of ${host}`);
567
+ }
568
+
569
+ const hostKey = getNodeKey(host); // this routine assumes that the node is coming from a different shadow (it is not owned by the host)
570
+ // just in case the provided node is not an element
571
+
572
+ let currentElement = node instanceof Element ? node : parentElementGetter.call(node);
573
+
574
+ while (!isNull(currentElement) && currentElement !== host) {
575
+ const elmOwnerKey = getNodeNearestOwnerKey(currentElement);
576
+ const parent = parentElementGetter.call(currentElement);
577
+
578
+ if (elmOwnerKey === hostKey) {
579
+ // we have reached an element inside the host's template, and only if
580
+ // that element is an slot, then the node is considered slotted
581
+ return isSlotElement(currentElement);
582
+ } else if (parent === host) {
583
+ return false;
584
+ } else if (!isNull(parent) && getNodeNearestOwnerKey(parent) !== elmOwnerKey) {
585
+ // we are crossing a boundary of some sort since the elm and its parent
586
+ // have different owner key. for slotted elements, this is possible
587
+ // if the parent happens to be a slot.
588
+ if (isSlotElement(parent)) {
589
+ /**
590
+ * the slot parent might be allocated inside another slot, think of:
591
+ * <x-root> (<--- root element)
592
+ * <x-parent> (<--- own by x-root)
593
+ * <x-child> (<--- own by x-root)
594
+ * <slot> (<--- own by x-child)
595
+ * <slot> (<--- own by x-parent)
596
+ * <div> (<--- own by x-root)
597
+ *
598
+ * while checking if x-parent has the div slotted, we need to traverse
599
+ * up, but when finding the first slot, we skip that one in favor of the
600
+ * most outer slot parent before jumping into its corresponding host.
601
+ */
602
+ currentElement = getNodeOwner(foldSlotElement(parent));
603
+
604
+ if (!isNull(currentElement)) {
605
+ if (currentElement === host) {
606
+ // the slot element is a top level element inside the shadow
607
+ // of a host that was allocated into host in question
608
+ return true;
609
+ } else if (getNodeNearestOwnerKey(currentElement) === hostKey) {
610
+ // the slot element is an element inside the shadow
611
+ // of a host that was allocated into host in question
612
+ return true;
613
+ }
618
614
  }
615
+ } else {
616
+ return false;
617
+ }
618
+ } else {
619
+ currentElement = parent;
619
620
  }
620
- return false;
621
+ }
622
+
623
+ return false;
621
624
  }
625
+
622
626
  function getNodeOwner(node) {
623
- if (!(node instanceof _Node)) {
624
- return null;
625
- }
626
- const ownerKey = getNodeNearestOwnerKey(node);
627
- if (isUndefined(ownerKey)) {
628
- return null;
629
- }
630
- let nodeOwner = node;
631
- // At this point, node is a valid node with owner identity, now we need to find the owner node
632
- // search for a custom element with a VM that owns the first element with owner identity attached to it
633
- while (!isNull(nodeOwner) && getNodeKey(nodeOwner) !== ownerKey) {
634
- nodeOwner = parentNodeGetter.call(nodeOwner);
635
- }
636
- if (isNull(nodeOwner)) {
637
- return null;
638
- }
639
- return nodeOwner;
627
+ if (!(node instanceof _Node)) {
628
+ return null;
629
+ }
630
+
631
+ const ownerKey = getNodeNearestOwnerKey(node);
632
+
633
+ if (isUndefined(ownerKey)) {
634
+ return null;
635
+ }
636
+
637
+ let nodeOwner = node; // At this point, node is a valid node with owner identity, now we need to find the owner node
638
+ // search for a custom element with a VM that owns the first element with owner identity attached to it
639
+
640
+ while (!isNull(nodeOwner) && getNodeKey(nodeOwner) !== ownerKey) {
641
+ nodeOwner = parentNodeGetter.call(nodeOwner);
642
+ }
643
+
644
+ if (isNull(nodeOwner)) {
645
+ return null;
646
+ }
647
+
648
+ return nodeOwner;
640
649
  }
641
650
  function isSyntheticSlotElement(node) {
642
- return isSlotElement(node) && isNodeShadowed(node);
651
+ return isSlotElement(node) && isNodeShadowed(node);
643
652
  }
644
653
  function isSlotElement(node) {
645
- return node instanceof HTMLSlotElement;
654
+ return node instanceof HTMLSlotElement;
646
655
  }
647
656
  function isNodeOwnedBy(owner, node) {
648
- if (process.env.NODE_ENV !== 'production') {
649
- assert.invariant(owner instanceof HTMLElement, `isNodeOwnedBy() should be called with an element as the first argument instead of ${owner}`);
650
- assert.invariant(node instanceof _Node, `isNodeOwnedBy() should be called with a node as the second argument instead of ${node}`);
651
- assert.invariant(compareDocumentPosition.call(node, owner) & DOCUMENT_POSITION_CONTAINS, `isNodeOwnedBy() should never be called with a node that is not a child node of ${owner}`);
652
- }
653
- const ownerKey = getNodeNearestOwnerKey(node);
654
- return isUndefined(ownerKey) || getNodeKey(owner) === ownerKey;
657
+ if (process.env.NODE_ENV !== 'production') {
658
+ assert.invariant(owner instanceof HTMLElement, `isNodeOwnedBy() should be called with an element as the first argument instead of ${owner}`);
659
+ assert.invariant(node instanceof _Node, `isNodeOwnedBy() should be called with a node as the second argument instead of ${node}`);
660
+ assert.invariant(compareDocumentPosition.call(node, owner) & DOCUMENT_POSITION_CONTAINS, `isNodeOwnedBy() should never be called with a node that is not a child node of ${owner}`);
661
+ }
662
+
663
+ const ownerKey = getNodeNearestOwnerKey(node);
664
+
665
+ if (isUndefined(ownerKey)) {
666
+ if (lwcRuntimeFlags.ENABLE_LIGHT_GET_ROOT_NODE_PATCH) {
667
+ // in case of root level light DOM element slotting into a synthetic shadow
668
+ const host = parentNodeGetter.call(node);
669
+
670
+ if (!isNull(host) && isSyntheticSlotElement(host)) {
671
+ return false;
672
+ }
673
+ } // in case of manually inserted elements
674
+
675
+
676
+ return true;
677
+ }
678
+
679
+ return getNodeKey(owner) === ownerKey;
655
680
  }
656
681
  function shadowRootChildNodes(root) {
657
- const elm = getHost(root);
658
- return getAllMatches(elm, arrayFromCollection(childNodesGetter.call(elm)));
682
+ const elm = getHost(root);
683
+ return getAllMatches(elm, arrayFromCollection(childNodesGetter.call(elm)));
659
684
  }
660
685
  function getAllSlottedMatches(host, nodeList) {
661
- const filteredAndPatched = [];
662
- for (let i = 0, len = nodeList.length; i < len; i += 1) {
663
- const node = nodeList[i];
664
- if (!isNodeOwnedBy(host, node) && isNodeSlotted(host, node)) {
665
- ArrayPush.call(filteredAndPatched, node);
666
- }
686
+ const filteredAndPatched = [];
687
+
688
+ for (let i = 0, len = nodeList.length; i < len; i += 1) {
689
+ const node = nodeList[i];
690
+
691
+ if (!isNodeOwnedBy(host, node) && isNodeSlotted(host, node)) {
692
+ ArrayPush.call(filteredAndPatched, node);
667
693
  }
668
- return filteredAndPatched;
694
+ }
695
+
696
+ return filteredAndPatched;
669
697
  }
670
698
  function getFirstSlottedMatch(host, nodeList) {
671
- for (let i = 0, len = nodeList.length; i < len; i += 1) {
672
- const node = nodeList[i];
673
- if (!isNodeOwnedBy(host, node) && isNodeSlotted(host, node)) {
674
- return node;
675
- }
699
+ for (let i = 0, len = nodeList.length; i < len; i += 1) {
700
+ const node = nodeList[i];
701
+
702
+ if (!isNodeOwnedBy(host, node) && isNodeSlotted(host, node)) {
703
+ return node;
676
704
  }
677
- return null;
705
+ }
706
+
707
+ return null;
678
708
  }
679
709
  function getAllMatches(owner, nodeList) {
680
- const filteredAndPatched = [];
681
- for (let i = 0, len = nodeList.length; i < len; i += 1) {
682
- const node = nodeList[i];
683
- const isOwned = isNodeOwnedBy(owner, node);
684
- if (isOwned) {
685
- // Patch querySelector, querySelectorAll, etc
686
- // if element is owned by VM
687
- ArrayPush.call(filteredAndPatched, node);
688
- }
710
+ const filteredAndPatched = [];
711
+
712
+ for (let i = 0, len = nodeList.length; i < len; i += 1) {
713
+ const node = nodeList[i];
714
+ const isOwned = isNodeOwnedBy(owner, node);
715
+
716
+ if (isOwned) {
717
+ // Patch querySelector, querySelectorAll, etc
718
+ // if element is owned by VM
719
+ ArrayPush.call(filteredAndPatched, node);
689
720
  }
690
- return filteredAndPatched;
721
+ }
722
+
723
+ return filteredAndPatched;
691
724
  }
692
725
  function getFirstMatch(owner, nodeList) {
693
- for (let i = 0, len = nodeList.length; i < len; i += 1) {
694
- if (isNodeOwnedBy(owner, nodeList[i])) {
695
- return nodeList[i];
696
- }
726
+ for (let i = 0, len = nodeList.length; i < len; i += 1) {
727
+ if (isNodeOwnedBy(owner, nodeList[i])) {
728
+ return nodeList[i];
697
729
  }
698
- return null;
730
+ }
731
+
732
+ return null;
699
733
  }
700
734
  function shadowRootQuerySelector(root, selector) {
701
- const elm = getHost(root);
702
- const nodeList = arrayFromCollection(querySelectorAll$1.call(elm, selector));
703
- return getFirstMatch(elm, nodeList);
735
+ const elm = getHost(root);
736
+ const nodeList = arrayFromCollection(querySelectorAll$1.call(elm, selector));
737
+ return getFirstMatch(elm, nodeList);
704
738
  }
705
739
  function shadowRootQuerySelectorAll(root, selector) {
706
- const elm = getHost(root);
707
- const nodeList = querySelectorAll$1.call(elm, selector);
708
- return getAllMatches(elm, arrayFromCollection(nodeList));
740
+ const elm = getHost(root);
741
+ const nodeList = querySelectorAll$1.call(elm, selector);
742
+ return getAllMatches(elm, arrayFromCollection(nodeList));
709
743
  }
710
744
  function getFilteredChildNodes(node) {
711
- if (!isSyntheticShadowHost(node) && !isSlotElement(node)) {
712
- // regular element - fast path
713
- const children = childNodesGetter.call(node);
714
- return arrayFromCollection(children);
715
- }
716
- if (isSyntheticShadowHost(node)) {
717
- // we need to get only the nodes that were slotted
718
- const slots = arrayFromCollection(querySelectorAll$1.call(node, 'slot'));
719
- const resolver = getShadowRootResolver(getShadowRoot(node));
720
- // Typescript is inferring the wrong function type for this particular
721
- // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
722
- // @ts-ignore type-mismatch
723
- return ArrayReduce.call(slots, (seed, slot) => {
724
- if (resolver === getShadowRootResolver(slot)) {
725
- ArrayPush.apply(seed, getFilteredSlotAssignedNodes(slot));
726
- }
727
- return seed;
728
- }, []);
729
- }
730
- else {
731
- // slot element
732
- const children = arrayFromCollection(childNodesGetter.call(node));
733
- const resolver = getShadowRootResolver(node);
734
- return ArrayFilter.call(children, (child) => resolver === getShadowRootResolver(child));
735
- }
745
+ if (!isSyntheticShadowHost(node) && !isSlotElement(node)) {
746
+ // regular element - fast path
747
+ const children = childNodesGetter.call(node);
748
+ return arrayFromCollection(children);
749
+ }
750
+
751
+ if (isSyntheticShadowHost(node)) {
752
+ // we need to get only the nodes that were slotted
753
+ const slots = arrayFromCollection(querySelectorAll$1.call(node, 'slot'));
754
+ const resolver = getShadowRootResolver(getShadowRoot(node)); // Typescript is inferring the wrong function type for this particular
755
+ // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
756
+ // @ts-ignore type-mismatch
757
+
758
+ return ArrayReduce.call(slots, (seed, slot) => {
759
+ if (resolver === getShadowRootResolver(slot)) {
760
+ ArrayPush.apply(seed, getFilteredSlotAssignedNodes(slot));
761
+ }
762
+
763
+ return seed;
764
+ }, []);
765
+ } else {
766
+ // slot element
767
+ const children = arrayFromCollection(childNodesGetter.call(node));
768
+ const resolver = getShadowRootResolver(node);
769
+ return ArrayFilter.call(children, child => resolver === getShadowRootResolver(child));
770
+ }
736
771
  }
737
772
  function getFilteredSlotAssignedNodes(slot) {
738
- const owner = getNodeOwner(slot);
739
- if (isNull(owner)) {
740
- return [];
741
- }
742
- const childNodes = arrayFromCollection(childNodesGetter.call(slot));
743
- return ArrayFilter.call(childNodes, (child) => !isNodeShadowed(child) || !isNodeOwnedBy(owner, child));
773
+ const owner = getNodeOwner(slot);
774
+
775
+ if (isNull(owner)) {
776
+ return [];
777
+ }
778
+
779
+ const childNodes = arrayFromCollection(childNodesGetter.call(slot));
780
+ return ArrayFilter.call(childNodes, child => !isNodeShadowed(child) || !isNodeOwnedBy(owner, child));
744
781
  }
745
782
 
746
783
  /*
@@ -3965,11 +4002,11 @@
3965
4002
  // element with shadowRoot attached
3966
4003
  const owner = getNodeOwner(this);
3967
4004
 
3968
- if (isNull(owner)) {
3969
- return null;
3970
- } else if (getNodeKey(this)) {
4005
+ if (!isUndefined(getNodeKey(this))) {
3971
4006
  // it is a custom element, and we should then filter by slotted elements
3972
4007
  return getFirstSlottedMatch(this, nodeList);
4008
+ } else if (isNull(owner)) {
4009
+ return null;
3973
4010
  } else {
3974
4011
  // regular element, we should then filter by ownership
3975
4012
  return getFirstMatch(owner, nodeList);
@@ -4016,11 +4053,11 @@
4016
4053
  // element with shadowRoot attached
4017
4054
  const owner = getNodeOwner(context);
4018
4055
 
4019
- if (isNull(owner)) {
4020
- filtered = [];
4021
- } else if (getNodeKey(context)) {
4056
+ if (!isUndefined(getNodeKey(context))) {
4022
4057
  // it is a custom element, and we should then filter by slotted elements
4023
4058
  filtered = getAllSlottedMatches(context, unfilteredNodes);
4059
+ } else if (isNull(owner)) {
4060
+ filtered = [];
4024
4061
  } else {
4025
4062
  // regular element, we should then filter by ownership
4026
4063
  filtered = getAllMatches(owner, unfilteredNodes);
@@ -5136,6 +5173,6 @@
5136
5173
  }));
5137
5174
  });
5138
5175
  }
5139
- /** version: 2.23.5 */
5176
+ /** version: 2.24.0 */
5140
5177
 
5141
5178
  })();