Skip to content

Commit

Permalink
Avoid fetching selections when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Feb 24, 2022
1 parent d462f80 commit b212f9e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ class Selection {
}

getRange() {
const root = this.scroll.domNode;
if ('isConnected' in root && !root.isConnected) {
// document.getSelection() forces layout on Blink, so we trend to
// not calling it.
return [null, null];
}
const normalized = this.getNativeRange();
if (normalized == null) return [null, null];
const range = this.normalizedToRange(normalized);
Expand Down

0 comments on commit b212f9e

Please sign in to comment.