From 91fb0579f1447f64cbd13041db6d3fcd9f0f0d07 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 6 Aug 2018 17:35:06 +0300 Subject: [PATCH] code clarification --- content/apply.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/content/apply.js b/content/apply.js index 4e27cdd4..34fd3f53 100644 --- a/content/apply.js +++ b/content/apply.js @@ -235,7 +235,7 @@ if (!Array.isArray(sections)) continue; applySections(id, sections.map(({code}) => code).join('\n')); } - docRootObserver.start({sort: true}); + docRootObserver.firstStart(); } if (!isOwnPage && !docRewriteObserver && styleElements.size) { @@ -431,13 +431,16 @@ function init() { observer = new MutationObserver(sortStyleElements); - docRootObserver = {start, stop, evade, disconnect: stop}; + docRootObserver = {firstStart, start, stop, evade, disconnect: stop}; setTimeout(sortStyleElements); } - function start({sort = false} = {}) { - if (sort && sortStyleMap()) { + function firstStart() { + if (sortStyleMap()) { sortStyleElements(); } + start(); + } + function start() { if (!observing && ROOT && observer) { observer.observe(ROOT, {childList: true}); observing = true;