Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
khaitruong922 committed Sep 25, 2024
1 parent 6d841f6 commit ba8cd7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 0 additions & 12 deletions ext/js/dom/text-source-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ export class TextSourceRange {
return this._imposterSourceElement;
}

/**
* Determines whether the imposter source element is an input or textarea element.
* @returns {boolean} `true` if the imposter source element is an input or textarea element, `false` otherwise.
*/
isImposterInputOrTextArea() {
if (this._imposterSourceElement) {
const type = this._imposterSourceElement.nodeName.toUpperCase();
return type === 'INPUT' || type === 'TEXTAREA';
}
return false;
}

/**
* Creates a clone of the instance.
* @returns {TextSourceRange} The new clone.
Expand Down
12 changes: 8 additions & 4 deletions ext/js/language/text-scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {log} from '../core/log.js';
import {clone} from '../core/utilities.js';
import {anyNodeMatchesSelector, everyNodeMatchesSelector, getActiveModifiers, getActiveModifiersAndButtons, isPointInSelection} from '../dom/document-util.js';
import {TextSourceElement} from '../dom/text-source-element.js';
import {TextSourceRange} from '../dom/text-source-range.js';

/**
* @augments EventDispatcher<import('text-scanner').Events>
Expand Down Expand Up @@ -466,9 +465,14 @@ export class TextScanner extends EventDispatcher {
async _search(textSource, searchTerms, searchKanji, inputInfo, showEmpty = false) {
try {
const isAltText = textSource instanceof TextSourceElement;
const isInputOrTextArea = textSource instanceof TextSourceRange && textSource.isImposterInputOrTextArea();
if (inputInfo.pointerType === 'touch' && (isAltText || isInputOrTextArea)) {
return;
if (inputInfo.pointerType === 'touch') {
if (isAltText) {
return;
}
const {imposterSourceElement} = textSource;
if (imposterSourceElement instanceof HTMLTextAreaElement || imposterSourceElement instanceof HTMLInputElement) {
return;
}
}

const inputInfoDetail = inputInfo.detail;
Expand Down

0 comments on commit ba8cd7c

Please sign in to comment.