lwc 2.5.3 → 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 +75 -71
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +75 -71
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +64 -52
  5. package/dist/engine-dom/iife/es5/engine-dom.js +115 -90
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +102 -69
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +75 -71
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +64 -52
  11. package/dist/engine-dom/umd/es5/engine-dom.js +115 -90
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +102 -69
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +57 -71
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +57 -71
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +75 -39
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +75 -39
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +74 -38
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +75 -39
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +74 -38
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +75 -39
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +74 -38
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +75 -39
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +74 -38
  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 +2 -2
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  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 +2 -2
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  41. package/package.json +8 -8
@@ -127,7 +127,7 @@
127
127
  const KEY__SHADOW_TOKEN = '$shadowToken$';
128
128
  const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
129
129
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
130
- /** version: 2.5.3 */
130
+ /** version: 2.5.4 */
131
131
 
132
132
  /*
133
133
  * Copyright (c) 2018, salesforce.com, inc.
@@ -466,7 +466,7 @@
466
466
  }
467
467
 
468
468
  const runtimeFlags = _globalThis.lwcRuntimeFlags;
469
- /** version: 2.5.3 */
469
+ /** version: 2.5.4 */
470
470
 
471
471
  /*
472
472
  * Copyright (c) 2018, salesforce.com, inc.
@@ -954,6 +954,15 @@
954
954
  function isNodeShadowed(node) {
955
955
  return !isUndefined(getNodeOwnerKey(node));
956
956
  }
957
+ /**
958
+ * Returns true if this node is a shadow host, is in a shadow host, or contains a shadow host
959
+ * anywhere in its tree.
960
+ */
961
+
962
+
963
+ function isNodeOrDescendantsShadowed(node) {
964
+ return isNodeShadowed(node) || isSyntheticShadowHost(node) || containsHost(node);
965
+ }
957
966
  /*
958
967
  * Copyright (c) 2018, salesforce.com, inc.
959
968
  * All rights reserved.
@@ -1143,13 +1152,13 @@
1143
1152
  }
1144
1153
 
1145
1154
  function getFilteredChildNodes(node) {
1146
- if (!isHostElement(node) && !isSlotElement(node)) {
1155
+ if (!isSyntheticShadowHost(node) && !isSlotElement(node)) {
1147
1156
  // regular element - fast path
1148
1157
  const children = childNodesGetter.call(node);
1149
1158
  return arrayFromCollection(children);
1150
1159
  }
1151
1160
 
1152
- if (isHostElement(node)) {
1161
+ if (isSyntheticShadowHost(node)) {
1153
1162
  // we need to get only the nodes that were slotted
1154
1163
  const slots = arrayFromCollection(querySelectorAll$1.call(node, 'slot'));
1155
1164
  const resolver = getShadowRootResolver(getShadowRoot(node)); // Typescript is inferring the wrong function type for this particular
@@ -1591,7 +1600,7 @@
1591
1600
 
1592
1601
 
1593
1602
  function hasMountedChildren(node) {
1594
- return isSyntheticSlotElement(node) || isHostElement(node);
1603
+ return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
1595
1604
  }
1596
1605
 
1597
1606
  function getShadowParent(node, value) {
@@ -1712,9 +1721,9 @@
1712
1721
 
1713
1722
 
1714
1723
  function childNodesGetterPatched() {
1715
- if (isHostElement(this)) {
1724
+ if (isSyntheticShadowHost(this)) {
1716
1725
  const owner = getNodeOwner(this);
1717
- const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1726
+ const childNodes = isNull(owner) ? getFilteredChildNodes(this) : getAllMatches(owner, getFilteredChildNodes(this));
1718
1727
 
1719
1728
  return createStaticNodeList(childNodes);
1720
1729
  } // nothing to do here since this does not have a synthetic shadow attached to it
@@ -1817,7 +1826,8 @@
1817
1826
  textContent: {
1818
1827
  get() {
1819
1828
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1820
- if (isNodeShadowed(this) || isHostElement(this)) {
1829
+ // See note on get innerHTML in faux-shadow/element.ts
1830
+ if (isNodeOrDescendantsShadowed(this)) {
1821
1831
  return textContentGetterPatched.call(this);
1822
1832
  }
1823
1833
 
@@ -1928,7 +1938,7 @@
1928
1938
  return false;
1929
1939
  }
1930
1940
 
1931
- if (isNodeShadowed(this) || isHostElement(this)) {
1941
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1932
1942
  return containsPatched.call(this, otherNode);
1933
1943
  }
1934
1944
 
@@ -1950,7 +1960,7 @@
1950
1960
  cloneNode: {
1951
1961
  value(deep) {
1952
1962
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1953
- if (isNodeShadowed(this) || isHostElement(this)) {
1963
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1954
1964
  return cloneNodePatched.call(this, deep);
1955
1965
  }
1956
1966
 
@@ -2057,7 +2067,7 @@
2057
2067
  } = document;
2058
2068
 
2059
2069
  function hasInternalSlot(root) {
2060
- return Boolean(InternalSlot.get(root));
2070
+ return InternalSlot.has(root);
2061
2071
  }
2062
2072
 
2063
2073
  function getInternalSlot(root) {
@@ -2111,14 +2121,36 @@
2111
2121
  // and we can avoid having to cast the type before calling this method in a few places.
2112
2122
 
2113
2123
 
2114
- function isHostElement(node) {
2115
- return !isUndefined(InternalSlot.get(node));
2124
+ function isSyntheticShadowHost(node) {
2125
+ const shadowRootRecord = InternalSlot.get(node);
2126
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.host;
2127
+ }
2128
+
2129
+ function isSyntheticShadowRoot(node) {
2130
+ const shadowRootRecord = InternalSlot.get(node);
2131
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
2132
+ } // Return true if any descendant is a host element
2133
+
2134
+
2135
+ function containsHost(node) {
2136
+ // IE requires all arguments
2137
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker#browser_compatibility
2138
+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
2139
+ let descendant;
2140
+
2141
+ while (!isNull(descendant = walker.nextNode())) {
2142
+ if (isSyntheticShadowHost(descendant)) {
2143
+ return true;
2144
+ }
2145
+ }
2146
+
2147
+ return false;
2116
2148
  }
2117
2149
 
2118
2150
  let uid = 0;
2119
2151
 
2120
2152
  function attachShadow(elm, options) {
2121
- if (!isUndefined(InternalSlot.get(elm))) {
2153
+ if (InternalSlot.has(elm)) {
2122
2154
  throw new Error(`Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree.`);
2123
2155
  }
2124
2156
 
@@ -2710,7 +2742,7 @@
2710
2742
  } else {
2711
2743
  current = current.parentNode;
2712
2744
  }
2713
- } else if ((current instanceof SyntheticShadowRoot || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2745
+ } else if ((isSyntheticShadowRoot(current) || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2714
2746
  current = current.host;
2715
2747
  } else if (current instanceof _Node) {
2716
2748
  current = current.parentNode;
@@ -2772,7 +2804,7 @@
2772
2804
  lastRoot = root;
2773
2805
  }
2774
2806
 
2775
- if (!(root instanceof SyntheticShadowRoot) || !isUndefined(rootIdx) && rootIdx > -1) {
2807
+ if (!isSyntheticShadowRoot(root) || !isUndefined(rootIdx) && rootIdx > -1) {
2776
2808
  return ancestor;
2777
2809
  }
2778
2810
  }
@@ -3583,10 +3615,10 @@
3583
3615
  if (ArrayIndexOf.call(targetObservers, this) === -1) {
3584
3616
  ArrayPush.call(targetObservers, this);
3585
3617
  } // else There is more bookkeeping to do here https://dom.spec.whatwg.org/#dom-mutationobserver-observe Step #7
3586
- // If the target is a SyntheticShadowRoot, observe the host since the shadowRoot is an empty documentFragment
3618
+ // SyntheticShadowRoot instances are not actually a part of the DOM so observe the host instead.
3587
3619
 
3588
3620
 
3589
- if (target instanceof SyntheticShadowRoot) {
3621
+ if (isSyntheticShadowRoot(target)) {
3590
3622
  target = target.host;
3591
3623
  } // maintain a list of all nodes observed by this observer
3592
3624
 
@@ -3629,7 +3661,7 @@
3629
3661
  */
