lwc 2.5.1 → 2.5.4

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 +84 -73
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +85 -74
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +68 -55
  5. package/dist/engine-dom/iife/es5/engine-dom.js +125 -93
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +106 -72
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +86 -75
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +69 -56
  11. package/dist/engine-dom/umd/es5/engine-dom.js +126 -94
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +107 -73
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +66 -73
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +66 -73
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +75 -39
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +76 -40
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +75 -39
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +76 -40
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +75 -39
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +77 -41
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +76 -40
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +77 -41
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +76 -40
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +3 -3
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +3 -3
  33. package/dist/wire-service/iife/es5/wire-service.js +3 -3
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +3 -3
  36. package/dist/wire-service/umd/es2017/wire-service.js +4 -4
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +4 -4
  38. package/dist/wire-service/umd/es5/wire-service.js +4 -4
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +4 -4
  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.1 */
197
+ /** version: 2.5.4 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) 2018, salesforce.com, inc.
@@ -533,7 +533,7 @@ if (!_globalThis.lwcRuntimeFlags) {
533
533
  }
534
534
 
535
535
  const runtimeFlags = _globalThis.lwcRuntimeFlags;
536
- /** version: 2.5.1 */
536
+ /** version: 2.5.4 */
537
537
 
538
538
  /*
539
539
  * Copyright (c) 2018, salesforce.com, inc.
@@ -593,7 +593,7 @@ function getEventListenerWrapper(fnOrObj) {
593
593
  const currentTarget = eventCurrentTargetGetter.call(event);
594
594
 
595
595
  if (process.env.NODE_ENV !== 'production') {
596
- assert.invariant(isFalse(isHostElement(currentTarget)), 'This routine should not be used to wrap event listeners for host elements and shadow roots.');
596
+ assert.invariant(isFalse(isSyntheticShadowHost(currentTarget)), 'This routine should not be used to wrap event listeners for host elements and shadow roots.');
597
597
  }
598
598
 
599
599
  const {
@@ -1038,6 +1038,15 @@ function getNodeKey(node) {
1038
1038
  function isNodeShadowed(node) {
1039
1039
  return !isUndefined(getNodeOwnerKey(node));
1040
1040
  }
1041
+ /**
1042
+ * Returns true if this node is a shadow host, is in a shadow host, or contains a shadow host
1043
+ * anywhere in its tree.
1044
+ */
1045
+
1046
+
1047
+ function isNodeOrDescendantsShadowed(node) {
1048
+ return isNodeShadowed(node) || isSyntheticShadowHost(node) || containsHost(node);
1049
+ }
1041
1050
  /*
1042
1051
  * Copyright (c) 2018, salesforce.com, inc.
1043
1052
  * All rights reserved.
@@ -1237,13 +1246,13 @@ function shadowRootQuerySelectorAll(root, selector) {
1237
1246
  }
1238
1247
 
1239
1248
  function getFilteredChildNodes(node) {
1240
- if (!isHostElement(node) && !isSlotElement(node)) {
1249
+ if (!isSyntheticShadowHost(node) && !isSlotElement(node)) {
1241
1250
  // regular element - fast path
1242
1251
  const children = childNodesGetter.call(node);
1243
1252
  return arrayFromCollection(children);
1244
1253
  }
1245
1254
 
1246
- if (isHostElement(node)) {
1255
+ if (isSyntheticShadowHost(node)) {
1247
1256
  // we need to get only the nodes that were slotted
1248
1257
  const slots = arrayFromCollection(querySelectorAll$1.call(node, 'slot'));
1249
1258
  const resolver = getShadowRootResolver(getShadowRoot(node)); // Typescript is inferring the wrong function type for this particular
@@ -1685,7 +1694,7 @@ function getOuterHTML(node) {
1685
1694
 
1686
1695
 
1687
1696
  function hasMountedChildren(node) {
1688
- return isSyntheticSlotElement(node) || isHostElement(node);
1697
+ return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
1689
1698
  }
1690
1699
 
1691
1700
  function getShadowParent(node, value) {
@@ -1806,9 +1815,9 @@ function cloneNodePatched(deep) {
1806
1815
 
1807
1816
 
1808
1817
  function childNodesGetterPatched() {
1809
- if (isHostElement(this)) {
1818
+ if (isSyntheticShadowHost(this)) {
1810
1819
  const owner = getNodeOwner(this);
1811
- const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1820
+ const childNodes = isNull(owner) ? getFilteredChildNodes(this) : getAllMatches(owner, getFilteredChildNodes(this));
1812
1821
 
1813
1822
  if (process.env.NODE_ENV !== 'production' && isFalse(hasNativeSymbolSupport) && isExternalChildNodeAccessorFlagOn()) {
1814
1823
  // inserting a comment node as the first childNode to trick the IE11
@@ -1919,7 +1928,8 @@ defineProperties(_Node.prototype, {
1919
1928
  textContent: {
1920
1929
  get() {
1921
1930
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1922
- if (isNodeShadowed(this) || isHostElement(this)) {
1931
+ // See note on get innerHTML in faux-shadow/element.ts
1932
+ if (isNodeOrDescendantsShadowed(this)) {
1923
1933
  return textContentGetterPatched.call(this);
1924
1934
  }
1925
1935
 
@@ -2030,7 +2040,7 @@ defineProperties(_Node.prototype, {
2030
2040
  return false;
2031
2041
  }
2032
2042
 
2033
- if (isNodeShadowed(this) || isHostElement(this)) {
2043
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
2034
2044
  return containsPatched.call(this, otherNode);
2035
2045
  }
2036
2046
 
@@ -2052,7 +2062,7 @@ defineProperties(_Node.prototype, {
2052
2062
  cloneNode: {
2053
2063
  value(deep) {
2054
2064
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
2055
- if (isNodeShadowed(this) || isHostElement(this)) {
2065
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
2056
2066
  return cloneNodePatched.call(this, deep);
2057
2067
  }
2058
2068
 
@@ -2190,7 +2200,7 @@ const {
2190
2200
  } = document;
2191
2201
 
2192
2202
  function hasInternalSlot(root) {
2193
- return Boolean(InternalSlot.get(root));
2203
+ return InternalSlot.has(root);
2194
2204
  }
2195
2205
 
2196
2206
  function getInternalSlot(root) {
@@ -2244,14 +2254,36 @@ function getShadowRoot(elm) {
2244
2254
  // and we can avoid having to cast the type before calling this method in a few places.
2245
2255
 
2246
2256
 
2247
- function isHostElement(node) {
2248
- return !isUndefined(InternalSlot.get(node));
2257
+ function isSyntheticShadowHost(node) {
2258
+ const shadowRootRecord = InternalSlot.get(node);
2259
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.host;
2260
+ }
2261
+
2262
+ function isSyntheticShadowRoot(node) {
2263
+ const shadowRootRecord = InternalSlot.get(node);
2264
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
2265
+ } // Return true if any descendant is a host element
2266
+
2267
+
2268
+ function containsHost(node) {
2269
+ // IE requires all arguments
2270
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker#browser_compatibility
2271
+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
2272
+ let descendant;
2273
+
2274
+ while (!isNull(descendant = walker.nextNode())) {
2275
+ if (isSyntheticShadowHost(descendant)) {
2276
+ return true;
2277
+ }
2278
+ }
2279
+
2280
+ return false;
2249
2281
  }
2250
2282
 
2251
2283
  let uid = 0;
2252
2284
 
2253
2285
  function attachShadow(elm, options) {
2254
- if (!isUndefined(InternalSlot.get(elm))) {
2286
+ if (InternalSlot.has(elm)) {
2255
2287
  throw new Error(`Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree.`);
2256
2288
  }
2257
2289
 
@@ -2884,7 +2916,7 @@ function pathComposer(startNode, composed) {
2884
2916
  } else {
2885
2917
  current = current.parentNode;
2886
2918
  }
2887
- } else if ((current instanceof SyntheticShadowRoot || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2919
+ } else if ((isSyntheticShadowRoot(current) || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2888
2920
  current = current.host;
2889
2921
  } else if (current instanceof _Node) {
2890
2922
  current = current.parentNode;
@@ -2946,7 +2978,7 @@ function retarget(refNode, path) {
2946
2978
  lastRoot = root;
2947
2979
  }
2948
2980
 
2949
- if (!(root instanceof SyntheticShadowRoot) || !isUndefined(rootIdx) && rootIdx > -1) {
2981
+ if (!isSyntheticShadowRoot(root) || !isUndefined(rootIdx) && rootIdx > -1) {
2950
2982
  return ancestor;
2951
2983
  }
2952
2984
  }
@@ -3757,10 +3789,10 @@ function patchedObserve(target, options) {
3757
3789
  if (ArrayIndexOf.call(targetObservers, this) === -1) {
3758
3790
  ArrayPush.call(targetObservers, this);
3759
3791
  } // else There is more bookkeeping to do here https://dom.spec.whatwg.org/#dom-mutationobserver-observe Step #7
3760
- // If the target is a SyntheticShadowRoot, observe the host since the shadowRoot is an empty documentFragment
3792
+ // SyntheticShadowRoot instances are not actually a part of the DOM so observe the host instead.
3761
3793
 
3762
3794
 
3763
- if (target instanceof SyntheticShadowRoot) {
3795
+ if (isSyntheticShadowRoot(target)) {
3764
3796
  target = target.host;
3765
3797
  } // maintain a list of all nodes observed by this observer
3766
3798
 
@@ -3803,7 +3835,7 @@ defineProperty(window, 'MutationObserver', {
3803
3835
  */
