diff --git a/build/html2canvas.js b/build/html2canvas.js
index ac4c00a..d2a85a9 100644
--- a/build/html2canvas.js
+++ b/build/html2canvas.js
@@ -13,6 +13,10 @@ window.html2canvas = function(nodeList, options) {
window.html2canvas.logging = true;
window.html2canvas.start = Date.now();
}
+
+ options.async = typeof(options.async) === "undefined" ? true : options.async;
+ options.removeContainer = typeof(options.removeContainer) === "undefined" ? true : options.removeContainer;
+
return renderDocument(document, options, window.innerWidth, window.innerHeight).then(function(canvas) {
if (typeof(options.onrendered) === "function") {
log("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas");
@@ -23,7 +27,7 @@ window.html2canvas = function(nodeList, options) {
};
function renderDocument(document, options, windowWidth, windowHeight) {
- return createWindowClone(document, windowWidth, windowHeight).then(function(container) {
+ return createWindowClone(document, windowWidth, windowHeight, options).then(function(container) {
log("Document cloned");
var clonedWindow = container.contentWindow;
//var element = (nodeList === undefined) ? document.body : nodeList[0];
@@ -36,7 +40,10 @@ function renderDocument(document, options, windowWidth, windowHeight) {
var renderer = new CanvasRenderer(width, height, imageLoader);
var parser = new NodeParser(node, renderer, support, imageLoader, options);
return parser.ready.then(function() {
- container.parentNode.removeChild(container);
+ log("Finished rendering");
+ if (options.removeContainer) {
+ container.parentNode.removeChild(container);
+ }
return renderer.canvas;
});
});
@@ -62,7 +69,7 @@ function smallImage() {
return "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
}
-function createWindowClone(ownerDocument, width, height) {
+function createWindowClone(ownerDocument, width, height, options) {
var documentElement = ownerDocument.documentElement.cloneNode(true),
container = ownerDocument.createElement("iframe");
@@ -74,18 +81,6 @@ function createWindowClone(ownerDocument, width, height) {
ownerDocument.body.appendChild(container);
return new Promise(function(resolve) {
- var loadedTimer = function() {
- /* Chrome doesn't detect relative background-images assigned in style sheets when fetched through getComputedStyle,
- before a certain time has passed
- */
- if (container.contentWindow.getComputedStyle(div, null)['backgroundImage'] !== "none") {
- documentClone.body.removeChild(div);
- documentClone.body.removeChild(style);
- resolve(container);
- } else {
- window.setTimeout(loadedTimer, 10);
- }
- };
var documentClone = container.contentWindow.document;
/* Chrome doesn't detect relative background-images assigned in inline