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
@@ -194,7 +194,7 @@ const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
194
194
  // we can't use typeof since it will fail when transpiling.
195
195
 
196
196
  const hasNativeSymbolSupport = /*@__PURE__*/(() => Symbol('x').toString() === 'Symbol(x)')();
197
- /** version: 2.5.10 */
197
+ /** version: 2.6.3 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) 2018, salesforce.com, inc.
@@ -302,6 +302,7 @@ const {
302
302
  getElementsByClassName: getElementsByClassName$1
303
303
  } = HTMLElement.prototype;
304
304
  const shadowRootGetter = hasOwnProperty.call(Element.prototype, 'shadowRoot') ? getOwnPropertyDescriptor(Element.prototype, 'shadowRoot').get : () => null;
305
+ const assignedSlotGetter$1 = hasOwnProperty.call(Element.prototype, 'assignedSlot') ? getOwnPropertyDescriptor(Element.prototype, 'assignedSlot').get : () => null;
305
306
  /*
306
307
  * Copyright (c) 2018, salesforce.com, inc.
307
308
  * All rights reserved.
@@ -521,20 +522,6 @@ function arrayFromCollection(collection) {
521
522
 
522
523
  return cloned;
523
524
  }
524
- /**
525
- * Copyright (C) 2018 salesforce.com, inc.
526
- */
527
-
528
-
529
- if (!_globalThis.lwcRuntimeFlags) {
530
- Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
531
- value: create(null)
532
- });
533
- }
534
-
535
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
536
- /** version: 2.5.10 */
537
-
538
525
  /*
539
526
  * Copyright (c) 2018, salesforce.com, inc.
540
527
  * All rights reserved.
@@ -542,6 +529,7 @@ const runtimeFlags = _globalThis.lwcRuntimeFlags;
542
529
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
543
530
  */
544
531
 
532
+
545
533
  const eventTargetPrototype = typeof EventTarget !== 'undefined' ? EventTarget.prototype : _Node.prototype;
546
534
  const {
547
535
  addEventListener,
@@ -596,19 +584,9 @@ function getEventListenerWrapper(fnOrObj) {
596
584
  assert.invariant(isFalse(isSyntheticShadowHost(currentTarget)), 'This routine should not be used to wrap event listeners for host elements and shadow roots.');
597
585
  }
598
586
 
599
- const {
600
- composed
601
- } = event;
602
- let shouldInvoke;
603
-
604
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
605
- shouldInvoke = !(eventToShadowRootMap.has(event) && isFalse(composed));
606
- } else {
607
- const actualTarget = getActualTarget(event);
608
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
609
- }
587
+ const actualTarget = getActualTarget(event);
610
588
 
611
- if (!shouldInvoke) {
589
+ if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
612
590
  return;
613
591
  }
614
592
 
@@ -629,25 +607,6 @@ function getEventListenerWrapper(fnOrObj) {
629
607
 
630
608
 
631
609
  const eventToContextMap = new WeakMap();
632
-
633
- function isChildNode(root, node) {
634
- return !!(compareDocumentPosition.call(root, node) & DOCUMENT_POSITION_CONTAINED_BY);
635
- }
636
-
637
- const GET_ROOT_NODE_CONFIG_FALSE = {
638
- composed: false
639
- };
640
-
641
- function getRootNodeHost(node, options) {
642
- let rootNode = node.getRootNode(options);
643
-
644
- if (isSyntheticShadowRoot(rootNode)) {
645
- rootNode = getHost(rootNode);
646
- }
647
-
648
- return rootNode;
649
- }
650
-
651
610
  const customElementToWrappedListeners = new WeakMap();
652
611
 
653
612
  function getEventMap(elm) {
@@ -692,16 +651,9 @@ function getWrappedShadowRootListener(listener) {
692
651
  currentTarget = getShadowRoot(currentTarget);
693
652
  }
694
653
 
695
- let shouldInvoke;
654
+ const actualTarget = getActualTarget(event);
696
655
 
697
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
698
- shouldInvoke = shouldInvokeShadowRootListener(event);
699
- } else {
700
- const actualTarget = getActualTarget(event);
701
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
702
- }
703
-
704
- if (shouldInvoke) {
656
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
705
657
  listener.call(currentTarget, event);
706
658
  }
707
659
  };
