1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | var _assign = require('object-assign');
|
12 |
|
13 | var DOMLazyTree = require('./DOMLazyTree');
|
14 | var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
15 |
|
16 | var ReactDOMEmptyComponent = function (instantiate) {
|
17 |
|
18 | this._currentElement = null;
|
19 |
|
20 | this._hostNode = null;
|
21 | this._hostParent = null;
|
22 | this._hostContainerInfo = null;
|
23 | this._domID = 0;
|
24 | };
|
25 | _assign(ReactDOMEmptyComponent.prototype, {
|
26 | mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
|
27 | var domID = hostContainerInfo._idCounter++;
|
28 | this._domID = domID;
|
29 | this._hostParent = hostParent;
|
30 | this._hostContainerInfo = hostContainerInfo;
|
31 |
|
32 | var nodeValue = ' react-empty: ' + this._domID + ' ';
|
33 | if (transaction.useCreateElement) {
|
34 | var ownerDocument = hostContainerInfo._ownerDocument;
|
35 | var node = ownerDocument.createComment(nodeValue);
|
36 | ReactDOMComponentTree.precacheNode(this, node);
|
37 | return DOMLazyTree(node);
|
38 | } else {
|
39 | if (transaction.renderToStaticMarkup) {
|
40 |
|
41 |
|
42 |
|
43 | return '';
|
44 | }
|
45 | return '<!--' + nodeValue + '-->';
|
46 | }
|
47 | },
|
48 | receiveComponent: function () {},
|
49 | getHostNode: function () {
|
50 | return ReactDOMComponentTree.getNodeFromInstance(this);
|
51 | },
|
52 | unmountComponent: function () {
|
53 | ReactDOMComponentTree.uncacheNode(this);
|
54 | }
|
55 | });
|
56 |
|
57 | module.exports = ReactDOMEmptyComponent; |
\ | No newline at end of file |