@samitouri / QOS-React-2 / commits / eebad16636

Use an iframe to create a testDocument… instead of `createHTMLDocument` since it isn't fully support by the browsers we care about.

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

Thomas Aylott committed Nov 25, 2013 at 15:05 UTC eebad166367d85ff61846961a332030c6c81b4f5
1 file changed +7 -5
src/test/getTestDocument.js
+7 -5
@@ -23,11 +23,13 @@
23 * (jst).
24 */
25 function getTestDocument() {
26 - if (document.implementation &&
27 - document.implementation.createHTMLDocument) {
28 - return document.implementation.createHTMLDocument('test doc');
29 - }
30 - return null;
26 + var iframe = document.createElement('iframe');
27 + iframe.style.cssText = 'position:absolute; visibility:hidden; bottom:100%; right:100%';
28 + iframe.src = 'data:text/html,<!doctype html><meta charset=utf-8><title>test doc</title>';
29 + document.body.appendChild(iframe);
30 + var testDocument = iframe.contentDocument;
31 + iframe.parentNode.removeChild(iframe);
32 + return testDocument;
33 }
34
35 module.exports = getTestDocument;