1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | var ReactRef = require('./ReactRef');
|
12 | var ReactInstrumentation = require('./ReactInstrumentation');
|
13 |
|
14 | var warning = require('fbjs/lib/warning');
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function attachRefs() {
|
21 | ReactRef.attachRefs(this, this._currentElement);
|
22 | }
|
23 |
|
24 | var ReactReconciler = {
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | mountComponent: function (internalInstance, transaction, hostParent, hostContainerInfo, context, parentDebugID) // 0 in production and for roots
|
37 | {
|
38 | if (process.env.NODE_ENV !== 'production') {
|
39 | if (internalInstance._debugID !== 0) {
|
40 | ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
|
41 | }
|
42 | }
|
43 | var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
|
44 | if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
45 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
46 | }
|
47 | if (process.env.NODE_ENV !== 'production') {
|
48 | if (internalInstance._debugID !== 0) {
|
49 | ReactInstrumentation.debugTool.onMountComponent(internalInstance._debugID);
|
50 | }
|
51 | }
|
52 | return markup;
|
53 | },
|
54 |
|
55 | |
56 |
|
57 |
|
58 |
|
59 | getHostNode: function (internalInstance) {
|
60 | return internalInstance.getHostNode();
|
61 | },
|
62 |
|
63 | |
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | unmountComponent: function (internalInstance, safely) {
|
70 | if (process.env.NODE_ENV !== 'production') {
|
71 | if (internalInstance._debugID !== 0) {
|
72 | ReactInstrumentation.debugTool.onBeforeUnmountComponent(internalInstance._debugID);
|
73 | }
|
74 | }
|
75 | ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
|
76 | internalInstance.unmountComponent(safely);
|
77 | if (process.env.NODE_ENV !== 'production') {
|
78 | if (internalInstance._debugID !== 0) {
|
79 | ReactInstrumentation.debugTool.onUnmountComponent(internalInstance._debugID);
|
80 | }
|
81 | }
|
82 | },
|
83 |
|
84 | |
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | receiveComponent: function (internalInstance, nextElement, transaction, context) {
|
94 | var prevElement = internalInstance._currentElement;
|
95 |
|
96 | if (nextElement === prevElement && context === internalInstance._context) {
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | return;
|
108 | }
|
109 |
|
110 | if (process.env.NODE_ENV !== 'production') {
|
111 | if (internalInstance._debugID !== 0) {
|
112 | ReactInstrumentation.debugTool.onBeforeUpdateComponent(internalInstance._debugID, nextElement);
|
113 | }
|
114 | }
|
115 |
|
116 | var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement);
|
117 |
|
118 | if (refsChanged) {
|
119 | ReactRef.detachRefs(internalInstance, prevElement);
|
120 | }
|
121 |
|
122 | internalInstance.receiveComponent(nextElement, transaction, context);
|
123 |
|
124 | if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
125 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
126 | }
|
127 |
|
128 | if (process.env.NODE_ENV !== 'production') {
|
129 | if (internalInstance._debugID !== 0) {
|
130 | ReactInstrumentation.debugTool.onUpdateComponent(internalInstance._debugID);
|
131 | }
|
132 | }
|
133 | },
|
134 |
|
135 | |
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 | performUpdateIfNecessary: function (internalInstance, transaction, updateBatchNumber) {
|
143 | if (internalInstance._updateBatchNumber !== updateBatchNumber) {
|
144 |
|
145 |
|
146 | process.env.NODE_ENV !== 'production' ? warning(internalInstance._updateBatchNumber == null || internalInstance._updateBatchNumber === updateBatchNumber + 1, 'performUpdateIfNecessary: Unexpected batch number (current %s, ' + 'pending %s)', updateBatchNumber, internalInstance._updateBatchNumber) : void 0;
|
147 | return;
|
148 | }
|
149 | if (process.env.NODE_ENV !== 'production') {
|
150 | if (internalInstance._debugID !== 0) {
|
151 | ReactInstrumentation.debugTool.onBeforeUpdateComponent(internalInstance._debugID, internalInstance._currentElement);
|
152 | }
|
153 | }
|
154 | internalInstance.performUpdateIfNecessary(transaction);
|
155 | if (process.env.NODE_ENV !== 'production') {
|
156 | if (internalInstance._debugID !== 0) {
|
157 | ReactInstrumentation.debugTool.onUpdateComponent(internalInstance._debugID);
|
158 | }
|
159 | }
|
160 | }
|
161 | };
|
162 |
|
163 | module.exports = ReactReconciler; |
\ | No newline at end of file |