mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user