@lwc/synthetic-shadow 2.5.3 → 2.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -194,7 +194,7 @@ const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
194
194
 
195
195
 
196
196
  const hasNativeSymbolSupport = /*@__PURE__*/(() => Symbol('x').toString() === 'Symbol(x)')();
197
- /** version: 2.5.3 */
197
+ /** version: 2.5.7 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) 2018, salesforce.com, inc.
@@ -526,7 +526,7 @@ if (!_globalThis.lwcRuntimeFlags) {
526
526
  }
527
527
 
528
528
  const runtimeFlags = _globalThis.lwcRuntimeFlags;
529
- /** version: 2.5.3 */
529
+ /** version: 2.5.7 */
530
530
 
531
531
  /*
532
532
  * Copyright (c) 2018, salesforce.com, inc.
@@ -584,7 +584,7 @@ function getEventListenerWrapper(fnOrObj) {
584
584
  const currentTarget = eventCurrentTargetGetter.call(event);
585
585
 
586
586
  if (process.env.NODE_ENV !== 'production') {
587
- assert.invariant(isFalse(isHostElement(currentTarget)), 'This routine should not be used to wrap event listeners for host elements and shadow roots.');
587
+ assert.invariant(isFalse(isSyntheticShadowHost(currentTarget)), 'This routine should not be used to wrap event listeners for host elements and shadow roots.');
588
588
  }
589
589
 
590
590
  const {
@@ -629,9 +629,9 @@ const GET_ROOT_NODE_CONFIG_FALSE = {
629
629
  };
630
630
 
631
631
  function getRootNodeHost(node, options) {
632
- let rootNode = node.getRootNode(options); // is SyntheticShadowRootInterface
632
+ let rootNode = node.getRootNode(options);
633
633
 
634
- if ('mode' in rootNode && 'delegatesFocus' in rootNode) {
634
+ if (isSyntheticShadowRoot(rootNode)) {
635
635
  rootNode = getHost(rootNode);
636
636
  }
637
637
 
@@ -1207,13 +1207,13 @@ function shadowRootQuerySelectorAll(root, selector) {
1207
1207
  return getAllMatches(elm, arrayFromCollection(nodeList));
1208
1208
  }
1209
1209
  function getFilteredChildNodes(node) {
1210
- if (!isHostElement(node) && !isSlotElement(node)) {
1210
+ if (!isSyntheticShadowHost(node) && !isSlotElement(node)) {
1211
1211
  // regular element - fast path
1212
1212
  const children = childNodesGetter.call(node);
1213
1213
  return arrayFromCollection(children);
1214
1214
  }
1215
1215
 
1216
- if (isHostElement(node)) {
1216
+ if (isSyntheticShadowHost(node)) {
1217
1217
  // we need to get only the nodes that were slotted
1218
1218
  const slots = arrayFromCollection(querySelectorAll$1.call(node, 'slot'));
1219
1219
  const resolver = getShadowRootResolver(getShadowRoot(node)); // Typescript is inferring the wrong function type for this particular
@@ -1646,7 +1646,7 @@ function getOuterHTML(node) {
1646
1646
  */
1647
1647
 
1648
1648
  function hasMountedChildren(node) {
1649
- return isSyntheticSlotElement(node) || isHostElement(node);
1649
+ return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
1650
1650
  }
1651
1651
 
