aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/util.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-04 20:27:46 -0800
committerAlex Yatskov <alex@foosoft.net>2017-03-04 20:27:46 -0800
commit6b6190ade7eb825720dd5cbe4485a360d6985ad2 (patch)
treef70f1c8c126baf99bbffd846500ee7ae6bf77e7a /ext/fg/js/util.js
parent5daf2accf4d6628131cd8e054ca6258a669eb715 (diff)
misc fixes
Diffstat (limited to 'ext/fg/js/util.js')
-rw-r--r--ext/fg/js/util.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js
index ac6ee428..be809bfb 100644
--- a/ext/fg/js/util.js
+++ b/ext/fg/js/util.js
@@ -119,8 +119,17 @@ function docImposterHide() {
}
function docRangeFromPoint(point, imposter) {
- if (!document.elementFromPoint) {
- document.elementFromPoint = (x, y) => {
+ const element = document.elementFromPoint(point.x, point.y);
+ if (element !== null) {
+ if (element.nodeName === 'IMG' || element.nodeName === 'BUTTON') {
+ return new TextSourceElement(element);
+ } else if (imposter && (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA')) {
+ docImposterCreate(element);
+ }
+ }
+
+ if (!document.caretRangeFromPoint) {
+ document.caretRangeFromPoint = (x, y) => {
const position = document.caretPositionFromPoint(x,y);
if (position === null) {
return null;
@@ -133,15 +142,6 @@ function docRangeFromPoint(point, imposter) {
};
}
- const element = document.elementFromPoint(point.x, point.y);
- if (element !== null) {
- if (element.nodeName === 'IMG' || element.nodeName === 'BUTTON') {
- return new TextSourceElement(element);
- } else if (imposter && (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA')) {
- docImposterCreate(element);
- }
- }
-
const range = document.caretRangeFromPoint(point.x, point.y);
if (range !== null) {
docImposterHide();