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