aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/document.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/document.js')
-rw-r--r--ext/fg/js/document.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index a017a0a6..e6a16bd5 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -70,12 +70,6 @@ function docImposterCreate(element) {
return imposter;
}
-function docImposterDestroy() {
- for (const element of document.getElementsByClassName('yomichan-imposter')) {
- element.parentNode.removeChild(element);
- }
-}
-
function docRangeFromPoint(point) {
const element = document.elementFromPoint(point.x, point.y);
let imposter = null;
@@ -92,12 +86,18 @@ function docRangeFromPoint(point) {
}
const range = document.caretRangeFromPoint(point.x, point.y);
- if (imposter !== null) {
- imposter.style.zIndex = -2147483646;
- imposter.style.pointerEvents = 'none';
+ if (range !== null && isPointInRange(point, range)) {
+ if (imposter !== null) {
+ imposter.style.zIndex = -2147483646;
+ imposter.style.pointerEvents = 'none';
+ }
+ return new TextSourceRange(range, '', imposter);
+ } else {
+ if (imposter !== null) {
+ imposter.parentNode.removeChild(imposter);
+ }
+ return null;
}
-
- return range !== null && isPointInRange(point, range) ? new TextSourceRange(range) : null;
}
function docSentenceExtract(source, extent) {