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