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