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
@@ -197,7 +197,7 @@
197
197
  // we can't use typeof since it will fail when transpiling.
198
198
 
199
199
  const hasNativeSymbolSupport = /*@__PURE__*/(() => Symbol('x').toString() === 'Symbol(x)')();
200
- /** version: 2.5.10 */
200
+ /** version: 2.6.3 */
201
201
 
202
202
  /*
203
203
  * Copyright (c) 2018, salesforce.com, inc.
@@ -305,6 +305,7 @@
305
305
  getElementsByClassName: getElementsByClassName$1
306
306
  } = HTMLElement.prototype;
307
307
  const shadowRootGetter = hasOwnProperty.call(Element.prototype, 'shadowRoot') ? getOwnPropertyDescriptor(Element.prototype, 'shadowRoot').get : () => null;
308
+ const assignedSlotGetter$1 = hasOwnProperty.call(Element.prototype, 'assignedSlot') ? getOwnPropertyDescriptor(Element.prototype, 'assignedSlot').get : () => null;
308
309
  /*
309
310
  * Copyright (c) 2018, salesforce.com, inc.
310
311
  * All rights reserved.
@@ -524,20 +525,6 @@
524
525
 
525
526
  return cloned;
526
527
  }
527
- /**
528
- * Copyright (C) 2018 salesforce.com, inc.
529
- */
530
-
531
-
532
- if (!_globalThis.lwcRuntimeFlags) {
533
- Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
534
- value: create(null)
535
- });
536
- }
537
-
538
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
539
- /** version: 2.5.10 */
540
-
541
528
  /*
542
529
  * Copyright (c) 2018, salesforce.com, inc.
543
530
  * All rights reserved.
@@ -545,6 +532,7 @@
545
532
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
546
533
  */
547
534
 
535
+
548
536
  const eventTargetPrototype = typeof EventTarget !== 'undefined' ? EventTarget.prototype : _Node.prototype;
549
537
  const {
550
538
  addEventListener,
@@ -599,19 +587,9 @@
599
587
  assert.invariant(isFalse(isSyntheticShadowHost(currentTarget)), 'This routine should not be used to wrap event listeners for host elements and shadow roots.');
600
588
  }
601
589
 
602
- const {
603
- composed
604
- } = event;
605
- let shouldInvoke;
606
-
607
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
608
- shouldInvoke = !(eventToShadowRootMap.has(event) && isFalse(composed));
609
- } else {
610
- const actualTarget = getActualTarget(event);
611
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
612
- }
590
+ const actualTarget = getActualTarget(event);
613
591
 
614
- if (!shouldInvoke) {
592
+ if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
615
593
  return;
616
594
  }
617
595
 
@@ -632,25 +610,6 @@
632
610
 
633
611
 
634
612
  const eventToContextMap = new WeakMap();
635
-
636
- function isChildNode(root, node) {
637
- return !!(compareDocumentPosition.call(root, node) & DOCUMENT_POSITION_CONTAINED_BY);
638
- }
639
-
640
- const GET_ROOT_NODE_CONFIG_FALSE = {
641
- composed: false
642
- };
643
-
644
- function getRootNodeHost(node, options) {
645
- let rootNode = node.getRootNode(options);
646
-
647
- if (isSyntheticShadowRoot(rootNode)) {
648
- rootNode = getHost(rootNode);
649
- }
650
-
651
- return rootNode;
652
- }
653
-
654
613
  const customElementToWrappedListeners = new WeakMap();
655
614
 
656
615
  function getEventMap(elm) {
@@ -695,16 +654,9 @@
695
654
  currentTarget = getShadowRoot(currentTarget);
696
655
  }
697
656
 
698
- let shouldInvoke;
657
+ const actualTarget = getActualTarget(event);
699
658
 
700
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
701
- shouldInvoke = shouldInvokeShadowRootListener(event);
702
- } else {
703
- const actualTarget = getActualTarget(event);
704
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
705
- }
706
-
707
- if (shouldInvoke) {
659
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
708
660
  listener.call(currentTarget, event);
709
661
  }
710
662
  };
@@ -731,16 +683,9 @@
731
683
  customElementWrappedListener = function (event) {
732
684
  // currentTarget is always defined inside an event listener
733
685
  const currentTarget = eventCurrentTargetGetter.call(event);
734
- let shouldInvoke;
735
-
736
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
737
- shouldInvoke = shouldInvokeCustomElementListener(event);
738
- } else {
739
- const actualTarget = getActualTarget(event);
740
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
741
- }
686
+ const actualTarget = getActualTarget(event);
742
687
 
