fixing leaking EventHandlers when using HTMLCanvasElement

pull/188/head
rebser 2024-01-19 08:38:59 +01:00 committed by GitHub
parent 2f0469fe6e
commit 155f07dccd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -4,7 +4,10 @@ import { isMediaLoaded } from './isMediaLoaded';
export function awaitMediaLoaded(media: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement) {
// eslint-disable-next-line consistent-return
return new Promise((resolve, reject) => {
if (media instanceof env.getEnv().Canvas || isMediaLoaded(media)) resolve(null);
if (media instanceof env.getEnv().Canvas || isMediaLoaded(media)) {
resolve(null);
return;
}
function onError(e: Event) {
if (!e.currentTarget) return;