lwc 2.5.10 → 2.6.3

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 (41) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +674 -471
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +674 -471
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -9
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +647 -446
  5. package/dist/engine-dom/iife/es5/engine-dom.js +737 -433
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -9
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +704 -408
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +674 -471
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -9
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +647 -446
  11. package/dist/engine-dom/umd/es5/engine-dom.js +737 -433
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -9
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +704 -408
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +754 -549
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -9
  16. package/dist/engine-server/esm/es2017/engine-server.js +754 -549
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +135 -140
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +135 -140
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +135 -140
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +146 -137
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +146 -137
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +135 -140
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +135 -140
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +146 -137
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +146 -137
  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 +11 -11
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +11 -11
  36. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service.js +11 -11
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +11 -11
  41. package/package.json +8 -8
@@ -127,7 +127,7 @@
127
127
  const KEY__SHADOW_TOKEN = '$shadowToken$';
128
128
  const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
129
129
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
130
- /** version: 2.5.10 */
130
+ /** version: 2.6.3 */
131
131
 
132
132
  /*
133
133
  * Copyright (c) 2018, salesforce.com, inc.
@@ -235,6 +235,7 @@
235
235
  getElementsByClassName: getElementsByClassName$1
236
236
  } = HTMLElement.prototype;
237
237
  const shadowRootGetter = hasOwnProperty.call(Element.prototype, 'shadowRoot') ? getOwnPropertyDescriptor(Element.prototype, 'shadowRoot').get : () => null;
238
+ const assignedSlotGetter$1 = hasOwnProperty.call(Element.prototype, 'assignedSlot') ? getOwnPropertyDescriptor(Element.prototype, 'assignedSlot').get : () => null;
238
239
  /*
239
240
  * Copyright (c) 2018, salesforce.com, inc.
240
241
  * All rights reserved.
@@ -454,20 +455,6 @@
454
455
 
455
456
  return cloned;
456
457
  }
457
- /**
458
- * Copyright (C) 2018 salesforce.com, inc.
459
- */
460
-
461
-
462
- if (!_globalThis.lwcRuntimeFlags) {
463
- Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
464
- value: create(null)
465
- });
466
- }
467
-
468
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
469
- /** version: 2.5.10 */
470
-
471
458
  /*
472
459
  * Copyright (c) 2018, salesforce.com, inc.
473
460
  * All rights reserved.
@@ -475,6 +462,7 @@
475
462
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
476
463
  */
477
464
 
465
+
478
466
  const eventTargetPrototype = typeof EventTarget !== 'undefined' ? EventTarget.prototype : _Node.prototype;
479
467
  const {
480
468
  addEventListener,
@@ -525,19 +513,9 @@
525
513
  // This function is invoked from an event listener and currentTarget is always defined.
526
514
  const currentTarget = eventCurrentTargetGetter.call(event);
527
515
 
528
- const {
529
- composed
530
- } = event;
531
- let shouldInvoke;
532
-
533
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
534
- shouldInvoke = !(eventToShadowRootMap.has(event) && isFalse(composed));
535
- } else {
536
- const actualTarget = getActualTarget(event);
537
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
538
- }
516
+ const actualTarget = getActualTarget(event);
539
517
 
540
- if (!shouldInvoke) {
518
+ if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
541
519
  return;
542
520
  }
543
521
 
@@ -558,25 +536,6 @@
558
536
 
559
537
 
560
538
  const eventToContextMap = new WeakMap();
561
-
562
- function isChildNode(root, node) {
563
- return !!(compareDocumentPosition.call(root, node) & DOCUMENT_POSITION_CONTAINED_BY);
564
- }
565
-
566
- const GET_ROOT_NODE_CONFIG_FALSE = {
567
- composed: false
568
- };
569
-
570
- function getRootNodeHost(node, options) {
571
- let rootNode = node.getRootNode(options);
572
-
573
- if (isSyntheticShadowRoot(rootNode)) {
574
- rootNode = getHost(rootNode);
575
- }
576
-
577
- return rootNode;
578
- }
579
-
580
539
  const customElementToWrappedListeners = new WeakMap();
581
540
 
582
541
  function getEventMap(elm) {
@@ -621,16 +580,9 @@
621
580
  currentTarget = getShadowRoot(currentTarget);
622
581
  }
623
582
 
624
- let shouldInvoke;
583
+ const actualTarget = getActualTarget(event);
625
584
 
626
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
627
- shouldInvoke = shouldInvokeShadowRootListener(event);
628
- } else {
629
- const actualTarget = getActualTarget(event);
630
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
631
- }
632
-
633
- if (shouldInvoke) {
585
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
634
586
  listener.call(currentTarget, event);
635
587
  }
