Add onclone callback option to allow modifying cloned document prior to rendering

This commit is contained in:
Niklas von Hertzen
2014-10-26 19:10:09 +02:00
parent 8184b7cf51
commit 1793b802b1
4 changed files with 81 additions and 4 deletions

View File

@ -45,7 +45,10 @@ function renderDocument(document, options, windowWidth, windowHeight) {
document.querySelector(selector).removeAttribute(html2canvasNodeAttribute);
var clonedWindow = container.contentWindow;
var node = clonedWindow.document.querySelector(selector);
return renderWindow(node, container, options, windowWidth, windowHeight);
var oncloneHandler = (typeof(options.onclone) === "function") ? Promise.resolve(options.onclone(clonedWindow.document)) : Promise.resolve(true);
return oncloneHandler.then(function() {
return renderWindow(node, container, options, windowWidth, windowHeight);
});
});
}