mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix crash if an img tag has no src, fix undefined variables
This commit is contained in:
parent
a661952fc1
commit
553f84b51b
@ -25,7 +25,8 @@ html2canvas.Preload = function(element, opts){
|
|||||||
doc = element.ownerDocument,
|
doc = element.ownerDocument,
|
||||||
domImages = doc.images, // TODO probably should limit it to images present in the element only
|
domImages = doc.images, // TODO probably should limit it to images present in the element only
|
||||||
imgLen = domImages.length,
|
imgLen = domImages.length,
|
||||||
link = doc.createElement("a");
|
link = doc.createElement("a"),
|
||||||
|
timeoutTimer;
|
||||||
|
|
||||||
link.href = window.location.href;
|
link.href = window.location.href;
|
||||||
pageOrigin = link.protocol + link.host;
|
pageOrigin = link.protocol + link.host;
|
||||||
@ -214,7 +215,7 @@ html2canvas.Preload = function(element, opts){
|
|||||||
methods = {
|
methods = {
|
||||||
loadImage: function( src ) {
|
loadImage: function( src ) {
|
||||||
var img;
|
var img;
|
||||||
if ( images[src] === undefined ) {
|
if ( src && images[src] === undefined ) {
|
||||||
if ( src.match(/data:image\/.*;base64,/i) ) {
|
if ( src.match(/data:image\/.*;base64,/i) ) {
|
||||||
|
|
||||||
//Base64 src
|
//Base64 src
|
||||||
@ -257,7 +258,7 @@ html2canvas.Preload = function(element, opts){
|
|||||||
|
|
||||||
},
|
},
|
||||||
cleanupDOM: function(cause) {
|
cleanupDOM: function(cause) {
|
||||||
var img;
|
var img, src;
|
||||||
if (!images.cleanupDone) {
|
if (!images.cleanupDone) {
|
||||||
if (cause && typeof cause === "string") {
|
if (cause && typeof cause === "string") {
|
||||||
html2canvas.log("html2canvas: Cleanup because: " + cause);
|
html2canvas.log("html2canvas: Cleanup because: " + cause);
|
||||||
@ -320,10 +321,7 @@ html2canvas.Preload = function(element, opts){
|
|||||||
this.log('html2canvas: Preload: Finding images');
|
this.log('html2canvas: Preload: Finding images');
|
||||||
// load <img> images
|
// load <img> images
|
||||||
for (i = 0; i < imgLen; i+=1){
|
for (i = 0; i < imgLen; i+=1){
|
||||||
var imgSrc = domImages[i].getAttribute( "src" );
|
methods.loadImage( domImages[i].getAttribute( "src" ) );
|
||||||
if ( imgSrc ) {
|
|
||||||
methods.loadImage( imgSrc );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
images.firstRun = false;
|
images.firstRun = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user