Skip to content

Commit

Permalink
Check if docView is null in change and composition handling
Browse files Browse the repository at this point in the history
FIX: Fix a crash when a view was being destroyed during input reading.

Closes ProseMirror/prosemirror#1235
  • Loading branch information
marijnh committed Jan 17, 2022
1 parent b1f19a4 commit 8f246f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/domobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class DOMObserver {
checkCSS(this.view)
}
this.handleDOMChange(from, to, typeOver, added)
if (this.view.docView.dirty) this.view.updateState(this.view.state)
if (this.view.docView && this.view.docView.dirty) this.view.updateState(this.view.state)
else if (!this.currentSelection.eq(sel)) selectionToDOM(this.view)
this.currentSelection.set(sel)
}
Expand Down
2 changes: 1 addition & 1 deletion src/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export function endComposition(view, forceUpdate) {
if (browser.android && view.domObserver.flushingSoon >= 0) return
view.domObserver.forceFlush()
clearComposition(view)
if (forceUpdate || view.docView.dirty) {
if (forceUpdate || view.docView && view.docView.dirty) {
let sel = selectionFromDOM(view)
if (sel && !sel.eq(view.state.selection)) view.dispatch(view.state.tr.setSelection(sel))
else view.updateState(view.state)
Expand Down

0 comments on commit 8f246f3

Please sign in to comment.