aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2017-10-13 17:46:23 -0700
committerGitHub <noreply@github.com>2017-10-13 17:46:23 -0700
commit05648b9995955e057af0217f3eaa778a252c5bd7 (patch)
tree375a4604e03875e7aa9904dcd6f28346c5fbf06c /ext
parentad6ffc54c3795c623eafd0f0a86dd462bc5593c4 (diff)
parent5502bf8aed8b9b4158cfe02ea5b042b03ef2f5cf (diff)
Merge pull request #92 from RodericDay/dev
Place `nodeType` checks inside `caretRangeFromPoint` function
Diffstat (limited to 'ext')
-rw-r--r--ext/fg/js/document.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index a1806d77..821a279f 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -76,7 +76,7 @@ function docRangeFromPoint(point) {
if (!document.caretRangeFromPoint) {
document.caretRangeFromPoint = (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();
range.setStart(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);
- if (range && range.startContainer.nodeType === 3 && range.endContainer.nodeType === 3) {
+ if (range) {
return new TextSourceRange(range);
}
}