Skip to content

Commit

Permalink
fix(selection): Fix getRangeContainer to handle cases where there's n…
Browse files Browse the repository at this point in the history
…o selection in the document
  • Loading branch information
marcbachmann committed Jan 22, 2024
1 parent 2738b1c commit 073d92f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/selection-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class SelectionWatcher {
// rangeCount is 0 or 1 in all browsers except firefox
// firefox can work with multiple ranges
// (on a mac hold down the command key to select multiple ranges)
if (this.selection.rangeCount && successfulSync) {
if (this.selection?.rangeCount && successfulSync) {
const range = this.selection.getRangeAt(0)
const hostNode = parser.getHost(range.commonAncestorContainer)
if (hostNode) return new RangeContainer(hostNode, range)
Expand Down

0 comments on commit 073d92f

Please sign in to comment.