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
@@ -125,7 +125,7 @@
125
125
  const KEY__SHADOW_TOKEN = '$shadowToken$';
126
126
  const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
127
127
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
128
- /** version: 2.5.3 */
128
+ /** version: 2.5.4 */
129
129
 
130
130
  /*
131
131
  * Copyright (c) 2018, salesforce.com, inc.
@@ -464,7 +464,7 @@
464
464
  }
465
465
 
466
466
  const runtimeFlags = _globalThis.lwcRuntimeFlags;
467
- /** version: 2.5.3 */
467
+ /** version: 2.5.4 */
468
468
 
469
469
  /*
470
470
  * Copyright (c) 2018, salesforce.com, inc.
@@ -952,6 +952,15 @@
952
952
  function isNodeShadowed(node) {
953
953
  return !isUndefined(getNodeOwnerKey(node));
954
954
  }
955
+ /**
956
+ * Returns true if this node is a shadow host, is in a shadow host, or contains a shadow host
957
+ * anywhere in its tree.
958
+ */
959
+
960
+
961
+ function isNodeOrDescendantsShadowed(node) {
962
+ return isNodeShadowed(node) || isSyntheticShadowHost(node) || containsHost(node);
963
+ }
955
964
  /*
956
965
  * Copyright (c) 2018, salesforce.com, inc.
957
966
  * All rights reserved.
@@ -1141,13 +1150,13 @@
1141
1150
  }
1142
1151
 
1143
1152
  function getFilteredChildNodes(node) {
1144
- if (!isHostElement(node) && !isSlotElement(node)) {
1153
+ if (!isSyntheticShadowHost(node) && !isSlotElement(node)) {
1145
1154
  // regular element - fast path
1146
1155
  const children = childNodesGetter.call(node);
1147
1156
  return arrayFromCollection(children);
1148
1157
  }
1149
1158
 
1150
- if (isHostElement(node)) {
1159
+ if (isSyntheticShadowHost(node)) {
1151
1160
  // we need to get only the nodes that were slotted
1152
1161
  const slots = arrayFromCollection(querySelectorAll$1.call(node, 'slot'));
1153
1162
  const resolver = getShadowRootResolver(getShadowRoot(node)); // Typescript is inferring the wrong function type for this particular
@@ -1589,7 +1598,7 @@
1589
1598
 
1590
1599
 
1591
1600
  function hasMountedChildren(node) {
1592
- return isSyntheticSlotElement(node) || isHostElement(node);
1601
+ return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
1593
1602
  }
1594
1603
 
1595
1604
  function getShadowParent(node, value) {
@@ -1710,9 +1719,9 @@
1710
1719
 
1711
1720
 
1712
1721
  function childNodesGetterPatched() {
1713
- if (isHostElement(this)) {
1722
+ if (isSyntheticShadowHost(this)) {
1714
1723
  const owner = getNodeOwner(this);
1715
- const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1724
+ const childNodes = isNull(owner) ? getFilteredChildNodes(this) : getAllMatches(owner, getFilteredChildNodes(this));
1716
1725
 
1717
1726
  return createStaticNodeList(childNodes);
1718
1727
  } // nothing to do here since this does not have a synthetic shadow attached to it
@@ -1815,7 +1824,8 @@
1815
1824
  textContent: {
1816
1825
  get() {
1817
1826
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1818
- if (isNodeShadowed(this) || isHostElement(this)) {
1827
+ // See note on get innerHTML in faux-shadow/element.ts
1828
+ if (isNodeOrDescendantsShadowed(this)) {
1819
1829
  return textContentGetterPatched.call(this);
1820
1830
  }
1821
1831
 
@@ -1926,7 +1936,7 @@
1926
1936
  return false;
1927
1937
  }
1928
1938
 
1929
- if (isNodeShadowed(this) || isHostElement(this)) {
1939
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1930
1940
  return containsPatched.call(this, otherNode);
1931
1941
  }
1932
1942
 
@@ -1948,7 +1958,7 @@
1948
1958
  cloneNode: {
1949
1959
  value(deep) {
1950
1960
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1951
- if (isNodeShadowed(this) || isHostElement(this)) {
1961
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1952
1962
  return cloneNodePatched.call(this, deep);
1953
1963
  }
1954
1964
 
@@ -2055,7 +2065,7 @@
2055
2065
  } = document;
2056
2066
 
2057
2067
  function hasInternalSlot(root) {
2058
- return Boolean(InternalSlot.get(root));
2068
+ return InternalSlot.has(root);
2059
2069
  }
2060
2070
 
2061
2071
  function getInternalSlot(root) {
@@ -2109,14 +2119,36 @@
2109
2119
  // and we can avoid having to cast the type before calling this method in a few places.
2110
2120
 
2111
2121
 
2112
- function isHostElement(node) {
2113
- return !isUndefined(InternalSlot.get(node));
2122
+ function isSyntheticShadowHost(node) {
2123
+ const shadowRootRecord = InternalSlot.get(node);
2124
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.host;
2125
+ }
2126
+
2127
+ function isSyntheticShadowRoot(node) {
2128
+ const shadowRootRecord = InternalSlot.get(node);
2129
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
2130
+ } // Return true if any descendant is a host element
2131
+
2132
+
2133
+ function containsHost(node) {
2134
+ // IE requires all arguments
2135
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker#browser_compatibility
2136
+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
2137
+ let descendant;
2138
+
2139
+ while (!isNull(descendant = walker.nextNode())) {
2140
+ if (isSyntheticShadowHost(descendant)) {
2141
+ return true;
2142
+ }
2143
+ }
2144
+
2145
+ return false;
2114
2146
  }
2115
2147
 
2116
2148
  let uid = 0;
2117
2149
 
2118
2150
  function attachShadow(elm, options) {
2119
- if (!isUndefined(InternalSlot.get(elm))) {
2151
+ if (InternalSlot.has(elm)) {
2120
2152
  throw new Error(`Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree.`);
2121
2153
  }
2122
2154
 
@@ -2708,7 +2740,7 @@
2708
2740
  } else {
2709
2741
  current = current.parentNode;
2710
2742
  }
2711
- } else if ((current instanceof SyntheticShadowRoot || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2743
+ } else if ((isSyntheticShadowRoot(current) || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2712
2744
  current = current.host;
2713
2745
  } else if (current instanceof _Node) {
2714
2746
  current = current.parentNode;
@@ -2770,7 +2802,7 @@
2770
2802
  lastRoot = root;
2771
2803
  }
2772
2804
 
2773
- if (!(root instanceof SyntheticShadowRoot) || !isUndefined(rootIdx) && rootIdx > -1) {
2805
+ if (!isSyntheticShadowRoot(root) || !isUndefined(rootIdx) && rootIdx > -1) {
2774
2806
  return ancestor;
2775
2807
  }
2776
2808
  }
@@ -3581,10 +3613,10 @@
3581
3613
  if (ArrayIndexOf.call(targetObservers, this) === -1) {
3582
3614
  ArrayPush.call(targetObservers, this);
3583
3615
  } // else There is more bookkeeping to do here https://dom.spec.whatwg.org/#dom-mutationobserver-observe Step #7
3584
- // If the target is a SyntheticShadowRoot, observe the host since the shadowRoot is an empty documentFragment
3616
+ // SyntheticShadowRoot instances are not actually a part of the DOM so observe the host instead.
3585
3617
 
3586
3618
 
3587
- if (target instanceof SyntheticShadowRoot) {
3619
+ if (isSyntheticShadowRoot(target)) {
3588
3620
  target = target.host;
3589
3621
  } // maintain a list of all nodes observed by this observer
3590
3622
 
@@ -3627,7 +3659,7 @@
3627
3659
  */
