1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | 'use strict';
|
12 |
|
13 | var UserAgent = require("fbjs/lib/UserAgent");
|
14 |
|
15 | var invariant = require("fbjs/lib/invariant");
|
16 |
|
17 | var isOldIE = UserAgent.isBrowser('IE <= 9');
|
18 |
|
19 |
|
20 |
|
21 | function getSafeBodyFromHTML(html) {
|
22 | var doc;
|
23 | var root = null;
|
24 |
|
25 | if (!isOldIE && document.implementation && document.implementation.createHTMLDocument) {
|
26 | doc = document.implementation.createHTMLDocument('foo');
|
27 | !doc.documentElement ? process.env.NODE_ENV !== "production" ? invariant(false, 'Missing doc.documentElement') : invariant(false) : void 0;
|
28 | doc.documentElement.innerHTML = html;
|
29 | root = doc.getElementsByTagName('body')[0];
|
30 | }
|
31 |
|
32 | return root;
|
33 | }
|
34 |
|
35 | module.exports = getSafeBodyFromHTML; |
\ | No newline at end of file |