1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | 'use strict';
|
12 |
|
13 | var _prodInvariant = require('./reactProdInvariant');
|
14 |
|
15 | var DOMLazyTree = require('./DOMLazyTree');
|
16 | var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
17 |
|
18 | var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup');
|
19 | var emptyFunction = require('fbjs/lib/emptyFunction');
|
20 | var invariant = require('fbjs/lib/invariant');
|
21 |
|
22 | var Danger = {
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
|
32 | !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a worker thread. Make sure `window` and `document` are available globally before requiring React when unit testing or use ReactDOMServer.renderToString() for server rendering.') : _prodInvariant('56') : void 0;
|
33 | !markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : _prodInvariant('57') : void 0;
|
34 | !(oldChild.nodeName !== 'HTML') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the <html> node. This is because browser quirks make this unreliable and/or slow. If you want to render to the root you must use server rendering. See ReactDOMServer.renderToString().') : _prodInvariant('58') : void 0;
|
35 |
|
36 | if (typeof markup === 'string') {
|
37 | var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
38 | oldChild.parentNode.replaceChild(newChild, oldChild);
|
39 | } else {
|
40 | DOMLazyTree.replaceChildWithTree(oldChild, markup);
|
41 | }
|
42 | }
|
43 | };
|
44 |
|
45 | module.exports = Danger; |
\ | No newline at end of file |