slate-react 0.88.2-202301435052 → 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.
package/dist/index.es.js CHANGED
@@ -213,8 +213,18 @@ var normalizeDOMPoint = domPoint => {
213
213
  * Determines wether the active element is nested within a shadowRoot
214
214
  */
215
215
 
216
- var hasShadowRoot = () => {
217
- return !!(window.document.activeElement && window.document.activeElement.shadowRoot);
216
+ var hasShadowRoot = node => {
217
+ var parent = node && node.parentNode;
218
+
219
+ while (parent) {
220
+ if (parent.toString() === '[object ShadowRoot]') {
221
+ return true;
222
+ }
223
+
224
+ parent = parent.parentNode;
225
+ }
226
+
227
+ return false;
218
228
  };
219
229
  /**
220
230
  * Get the nearest editable child and index at `index` in a `parent`, preferring
@@ -947,7 +957,7 @@ var ReactEditor = {
947
957
  // (2020/08/08)
948
958
  // https://bugs.chromium.org/p/chromium/issues/detail?id=447523
949
959
 
950
- if (IS_CHROME && hasShadowRoot()) {
960
+ if (IS_CHROME && hasShadowRoot(anchorNode)) {
951
961
  isCollapsed = domRange.anchorNode === domRange.focusNode && domRange.anchorOffset === domRange.focusOffset;
952
962
  } else {
953
963
  isCollapsed = domRange.isCollapsed;