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