743
- if (shouldInvoke) {
688
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
744
689
  listener.call(currentTarget, event);
745
690
  }
746
691
  };
@@ -861,70 +806,6 @@
861
806
  }
862
807
  }
863
808
 
864
- function shouldInvokeCustomElementListener(event) {
865
- const {
866
- composed
867
- } = event;
868
-
869
- if (isTrue(composed)) {
870
- // Listeners on host elements should always be invoked for {composed: true} events.
871
- return true;
872
- } // If this {composed: false} event was dispatched on any root.
873
-
874
-
875
- if (eventToShadowRootMap.has(event)) {
876
- return false;
877
- }
878
-
879
- const target = eventTargetGetter.call(event);
880
- const currentTarget = eventCurrentTargetGetter.call(event); // If this {composed: false} event was dispatched on the current target host.
881
-
882
- if (target === currentTarget) {
883
- return true;
884
- } // At this point the event must be {bubbles: true, composed: false} and was dispatched from a
885
- // shadow-excluding descendant node. In this case, we only invoke the listener if the target
886
- // host was assigned to a slot in the composed subtree of the current target host.
887
-
888
-
889
- const targetHost = getRootNodeHost(target, GET_ROOT_NODE_CONFIG_FALSE);
890
- const currentTargetHost = currentTarget;
891
- return isChildNode(targetHost, currentTargetHost);
892
- }
893
-
894
- function shouldInvokeShadowRootListener(event) {
895
- const {
896
- composed
897
- } = event;
898
- const target = eventTargetGetter.call(event);
899
- const currentTarget = eventCurrentTargetGetter.call(event); // If the event was dispatched on the host or its root.
900
-
901
- if (target === currentTarget) {
902
- // Invoke the listener if the event was dispatched directly on the root.
903
- return eventToShadowRootMap.get(event) === getShadowRoot(target);
904
- } // At this point the event is {bubbles: true} and was dispatched from a shadow-including descendant node.
905
-
906
-
907
- if (isTrue(composed)) {
908
- // Invoke the listener if the event is {composed: true}.
909
- return true;
910
- } // At this point the event must be {bubbles: true, composed: false}.
911
-
912
-
913
- if (isTrue(eventToShadowRootMap.has(event))) {
914
- // Don't invoke the listener because the event was dispatched on a descendant root.
915
- return false;
916
- }
917
-
918
- const targetHost = getRootNodeHost(target, GET_ROOT_NODE_CONFIG_FALSE);
919
- const currentTargetHost = currentTarget;
920
- const isCurrentTargetSlotted = isChildNode(targetHost, currentTargetHost); // At this point the event must be {bubbles: true, composed: false} and was dispatched from a
921
- // shadow-excluding descendant node. In this case, we only invoke the listener if the target
922
- // host was assigned to a slot in the composed subtree of the current target host, or the
923
- // descendant node is in the shadow tree of the current root.
924
-
925
- return isCurrentTargetSlotted || targetHost === currentTargetHost;
926
- }
927
-
928
809
  function addCustomElementEventListener(type, listener, _options) {
929
810
  if (process.env.NODE_ENV !== 'production') {
930
811
  if (!isFunction(listener)) {
@@ -1041,6 +922,15 @@
1041
922
  function isNodeShadowed(node) {
1042
923
  return !isUndefined(getNodeOwnerKey(node));
1043
924
  }
925
+ /**
926
+ * Returns true if this node is a shadow host, is in a shadow host, or contains a shadow host
927
+ * anywhere in its tree.
928
+ */
929
+
930
+
931
+ function isNodeOrDescendantsShadowed(node) {
932
+ return isNodeShadowed(node) || isSyntheticShadowHost(node) || containsHost(node);
933
+ }
1044
934
  /*
1045
935
  * Copyright (c) 2018, salesforce.com, inc.
1046
936
  * All rights reserved.
@@ -1672,6 +1562,20 @@
1672
1562
  }
1673
1563
  }
1674
1564
  }
1565
+ /**
1566
+ * Copyright (C) 2018 salesforce.com, inc.
1567
+ */
1568
+
1569
+
1570
+ if (!_globalThis.lwcRuntimeFlags) {
1571
+ Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
1572
+ value: create(null)
1573
+ });
1574
+ }
1575
+
1576
+ const runtimeFlags = _globalThis.lwcRuntimeFlags;
1577
+ /** version: 2.6.3 */
1578
+
1675
1579
  /*
1676
1580
  * Copyright (c) 2018, salesforce.com, inc.
1677
1581
  * All rights reserved.
@@ -1686,7 +1590,6 @@
1686
1590
  * because we don't want to patch the children getters for those elements.
1687
1591
  */
1688
1592
 
1689
-
1690
1593
  function hasMountedChildren(node) {
1691
1594
  return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
1692
1595
  }
@@ -1765,7 +1668,9 @@
1765
1668
  }
