Remove mutation observer to improve inspector perf

This commit is contained in:
Oliver Blanthorn 2019-11-12 09:39:01 +00:00
parent 054ef164d0
commit fcb240ce60
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -82,18 +82,18 @@ config.addChangeListener("theme", retheme)
// Sometimes pages will overwrite class names of elements. We use a MutationObserver to make sure that the HTML element always has a TridactylTheme class
// We can't just call theme() because it would first try to remove class names from the element, which would trigger the MutationObserver before we had a chance to add the theme class and thus cause infinite recursion
const cb = async mutationList => {
const theme = await config.getAsync("theme")
mutationList
.filter(m => m.target.className.search(prefixTheme("")) === -1)
.forEach(m => m.target.classList.add(prefixTheme(theme)))
}
// const cb = async mutationList => {
// const theme = await config.getAsync("theme")
// mutationList
// .filter(m => m.target.className.search(prefixTheme("")) === -1)
// .forEach(m => m.target.classList.add(prefixTheme(theme)))
// }
new MutationObserver(cb).observe(document.documentElement, {
attributes: true,
childList: false,
characterData: false,
subtree: false,
attributeOldValue: false,
attributeFilter: ["class"],
})
// new MutationObserver(cb).observe(document.documentElement, {
// attributes: true,
// childList: false,
// characterData: false,
// subtree: false,
// attributeOldValue: false,
// attributeFilter: ["class"],
// })