diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index e79dbd11..a22ae953 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -36,6 +36,9 @@ export class AnimeNotifier { Diff.persistentClasses.add("mounted") Diff.persistentClasses.add("image-found") + // Never remove src property on diffs + Diff.persistentAttributes.add("src") + if("IntersectionObserver" in window) { // Enable lazy load this.visibilityObserver = new IntersectionObserver( @@ -374,10 +377,10 @@ export class AnimeNotifier { loading(isLoading: boolean) { if(isLoading) { - document.body.style.cursor = "progress" + document.documentElement.style.cursor = "progress" this.app.loading.classList.remove(this.app.fadeOutClass) } else { - document.body.style.cursor = "auto" + document.documentElement.style.cursor = "auto" this.app.loading.classList.add(this.app.fadeOutClass) } } diff --git a/scripts/Diff.ts b/scripts/Diff.ts index f15765ed..d450c0d9 100644 --- a/scripts/Diff.ts +++ b/scripts/Diff.ts @@ -1,5 +1,6 @@ export class Diff { static persistentClasses = new Set() + static persistentAttributes = new Set() // Reuse container for diffs to avoid memory allocation static container: HTMLElement @@ -22,7 +23,9 @@ export class Diff { } Diff.rootContainer.innerHTML = html.replace("", "") - Diff.childNodes(aRoot, Diff.rootContainer) + console.log(aRoot.getElementsByTagName("body")[0]) + console.log(Diff.rootContainer.getElementsByTagName("body")[0]) + Diff.childNodes(aRoot.getElementsByTagName("body")[0], Diff.rootContainer.getElementsByTagName("body")[0]) } // childNodes diffs the child nodes of 2 given elements and applies DOM mutations. @@ -80,7 +83,7 @@ export class Diff { let attrib = elemA.attributes[x] if(attrib.specified) { - if(!elemB.hasAttribute(attrib.name)) { + if(!elemB.hasAttribute(attrib.name) && !Diff.persistentAttributes.has(attrib.name)) { removeAttributes.push(attrib) } } diff --git a/scripts/main.ts b/scripts/main.ts index 8bea2009..4f1ab54e 100644 --- a/scripts/main.ts +++ b/scripts/main.ts @@ -4,4 +4,7 @@ import { AnimeNotifier } from "./AnimeNotifier" let app = new Application() let arn = new AnimeNotifier(app) -arn.init() \ No newline at end of file +arn.init() + +// For debugging purposes +window["arn"] = arn \ No newline at end of file