@portabletext/editor 7.12.1 → 7.12.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/lib/index.js CHANGED
@@ -107,7 +107,7 @@ const getDefaultView = (value) => value && value.ownerDocument && value.ownerDoc
107
107
  for (; current;) {
108
108
  if (current.matches && current.matches(selector)) return current;
109
109
  if (current.parentElement) current = current.parentElement;
110
- else if (current.parentNode && "host" in current.parentNode) current = current.parentNode.host;
110
+ else if (isShadowRoot(current.parentNode)) current = current.parentNode.host;
111
111
  else return null;
112
112
  }
113
113
  return null;
@@ -117,11 +117,11 @@ const getDefaultView = (value) => value && value.ownerDocument && value.ownerDoc
117
117
  let current = child;
118
118
  for (; current;) {
119
119
  if (current === parent) return !0;
120
- if (current.parentNode) current = "host" in current.parentNode ? current.parentNode.host : current.parentNode;
120
+ if (current.parentNode) current = isShadowRoot(current.parentNode) ? current.parentNode.host : current.parentNode;
121
121
  else return !1;
122
122
  }
123
123
  return !1;
124
- }, KEYED_SEGMENT_PATTERN = /\[_key=="(.+?)"\]/;
124
+ }, isShadowRoot = (value) => isDOMNode(value) && value.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in value, KEYED_SEGMENT_PATTERN = /\[_key=="(.+?)"\]/;
125
125
  /**
126
126
  * Deserialize a serialized keyed path using Sanity's bracket notation.
127
127
  *