Merge pull request #219 from toasted-nutbread/fix-null-caret-position

Handle null return value of document.caretPositionFromPoint
This commit is contained in:
Alex Yatskov 2019-09-22 10:06:52 -07:00 committed by GitHub
commit db405ffd24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -267,6 +267,9 @@ const caretRangeFromPoint = (() => {
// Firefox // Firefox
return (x, y) => { return (x, y) => {
const position = document.caretPositionFromPoint(x, y); const position = document.caretPositionFromPoint(x, y);
if (position === null) {
return null;
}
const node = position.offsetNode; const node = position.offsetNode;
if (node === null) { if (node === null) {
return null; return null;