summaryrefslogtreecommitdiff
path: root/ext/mixed/js/document-util.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-23 20:31:48 -0500
committerGitHub <noreply@github.com>2020-11-23 20:31:48 -0500
commit068b1eef71ed1167e7e39effa00cda7deb9251f2 (patch)
treea1a593e6cff0009da2829d2803b570a19fa1ac46 /ext/mixed/js/document-util.js
parent12e5cec99c64af164ddb56fd8262d98a23205083 (diff)
Text scanner improvements (#1056)
* Only ignore nodes on non-web pages * Fix issue where options might not be assigned on nested frontends * Refactor default TextScanner options * Add option to enable search only on click * Simplify restore state assignment * Update options context passing * Fix empty title * Use TextScanner to scan content inside of Display * Rename ignoreNodes to excludeSelector(s) * Fix options update incorrectly triggering a re-search * Fix copy throwing an error on the search page * Replace _onSearchQueryUpdated with _search * Use include selector instead of exclude selector
Diffstat (limited to 'ext/mixed/js/document-util.js')
-rw-r--r--ext/mixed/js/document-util.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/mixed/js/document-util.js b/ext/mixed/js/document-util.js
index da27a75d..611ff98c 100644
--- a/ext/mixed/js/document-util.js
+++ b/ext/mixed/js/document-util.js
@@ -261,6 +261,18 @@ class DocumentUtil {
return false;
}
+ static everyNodeMatchesSelector(nodes, selector) {
+ const ELEMENT_NODE = Node.ELEMENT_NODE;
+ for (let node of nodes) {
+ while (true) {
+ if (node === null) { return false; }
+ if (node.nodeType === ELEMENT_NODE && node.matches(selector)) { break; }
+ node = node.parentNode;
+ }
+ }
+ return true;
+ }
+
static getModifierKeys(os) {
switch (os) {
case 'win':