Skip to content

Commit

Permalink
Merge pull request #3538 from quilljs/zh-perf-get-range
Browse files Browse the repository at this point in the history
Avoid fetching selections when possible
  • Loading branch information
jhchen authored Feb 25, 2022
2 parents d462f80 + b212f9e commit 6cbebf2
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 6cbebf2

Please sign in to comment.