1652
1652
  function getShadowParent(node, value) {
@@ -1767,7 +1767,7 @@ function cloneNodePatched(deep) {
1767
1767
 
1768
1768
 
1769
1769
  function childNodesGetterPatched() {
1770
- if (isHostElement(this)) {
1770
+ if (isSyntheticShadowHost(this)) {
1771
1771
  const owner = getNodeOwner(this);
1772
1772
  const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
1773
1773
 
@@ -1880,7 +1880,7 @@ defineProperties(_Node.prototype, {
1880
1880
  textContent: {
1881
1881
  get() {
1882
1882
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
1883
- if (isNodeShadowed(this) || isHostElement(this)) {
1883
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1884
1884
  return textContentGetterPatched.call(this);
1885
1885
  }
1886
1886
 
@@ -1991,7 +1991,7 @@ defineProperties(_Node.prototype, {
1991
1991
  return false;
1992
1992
  }
1993
1993
 
1994
- if (isNodeShadowed(this) || isHostElement(this)) {
1994
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
1995
1995
  return containsPatched.call(this, otherNode);
1996
1996
  }
1997
1997
 
@@ -2013,7 +2013,7 @@ defineProperties(_Node.prototype, {
2013
2013
  cloneNode: {
2014
2014
  value(deep) {
2015
2015
  if (!runtimeFlags.ENABLE_NODE_PATCH) {
2016
- if (isNodeShadowed(this) || isHostElement(this)) {
2016
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
2017
2017
  return cloneNodePatched.call(this, deep);
2018
2018
  }
2019
2019
 
@@ -2148,7 +2148,7 @@ const {
2148
2148
  createDocumentFragment
2149
2149
  } = document;
2150
2150
  function hasInternalSlot(root) {
2151
- return Boolean(InternalSlot.get(root));
2151
+ return InternalSlot.has(root);
2152
2152
  }
2153
2153
 
2154
2154
  function getInternalSlot(root) {
@@ -2196,12 +2196,17 @@ function getShadowRoot(elm) {
2196
2196
  } // Intentionally adding `Node` here in addition to `Element` since this check is harmless for nodes
2197
2197
  // and we can avoid having to cast the type before calling this method in a few places.
2198
2198
 
2199
- function isHostElement(node) {
2200
- return !isUndefined(InternalSlot.get(node));
2199
+ function isSyntheticShadowHost(node) {
2200
+ const shadowRootRecord = InternalSlot.get(node);
2201
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.host;
2202
+ }
2203
+ function isSyntheticShadowRoot(node) {
2204
+ const shadowRootRecord = InternalSlot.get(node);
2205
+ return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
2201
2206
  }
2202
2207
  let uid = 0;
2203
2208
  function attachShadow(elm, options) {
2204
- if (!isUndefined(InternalSlot.get(elm))) {
2209
+ if (InternalSlot.has(elm)) {
2205
2210
  throw new Error(`Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree.`);
2206
2211
  }
2207
2212
 
@@ -2830,7 +2835,7 @@ function pathComposer(startNode, composed) {
2830
2835
  } else {
2831
2836
  current = current.parentNode;
2832
2837
  }
2833
- } else if ((current instanceof SyntheticShadowRoot || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2838
+ } else if ((isSyntheticShadowRoot(current) || isInstanceOfNativeShadowRoot(current)) && (composed || current !== startRoot)) {
2834
2839
  current = current.host;
2835
2840
  } else if (current instanceof _Node) {
2836
2841
  current = current.parentNode;
@@ -2891,7 +2896,7 @@ function retarget(refNode, path) {
2891
2896
  lastRoot = root;
2892
2897
  }
2893
2898
 
2894
- if (!(root instanceof SyntheticShadowRoot) || !isUndefined(rootIdx) && rootIdx > -1) {
2899
+ if (!isSyntheticShadowRoot(root) || !isUndefined(rootIdx) && rootIdx > -1) {
2895
2900
  return ancestor;
2896
2901
  }
2897
2902
  }
@@ -3695,10 +3700,10 @@ function patchedObserve(target, options) {
3695
3700
  if (ArrayIndexOf.call(targetObservers, this) === -1) {
3696
3701
  ArrayPush.call(targetObservers, this);
3697
3702
  } // else There is more bookkeeping to do here https://dom.spec.whatwg.org/#dom-mutationobserver-observe Step #7
3698
- // If the target is a SyntheticShadowRoot, observe the host since the shadowRoot is an empty documentFragment
3703
+ // SyntheticShadowRoot instances are not actually a part of the DOM so observe the host instead.
3699
3704
 
3700
3705
 
3701
- if (target instanceof SyntheticShadowRoot) {
3706
+ if (isSyntheticShadowRoot(target)) {
3702
3707
  target = target.host;
3703
3708
  } // maintain a list of all nodes observed by this observer
3704
3709
 
@@ -3742,7 +3747,7 @@ defineProperty(window, 'MutationObserver', {
3742
3747
  */
3743
3748
 
3744
3749
  function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3745
- if (isHostElement(this)) {
3750
+ if (isSyntheticShadowHost(this)) {
3746
3751
  // Typescript does not like it when you treat the `arguments` object as an array
3747
3752
  // @ts-ignore type-mismatch
3748
3753
  return addCustomElementEventListener.apply(this, arguments);
@@ -3770,7 +3775,7 @@ function patchedAddEventListener$1(type, listener, optionsOrCapture) {
3770
3775
  }
3771
3776
 
3772
3777
  function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
3773
- if (isHostElement(this)) {
3778
+ if (isSyntheticShadowHost(this)) {
3774
3779
  // Typescript does not like it when you treat the `arguments` object as an array
3775
3780
  // @ts-ignore type-mismatch
3776
3781
  return removeCustomElementEventListener.apply(this, arguments);
@@ -3936,7 +3941,7 @@ function patchedTargetGetter() {
3936
3941
  let actualCurrentTarget = originalCurrentTarget;
3937
3942
  let actualPath = composedPath; // Address the possibility that `currentTarget` is a shadow root
3938
3943
 
3939
- if (isHostElement(originalCurrentTarget)) {
3944
+ if (isSyntheticShadowHost(originalCurrentTarget)) {
3940
3945
  const context = eventToContextMap.get(this);
3941
3946
 
3942
3947
  if (context === 1
@@ -3947,7 +3952,7 @@ function patchedTargetGetter() {
3947
3952
  } // Address the possibility that `target` is a shadow root
3948
3953
 
3949
3954
 
3950
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
3955
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
3951
3956
  actualPath = pathComposer(getShadowRoot(originalTarget), this.composed);
3952
3957
  }
3953
3958
 
@@ -3984,7 +3989,7 @@ function patchedComposedPathValue() {
3984
3989
 
3985
3990
  let actualTarget = originalTarget;
3986
3991
 
3987
- if (isHostElement(originalTarget) && eventToShadowRootMap.has(this)) {
3992
+ if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
3988
3993
  actualTarget = getShadowRoot(originalTarget);
3989
3994
  }
3990
3995
 
@@ -4255,7 +4260,7 @@ function getNonPatchedFilteredArrayOfNodes(context, unfilteredNodes) {
4255
4260
  const ownerKey = getNodeOwnerKey(context); // a node inside a shadow.
4256
4261
 
4257
4262
  if (!isUndefined(ownerKey)) {
4258
- if (isHostElement(context)) {
4263
+ if (isSyntheticShadowHost(context)) {
4259
4264
  // element with shadowRoot attached
4260
4265
  const owner = getNodeOwner(context);
4261
4266
 
@@ -4316,7 +4321,7 @@ function attachShadowPatched(options) {
4316
4321
  }
4317
4322
 
4318
4323
  function shadowRootGetterPatched() {
4319
- if (isHostElement(this)) {
4324
+ if (isSyntheticShadowHost(this)) {
4320
4325
  const shadow = getShadowRoot(this);
4321
4326
 
4322
4327
  if (shadow.mode === 'open') {
@@ -4354,7 +4359,7 @@ defineProperties(Element.prototype, {
4354
4359
  innerHTML: {
4355
4360
  get() {
4356
4361
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4357
- if (isNodeShadowed(this) || isHostElement(this)) {
4362
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
4358
4363
  return innerHTMLGetterPatched.call(this);
4359
4364
  }
4360
4365
 
@@ -4379,7 +4384,7 @@ defineProperties(Element.prototype, {
4379
4384
  outerHTML: {
4380
4385
  get() {
4381
4386
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
4382
- if (isNodeShadowed(this) || isHostElement(this)) {
4387
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
4383
4388
  return outerHTMLGetterPatched.call(this);
4384
4389
  }
4385
4390
 
@@ -4484,7 +4489,7 @@ if (hasOwnProperty.call(HTMLElement.prototype, 'children')) {
4484
4489
  function querySelectorPatched() {
4485
4490
  const nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
4486
4491
 
4487
- if (isHostElement(this)) {
4492
+ if (isSyntheticShadowHost(this)) {
4488
4493
  // element with shadowRoot attached
4489
4494
  const owner = getNodeOwner(this);
4490
4495
 
@@ -4535,7 +4540,7 @@ function querySelectorPatched() {
4535
4540
  function getFilteredArrayOfNodes(context, unfilteredNodes, shadowDomSemantic) {
4536
4541
  let filtered;
4537
4542
 
4538
- if (isHostElement(context)) {
4543
+ if (isSyntheticShadowHost(context)) {
4539
4544
  // element with shadowRoot attached
4540
4545
  const owner = getNodeOwner(context);
4541
4546
 
@@ -4743,7 +4748,7 @@ function isVisible(element) {
4743
4748
 
4744
4749
 
4745
4750
  function isTabbable(element) {
4746
- if (isHostElement(element) && isDelegatingFocus(element)) {
4751
+ if (isSyntheticShadowHost(element) && isDelegatingFocus(element)) {
4747
4752
  return false;
4748
4753
  }
4749
4754
 
@@ -5436,7 +5441,7 @@ function focusPatched() {
5436
5441
  disableKeyboardFocusNavigationRoutines();
5437
5442
  }
5438
5443
 
5439
- if (isHostElement(this) && isDelegatingFocus(this)) {
5444
+ if (isSyntheticShadowHost(this) && isDelegatingFocus(this)) {
5440
5445
  hostElementFocus.call(this);
5441
5446
  return;
5442
5447
  } // Typescript does not like it when you treat the `arguments` object as an array
@@ -5455,7 +5460,7 @@ function focusPatched() {
5455
5460
  defineProperties(HTMLElement.prototype, {
5456
5461
  tabIndex: {
5457
5462
  get() {
5458
- if (isHostElement(this)) {
5463
+ if (isSyntheticShadowHost(this)) {
5459
5464
  return tabIndexGetterPatched.call(this);
5460
5465
  }
5461
5466
 
@@ -5463,7 +5468,7 @@ defineProperties(HTMLElement.prototype, {
5463
5468
  },
5464
5469
 
5465
5470
  set(v) {
5466
- if (isHostElement(this)) {
5471
+ if (isSyntheticShadowHost(this)) {
5467
5472
  return tabIndexSetterPatched.call(this, v);
5468
5473
  }
5469
5474
 
@@ -5475,7 +5480,7 @@ defineProperties(HTMLElement.prototype, {
5475
5480
  },
5476
5481
  blur: {
5477
5482
  value() {
5478
- if (isHostElement(this)) {
5483
+ if (isSyntheticShadowHost(this)) {
5479
5484
  return blurPatched.call(this);
5480
5485
  }
5481
5486
 
@@ -5507,7 +5512,7 @@ if (innerTextGetter !== null && innerTextSetter !== null) {
5507
5512
  }
5508
5513
 
5509
5514
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5510
- if (isNodeShadowed(this) || isHostElement(this)) {
5515
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5511
5516
  return getInnerText(this);
5512
5517
  }
5513
5518
 
@@ -5543,7 +5548,7 @@ if (outerTextGetter !== null && outerTextSetter !== null) {
5543
5548
  }
5544
5549
 
5545
5550
  if (!runtimeFlags.ENABLE_ELEMENT_PATCH) {
5546
- if (isNodeShadowed(this) || isHostElement(this)) {
5551
+ if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
5547
5552
  return getInnerText(this);
5548
5553
  }
5549
5554
 
@@ -5645,7 +5650,7 @@ function adoptChildNode(node, fn, shadowToken) {
5645
5650
  if (node instanceof Element) {
5646
5651
  setShadowToken(node, shadowToken);
5647
5652
 
5648
- if (isHostElement(node)) {
5653
+ if (isSyntheticShadowHost(node)) {
5649
5654
  // Root LWC elements can't get content slotted into them, therefore we don't observe their children.
5650
5655
  return;
5651
5656
  }
@@ -5752,4 +5757,4 @@ defineProperty(Element.prototype, '$domManual$', {
5752
5757
 
5753
5758
  configurable: true
5754
5759
  });
5755
- /** version: 2.5.3 */
5760
+ /** version: 2.5.7 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/synthetic-shadow",
3
- "version": "2.5.3",
3
+ "version": "2.5.7",
4
4
  "description": "Synthetic Shadow Root for LWC",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "access": "public"
37
37
  },
38
38
  "devDependencies": {
39
- "@lwc/features": "2.5.3",
40
- "@lwc/shared": "2.5.3"
39
+ "@lwc/features": "2.5.7",
40
+ "@lwc/shared": "2.5.7"
41
41
  },
42
- "gitHead": "ac4aabb18775261b4b6f71eefd5e4cfc172c895b"
42
+ "gitHead": "21ceae9481bd9222dc503fc4ba664a0f45f6070c"
43
43
  }