Place nodeType
checks inside caretRangeFromPoint
function
Checked that it does not un-fix #80 Squelches alerts (but does not fix underlying issue) for #89
This commit is contained in:
parent
ad6ffc54c3
commit
5502bf8aed
@ -76,7 +76,7 @@ function docRangeFromPoint(point) {
|
|||||||
if (!document.caretRangeFromPoint) {
|
if (!document.caretRangeFromPoint) {
|
||||||
document.caretRangeFromPoint = (x, y) => {
|
document.caretRangeFromPoint = (x, y) => {
|
||||||
const position = document.caretPositionFromPoint(x,y);
|
const position = document.caretPositionFromPoint(x,y);
|
||||||
if (position && position.offsetNode) {
|
if (position && position.offsetNode && position.offsetNode.nodeType === Node.TEXT_NODE) {
|
||||||
const range = document.createRange();
|
const range = document.createRange();
|
||||||
range.setStart(position.offsetNode, position.offset);
|
range.setStart(position.offsetNode, position.offset);
|
||||||
range.setEnd(position.offsetNode, position.offset);
|
range.setEnd(position.offsetNode, position.offset);
|
||||||
@ -86,7 +86,7 @@ function docRangeFromPoint(point) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const range = document.caretRangeFromPoint(point.x, point.y);
|
const range = document.caretRangeFromPoint(point.x, point.y);
|
||||||
if (range && range.startContainer.nodeType === 3 && range.endContainer.nodeType === 3) {
|
if (range) {
|
||||||
return new TextSourceRange(range);
|
return new TextSourceRange(range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user