diff options
author | James Maa <jmaa@berkeley.edu> | 2024-06-16 18:39:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-17 01:39:44 +0000 |
commit | 1d2a91523604cce7dd608408da65bea5645fc7d4 (patch) | |
tree | 7c2b915dc29fffc707a5376002682256bce2c6de /ext/js/dom | |
parent | 0283b298af2d04c7bc013fad7db5966d651f0142 (diff) |
Fix DOMTextScanner entering initial div on backwards seeks (#1071)
* Fix dom-text-scanner entering initial div on reverse seeks
* Add new case
* Add launch.json
* Cleanup launch.json
Diffstat (limited to 'ext/js/dom')
-rw-r--r-- | ext/js/dom/dom-text-scanner.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/js/dom/dom-text-scanner.js b/ext/js/dom/dom-text-scanner.js index eb56baf9..5325b894 100644 --- a/ext/js/dom/dom-text-scanner.js +++ b/ext/js/dom/dom-text-scanner.js @@ -37,6 +37,8 @@ export class DOMTextScanner { if (resetOffset) { node = ruby; } /** @type {Node} */ + this._initialNode = node; + /** @type {Node} */ this._node = node; /** @type {number} */ this._offset = offset; @@ -129,11 +131,16 @@ export class DOMTextScanner { } } else if (nodeType === ELEMENT_NODE) { lastNode = node; + const initialNodeAtBeginningOfNodeGoingBackwards = node === this._initialNode && this._offset === 0 && !forward; + const initialNodeAtEndOfNodeGoingForwards = node === this._initialNode && this._offset === node.childNodes.length && forward; this._offset = 0; ({enterable, newlines} = DOMTextScanner.getElementSeekInfo(/** @type {Element} */ (node))); if (newlines > this._newlines && generateLayoutContent) { this._newlines = newlines; } + if (initialNodeAtBeginningOfNodeGoingBackwards || initialNodeAtEndOfNodeGoingForwards) { + enterable = false; + } } /** @type {Node[]} */ |