Merge pull request #9658 from fredj/f9628

Don't use HTMLImageElement.decode method on Safari
This commit is contained in:
Frédéric Junod
2019-06-06 16:34:57 +02:00
committed by GitHub

View File

@@ -6,6 +6,7 @@ import ImageState from './ImageState.js';
import {listenOnce, unlistenByKey} from './events.js';
import EventType from './events/EventType.js';
import {getHeight} from './extent.js';
import {SAFARI} from './has.js';
/**
@@ -157,7 +158,11 @@ class ImageWrapper extends ImageBase {
*/
export function listenImage(image, loadHandler, errorHandler) {
const img = /** @type {HTMLImageElement} */ (image);
if (img.decode) {
// The decode function is supported by Safari but not when the image is a svg file.
// FIXME: remove `!SAFARI` in the test when this bug is fixed upstream.
// See: https://bugs.webkit.org/show_bug.cgi?id=198527
if (!SAFARI && img.decode) {
const promise = img.decode();
let listening = true;
const unlisten = function() {