fix(face-landmarks) fix createImageBitMap polyfill on Safari 14

The polyfill returns an Image object instead of an ImageBitmap. The
latter has a close method, however, which we call.

Make sure we provide a dummy close method to avoid errors.
This commit is contained in:
Saúl Ibarra Corretgé 2022-08-08 15:23:35 +02:00 committed by Saúl Ibarra Corretgé
parent dd044ad252
commit ef748c576d
1 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Safari polyfill for createImageBitmap
* Safari < 15 polyfill for createImageBitmap
* https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap
*
* Support source image types: Canvas.
@ -16,6 +16,9 @@ if (!('createImageBitmap' in window)) {
}
const img = document.createElement('img');
// eslint-disable-next-line no-empty-function
img.close = () => {};
img.addEventListener('load', () => {
resolve(img);
});