diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-10-20 20:54:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 20:54:26 -0400 |
commit | 6f980d8f2be1714a29ceac1e402198f68b377880 (patch) | |
tree | eea02fa59eabc24f9af5f9974badb9b30cc39fa6 /ext/mixed/js | |
parent | 9bda0a9eb43e127fdaa0066fba7e3e73c9f74812 (diff) |
Text source range refactor (#949)
* Rename functions for better clarity
* Remove unused properties
* Add getNodesInRange function
* Improve ignore nodes check
* Use private fields
Diffstat (limited to 'ext/mixed/js')
-rw-r--r-- | ext/mixed/js/text-scanner.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index d8bdd653..f4b8df68 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -178,13 +178,12 @@ class TextScanner extends EventDispatcher { clonedTextSource.setEndOffset(length, layoutAwareScan); - if (this._ignoreNodes !== null && clonedTextSource.range) { + if (this._ignoreNodes !== null) { length = clonedTextSource.text().length; - while (clonedTextSource.range && length > 0) { - const nodes = DocumentUtil.getNodesInRange(clonedTextSource.range); - if (!DocumentUtil.anyNodeMatchesSelector(nodes, this._ignoreNodes)) { - break; - } + while ( + length > 0 && + DocumentUtil.anyNodeMatchesSelector(clonedTextSource.getNodesInRange(), this._ignoreNodes) + ) { --length; clonedTextSource.setEndOffset(length, layoutAwareScan); } @@ -247,7 +246,7 @@ class TextScanner extends EventDispatcher { let optionsContext = null; try { - if (this._textSourceCurrent !== null && this._textSourceCurrent.equals(textSource)) { + if (this._textSourceCurrent !== null && this._textSourceCurrent.hasSameStart(textSource)) { return; } @@ -772,7 +771,7 @@ class TextScanner extends EventDispatcher { if ( this._textSourceCurrent !== null && - !this._textSourceCurrent.equals(textSourceCurrentPrevious) + !this._textSourceCurrent.hasSameStart(textSourceCurrentPrevious) ) { this._preventScroll = preventScroll; this._preventNextContextMenu = true; |