mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Fix chrome issue with the crossOrigin images
In Chrome browser if the image loaded before without crossorigin it will be cached and used later even if the next usage has crossorigin so it will fail with CORS error. so add a random query parameter just to prevent the Chrome from using the cached image. see more info about the Chrome issue in this link: https://stackoverflow.com/a/49503414
This commit is contained in:
parent
6020386bbe
commit
7aab59b3e3
@ -96,6 +96,10 @@ export class Cache {
|
|||||||
//ios safari 10.3 taints canvas with data urls unless crossOrigin is set to anonymous
|
//ios safari 10.3 taints canvas with data urls unless crossOrigin is set to anonymous
|
||||||
if (isInlineBase64Image(src) || useCORS) {
|
if (isInlineBase64Image(src) || useCORS) {
|
||||||
img.crossOrigin = 'anonymous';
|
img.crossOrigin = 'anonymous';
|
||||||
|
// in chrome if the image loaded before without crossorigin it will be cached and used later even if the next usage has crossorigin
|
||||||
|
// so it will fail with CORS error, so add a random query parameter just to prevent the chrome from using the cached image
|
||||||
|
// see more info about the chrome issue in this link: https://stackoverflow.com/a/49503414
|
||||||
|
src = src + (src.indexOf('?') === -1 ? '?' : '&') + 'cacheBusting=1';
|
||||||
}
|
}
|
||||||
img.src = src;
|
img.src = src;
|
||||||
if (img.complete === true) {
|
if (img.complete === true) {
|
||||||
|
Loading…
Reference in New Issue
Block a user