Fix bug with iframe not being loaded in-time

This commit is contained in:
Niklas von Hertzen 2014-03-24 19:05:32 +02:00
parent 650ead63e5
commit fee91055b2
3 changed files with 9 additions and 19 deletions

View File

@ -135,6 +135,10 @@ function createWindowClone(ownerDocument, width, height, options) {
/* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
if window url is about:blank, we can assign the url to current by writing onto the document
*/
container.contentWindow.onload = container.onload = function() {
resolve(container);
};
documentClone.open();
documentClone.write("<!DOCTYPE html>");
documentClone.close();
@ -143,15 +147,6 @@ function createWindowClone(ownerDocument, width, height, options) {
if (options.type === "view") {
container.contentWindow.scrollTo(window.pageXOffset, window.pageYOffset);
}
var timeout = setTimeout(function() {
resolve(container);
}, 100);
container.contentWindow.onload = function() {
clearTimeout(timeout);
resolve(container);
};
});
}

File diff suppressed because one or more lines are too long

View File

@ -96,6 +96,10 @@ function createWindowClone(ownerDocument, width, height, options) {
/* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
if window url is about:blank, we can assign the url to current by writing onto the document
*/
container.contentWindow.onload = container.onload = function() {
resolve(container);
};
documentClone.open();
documentClone.write("<!DOCTYPE html>");
documentClone.close();
@ -104,15 +108,6 @@ function createWindowClone(ownerDocument, width, height, options) {
if (options.type === "view") {
container.contentWindow.scrollTo(window.pageXOffset, window.pageYOffset);
}
var timeout = setTimeout(function() {
resolve(container);
}, 100);
container.contentWindow.onload = function() {
clearTimeout(timeout);
resolve(container);
};
});
}