3628
3660
 
3629
3661
  function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3630
- if (isHostElement(this)) {
3662
+ if (isSyntheticShadowHost(this)) {
3631
3663
  // Typescript does not like it when you treat the `arguments` object as an array
3632
3664
  // @ts-ignore type-mismatch
3633
3665
  return addCustomElementEventListener.apply(this, arguments);
@@ -3655,7 +3687,7 @@
3655
3687
  }
3656
3688
 
3657
3689
  function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
3658
- if (isHostElement(this)) {
3690
+ if (isSyntheticShadowHost(this)) {
3659
3691
  // Typescript does not like it when you treat the `arguments` object as an array
3660
3692
  // @ts-ignore type-mismatch
3661
3693
  return removeCustomElementEventListener.apply(this, arguments);
@@ -3821,7 +3853,7 @@
3821
3853
  let actualCurrentTarget = originalCurrentTarget;
3822
3854
  let actualPath = composedPath; // Address the possibility that `currentTarget` is a shadow root
3823
3855
 
3824
- if (isHostElement(originalCurrentTarget)) {
3856
+ if (isSyntheticShadowHost(originalCurrentTarget)) {
3825
3857
  const context = eventToContextMap.get(this);
3826
3858
 
3827
3859
  if (context === 1
@@ -3832,7 +3864,7 @@
3832
3864
  } // Address the possibility that `target` is a shadow root
3833
3865
 
3834
3866
 
3835
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
3867
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
3836
3868
  actualPath = pathComposer(getShadowRoot(originalTarget), this.composed);
3837
3869
  }
3838
3870
 
@@ -3869,7 +3901,7 @@
3869
3901
 
3870
3902
  let actualTarget = originalTarget;
3871
3903
 
3872
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
3904
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
3873
3905
  actualTarget = getShadowRoot(originalTarget);
3874
3906
  }
3875
3907
 
@@ -4137,7 +4169,7 @@
4137
4169
  const ownerKey = getNodeOwnerKey(context); // a node inside a shadow.
4138
4170
 
4139
4171
  if (!isUndefined(ownerKey)) {
4140
- if (isHostElement(context)) {
4172
+ if (isSyntheticShadowHost(context)) {
4141
4173
  // element with shadowRoot attached
4142
4174
  const owner = getNodeOwner(context);
4143
4175
 
@@ -4198,7 +4230,7 @@
4198
4230
  }
4199
4231
 
4200
4232
  function shadowRootGetterPatched() {
4201
- if (isHostElement(this)) {
4233
+ if (isSyntheticShadowHost(this)) {
4202
4234
  const shadow = getShadowRoot(this);
4203
4235
 
4204
4236
  if (shadow.mode === 'open') {
@@ -4236,7 +4268,10 @@
4236
4268
  innerHTML: {
4237
4269
  get() {
4238
4270
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4239
- if (isNodeShadowed(this) || isHostElement(this)) {
4271
+ // If this element is in synthetic shadow, if it's a synthetic shadow host,
4272
+ // or if any of its descendants are synthetic shadow hosts, then we can't
4273
+ // use the native innerHTML because it would expose private node internals.
4274
+ if (isNodeOrDescendantsShadowed(this)) {
4240
4275
  return innerHTMLGetterPatched.call(this);
4241
4276
  }
4242
4277
 
@@ -4261,7 +4296,8 @@
4261
4296
  outerHTML: {
4262
4297
  get() {
4263
4298
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4264
- if (isNodeShadowed(this) || isHostElement(this)) {
4299
+ // See notes above on get innerHTML
4300
+ if (isNodeOrDescendantsShadowed(this)) {
4265
4301
  return outerHTMLGetterPatched.call(this);
4266
4302
  }
4267
4303
 
@@ -4366,7 +4402,7 @@
4366
4402
  function querySelectorPatched() {
4367
4403
  const nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
4368
4404
 
4369
- if (isHostElement(this)) {
4405
+ if (isSyntheticShadowHost(this)) {
4370
4406
  // element with shadowRoot attached
4371
4407
  const owner = getNodeOwner(this);
4372
4408
 
@@ -4417,7 +4453,7 @@
4417
4453
  function getFilteredArrayOfNodes(context, unfilteredNodes, shadowDomSemantic) {
4418
4454
  let filtered;
4419
4455
 
4420
- if (isHostElement(context)) {
4456
+ if (isSyntheticShadowHost(context)) {
4421
4457
  // element with shadowRoot attached
4422
4458
  const owner = getNodeOwner(context);
4423
4459
 
@@ -4626,7 +4662,7 @@
4626
4662
 
4627
4663
 
4628
4664
  function isTabbable(element) {
4629
- if (isHostElement(element) && isDelegatingFocus(element)) {
4665
+ if (isSyntheticShadowHost(element) && isDelegatingFocus(element)) {
4630
4666
  return false;
4631
4667
  }
4632
4668
 
@@ -5315,7 +5351,7 @@
5315
5351
  disableKeyboardFocusNavigationRoutines();
5316
5352
  }
5317
5353
 
5318
- if (isHostElement(this) && isDelegatingFocus(this)) {
5354
+ if (isSyntheticShadowHost(this) && isDelegatingFocus(this)) {
5319
5355
  hostElementFocus.call(this);
5320
5356
  return;
5321
5357
  } // Typescript does not like it when you treat the `arguments` object as an array
@@ -5334,7 +5370,7 @@
5334
5370
  defineProperties(HTMLElement.prototype, {
5335
5371
  tabIndex: {
5336
5372
  get() {
5337
- if (isHostElement(this)) {
5373
+ if (isSyntheticShadowHost(this)) {
5338
5374
  return tabIndexGetterPatched.call(this);
5339
5375
  }
5340
5376
 
@@ -5342,7 +5378,7 @@
5342
5378
  },
5343
5379
 
5344
5380
  set(v) {
5345
- if (isHostElement(this)) {
5381
+ if (isSyntheticShadowHost(this)) {
5346
5382
  return tabIndexSetterPatched.call(this, v);
5347
5383
  }
5348
5384
 
@@ -5354,7 +5390,7 @@
5354
5390
  },
5355
5391
  blur: {
5356
5392
  value() {
5357
- if (isHostElement(this)) {
5393
+ if (isSyntheticShadowHost(this)) {
5358
5394
  return blurPatched.call(this);
5359
5395
  }
5360
5396
 
@@ -5386,7 +5422,7 @@
5386
5422
  }
5387
5423
 
5388
5424
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5389
- if (isNodeShadowed(this) || isHostElement(this)) {
5425
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5390
5426
  return getInnerText(this);
5391
5427
  }
5392
5428
 
@@ -5422,7 +5458,7 @@
5422
5458
  }
5423
5459
 
5424
5460
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5425
- if (isNodeShadowed(this) || isHostElement(this)) {
5461
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5426
5462
  return getInnerText(this);
5427
5463
  }
5428
5464
 
@@ -5527,7 +5563,7 @@
5527
5563
  if (node instanceof Element) {
5528
5564
  setShadowToken(node, shadowToken);
5529
5565
 
5530
- if (isHostElement(node)) {
5566
+ if (isSyntheticShadowHost(node)) {
5531
5567
  // Root LWC elements can't get content slotted into them, therefore we don't observe their children.
5532
5568
  return;
5533
5569
  }
@@ -5634,6 +5670,6 @@
5634
5670
 
5635
5671
  configurable: true
5636
5672
  });
5637
- /** version: 2.5.3 */
5673
+ /** version: 2.5.4 */
5638
5674
 
5639
5675
  })();