3630
3662
 
3631
3663
  function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3632
- if (isHostElement(this)) {
3664
+ if (isSyntheticShadowHost(this)) {
3633
3665
  // Typescript does not like it when you treat the `arguments` object as an array
3634
3666
  // @ts-ignore type-mismatch
3635
3667
  return addCustomElementEventListener.apply(this, arguments);
@@ -3657,7 +3689,7 @@
3657
3689
  }
3658
3690
 
3659
3691
  function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
3660
- if (isHostElement(this)) {
3692
+ if (isSyntheticShadowHost(this)) {
3661
3693
  // Typescript does not like it when you treat the `arguments` object as an array
3662
3694
  // @ts-ignore type-mismatch
3663
3695
  return removeCustomElementEventListener.apply(this, arguments);
@@ -3823,7 +3855,7 @@
3823
3855
  let actualCurrentTarget = originalCurrentTarget;
3824
3856
  let actualPath = composedPath; // Address the possibility that `currentTarget` is a shadow root
3825
3857
 
3826
- if (isHostElement(originalCurrentTarget)) {
3858
+ if (isSyntheticShadowHost(originalCurrentTarget)) {
3827
3859
  const context = eventToContextMap.get(this);
3828
3860
 
3829
3861
  if (context === 1
@@ -3834,7 +3866,7 @@
3834
3866
  } // Address the possibility that `target` is a shadow root
3835
3867
 
3836
3868
 
3837
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
3869
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
3838
3870
  actualPath = pathComposer(getShadowRoot(originalTarget), this.composed);
3839
3871
  }
3840
3872
 
@@ -3871,7 +3903,7 @@
3871
3903
 
3872
3904
  let actualTarget = originalTarget;
3873
3905
 
3874
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
3906
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
3875
3907
  actualTarget = getShadowRoot(originalTarget);
3876
3908
  }
3877
3909
 
@@ -4139,7 +4171,7 @@
4139
4171
  const ownerKey = getNodeOwnerKey(context); // a node inside a shadow.
4140
4172
 
4141
4173
  if (!isUndefined(ownerKey)) {
4142
- if (isHostElement(context)) {
4174
+ if (isSyntheticShadowHost(context)) {
4143
4175
  // element with shadowRoot attached
4144
4176
  const owner = getNodeOwner(context);
4145
4177
 
@@ -4200,7 +4232,7 @@
4200
4232
  }
4201
4233
 
4202
4234
  function shadowRootGetterPatched() {
4203
- if (isHostElement(this)) {
4235
+ if (isSyntheticShadowHost(this)) {
4204
4236
  const shadow = getShadowRoot(this);
4205
4237
 
4206
4238
  if (shadow.mode === 'open') {
@@ -4238,7 +4270,10 @@
4238
4270
  innerHTML: {
4239
4271
  get() {
4240
4272
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4241
- if (isNodeShadowed(this) || isHostElement(this)) {
4273
+ // If this element is in synthetic shadow, if it's a synthetic shadow host,
4274
+ // or if any of its descendants are synthetic shadow hosts, then we can't
4275
+ // use the native innerHTML because it would expose private node internals.
4276
+ if (isNodeOrDescendantsShadowed(this)) {
4242
4277
  return innerHTMLGetterPatched.call(this);
4243
4278
  }
4244
4279
 
@@ -4263,7 +4298,8 @@
4263
4298
  outerHTML: {
4264
4299
  get() {
4265
4300
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4266
- if (isNodeShadowed(this) || isHostElement(this)) {
4301
+ // See notes above on get innerHTML
4302
+ if (isNodeOrDescendantsShadowed(this)) {
4267
4303
  return outerHTMLGetterPatched.call(this);
4268
4304
  }
4269
4305
 
@@ -4368,7 +4404,7 @@
4368
4404
  function querySelectorPatched() {
4369
4405
  const nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
4370
4406
 
4371
- if (isHostElement(this)) {
4407
+ if (isSyntheticShadowHost(this)) {
4372
4408
  // element with shadowRoot attached
4373
4409
  const owner = getNodeOwner(this);
4374
4410
 
@@ -4419,7 +4455,7 @@
4419
4455
  function getFilteredArrayOfNodes(context, unfilteredNodes, shadowDomSemantic) {
4420
4456
  let filtered;
4421
4457
 
4422
- if (isHostElement(context)) {
4458
+ if (isSyntheticShadowHost(context)) {
4423
4459
  // element with shadowRoot attached
4424
4460
  const owner = getNodeOwner(context);
4425
4461
 
@@ -4628,7 +4664,7 @@
4628
4664
 
4629
4665
 
4630
4666
  function isTabbable(element) {
4631
- if (isHostElement(element) && isDelegatingFocus(element)) {
4667
+ if (isSyntheticShadowHost(element) && isDelegatingFocus(element)) {
4632
4668
  return false;
4633
4669
  }
4634
4670
 
@@ -5317,7 +5353,7 @@
5317
5353
  disableKeyboardFocusNavigationRoutines();
5318
5354
  }
5319
5355
 
5320
- if (isHostElement(this) && isDelegatingFocus(this)) {
5356
+ if (isSyntheticShadowHost(this) && isDelegatingFocus(this)) {
5321
5357
  hostElementFocus.call(this);
5322
5358
  return;
5323
5359
  } // Typescript does not like it when you treat the `arguments` object as an array
@@ -5336,7 +5372,7 @@
5336
5372
  defineProperties(HTMLElement.prototype, {
5337
5373
  tabIndex: {
5338
5374
  get() {
5339
- if (isHostElement(this)) {
5375
+ if (isSyntheticShadowHost(this)) {
5340
5376
  return tabIndexGetterPatched.call(this);
5341
5377
  }
5342
5378
 
@@ -5344,7 +5380,7 @@
5344
5380
  },
5345
5381
 
5346
5382
  set(v) {
5347
- if (isHostElement(this)) {
5383
+ if (isSyntheticShadowHost(this)) {
5348
5384
  return tabIndexSetterPatched.call(this, v);
5349
5385
  }
5350
5386
 
@@ -5356,7 +5392,7 @@
5356
5392
  },
5357
5393
  blur: {
5358
5394
  value() {
5359
- if (isHostElement(this)) {
5395
+ if (isSyntheticShadowHost(this)) {
5360
5396
  return blurPatched.call(this);
5361
5397
  }
5362
5398
 
@@ -5388,7 +5424,7 @@
5388
5424
  }
5389
5425
 
5390
5426
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5391
- if (isNodeShadowed(this) || isHostElement(this)) {
5427
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5392
5428
  return getInnerText(this);
5393
5429
  }
5394
5430
 
@@ -5424,7 +5460,7 @@
5424
5460
  }
5425
5461
 
5426
5462
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5427
- if (isNodeShadowed(this) || isHostElement(this)) {
5463
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5428
5464
  return getInnerText(this);
5429
5465
  }
5430
5466
 
@@ -5529,7 +5565,7 @@
5529
5565
  if (node instanceof Element) {
5530
5566
  setShadowToken(node, shadowToken);
5531
5567
 
5532
- if (isHostElement(node)) {
5568
+ if (isSyntheticShadowHost(node)) {
5533
5569
  // Root LWC elements can't get content slotted into them, therefore we don't observe their children.
5534
5570
  return;
5535
5571
  }
@@ -5636,6 +5672,6 @@
5636
5672
 
5637
5673
  configurable: true
5638
5674
  });
5639
- /** version: 2.5.3 */
5675
+ /** version: 2.5.4 */
5640
5676
 
5641
5677
  }));