From 6b6190ade7eb825720dd5cbe4485a360d6985ad2 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 4 Mar 2017 20:27:46 -0800 Subject: misc fixes --- ext/fg/js/util.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'ext/fg/js') 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(); -- cgit v1.2.3