code clarification

This commit is contained in:
tophf 2018-08-06 17:35:06 +03:00
parent 1a42e6bf00
commit 91fb0579f1

View File

@ -235,7 +235,7 @@
if (!Array.isArray(sections)) continue; if (!Array.isArray(sections)) continue;
applySections(id, sections.map(({code}) => code).join('\n')); applySections(id, sections.map(({code}) => code).join('\n'));
} }
docRootObserver.start({sort: true}); docRootObserver.firstStart();
} }
if (!isOwnPage && !docRewriteObserver && styleElements.size) { if (!isOwnPage && !docRewriteObserver && styleElements.size) {
@ -431,13 +431,16 @@
function init() { function init() {
observer = new MutationObserver(sortStyleElements); observer = new MutationObserver(sortStyleElements);
docRootObserver = {start, stop, evade, disconnect: stop}; docRootObserver = {firstStart, start, stop, evade, disconnect: stop};
setTimeout(sortStyleElements); setTimeout(sortStyleElements);
} }
function start({sort = false} = {}) { function firstStart() {
if (sort && sortStyleMap()) { if (sortStyleMap()) {
sortStyleElements(); sortStyleElements();
} }
start();
}
function start() {
if (!observing && ROOT && observer) { if (!observing && ROOT && observer) {
observer.observe(ROOT, {childList: true}); observer.observe(ROOT, {childList: true});
observing = true; observing = true;