diff options
Diffstat (limited to 'node_modules/react-dom/lib/ReactDOMEmptyComponent.js')
-rw-r--r-- | node_modules/react-dom/lib/ReactDOMEmptyComponent.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/node_modules/react-dom/lib/ReactDOMEmptyComponent.js b/node_modules/react-dom/lib/ReactDOMEmptyComponent.js new file mode 100644 index 000000000..89eecc566 --- /dev/null +++ b/node_modules/react-dom/lib/ReactDOMEmptyComponent.js @@ -0,0 +1,59 @@ +/** + * Copyright 2014-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 _assign = require('object-assign'); + +var DOMLazyTree = require('./DOMLazyTree'); +var ReactDOMComponentTree = require('./ReactDOMComponentTree'); + +var ReactDOMEmptyComponent = function (instantiate) { + // ReactCompositeComponent uses this: + this._currentElement = null; + // ReactDOMComponentTree uses these: + this._hostNode = null; + this._hostParent = null; + this._hostContainerInfo = null; + this._domID = 0; +}; +_assign(ReactDOMEmptyComponent.prototype, { + mountComponent: function (transaction, hostParent, hostContainerInfo, context) { + var domID = hostContainerInfo._idCounter++; + this._domID = domID; + this._hostParent = hostParent; + this._hostContainerInfo = hostContainerInfo; + + var nodeValue = ' react-empty: ' + this._domID + ' '; + if (transaction.useCreateElement) { + var ownerDocument = hostContainerInfo._ownerDocument; + var node = ownerDocument.createComment(nodeValue); + ReactDOMComponentTree.precacheNode(this, node); + return DOMLazyTree(node); + } else { + if (transaction.renderToStaticMarkup) { + // Normally we'd insert a comment node, but since this is a situation + // where React won't take over (static pages), we can simply return + // nothing. + return ''; + } + return '<!--' + nodeValue + '-->'; + } + }, + receiveComponent: function () {}, + getHostNode: function () { + return ReactDOMComponentTree.getNodeFromInstance(this); + }, + unmountComponent: function () { + ReactDOMComponentTree.uncacheNode(this); + } +}); + +module.exports = ReactDOMEmptyComponent;
\ No newline at end of file |