aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/util.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-07-09 15:23:11 -0700
committerAlex Yatskov <alex@foosoft.net>2017-07-09 15:23:11 -0700
commitb3984ccd54340195fc352033f61d33e4b5f492ea (patch)
tree2c75588abd020998c0745f8871a043ae48c77073 /ext/fg/js/util.js
parentd57c5530b7ad56a7cc89782b4d186d8fddb55d86 (diff)
cleanup
Diffstat (limited to 'ext/fg/js/util.js')
-rw-r--r--ext/fg/js/util.js18
1 files changed, 7 insertions, 11 deletions
diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js
index e1b0e080..2acd81c4 100644
--- a/ext/fg/js/util.js
+++ b/ext/fg/js/util.js
@@ -117,7 +117,7 @@ function docImposterDestroy() {
function docRangeFromPoint(point) {
const element = document.elementFromPoint(point.x, point.y);
- if (element !== null) {
+ if (element) {
if (element.nodeName === 'IMG' || element.nodeName === 'BUTTON') {
return new TextSourceElement(element);
} else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
@@ -128,23 +128,19 @@ function docRangeFromPoint(point) {
if (!document.caretRangeFromPoint) {
document.caretRangeFromPoint = (x, y) => {
const position = document.caretPositionFromPoint(x,y);
- if (position === null) {
- return null;
+ if (position) {
+ const range = document.createRange();
+ range.setStart(position.offsetNode, position.offset);
+ range.setEnd(position.offsetNode, position.offset);
+ return range;
}
-
- const range = document.createRange();
- range.setStart(position.offsetNode, position.offset);
- range.setEnd(position.offsetNode, position.offset);
- return range;
};
}
const range = document.caretRangeFromPoint(point.x, point.y);
- if (range !== null) {
+ if (range) {
return new TextSourceRange(range);
}
-
- return null;
}
function docSentenceExtract(source, extent) {