aboutsummaryrefslogtreecommitdiff
path: root/node_modules/react-dom/lib/ReactServerRendering.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
commitde98e0b232509d5f40c135d540a70e415272ff85 (patch)
treea79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/react-dom/lib/ReactServerRendering.js
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
downloadwallet-core-de98e0b232509d5f40c135d540a70e415272ff85.tar.xz
node_modules
Diffstat (limited to 'node_modules/react-dom/lib/ReactServerRendering.js')
-rw-r--r--node_modules/react-dom/lib/ReactServerRendering.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/node_modules/react-dom/lib/ReactServerRendering.js b/node_modules/react-dom/lib/ReactServerRendering.js
new file mode 100644
index 000000000..1f8e30e56
--- /dev/null
+++ b/node_modules/react-dom/lib/ReactServerRendering.js
@@ -0,0 +1,89 @@
+/**
+ * Copyright 2013-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ */
+'use strict';
+
+var _prodInvariant = require('./reactProdInvariant');
+
+var React = require('react/lib/React');
+var ReactDOMContainerInfo = require('./ReactDOMContainerInfo');
+var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
+var ReactInstrumentation = require('./ReactInstrumentation');
+var ReactMarkupChecksum = require('./ReactMarkupChecksum');
+var ReactReconciler = require('./ReactReconciler');
+var ReactServerBatchingStrategy = require('./ReactServerBatchingStrategy');
+var ReactServerRenderingTransaction = require('./ReactServerRenderingTransaction');
+var ReactUpdates = require('./ReactUpdates');
+
+var emptyObject = require('fbjs/lib/emptyObject');
+var instantiateReactComponent = require('./instantiateReactComponent');
+var invariant = require('fbjs/lib/invariant');
+
+var pendingTransactions = 0;
+
+/**
+ * @param {ReactElement} element
+ * @return {string} the HTML markup
+ */
+function renderToStringImpl(element, makeStaticMarkup) {
+ var transaction;
+ try {
+ ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
+
+ transaction = ReactServerRenderingTransaction.getPooled(makeStaticMarkup);
+
+ pendingTransactions++;
+
+ return transaction.perform(function () {
+ var componentInstance = instantiateReactComponent(element, true);
+ var markup = ReactReconciler.mountComponent(componentInstance, transaction, null, ReactDOMContainerInfo(), emptyObject, 0 /* parentDebugID */
+ );
+ if (process.env.NODE_ENV !== 'production') {
+ ReactInstrumentation.debugTool.onUnmountComponent(componentInstance._debugID);
+ }
+ if (!makeStaticMarkup) {
+ markup = ReactMarkupChecksum.addChecksumToMarkup(markup);
+ }
+ return markup;
+ }, null);
+ } finally {
+ pendingTransactions--;
+ ReactServerRenderingTransaction.release(transaction);
+ // Revert to the DOM batching strategy since these two renderers
+ // currently share these stateful modules.
+ if (!pendingTransactions) {
+ ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
+ }
+ }
+}
+
+/**
+ * Render a ReactElement to its initial HTML. This should only be used on the
+ * server.
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring
+ */
+function renderToString(element) {
+ !React.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : _prodInvariant('46') : void 0;
+ return renderToStringImpl(element, false);
+}
+
+/**
+ * Similar to renderToString, except this doesn't create extra DOM attributes
+ * such as data-react-id that React uses internally.
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup
+ */
+function renderToStaticMarkup(element) {
+ !React.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : _prodInvariant('47') : void 0;
+ return renderToStringImpl(element, true);
+}
+
+module.exports = {
+ renderToString: renderToString,
+ renderToStaticMarkup: renderToStaticMarkup
+}; \ No newline at end of file