From c0bf6ff0339c3cdbb4976a6df844c67d50f90835 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 31 Aug 2019 23:46:29 -0400 Subject: Fix issues caused by scanning ranges which don't start with a text node The rects returned by range.getClientRects() could include the entire start element's bounding box. --- ext/fg/js/document.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index fc8000dd..71a3d7f2 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -195,6 +195,11 @@ function docSentenceExtract(source, extent) { } function isPointInRange(x, y, range) { + // Require a text node to start + if (range.startContainer.nodeType !== Node.TEXT_NODE) { + return false; + } + // Scan forward const nodePre = range.endContainer; const offsetPre = range.endOffset; -- cgit v1.2.3