636
588
  };
@@ -657,16 +609,9 @@
657
609
  customElementWrappedListener = function (event) {
658
610
  // currentTarget is always defined inside an event listener
659
611
  const currentTarget = eventCurrentTargetGetter.call(event);
660
- let shouldInvoke;
661
-
662
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
663
- shouldInvoke = shouldInvokeCustomElementListener(event);
664
- } else {
665
- const actualTarget = getActualTarget(event);
666
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
667
- }
612
+ const actualTarget = getActualTarget(event);
668
613
 
669
- if (shouldInvoke) {
614
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
670
615
  listener.call(currentTarget, event);
671
616
  }
672
617
  };
@@ -787,70 +732,6 @@
787
732
  }
788
733
  }
789
734
 
790
- function shouldInvokeCustomElementListener(event) {
791
- const {
792
- composed
793
- } = event;
794
-
795
- if (isTrue(composed)) {
796
- // Listeners on host elements should always be invoked for {composed: true} events.
797
- return true;
798
- } // If this {composed: false} event was dispatched on any root.
799
-
800
-
801
- if (eventToShadowRootMap.has(event)) {
802
- return false;
803
- }
804
-
805
- const target = eventTargetGetter.call(event);
806
- const currentTarget = eventCurrentTargetGetter.call(event); // If this {composed: false} event was dispatched on the current target host.
807
-
808
- if (target === currentTarget) {
809
- return true;
810
- } // At this point the event must be {bubbles: true, composed: false} and was dispatched from a
811
- // shadow-excluding descendant node. In this case, we only invoke the listener if the target
812
- // host was assigned to a slot in the composed subtree of the current target host.
813
-
814
-
815
- const targetHost = getRootNodeHost(target, GET_ROOT_NODE_CONFIG_FALSE);
816
- const currentTargetHost = currentTarget;
817
- return isChildNode(targetHost, currentTargetHost);
818
- }
819
-
820
- function shouldInvokeShadowRootListener(event) {
821
- const {
822
- composed
823
- } = event;
824
- const target = eventTargetGetter.call(event);
825
- const currentTarget = eventCurrentTargetGetter.call(event); // If the event was dispatched on the host or its root.
826
-
827
- if (target === currentTarget) {
828
- // Invoke the listener if the event was dispatched directly on the root.
829
- return eventToShadowRootMap.get(event) === getShadowRoot(target);
830
- } // At this point the event is {bubbles: true} and was dispatched from a shadow-including descendant node.
831
-
832
-
833
- if (isTrue(composed)) {
834
- // Invoke the listener if the event is {composed: true}.
835
- return true;
836
- } // At this point the event must be {bubbles: true, composed: false}.
837
-
838
-
839
- if (isTrue(eventToShadowRootMap.has(event))) {
840
- // Don't invoke the listener because the event was dispatched on a descendant root.
841
- return false;
842
- }
843
-
844
- const targetHost = getRootNodeHost(target, GET_ROOT_NODE_CONFIG_FALSE);
845
- const currentTargetHost = currentTarget;
846
- const isCurrentTargetSlotted = isChildNode(targetHost, currentTargetHost); // At this point the event must be {bubbles: true, composed: false} and was dispatched from a
847
- // shadow-excluding descendant node. In this case, we only invoke the listener if the target
848
- // host was assigned to a slot in the composed subtree of the current target host, or the
849
- // descendant node is in the shadow tree of the current root.
850
-
851
- return isCurrentTargetSlotted || targetHost === currentTargetHost;
852
- }
853
-
854
735
  function addCustomElementEventListener(type, listener, _options) {
855
736
 
856
737
 
@@ -954,6 +835,15 @@
954
835
  function isNodeShadowed(node) {
955
836
  return !isUndefined(getNodeOwnerKey(node));
956
837
  }
838
+ /**
839
+ * Returns true if this node is a shadow host, is in a shadow host, or contains a shadow host
840
+ * anywhere in its tree.
841
+ */
842
+
843
+
844
+ function isNodeOrDescendantsShadowed(node) {
845
+ return isNodeShadowed(node) || isSyntheticShadowHost(node) || containsHost(node);
846
+ }
957
847
  /*
958
848
  * Copyright (c) 2018, salesforce.com, inc.
959
849
  * All rights reserved.
@@ -1575,6 +1465,20 @@
1575
1465
  }
1576
1466
  }
1577
1467
  }
1468
+ /**
1469
+ * Copyright (C) 2018 salesforce.com, inc.
1470
+ */
1471
+
1472
+
1473
+ if (!_globalThis.lwcRuntimeFlags) {
1474
+ Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
1475
+ value: create(null)
1476
+ });
1477
+ }
1478
+
1479
+ const runtimeFlags = _globalThis.lwcRuntimeFlags;
1480
+ /** version: 2.6.3 */
1481
+
1578
1482
  /*
1579
1483
  * Copyright (c) 2018, salesforce.com, inc.
1580
1484
  * All rights reserved.
@@ -1589,7 +1493,6 @@
1589
1493
  * because we don't want to patch the children getters for those elements.
1590
1494
  */