3804
3836
 
3805
3837
  function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3806
- if (isHostElement(this)) {
3838
+ if (isSyntheticShadowHost(this)) {
3807
3839
  // Typescript does not like it when you treat the `arguments` object as an array
3808
3840
  // @ts-ignore type-mismatch
3809
3841
  return addCustomElementEventListener.apply(this, arguments);
@@ -3831,7 +3863,7 @@ function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3831
3863
  }
3832
3864
 
3833
3865
  function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
3834
- if (isHostElement(this)) {
3866
+ if (isSyntheticShadowHost(this)) {
3835
3867
  // Typescript does not like it when you treat the `arguments` object as an array
3836
3868
  // @ts-ignore type-mismatch
3837
3869
  return removeCustomElementEventListener.apply(this, arguments);
@@ -3997,7 +4029,7 @@ function patchedTargetGetter() {
3997
4029
  let actualCurrentTarget = originalCurrentTarget;
3998
4030
  let actualPath = composedPath; // Address the possibility that `currentTarget` is a shadow root
3999
4031
 
4000
- if (isHostElement(originalCurrentTarget)) {
4032
+ if (isSyntheticShadowHost(originalCurrentTarget)) {
4001
4033
  const context = eventToContextMap.get(this);
4002
4034
 
4003
4035
  if (context === 1
@@ -4008,7 +4040,7 @@ function patchedTargetGetter() {
4008
4040
  } // Address the possibility that `target` is a shadow root
4009
4041
 
4010
4042
 
4011
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
4043
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
4012
4044
  actualPath = pathComposer(getShadowRoot(originalTarget), this.composed);
4013
4045
  }
4014
4046
 
@@ -4045,7 +4077,7 @@ function patchedComposedPathValue() {
4045
4077
 
4046
4078
  let actualTarget = originalTarget;
4047
4079
 
4048
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
4080
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
4049
4081
  actualTarget = getShadowRoot(originalTarget);
4050
4082
  }
4051
4083
 
@@ -4316,7 +4348,7 @@ function getNonPatchedFilteredArrayOfNodes(context, unfilteredNodes) {
4316
4348
  const ownerKey = getNodeOwnerKey(context); // a node inside a shadow.
4317
4349
 
4318
4350
  if (!isUndefined(ownerKey)) {
4319
- if (isHostElement(context)) {
4351
+ if (isSyntheticShadowHost(context)) {
4320
4352
  // element with shadowRoot attached
4321
4353
  const owner = getNodeOwner(context);
4322
4354
 
@@ -4377,7 +4409,7 @@ function attachShadowPatched(options) {
4377
4409
  }
4378
4410
 
4379
4411
  function shadowRootGetterPatched() {
4380
- if (isHostElement(this)) {
4412
+ if (isSyntheticShadowHost(this)) {
4381
4413
  const shadow = getShadowRoot(this);
4382
4414
 
4383
4415
  if (shadow.mode === 'open') {
@@ -4415,7 +4447,10 @@ defineProperties(Element.prototype, {
4415
4447
  innerHTML: {
4416
4448
  get() {
4417
4449
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4418
- if (isNodeShadowed(this) || isHostElement(this)) {
4450
+ // If this element is in synthetic shadow, if it's a synthetic shadow host,
4451
+ // or if any of its descendants are synthetic shadow hosts, then we can't
4452
+ // use the native innerHTML because it would expose private node internals.
4453
+ if (isNodeOrDescendantsShadowed(this)) {
4419
4454
  return innerHTMLGetterPatched.call(this);
4420
4455
  }
4421
4456
 
@@ -4440,7 +4475,8 @@ defineProperties(Element.prototype, {
4440
4475
  outerHTML: {
4441
4476
  get() {
4442
4477
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4443
- if (isNodeShadowed(this) || isHostElement(this)) {
4478
+ // See notes above on get innerHTML
4479
+ if (isNodeOrDescendantsShadowed(this)) {
4444
4480
  return outerHTMLGetterPatched.call(this);
4445
4481
  }
4446
4482
 
@@ -4545,7 +4581,7 @@ if (hasOwnProperty.call(HTMLElement.prototype, 'children')) {
4545
4581
  function querySelectorPatched() {
4546
4582
  const nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
4547
4583
 
4548
- if (isHostElement(this)) {
4584
+ if (isSyntheticShadowHost(this)) {
4549
4585
  // element with shadowRoot attached
4550
4586
  const owner = getNodeOwner(this);
4551
4587
 
@@ -4596,7 +4632,7 @@ function querySelectorPatched() {
4596
4632
  function getFilteredArrayOfNodes(context, unfilteredNodes, shadowDomSemantic) {
4597
4633
  let filtered;
4598
4634
 
4599
- if (isHostElement(context)) {
4635
+ if (isSyntheticShadowHost(context)) {
4600
4636
  // element with shadowRoot attached
4601
4637
  const owner = getNodeOwner(context);
4602
4638
 
@@ -4805,7 +4841,7 @@ function isVisible(element) {
4805
4841
 
4806
4842
 
4807
4843
  function isTabbable(element) {
4808
- if (isHostElement(element) && isDelegatingFocus(element)) {
4844
+ if (isSyntheticShadowHost(element) && isDelegatingFocus(element)) {
4809
4845
  return false;
4810
4846
  }
4811
4847
 
@@ -5504,7 +5540,7 @@ function focusPatched() {
5504
5540
  disableKeyboardFocusNavigationRoutines();
5505
5541
  }
5506
5542
 
5507
- if (isHostElement(this) && isDelegatingFocus(this)) {
5543
+ if (isSyntheticShadowHost(this) && isDelegatingFocus(this)) {
5508
5544
  hostElementFocus.call(this);
5509
5545
  return;
5510
5546
  } // Typescript does not like it when you treat the `arguments` object as an array
@@ -5523,7 +5559,7 @@ function focusPatched() {
5523
5559
  defineProperties(HTMLElement.prototype, {
5524
5560
  tabIndex: {
5525
5561
  get() {
5526
- if (isHostElement(this)) {
5562
+ if (isSyntheticShadowHost(this)) {
5527
5563
  return tabIndexGetterPatched.call(this);
5528
5564
  }
5529
5565
 
@@ -5531,7 +5567,7 @@ defineProperties(HTMLElement.prototype, {
5531
5567
  },
5532
5568
 
5533
5569
  set(v) {
5534
- if (isHostElement(this)) {
5570
+ if (isSyntheticShadowHost(this)) {
5535
5571
  return tabIndexSetterPatched.call(this, v);
5536
5572
  }
5537
5573
 
@@ -5543,7 +5579,7 @@ defineProperties(HTMLElement.prototype, {
5543
5579
  },
5544
5580
  blur: {
5545
5581
  value() {
5546
- if (isHostElement(this)) {
5582
+ if (isSyntheticShadowHost(this)) {
5547
5583
  return blurPatched.call(this);
5548
5584
  }
5549
5585
 
@@ -5575,7 +5611,7 @@ if (innerTextGetter !== null && innerTextSetter !== null) {
5575
5611
  }
5576
5612
 
5577
5613
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5578
- if (isNodeShadowed(this) || isHostElement(this)) {
5614
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5579
5615
  return getInnerText(this);
5580
5616
  }
5581
5617
 
@@ -5611,7 +5647,7 @@ if (outerTextGetter !== null && outerTextSetter !== null) {
5611
5647
  }
5612
5648
 
5613
5649
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5614
- if (isNodeShadowed(this) || isHostElement(this)) {
5650
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5615
5651
  return getInnerText(this);
5616
5652
  }
5617
5653
 
@@ -5716,7 +5752,7 @@ function adoptChildNode(node, fn, shadowToken) {
5716
5752
  if (node instanceof Element) {
5717
5753
  setShadowToken(node, shadowToken);
5718
5754
 
5719
- if (isHostElement(node)) {
5755
+ if (isSyntheticShadowHost(node)) {
5720
5756
  // Root LWC elements can't get content slotted into them, therefore we don't observe their children.
5721
5757
  return;
5722
5758
  }
@@ -5823,4 +5859,4 @@ defineProperty(Element.prototype, '$domManual$', {
5823
5859
 
5824
5860
  configurable: true
5825
5861
  });
5826
- /** version: 2.5.1 */
5862
+ /** version: 2.5.4 */