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