mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Remove mutation observer to improve inspector perf
This commit is contained in:
parent
054ef164d0
commit
fcb240ce60
|
|
@ -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"],
|
||||
// })
|
||||
|
|
|
|||
Loading…
Reference in a new issue