Skip to content

Commit

Permalink
add guard for selection setting
Browse files Browse the repository at this point in the history
closes slab#1940
  • Loading branch information
jhchen committed Jul 10, 2018
1 parent 9026999 commit 9a65a80
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions core/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ class Selection {
if (native.start.node === this.cursor.textNode) return; // cursor.restore() will handle
this.emitter.once(Emitter.events.SCROLL_UPDATE, () => {
try {
this.setNativeRange(
native.start.node,
native.start.offset,
native.end.node,
native.end.offset,
);
if (
this.root.contains(native.start.node) &&
this.root.contains(native.end.node)
) {
this.setNativeRange(
native.start.node,
native.start.offset,
native.end.node,
native.end.offset,
);
}
this.update(Emitter.sources.SILENT);
} catch (ignored) {
// ignore
Expand Down

0 comments on commit 9a65a80

Please sign in to comment.