1766
1669
 
1767
1670
  function compareDocumentPositionPatched(otherNode) {
1768
- if (this.getRootNode() === otherNode) {
1671
+ if (this === otherNode) {
1672
+ return 0;
1673
+ } else if (this.getRootNode() === otherNode) {
1769
1674
  // "this" is in a shadow tree where the shadow root is the "otherNode".
1770
1675
  return 10; // Node.DOCUMENT_POSITION_CONTAINS | Node.DOCUMENT_POSITION_PRECEDING
1771
1676
  } else if (getNodeOwnerKey(this) !== getNodeOwnerKey(otherNode)) {
@@ -1811,7 +1716,7 @@
1811
1716
  function childNodesGetterPatched() {
1812
1717
  if (isSyntheticShadowHost(this)) {
1813
1718
  const owner = getNodeOwner(this);
1814
- const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1719
+ const childNodes = isNull(owner) ? getFilteredChildNodes(this) : getAllMatches(owner, getFilteredChildNodes(this));
1815
1720
 
1816
1721
  if (process.env.NODE_ENV !== 'production' && isFalse(hasNativeSymbolSupport) && isExternalChildNodeAccessorFlagOn()) {
1817
1722
  // inserting a comment node as the first childNode to trick the IE11
@@ -1922,7 +1827,8 @@
1922
1827
  textContent: {
1923
1828
  get() {
1924
1829
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1925
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1830
+ // See note on get innerHTML in faux-shadow/element.ts
1831
+ if (isNodeOrDescendantsShadowed(this)) {
1926
1832
  return textContentGetterPatched.call(this);
1927
1833
  }
1928
1834
 
@@ -2157,7 +2063,22 @@
2157
2063
  }
2158
2064
 
2159
2065
  return rootNodes;
2160
- }
2066
+ } // Keep searching up the host tree until we find an element that is within the immediate shadow root
2067
+
2068
+
2069
+ const findAncestorHostInImmediateShadowRoot = (rootNode, targetRootNode) => {
2070
+ let host;
2071
+
2072
+ while (!isUndefined(host = rootNode.host)) {
2073
+ const thisRootNode = host.getRootNode();
2074
+
2075
+ if (thisRootNode === targetRootNode) {
2076
+ return host;
2077
+ }
2078
+
2079
+ rootNode = thisRootNode;
2080
+ }
2081
+ };
2161
2082
 
2162
2083
  function fauxElementsFromPoint(context, doc, left, top) {
2163
2084
  const elements = elementsFromPoint.call(doc, left, top);
@@ -2171,8 +2092,28 @@
2171
2092
  for (let i = 0; i < elements.length; i++) {
2172
2093
  const element = elements[i];
2173
2094
 
2174
- if (rootNodes.indexOf(element.getRootNode()) !== -1 && !isSyntheticSlotElement(element)) {
2175
- result.push(element);
2095
+ if (isSyntheticSlotElement(element)) {
2096
+ continue;
2097
+ }
2098
+
2099
+ const elementRootNode = element.getRootNode();
2100
+
2101
+ if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
2102
+ ArrayPush.call(result, element);
2103
+ continue;
2104
+ } // In cases where the host element is not visible but its shadow descendants are, then
2105
+ // we may get the shadow descendant instead of the host element here. (The
2106
+ // browser doesn't know the difference in synthetic shadow DOM.)
2107
+ // In native shadow DOM, however, elementsFromPoint would return the host but not
2108
+ // the child. So we need to detect if this shadow element's host is accessible from
2109
+ // the context's shadow root. Note we also need to be careful not to add the host
2110
+ // multiple times.
2111
+
2112
+
2113
+ const ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
2114
+
2115
+ if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
2116
+ ArrayPush.call(result, ancestorHost);
2176
2117
  }
2177
2118
  }
2178
2119
  }
@@ -2255,6 +2196,29 @@
2255
2196
  function isSyntheticShadowRoot(node) {
2256
2197
  const shadowRootRecord = InternalSlot.get(node);
2257
2198
  return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
2199
+ } // Return true if any descendant is a host element
2200
+
2201
+
2202
+ function containsHost(node) {
2203
+ // IE11 complains with "Unexpected call to method or property access." when calling walker.nextNode().
2204
+ // The fix for this is to only walk trees for nodes that are Node.ELEMENT_NODE.
2205
+ if (node.nodeType !== _Node.ELEMENT_NODE) {
2206
+ return false;
2207
+ } // IE requires all four arguments, even though the fourth is deprecated
2208
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker#browser_compatibility
2209
+ // @ts-ignore
2210
+
2211
+
2212
+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
2213
+ let descendant;
2214
+
2215
+ while (!isNull(descendant = walker.nextNode())) {
2216
+ if (isSyntheticShadowHost(descendant)) {
2217
+ return true;
2218
+ }
2219
+ }
2220
+
2221
+ return false;
2258
2222
  }
2259
2223
 
2260
2224
  let uid = 0;
@@ -2305,6 +2269,12 @@
2305
2269
  return `[object ShadowRoot]`;
2306
2270
  }
2307
2271
 
2272
+ },
2273
+ synthetic: {
2274
+ writable: false,
2275
+ enumerable: false,
2276
+ configurable: false,
2277
+ value: true
2308
2278
  }
2309
2279
  };
2310
2280
  const ShadowRootDescriptors = {
@@ -4143,6 +4113,14 @@
4143
4113
  */
4144
4114
 
4145
4115
  retargetRelatedTarget(MouseEvent);
4116
+ /*
4117
+ * Copyright (c) 2021, salesforce.com, inc.
4118
+ * All rights reserved.
4119
+ * SPDX-License-Identifier: MIT
4120
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4121
+ */
4122
+
4123
+ const assignedSlotGetter = hasOwnProperty.call(Text.prototype, 'assignedSlot') ? getOwnPropertyDescriptor(Text.prototype, 'assignedSlot').get : () => null;
4146
4124
  /*
4147
4125
  * Copyright (c) 2018, salesforce.com, inc.
4148
4126
  * All rights reserved.
@@ -4196,10 +4174,22 @@
4196
4174
  }
4197
4175
 
4198
4176
  function assignedSlotGetterPatched() {
4199
- const parentNode = parentNodeGetter.call(this);
4177
+ const parentNode = parentNodeGetter.call(this); // use original assignedSlot if parent has a native shdow root
4178
+
4179
+ if (parentNode instanceof Element) {
4180
+ const sr = shadowRootGetter.call(parentNode);
4181
+
4182
+ if (isInstanceOfNativeShadowRoot(sr)) {
4183
+ if (this instanceof Text) {
4184
+ return assignedSlotGetter.call(this);
4185
+ }
4186
+
4187
+ return assignedSlotGetter$1.call(this);
4188
+ }
4189
+ }
4200
4190
  /**
4201
4191
  * The node is assigned to a slot if:
4202
- * - it has a parent and it parent its parent is a slot element
4192
+ * - it has a parent and its parent is a slot element
4203
4193
  * - and if the slot owner key is different than the node owner key.
4204
4194
  *
4205
4195
  * When the slot and the slotted node are 2 different shadow trees, the owner keys will be
@@ -4208,6 +4198,7 @@
4208
4198
  * different than the node owner key (always `undefined`).
4209
4199
  */
4210
4200
 
4201
+
4211
4202
  if (!isNull(parentNode) && isSlotElement(parentNode) && getNodeOwnerKey(parentNode) !== getNodeOwnerKey(this)) {
4212
4203
  return parentNode;
4213
4204
  }
@@ -4424,7 +4415,10 @@
4424
4415
  innerHTML: {
4425
4416
  get() {
4426
4417
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4427
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
4418
+ // If this element is in synthetic shadow, if it's a synthetic shadow host,
4419
+ // or if any of its descendants are synthetic shadow hosts, then we can't
4420
+ // use the native innerHTML because it would expose private node internals.
4421
+ if (isNodeOrDescendantsShadowed(this)) {
4428
4422
  return innerHTMLGetterPatched.call(this);
4429
4423
  }
4430
4424
 
@@ -4449,7 +4443,8 @@
4449
4443
  outerHTML: {
4450
4444
  get() {
4451
4445
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4452
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
4446
+ // See notes above on get innerHTML
4447
+ if (isNodeOrDescendantsShadowed(this)) {
4453
4448
  return outerHTMLGetterPatched.call(this);
4454
4449
  }
4455
4450
 
@@ -5832,6 +5827,6 @@
5832
5827
 
5833
5828
  configurable: true
5834
5829
  });
5835
- /** version: 2.5.10 */
5830
+ /** version: 2.6.3 */
5836
5831
 
5837
5832
  })();