Use an iframe to create a testDocument…

instead of `createHTMLDocument` since it isn't fully support by the browsers we care about.

fixes #606
fixes #454
This commit is contained in:
Thomas Aylott
2013-11-25 15:05:35 -05:00
parent a7f0afceec
commit eebad16636
+7 -5
View File
@@ -23,11 +23,13 @@
* (jst).
*/
function getTestDocument() {
if (document.implementation &&
document.implementation.createHTMLDocument) {
return document.implementation.createHTMLDocument('test doc');
}
return null;
var iframe = document.createElement('iframe');
iframe.style.cssText = 'position:absolute; visibility:hidden; bottom:100%; right:100%';
iframe.src = 'data:text/html,<!doctype html><meta charset=utf-8><title>test doc</title>';
document.body.appendChild(iframe);
var testDocument = iframe.contentDocument;
iframe.parentNode.removeChild(iframe);
return testDocument;
}
module.exports = getTestDocument;