1591
1495
 
1592
-
1593
1496
  function hasMountedChildren(node) {
1594
1497
  return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
1595
1498
  }
@@ -1668,7 +1571,9 @@
1668
1571
  }
1669
1572
 
1670
1573
  function compareDocumentPositionPatched(otherNode) {
1671
- if (this.getRootNode() === otherNode) {
1574
+ if (this === otherNode) {
1575
+ return 0;
1576
+ } else if (this.getRootNode() === otherNode) {
1672
1577
  // "this" is in a shadow tree where the shadow root is the "otherNode".
1673
1578
  return 10; // Node.DOCUMENT_POSITION_CONTAINS | Node.DOCUMENT_POSITION_PRECEDING
1674
1579
  } else if (getNodeOwnerKey(this) !== getNodeOwnerKey(otherNode)) {
@@ -1714,7 +1619,7 @@
1714
1619
  function childNodesGetterPatched() {
1715
1620
  if (isSyntheticShadowHost(this)) {
1716
1621
  const owner = getNodeOwner(this);
1717
- const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1622
+ const childNodes = isNull(owner) ? getFilteredChildNodes(this) : getAllMatches(owner, getFilteredChildNodes(this));
1718
1623
 
1719
1624
  return createStaticNodeList(childNodes);
1720
1625
  } // nothing to do here since this does not have a synthetic shadow attached to it
@@ -1817,7 +1722,8 @@
1817
1722
  textContent: {
1818
1723
  get() {
1819
1724
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1820
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1725
+ // See note on get innerHTML in faux-shadow/element.ts
1726
+ if (isNodeOrDescendantsShadowed(this)) {
1821
1727
  return textContentGetterPatched.call(this);
1822
1728
  }
1823
1729
 
@@ -2021,7 +1927,22 @@
2021
1927
  }
2022
1928
 
2023
1929
  return rootNodes;
2024
- }
1930
+ } // Keep searching up the host tree until we find an element that is within the immediate shadow root
1931
+
1932
+
1933
+ const findAncestorHostInImmediateShadowRoot = (rootNode, targetRootNode) => {
1934
+ let host;
1935
+
1936
+ while (!isUndefined(host = rootNode.host)) {
1937
+ const thisRootNode = host.getRootNode();
1938
+
1939
+ if (thisRootNode === targetRootNode) {
1940
+ return host;
1941
+ }
1942
+
1943
+ rootNode = thisRootNode;
1944
+ }
1945
+ };
2025
1946
 
2026
1947
  function fauxElementsFromPoint(context, doc, left, top) {
2027
1948
  const elements = elementsFromPoint.call(doc, left, top);
@@ -2035,8 +1956,28 @@
2035
1956
  for (let i = 0; i < elements.length; i++) {
2036
1957
  const element = elements[i];
2037
1958
 
2038
- if (rootNodes.indexOf(element.getRootNode()) !== -1 && !isSyntheticSlotElement(element)) {
2039
- result.push(element);
1959
+ if (isSyntheticSlotElement(element)) {
1960
+ continue;
1961
+ }
1962
+
1963
+ const elementRootNode = element.getRootNode();
1964
+
1965
+ if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
1966
+ ArrayPush.call(result, element);
1967
+ continue;
1968
+ } // In cases where the host element is not visible but its shadow descendants are, then
1969
+ // we may get the shadow descendant instead of the host element here. (The
1970
+ // browser doesn't know the difference in synthetic shadow DOM.)
1971
+ // In native shadow DOM, however, elementsFromPoint would return the host but not
1972
+ // the child. So we need to detect if this shadow element's host is accessible from
1973
+ // the context's shadow root. Note we also need to be careful not to add the host
1974
+ // multiple times.
1975
+
1976
+
1977
+ const ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
1978
+
1979
+ if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
1980
+ ArrayPush.call(result, ancestorHost);
2040
1981
  }
2041
1982
  }
2042
1983
  }
@@ -2119,6 +2060,29 @@
2119
2060
  function isSyntheticShadowRoot(node) {
2120
2061
  const shadowRootRecord = InternalSlot.get(node);
2121
2062
  return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
2063
+ } // Return true if any descendant is a host element
2064
+
2065
+
2066
+ function containsHost(node) {
2067
+ // IE11 complains with "Unexpected call to method or property access." when calling walker.nextNode().
2068
+ // The fix for this is to only walk trees for nodes that are Node.ELEMENT_NODE.
2069
+ if (node.nodeType !== _Node.ELEMENT_NODE) {
2070
+ return false;
2071
+ } // IE requires all four arguments, even though the fourth is deprecated
2072
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker#browser_compatibility
2073
+ // @ts-ignore
2074
+
2075
+
2076
+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
2077
+ let descendant;
2078
+
2079
+ while (!isNull(descendant = walker.nextNode())) {
2080
+ if (isSyntheticShadowHost(descendant)) {
2081
+ return true;
2082
+ }
2083
+ }
2084
+
2085
+ return false;
2122
2086
  }
2123
2087
 
2124
2088
  let uid = 0;
@@ -2169,6 +2133,12 @@
2169
2133
  return `[object ShadowRoot]`;
2170
2134
  }
2171
2135
 
2136
+ },
2137
+ synthetic: {
2138
+ writable: false,
2139
+ enumerable: false,
2140
+ configurable: false,
2141
+ value: true
2172
2142
  }
