Fix race condition for content load

This commit is contained in:
Niklas von Hertzen 2014-11-03 23:29:57 +02:00
parent 525b5c4f36
commit aa3aafbc0c
3 changed files with 6 additions and 7 deletions

6
dist/html2canvas.js vendored
View File

@ -722,15 +722,15 @@ function createWindowClone(ownerDocument, containerDocument, width, height, opti
var y = ownerDocument.defaultView.pageYOffset;
documentClone.open();
documentClone.write("<!DOCTYPE html>");
documentClone.close();
documentClone.write("<!DOCTYPE html><html></html>");
// Chrome scrolls the parent document for some reason after the write to the cloned window???
if (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset) {
ownerDocument.defaultView.scrollTo(x, y);
}
documentClone.replaceChild(options.javascriptEnabled === true ? documentClone.adoptNode(documentElement) : removeScriptNodes(documentClone.adoptNode(documentElement)), documentClone.documentElement);
documentClone.close();
});
}

File diff suppressed because one or more lines are too long

View File

@ -154,15 +154,14 @@ function createWindowClone(ownerDocument, containerDocument, width, height, opti
var y = ownerDocument.defaultView.pageYOffset;
documentClone.open();
documentClone.write("<!DOCTYPE html>");
documentClone.close();
documentClone.write("<!DOCTYPE html><html></html>");
// Chrome scrolls the parent document for some reason after the write to the cloned window???
if (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset) {
ownerDocument.defaultView.scrollTo(x, y);
}
documentClone.replaceChild(options.javascriptEnabled === true ? documentClone.adoptNode(documentElement) : removeScriptNodes(documentClone.adoptNode(documentElement)), documentClone.documentElement);
documentClone.close();
});
}