Improve handling of null values from caretRangeFromPoint
This commit is contained in:
parent
ba972d8547
commit
dd52a1c01a
@ -85,20 +85,18 @@ function docRangeFromPoint(point) {
|
|||||||
range.setEnd(position.offsetNode, position.offset);
|
range.setEnd(position.offsetNode, position.offset);
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const range = document.caretRangeFromPoint(point.x, point.y);
|
const range = document.caretRangeFromPoint(point.x, point.y);
|
||||||
|
if (range === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(imposter !== null) imposter.style.zIndex = -2147483646;
|
if(imposter !== null) imposter.style.zIndex = -2147483646;
|
||||||
|
|
||||||
let rects;
|
const rects = range.getClientRects();
|
||||||
try {
|
|
||||||
rects = range.getClientRects();
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rects.length === 0) {
|
if (rects.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user