slate-react 0.88.2-202301434534 → 0.88.2

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.
@@ -1079,8 +1079,18 @@
1079
1079
  * Determines wether the active element is nested within a shadowRoot
1080
1080
  */
1081
1081
 
1082
- var hasShadowRoot = function hasShadowRoot() {
1083
- return !!(window.document.activeElement && window.document.activeElement.shadowRoot);
1082
+ var hasShadowRoot = function hasShadowRoot(node) {
1083
+ var parent = node && node.parentNode;
1084
+
1085
+ while (parent) {
1086
+ if (parent.toString() === '[object ShadowRoot]') {
1087
+ return true;
1088
+ }
1089
+
1090
+ parent = parent.parentNode;
1091
+ }
1092
+
1093
+ return false;
1084
1094
  };
1085
1095
  /**
1086
1096
  * Get the nearest editable child and index at `index` in a `parent`, preferring
@@ -1841,7 +1851,7 @@
1841
1851
  // (2020/08/08)
1842
1852
  // https://bugs.chromium.org/p/chromium/issues/detail?id=447523
1843
1853
 
1844
- if (IS_CHROME && hasShadowRoot()) {
1854
+ if (IS_CHROME && hasShadowRoot(anchorNode)) {
1845
1855
  isCollapsed = domRange.anchorNode === domRange.focusNode && domRange.anchorOffset === domRange.focusOffset;
1846
1856
  } else {
1847
1857
  isCollapsed = domRange.isCollapsed;