@@ -728,16 +680,9 @@ function getWrappedCustomElementListener(listener) {
728
680
  customElementWrappedListener = function (event) {
729
681
  // currentTarget is always defined inside an event listener
730
682
  const currentTarget = eventCurrentTargetGetter.call(event);
731
- let shouldInvoke;
732
-
733
- if (runtimeFlags.ENABLE_NON_COMPOSED_EVENTS_LEAKAGE) {
734
- shouldInvoke = shouldInvokeCustomElementListener(event);
735
- } else {
736
- const actualTarget = getActualTarget(event);
737
- shouldInvoke = shouldInvokeListener(event, actualTarget, currentTarget);
738
- }
683
+ const actualTarget = getActualTarget(event);
739
684
 
740
- if (shouldInvoke) {
685
+ if (shouldInvokeListener(event, actualTarget, currentTarget)) {
741
686
  listener.call(currentTarget, event);
742
687
  }
743
688
  };
@@ -858,70 +803,6 @@ function detachDOMListener(elm, type, wrappedListener) {
858
803
  }
859
804
  }
860
805
 
861
- function shouldInvokeCustomElementListener(event) {
862
- const {
863
- composed
864
- } = event;
865
-
866
- if (isTrue(composed)) {
867
- // Listeners on host elements should always be invoked for {composed: true} events.
868
- return true;
869
- } // If this {composed: false} event was dispatched on any root.
870
-
871
-
872
- if (eventToShadowRootMap.has(event)) {
873
- return false;
874
- }
875
-
876
- const target = eventTargetGetter.call(event);
877
- const currentTarget = eventCurrentTargetGetter.call(event); // If this {composed: false} event was dispatched on the current target host.
878
-
879
- if (target === currentTarget) {
880
- return true;
881
- } // At this point the event must be {bubbles: true, composed: false} and was dispatched from a
882
- // shadow-excluding descendant node. In this case, we only invoke the listener if the target
883
- // host was assigned to a slot in the composed subtree of the current target host.
884
-
885
-
886
- const targetHost = getRootNodeHost(target, GET_ROOT_NODE_CONFIG_FALSE);
887
- const currentTargetHost = currentTarget;
888
- return isChildNode(targetHost, currentTargetHost);
889
- }
890
-
891
- function shouldInvokeShadowRootListener(event) {
892
- const {
893
- composed
894
- } = event;
895
- const target = eventTargetGetter.call(event);
896
- const currentTarget = eventCurrentTargetGetter.call(event); // If the event was dispatched on the host or its root.
897
-
898
- if (target === currentTarget) {
899
- // Invoke the listener if the event was dispatched directly on the root.
900
- return eventToShadowRootMap.get(event) === getShadowRoot(target);
901
- } // At this point the event is {bubbles: true} and was dispatched from a shadow-including descendant node.
902
-
903
-
904
- if (isTrue(composed)) {
905
- // Invoke the listener if the event is {composed: true}.
906
- return true;
907
- } // At this point the event must be {bubbles: true, composed: false}.
908
-
909
-
910
- if (isTrue(eventToShadowRootMap.has(event))) {
911
- // Don't invoke the listener because the event was dispatched on a descendant root.
912
- return false;
913
- }
914
-
915
- const targetHost = getRootNodeHost(target, GET_ROOT_NODE_CONFIG_FALSE);
916
- const currentTargetHost = currentTarget;
917
- const isCurrentTargetSlotted = isChildNode(targetHost, currentTargetHost); // At this point the event must be {bubbles: true, composed: false} and was dispatched from a
918
- // shadow-excluding descendant node. In this case, we only invoke the listener if the target
919
- // host was assigned to a slot in the composed subtree of the current target host, or the
920
- // descendant node is in the shadow tree of the current root.
921
-
922
- return isCurrentTargetSlotted || targetHost === currentTargetHost;
923
- }
924
-
925
806
  function addCustomElementEventListener(type, listener, _options) {
926
807
  if (process.env.NODE_ENV !== 'production') {
927
808
  if (!isFunction(listener)) {
@@ -1038,6 +919,15 @@ function getNodeKey(node) {
1038
919
  function isNodeShadowed(node) {
1039
920
  return !isUndefined(getNodeOwnerKey(node));
1040
921
  }
922
+ /**
923
+ * Returns true if this node is a shadow host, is in a shadow host, or contains a shadow host
924
+ * anywhere in its tree.
925
+ */
926
+
927
+
928
+ function isNodeOrDescendantsShadowed(node) {
929
+ return isNodeShadowed(node) || isSyntheticShadowHost(node) || containsHost(node);
930
+ }
1041
931
  /*
1042
932
  * Copyright (c) 2018, salesforce.com, inc.
1043
933
  * All rights reserved.
@@ -1669,6 +1559,20 @@ function getOuterHTML(node) {
1669
1559
  }
1670
1560
  }
1671
1561
  }
1562
+ /**
1563
+ * Copyright (C) 2018 salesforce.com, inc.
1564
+ */
1565
+
1566
+
1567
+ if (!_globalThis.lwcRuntimeFlags) {
1568
+ Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
1569
+ value: create(null)
1570
+ });
1571
+ }
1572
+
1573
+ const runtimeFlags = _globalThis.lwcRuntimeFlags;
1574
+ /** version: 2.6.3 */
1575
+
1672
1576
  /*
1673
1577
  * Copyright (c) 2018, salesforce.com, inc.
1674
1578
  * All rights reserved.
@@ -1683,7 +1587,6 @@ function getOuterHTML(node) {
1683
1587
  * because we don't want to patch the children getters for those elements.
1684
1588
  */
1685
1589
 
1686
-
1687
1590
  function hasMountedChildren(node) {
1688
1591
  return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
1689
1592
  }
@@ -1762,7 +1665,9 @@ function parentElementGetterPatched() {
1762
1665
  }
1763
1666
 
1764
1667
  function compareDocumentPositionPatched(otherNode) {
1765
- if (this.getRootNode() === otherNode) {
1668
+ if (this === otherNode) {
1669
+ return 0;
1670
+ } else if (this.getRootNode() === otherNode) {
1766
1671
  // "this" is in a shadow tree where the shadow root is the "otherNode".
1767
1672
  return 10; // Node.DOCUMENT_POSITION_CONTAINS | Node.DOCUMENT_POSITION_PRECEDING
1768
1673
  } else if (getNodeOwnerKey(this) !== getNodeOwnerKey(otherNode)) {
@@ -1808,7 +1713,7 @@ function cloneNodePatched(deep) {
1808
1713
  function childNodesGetterPatched() {
1809
1714
  if (isSyntheticShadowHost(this)) {
1810
1715
  const owner = getNodeOwner(this);
1811
- const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1716
+ const childNodes = isNull(owner) ? getFilteredChildNodes(this) : getAllMatches(owner, getFilteredChildNodes(this));
1812
1717
 
1813
1718
  if (process.env.NODE_ENV !== 'production' && isFalse(hasNativeSymbolSupport) && isExternalChildNodeAccessorFlagOn()) {
1814
1719
  // inserting a comment node as the first childNode to trick the IE11
@@ -1919,7 +1824,8 @@ defineProperties(_Node.prototype, {
1919
1824
  textContent: {
1920
1825
  get() {
1921
1826
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1922
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1827
+ // See note on get innerHTML in faux-shadow/element.ts
1828
+ if (isNodeOrDescendantsShadowed(this)) {
1923
1829
  return textContentGetterPatched.call(this);
1924
1830
  }
1925
1831
 
@@ -2154,7 +2060,22 @@ function getAllRootNodes(node) {
2154
2060
  }
2155
2061
 
2156
2062
  return rootNodes;
2157
- }
2063
+ } // Keep searching up the host tree until we find an element that is within the immediate shadow root
2064
+
2065
+
2066
+ const findAncestorHostInImmediateShadowRoot = (rootNode, targetRootNode) => {
2067
+ let host;
2068
+
2069
+ while (!isUndefined(host = rootNode.host)) {
2070
+ const thisRootNode = host.getRootNode();
2071
+
2072
+ if (thisRootNode === targetRootNode) {
2073
+ return host;
2074
+ }
2075
+
2076
+ rootNode = thisRootNode;
2077
+ }
2078
+ };
2158
2079
 
2159
2080
  function fauxElementsFromPoint(context, doc, left, top) {
2160
2081
  const elements = elementsFromPoint.call(doc, left, top);
@@ -2168,8 +2089,28 @@ function fauxElementsFromPoint(context, doc, left, top) {
2168
2089
  for (let i = 0; i < elements.length; i++) {
2169
2090
  const element = elements[i];
2170
2091
 
2171
- if (rootNodes.indexOf(element.getRootNode()) !== -1 && !isSyntheticSlotElement(element)) {
2172
- result.push(element);
2092
+ if (isSyntheticSlotElement(element)) {
2093
+ continue;
2094
+ }
2095
+
2096
+ const elementRootNode = element.getRootNode();
2097
+
2098
+ if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
2099
+ ArrayPush.call(result, element);
2100
+ continue;
2101
+ } // In cases where the host element is not visible but its shadow descendants are, then
2102
+ // we may get the shadow descendant instead of the host element here. (The
2103
+ // browser doesn't know the difference in synthetic shadow DOM.)
2104
+ // In native shadow DOM, however, elementsFromPoint would return the host but not
2105
+ // the child. So we need to detect if this shadow element's host is accessible from
2106
+ // the context's shadow root. Note we also need to be careful not to add the host
2107
+ // multiple times.
2108
+
2109
+
2110
+ const ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
2111
+
2112
+ if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
2113
+ ArrayPush.call(result, ancestorHost);
2173
2114
  }
2174
2115
  }
2175
2116
  }
@@ -2252,6 +2193,29 @@ function isSyntheticShadowHost(node) {
2252
2193
  function isSyntheticShadowRoot(node) {
2253
2194
  const shadowRootRecord = InternalSlot.get(node);
2254
2195
  return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
2196
+ } // Return true if any descendant is a host element
2197
+
2198
+
2199
+ function containsHost(node) {
2200
+ // IE11 complains with "Unexpected call to method or property access." when calling walker.nextNode().
2201
+ // The fix for this is to only walk trees for nodes that are Node.ELEMENT_NODE.
2202
+ if (node.nodeType !== _Node.ELEMENT_NODE) {
2203
+ return false;
2204
+ } // IE requires all four arguments, even though the fourth is deprecated
2205
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker#browser_compatibility
2206
+ // @ts-ignore
2207
+
2208
+
2209
+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
2210
+ let descendant;
2211
+
2212
+ while (!isNull(descendant = walker.nextNode())) {
2213
+ if (isSyntheticShadowHost(descendant)) {
2214
+ return true;
2215
+ }
2216
+ }
2217
+
2218
+ return false;
2255
2219
  }
2256
2220
 
2257
2221
  let uid = 0;
@@ -2302,6 +2266,12 @@ const SyntheticShadowRootDescriptors = {
2302
2266
  return `[object ShadowRoot]`;
2303
2267
  }
2304
2268
 
2269
+ },
2270
+ synthetic: {
2271
+ writable: false,
2272
+ enumerable: false,
2273
+ configurable: false,
2274
+ value: true
2305
2275
  }
2306
2276
  };
2307
2277
  const ShadowRootDescriptors = {
@@ -4140,6 +4110,14 @@ retargetRelatedTarget(FocusEvent);
4140
4110
  */
4141
4111
 
4142
4112
  retargetRelatedTarget(MouseEvent);
4113
+ /*
4114
+ * Copyright (c) 2021, salesforce.com, inc.
4115
+ * All rights reserved.
4116
+ * SPDX-License-Identifier: MIT
4117
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4118
+ */
4119
+
4120
+ const assignedSlotGetter = hasOwnProperty.call(Text.prototype, 'assignedSlot') ? getOwnPropertyDescriptor(Text.prototype, 'assignedSlot').get : () => null;
4143
4121
  /*
4144
4122
  * Copyright (c) 2018, salesforce.com, inc.
4145
4123
  * All rights reserved.
@@ -4193,10 +4171,22 @@ function getFilteredSlotFlattenNodes(slot) {
4193
4171
  }
4194
4172
 
4195
4173
  function assignedSlotGetterPatched() {
4196
- const parentNode = parentNodeGetter.call(this);
4174
+ const parentNode = parentNodeGetter.call(this); // use original assignedSlot if parent has a native shdow root
4175
+
4176
+ if (parentNode instanceof Element) {
4177
+ const sr = shadowRootGetter.call(parentNode);
4178
+
4179
+ if (isInstanceOfNativeShadowRoot(sr)) {
4180
+ if (this instanceof Text) {
4181
+ return assignedSlotGetter.call(this);
4182
+ }
4183
+
4184
+ return assignedSlotGetter$1.call(this);
4185
+ }
4186
+ }
4197
4187
  /**
4198
4188
  * The node is assigned to a slot if:
4199
- * - it has a parent and it parent its parent is a slot element
4189
+ * - it has a parent and its parent is a slot element
4200
4190
  * - and if the slot owner key is different than the node owner key.
4201
4191
  *
4202
4192
  * When the slot and the slotted node are 2 different shadow trees, the owner keys will be
@@ -4205,6 +4195,7 @@ function assignedSlotGetterPatched() {
4205
4195
  * different than the node owner key (always `undefined`).
4206
4196
  */
4207
4197
 
4198
+
4208
4199
  if (!isNull(parentNode) && isSlotElement(parentNode) && getNodeOwnerKey(parentNode) !== getNodeOwnerKey(this)) {
4209
4200
  return parentNode;
4210
4201
  }
@@ -4421,7 +4412,10 @@ defineProperties(Element.prototype, {
4421
4412
  innerHTML: {
4422
4413
  get() {
4423
4414
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4424
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
4415
+ // If this element is in synthetic shadow, if it's a synthetic shadow host,
4416
+ // or if any of its descendants are synthetic shadow hosts, then we can't
4417
+ // use the native innerHTML because it would expose private node internals.
4418
+ if (isNodeOrDescendantsShadowed(this)) {
4425
4419
  return innerHTMLGetterPatched.call(this);
4426
4420
  }
4427
4421
 
@@ -4446,7 +4440,8 @@ defineProperties(Element.prototype, {
4446
4440
  outerHTML: {
4447
4441
  get() {
4448
4442
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4449
- if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
4443
+ // See notes above on get innerHTML
4444
+ if (isNodeOrDescendantsShadowed(this)) {
4450
4445
  return outerHTMLGetterPatched.call(this);
4451
4446
  }
4452
4447
 
@@ -5829,4 +5824,4 @@ defineProperty(Element.prototype, '$domManual$', {
5829
5824
 
5830
5825
  configurable: true
5831
5826
  });
5832
- /** version: 2.5.10 */
5827
+ /** version: 2.6.3 */