1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | var _prodInvariant = require('./reactProdInvariant');
|
12 |
|
13 | var DOMLazyTree = require('./DOMLazyTree');
|
14 | var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
15 |
|
16 | var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup');
|
17 | var emptyFunction = require('fbjs/lib/emptyFunction');
|
18 | var invariant = require('fbjs/lib/invariant');
|
19 |
|
20 | var Danger = {
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
|
30 | !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;
|
31 | !markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : _prodInvariant('57') : void 0;
|
32 | !(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;
|
33 |
|
34 | if (typeof markup === 'string') {
|
35 | var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
36 | oldChild.parentNode.replaceChild(newChild, oldChild);
|
37 | } else {
|
38 | DOMLazyTree.replaceChildWithTree(oldChild, markup);
|
39 | }
|
40 | }
|
41 | };
|
42 |
|
43 | module.exports = Danger; |
\ | No newline at end of file |