2173
2143
  };
2174
2144
  const ShadowRootDescriptors = {
@@ -3966,6 +3936,14 @@
3966
3936
  */
3967
3937
 
3968
3938
  retargetRelatedTarget(MouseEvent);
3939
+ /*
3940
+ * Copyright (c) 2021, salesforce.com, inc.
3941
+ * All rights reserved.
3942
+ * SPDX-License-Identifier: MIT
3943
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3944
+ */
3945
+
3946
+ const assignedSlotGetter = hasOwnProperty.call(Text.prototype, 'assignedSlot') ? getOwnPropertyDescriptor(Text.prototype, 'assignedSlot').get : () => null;
3969
3947
  /*
3970
3948
  * Copyright (c) 2018, salesforce.com, inc.
3971
3949
  * All rights reserved.
@@ -4016,10 +3994,22 @@
4016
3994
  }
4017
3995
 
4018
3996
  function assignedSlotGetterPatched() {
4019
- const parentNode = parentNodeGetter.call(this);
3997
+ const parentNode = parentNodeGetter.call(this); // use original assignedSlot if parent has a native shdow root
3998
+
3999
+ if (parentNode instanceof Element) {
4000
+ const sr = shadowRootGetter.call(parentNode);
4001
+
4002
+ if (isInstanceOfNativeShadowRoot(sr)) {
4003
+ if (this instanceof Text) {
4004
+ return assignedSlotGetter.call(this);
4005
+ }
4006
+
4007
+ return assignedSlotGetter$1.call(this);
4008
+ }
4009
+ }
4020
4010
  /**
4021
4011
  * The node is assigned to a slot if:
4022
- * - it has a parent and it parent its parent is a slot element
4012
+ * - it has a parent and its parent is a slot element
4023
4013
  * - and if the slot owner key is different than the node owner key.
4024
4014
  *
4025
4015
  * When the slot and the slotted node are 2 different shadow trees, the owner keys will be
@@ -4028,6 +4018,7 @@
4028
4018
  * different than the node owner key (always `undefined`).
4029
4019
  */
4030
4020
 
4021
+
4031
4022
  if (!isNull(parentNode) && isSlotElement(parentNode) && getNodeOwnerKey(parentNode) !== getNodeOwnerKey(this)) {
4032
4023
  return parentNode;
4033
4024
  }
@@ -4244,7 +4235,10 @@
4244
4235
  innerHTML: {
4245
4236
  get() {
4246
4237
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4247
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
4238
+ // If this element is in synthetic shadow, if it's a synthetic shadow host,
4239
+ // or if any of its descendants are synthetic shadow hosts, then we can't
4240
+ // use the native innerHTML because it would expose private node internals.
4241
+ if (isNodeOrDescendantsShadowed(this)) {
4248
4242
  return innerHTMLGetterPatched.call(this);
4249
4243
  }
4250
4244
 
@@ -4269,7 +4263,8 @@
4269
4263
  outerHTML: {
4270
4264
  get() {
4271
4265
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4272
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
4266
+ // See notes above on get innerHTML
4267
+ if (isNodeOrDescendantsShadowed(this)) {
4273
4268
  return outerHTMLGetterPatched.call(this);
4274
4269
  }
4275
4270
 
@@ -5642,6 +5637,6 @@
5642
5637
 
5643
5638
  configurable: true
5644
5639
  });
5645
- /** version: 2.5.10 */
5640
+ /** version: 2.6.3 */
5646
5641
 
5647
5642
  }));