I don’t think this is a bug… I think…
I’m using ProseMirror inside a ShadowRoot. In Firefox this fails at prosemirror-view/src/selection.js
on lines like view.root.getSelection()
because root is a ShadowRoot rather than a Document.
Chrome is fine because ShadowRoot has a .getSelection()
method. Firefox, however, doesn’t appear to implement that method on ShadowRoot (yet?) as mentioned on this MDN page. (On the other hand the page actually describing the .getSelection()
method says that Firefox does implement it. Guess that’s just wrong…)
I’ve successfully worked around the issue with this:
ShadowRoot.prototype.getSelection = document.getSelection.bind(document);
Which, rather surprisingly, works because in Firefox the document.getSelection
method crosses shadow dom boundaries. What I can gather from the spec suggests that is actually incorrect behavior.