From 8fc6c8bcde85db89246a1a455ae17cd46ab4d4b6 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 25 Feb 2022 01:26:50 +0300 Subject: [PATCH] cosmetics --- js/dom.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/dom.js b/js/dom.js index 3f70d36b..d5830f3c 100644 --- a/js/dom.js +++ b/js/dom.js @@ -381,8 +381,8 @@ function waitForSelector(selector, {recur, stopOnDomReady = true} = {}) { if (!el) el = $(selector); if (!el) return; if (!recur || - callRecur(mutations) === false || - stopOnDomReady && document.readyState === 'complete') { + callRecur(mutations) === false || + stopOnDomReady && document.readyState === 'complete') { observer.disconnect(); } if (resolve) { @@ -394,7 +394,8 @@ function waitForSelector(selector, {recur, stopOnDomReady = true} = {}) { return n.tagName && (n.matches(selector) || n.firstElementChild && $(selector, n)); } function callRecur([m0, m1]) { - if (m1 || (m0 = m0.addedNodes)[3] || [].some.call(m0, isMatching)) { // Skipping tiny records + // Checking addedNodes if only 1 MutationRecord to skip simple mutations quickly + if (m1 || (m0 = m0.addedNodes)[3] || [].some.call(m0, isMatching)) { const all = $$(selector); // Using one $$ call instead of ~100 calls for each node const added = !elems ? all : all.filter(el => !elems.includes(el)); if (added.length) {