From 50608e9cd4327c3503223dca85ab7b2b2b9e629c Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Mon, 11 Dec 2017 20:51:20 +0800 Subject: [PATCH] Fix external SVG loading with proxies (#802) --- CHANGELOG.md | 3 +++ src/Clone.js | 1 + src/ResourceLoader.js | 12 ++---------- src/index.js | 1 + tests/reftests/images/base.html | 3 +++ tests/reftests/images/cross-origin.html | 1 + 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c405ef..aec615b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ### Changelog ### #### v1.0.0-alpha4 - TBD #### + * Fix logging option (#1302) + * Add support for rendering webgl canvas content (#646) + * Fix external SVG loading with proxies (#802) #### v1.0.0-alpha3 - 9.12.2017 #### * Disable `foreignObjectRendering` by default (#1295) diff --git a/src/Clone.js b/src/Clone.js index e944fad..c60ca9d 100644 --- a/src/Clone.js +++ b/src/Clone.js @@ -177,6 +177,7 @@ export class DocumentCloner { backgroundColor: '#ffffff', canvas: null, imageTimeout: this.options.imageTimeout, + logging: this.options.logging, proxy: this.options.proxy, removeContainer: this.options.removeContainer, scale: this.options.scale, diff --git a/src/ResourceLoader.js b/src/ResourceLoader.js index 2fcb083..b946d5b 100644 --- a/src/ResourceLoader.js +++ b/src/ResourceLoader.js @@ -34,16 +34,8 @@ export default class ResourceLoader { return src; } - if (isSVG(src)) { - if (this.options.allowTaint === true || FEATURES.SUPPORT_SVG_DRAWING) { - return this.addImage(src, src, false); - } - } else { - if ( - this.options.allowTaint === true || - isInlineBase64Image(src) || - this.isSameOrigin(src) - ) { + if (!isSVG(src) || FEATURES.SUPPORT_SVG_DRAWING) { + if (this.options.allowTaint === true || isInlineImage(src) || this.isSameOrigin(src)) { return this.addImage(src, src, false); } else if (!this.isSameOrigin(src)) { if (typeof this.options.proxy === 'string') { diff --git a/src/index.js b/src/index.js index 5a2ff9b..a61b6c5 100644 --- a/src/index.js +++ b/src/index.js @@ -65,6 +65,7 @@ const html2canvas = (element: HTMLElement, conf: ?Options): Promise<*> => { async: true, allowTaint: false, imageTimeout: 15000, + logging: true, proxy: null, removeContainer: true, foreignObjectRendering: false, diff --git a/tests/reftests/images/base.html b/tests/reftests/images/base.html index 02b080c..1618a06 100644 --- a/tests/reftests/images/base.html +++ b/tests/reftests/images/base.html @@ -15,6 +15,9 @@

External image

+

External svg image

+ +

External image (using <base> href)

diff --git a/tests/reftests/images/cross-origin.html b/tests/reftests/images/cross-origin.html index 4ae8f2b..9e2ede3 100644 --- a/tests/reftests/images/cross-origin.html +++ b/tests/reftests/images/cross-origin.html @@ -16,5 +16,6 @@

External image (CORS)

+