summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-14 14:52:03 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-14 14:52:03 -0400
commit8b1e4d1c6fc5f496c05bb69fe9e6b2cd12c9090b (patch)
treedd96bd0e503d42bb870889c2187f3a390646f2e0
parent7dddcb8dca226e79453aa7734c99df1b18af4366 (diff)
Return only single element when deepDomScan is not enabled
-rw-r--r--ext/fg/js/document.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index f2459197..079a5034 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -89,8 +89,18 @@ function docImposterCreate(element, isTextarea) {
return [imposter, container];
}
+function docElementsFromPoint(x, y, all) {
+ if (all) {
+ return document.elementsFromPoint(x, y);
+ }
+
+ const e = document.elementFromPoint(x, y);
+ return e !== null ? [e] : [];
+}
+
function docRangeFromPoint(x, y, options) {
- const elements = document.elementsFromPoint(x, y);
+ const deepDomScan = options.scanning.deepDomScan;
+ const elements = docElementsFromPoint(x, y, deepDomScan);
let imposter = null;
let imposterContainer = null;
if (elements.length > 0) {
@@ -108,7 +118,7 @@ function docRangeFromPoint(x, y, options) {
}
}
- const range = caretRangeFromPointExt(x, y, options.scanning.deepDomScan ? elements : []);
+ const range = caretRangeFromPointExt(x, y, deepDomScan ? elements : []);
if (range !== null) {
if (imposter !== null) {
docSetImposterStyle(imposterContainer.style, 'z-index', '-2147483646');