Skip to content
Permalink
Browse files

Polyfill ShadowRoot.getSelection when not available

FIX: The `root` accessor on views now makes sure that, when it returns a
shadow root, that object has a `getSelection` method.

See https://discuss.prosemirror.net/t/prosemirror-inside-a-shadowroot/2387
  • Loading branch information
marijnh committed Dec 2, 2019
1 parent d44c736 commit bf61fc34b74baf2fb7884fae344a31f0f9fc708d
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/index.js
@@ -247,8 +247,10 @@ export class EditorView {
get root() {
let cached = this._root
if (cached == null) for (let search = this.dom.parentNode; search; search = search.parentNode) {
if (search.nodeType == 9 || (search.nodeType == 11 && search.host))
if (search.nodeType == 9 || (search.nodeType == 11 && search.host)) {
if (!search.getSelection) Object.getPrototypeOf(search).getSelection = () => document.getSelection()
return this._root = search
}
}
return cached || document
}

0 comments on commit bf61fc3

Please sign in to comment.
You can’t perform that action at this time.