Fixed a bug in Firefox WebP detection

This commit is contained in:
Eduard Urbach 2019-03-27 01:07:02 +09:00
parent bdb69f7e63
commit 7dcad4cf54

View File

@ -20,6 +20,7 @@ export default class AnimeNotifier {
analytics: Analytics analytics: Analytics
user: HTMLElement user: HTMLElement
title: string title: string
webpCheck: Promise<boolean>
webpEnabled: boolean webpEnabled: boolean
contentLoadedActions: Promise<any> contentLoadedActions: Promise<any>
statusMessage: StatusMessage statusMessage: StatusMessage
@ -106,7 +107,7 @@ export default class AnimeNotifier {
this.run() this.run()
} }
async run() { run() {
// Initiate the elements we need // Initiate the elements we need
this.user = document.getElementById("user") this.user = document.getElementById("user")
this.app.content = document.getElementById("content") this.app.content = document.getElementById("content")
@ -149,7 +150,7 @@ export default class AnimeNotifier {
this.infiniteScroller = new InfiniteScroller(this.app.content.parentElement, 150) this.infiniteScroller = new InfiniteScroller(this.app.content.parentElement, 150)
// WebP // WebP
this.webpEnabled = await supportsWebP() this.webpCheck = supportsWebP().then(val => this.webpEnabled = val)
// Loading // Loading
this.loading(false) this.loading(false)
@ -790,11 +791,13 @@ export default class AnimeNotifier {
} }
} }
lazyLoad(elements?: IterableIterator<Element>) { async lazyLoad(elements?: IterableIterator<Element>) {
if(!elements) { if(!elements) {
elements = findAll("lazy") elements = findAll("lazy")
} }
await this.webpCheck
for(let element of elements) { for(let element of elements) {
switch(element.tagName) { switch(element.tagName) {
case "IMG": case "IMG":