From 44d8e25706134a3d446263dc2bdeb37cbe134fba Mon Sep 17 00:00:00 2001 From: gijsroge Date: Tue, 3 Dec 2019 10:11:12 +0100 Subject: [PATCH 1/2] Fix issue in Webkit browsers where onloaded could not detect if an image was loaded when it was cached in the browser. --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 8a7f2b4..74a8629 100644 --- a/src/index.js +++ b/src/index.js @@ -34,7 +34,9 @@ export default function (elem, opts) { } forEach(elem, el => { - el.onload = onload; - el.onerror = onerror; + const img = new Image(); + img.src = el.src; + img.onload = onload; + img.onerror = onerror; }); } From 07cc06a921a0b968881de47800782035b2578a7d Mon Sep 17 00:00:00 2001 From: gijsroge Date: Tue, 3 Dec 2019 20:54:41 +0100 Subject: [PATCH 2/2] Use a different method to reset the image regardless cache in Webkit. --- src/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 74a8629..1527da5 100644 --- a/src/index.js +++ b/src/index.js @@ -34,9 +34,10 @@ export default function (elem, opts) { } forEach(elem, el => { - const img = new Image(); - img.src = el.src; - img.onload = onload; - img.onerror = onerror; + const src = el.src; + el.src = ''; + el.src = src; + el.onload = onload; + el.onerror = onerror; }); }