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.
This commit is contained in:
toasted-nutbread 2019-08-31 23:46:29 -04:00
parent a2139213c8
commit c0bf6ff033

View File

@ -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;