aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/util.js
diff options
context:
space:
mode:
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();