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;
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;