The library for web and native user interfaces.
Remove circular dependencies in React Core.
There is a circular dependency between `ReactID`, `ReactMount` and `ReactInstanceHandles`. Ben and I talked about this today. It seems like the simplest solution is to consolidate a lot of the code that Ben recently wrote into `ReactMount`. We can later find ways to trim code out of this module without causing circular deps.
Jordan Walke committed
Jul 24, 2013 at 17:19 UTC
2ee66262db9fb91b0d0e9d64cefeb223074f8e05
21 files changed
+356
-367
src/core/ReactComponent.js
+3
-3
@@ -23,8 +23,8 @@
23
var getReactRootElementInContainer = require('getReactRootElementInContainer');
24
var ReactCurrentOwner = require('ReactCurrentOwner');
25
var ReactDOMIDOperations = require('ReactDOMIDOperations');
26
-var ReactID = require('ReactID');
26
var ReactMarkupChecksum = require('ReactMarkupChecksum');
27
+var ReactMount = require('ReactMount');
28
var ReactOwner = require('ReactOwner');
29
var ReactReconcileTransaction = require('ReactReconcileTransaction');
30
var ReactUpdates = require('ReactUpdates');
@@ -256,7 +256,7 @@ var ReactComponent = {
256
this.isMounted(),
257
'getDOMNode(): A component must be mounted to have a DOM node.'
258
);
259
- return ReactID.getNode(this._rootNodeID);
259
+ return ReactMount.getNode(this._rootNodeID);
260
},
261
262
/**
@@ -382,7 +382,7 @@ var ReactComponent = {
382
if (props.ref != null) {
383
ReactOwner.removeComponentAsRefFrom(this, props.ref, props[OWNER]);
384
}
385
- ReactID.purgeID(this._rootNodeID);
385
+ ReactMount.purgeID(this._rootNodeID);
386
this._rootNodeID = null;
387
this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
388
},
src/core/ReactDOMIDOperations.js
+8
-8
@@ -24,7 +24,7 @@
24
var CSSPropertyOperations = require('CSSPropertyOperations');
25
var DOMChildrenOperations = require('DOMChildrenOperations');
26
var DOMPropertyOperations = require('DOMPropertyOperations');
27
-var ReactID = require('ReactID');
27
+var ReactMount = require('ReactMount');
28
29
var getTextContentAccessor = require('getTextContentAccessor');
30
var invariant = require('invariant');
@@ -65,7 +65,7 @@ var ReactDOMIDOperations = {
65
* @internal
66
*/
67
updatePropertyByID: function(id, name, value) {
68
- var node = ReactID.getNode(id);
68
+ var node = ReactMount.getNode(id);
69
invariant(
70
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
71
'updatePropertyByID(...): %s',
@@ -91,7 +91,7 @@ var ReactDOMIDOperations = {
91
* @internal
92
*/
93
deletePropertyByID: function(id, name, value) {
94
- var node = ReactID.getNode(id);
94
+ var node = ReactMount.getNode(id);
95
invariant(
96
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
97
'updatePropertyByID(...): %s',
@@ -128,7 +128,7 @@ var ReactDOMIDOperations = {
128
* @internal
129
*/
130
updateStylesByID: function(id, styles) {
131
- var node = ReactID.getNode(id);
131
+ var node = ReactMount.getNode(id);
132
CSSPropertyOperations.setValueForStyles(node, styles);
133
},
134
@@ -140,7 +140,7 @@ var ReactDOMIDOperations = {
140
* @internal
141
*/
142
updateInnerHTMLByID: function(id, html) {
143
- var node = ReactID.getNode(id);
143
+ var node = ReactMount.getNode(id);
144
// HACK: IE8- normalize whitespace in innerHTML, removing leading spaces.
145
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
146
node.innerHTML = (html && html.__html || '').replace(/^ /g, ' ');
@@ -154,7 +154,7 @@ var ReactDOMIDOperations = {
154
* @internal
155
*/
156
updateTextContentByID: function(id, content) {
157
- var node = ReactID.getNode(id);
157
+ var node = ReactMount.getNode(id);
158
node[textContentAccessor] = content;
159
},
160
@@ -167,7 +167,7 @@ var ReactDOMIDOperations = {
167
* @see {Danger.dangerouslyReplaceNodeWithMarkup}
168
*/
169
dangerouslyReplaceNodeWithMarkupByID: function(id, markup) {
170
- var node = ReactID.getNode(id);
170
+ var node = ReactMount.getNode(id);
171
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
172
},
173
@@ -176,7 +176,7 @@ var ReactDOMIDOperations = {
176
* Detect if any elements were removed instead of blindly purging.
177
*/
178
manageChildrenByParentID: function(parentID, domOperations) {
179
- var parent = ReactID.getNode(parentID);
179
+ var parent = ReactMount.getNode(parentID);
180
DOMChildrenOperations.manageChildren(parent, domOperations);
181
}
182
src/core/ReactDefaultInjection.js
+3
@@ -24,6 +24,8 @@ var ReactDOMInput = require('ReactDOMInput');
24
var ReactDOMOption = require('ReactDOMOption');
25
var ReactDOMSelect = require('ReactDOMSelect');
26
var ReactDOMTextarea = require('ReactDOMTextarea');
27
+var ReactEventEmitter = require('ReactEventEmitter');
28
+var ReactEventTopLevelCallback = require('ReactEventTopLevelCallback');
29
30
var DefaultDOMPropertyConfig = require('DefaultDOMPropertyConfig');
31
var DOMProperty = require('DOMProperty');
@@ -37,6 +39,7 @@ var SimpleEventPlugin = require('SimpleEventPlugin');
39
var MobileSafariClickEventPlugin = require('MobileSafariClickEventPlugin');
40
41
function inject() {
42
+ ReactEventEmitter.TopLevelCallbackCreator = ReactEventTopLevelCallback;
43
/**
44
* Inject module for resolving DOM hierarchy and plugin ordering.
45
*/
src/core/ReactEventEmitter.js
+6
-3
@@ -257,17 +257,20 @@ var ReactEventEmitter = {
257
* reason, and only in some cases).
258
*
259
* @param {boolean} touchNotMouse Listen to touch events instead of mouse.
260
- * @param {object} TopLevelCallbackCreator
260
*/
262
- ensureListening: function(touchNotMouse, TopLevelCallbackCreator) {
261
+ ensureListening: function(touchNotMouse) {
262
invariant(
263
ExecutionEnvironment.canUseDOM,
264
'ensureListening(...): Cannot toggle event listening in a Worker ' +
265
'thread. This is likely a bug in the framework. Please report ' +
266
'immediately.'
267
);
268
+ invariant(
269
+ ReactEventEmitter.TopLevelCallbackCreator,
270
+ 'ensureListening(...): Cannot be called without a top level callback ' +
271
+ 'creator being injected.'
272
+ );
273
if (!_isListening) {
270
- ReactEventEmitter.TopLevelCallbackCreator = TopLevelCallbackCreator;
274
listenAtTopLevel(touchNotMouse);
275
_isListening = true;
276
}
src/core/ReactEventTopLevelCallback.js
+4
-5
@@ -21,8 +21,7 @@
21
22
var ExecutionEnvironment = require('ExecutionEnvironment');
23
var ReactEventEmitter = require('ReactEventEmitter');
24
-var ReactID = require('ReactID');
25
-var ReactInstanceHandles = require('ReactInstanceHandles');
24
+var ReactMount = require('ReactMount');
25
26
var getEventTarget = require('getEventTarget');
27
@@ -34,7 +33,7 @@ var _topLevelListenersEnabled = true;
33
34
/**
35
* Top-level callback creator used to implement event handling using delegation.
37
- * This is used via dependency injection in `ReactEventEmitter.ensureListening`.
36
+ * This is used via dependency injection.
37
*/
38
var ReactEventTopLevelCallback = {
39
@@ -73,10 +72,10 @@ var ReactEventTopLevelCallback = {
72
nativeEvent.srcElement !== nativeEvent.target) {
73
nativeEvent.target = nativeEvent.srcElement;
74
}
76
- var topLevelTarget = ReactInstanceHandles.getFirstReactDOM(
75
+ var topLevelTarget = ReactMount.getFirstReactDOM(
76
getEventTarget(nativeEvent)
77
) || ExecutionEnvironment.global;
79
- var topLevelTargetID = ReactID.getID(topLevelTarget) || '';
78
+ var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
79
ReactEventEmitter.handleTopLevel(
80
topLevelType,
81
topLevelTarget,
src/core/ReactID.js
deleted
-163
@@ -1,163 +0,0 @@
1
-/**
2
- * Copyright 2013 Facebook, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- * @providesModule ReactID
17
- * @typechecks static-only
18
- */
19
-
20
-"use strict";
21
-
22
-var invariant = require('invariant');
23
-var ReactMount = require('ReactMount');
24
-var ATTR_NAME = 'data-reactid';
25
-var nodeCache = {};
26
-
27
-/**
28
- * Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
29
- * element can return its control whose name or ID equals ATTR_NAME. All
30
- * DOM nodes support `getAttributeNode` but this can also get called on
31
- * other objects so just return '' if we're given something other than a
32
- * DOM node (such as window).
33
- *
34
- * @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
35
- * @return {string} ID of the supplied `domNode`.
36
- */
37
-function getID(node) {
38
- var id = internalGetID(node);
39
- if (id) {
40
- if (nodeCache.hasOwnProperty(id)) {
41
- var cached = nodeCache[id];
42
- if (cached !== node) {
43
- invariant(
44
- !isValid(cached, id),
45
- 'ReactID: Two valid but unequal nodes with the same `%s`: %s',
46
- ATTR_NAME, id
47
- );
48
-
49
- nodeCache[id] = node;
50
- }
51
- } else {
52
- nodeCache[id] = node;
53
- }
54
- }
55
-
56
- return id;
57
-}
58
-
59
-function internalGetID(node) {
60
- // If node is something like a window, document, or text node, none of
61
- // which support attributes or a .getAttribute method, gracefully return
62
- // the empty string, as if the attribute were missing.
63
- return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
64
-}
65
-
66
-/**
67
- * Sets the React-specific ID of the given node.
68
- *
69
- * @param {DOMElement} node The DOM node whose ID will be set.
70
- * @param {string} id The value of the ID attribute.
71
- */
72
-function setID(node, id) {
73
- var oldID = internalGetID(node);
74
- if (oldID !== id) {
75
- delete nodeCache[oldID];
76
- }
77
- node.setAttribute(ATTR_NAME, id);
78
- nodeCache[id] = node;
79
-}
80
-
81
-/**
82
- * Finds the node with the supplied React-generated DOM ID.
83
- *
84
- * @param {string} id A React-generated DOM ID.
85
- * @return {DOMElement} DOM node with the suppled `id`.
86
- * @internal
87
- */
88
-function getNode(id) {
89
- if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
90
- nodeCache[id] = ReactMount.findReactNodeByID(id);
91
- }
92
- return nodeCache[id];
93
-}
94
-
95
-/**
96
- * A node is "valid" if it is contained by a currently mounted container.
97
- *
98
- * This means that the node does not have to be contained by a document in
99
- * order to be considered valid.
100
- *
101
- * @param {?DOMElement} node The candidate DOM node.
102
- * @param {string} id The expected ID of the node.
103
- * @return {boolean} Whether the node is contained by a mounted container.
104
- */
105
-function isValid(node, id) {
106
- if (node) {
107
- invariant(
108
- internalGetID(node) === id,
109
- 'ReactID: Unexpected modification of `%s`',
110
- ATTR_NAME
111
- );
112
-
113
- var container = ReactMount.findReactContainerForID(id);
114
- if (container && contains(container, node)) {
115
- return true;
116
- }
117
- }
118
-
119
- return false;
120
-}
121
-
122
-function contains(ancestor, descendant) {
123
- if (ancestor.contains) {
124
- // Supported natively in virtually all browsers, but not in jsdom.
125
- return ancestor.contains(descendant);
126
- }
127
-
128
- if (descendant === ancestor) {
129
- return true;
130
- }
131
-
132
- if (descendant.nodeType === 3) {
133
- // If descendant is a text node, start from descendant.parentNode
134
- // instead, so that we can assume all ancestors worth considering are
135
- // element nodes with nodeType === 1.
136
- descendant = descendant.parentNode;
137
- }
138
-
139
- while (descendant && descendant.nodeType === 1) {
140
- if (descendant === ancestor) {
141
- return true;
142
- }
143
- descendant = descendant.parentNode;
144
- }
145
-
146
- return false;
147
-}
148
-
149
-/**
150
- * Causes the cache to forget about one React-specific ID.
151
- *
152
- * @param {string} id The ID to forget.
153
- */
154
-function purgeID(id) {
155
- delete nodeCache[id];
156
-}
157
-
158
-exports.ATTR_NAME = ATTR_NAME;
159
-exports.getID = getID;
160
-exports.rawGetID = internalGetID;
161
-exports.setID = setID;
162
-exports.getNode = getNode;
163
-exports.purgeID = purgeID;
src/core/ReactInstanceHandles.js
+5
-100
@@ -19,8 +19,6 @@
19
20
"use strict";
21
22
-var ReactID = require('ReactID');
23
-
22
var invariant = require('invariant');
23
24
var SEPARATOR = '.';
@@ -239,103 +237,6 @@ var ReactInstanceHandles = {
237
);
238
},
239
242
- /**
243
- * True if the supplied `node` is rendered by React.
244
- *
245
- * @param {*} node DOM Element to check.
246
- * @return {boolean} True if the DOM Element appears to be rendered by React.
247
- * @internal
248
- */
249
- isRenderedByReact: function(node) {
250
- if (node.nodeType !== 1) {
251
- // Not a DOMElement, therefore not a React component
252
- return false;
253
- }
254
- var id = ReactID.getID(node);
255
- return id ? id.charAt(0) === SEPARATOR : false;
256
- },
257
-
258
- /**
259
- * Traverses up the ancestors of the supplied node to find a node that is a
260
- * DOM representation of a React component.
261
- *
262
- * @param {*} node
263
- * @return {?DOMEventTarget}
264
- * @internal
265
- */
266
- getFirstReactDOM: function(node) {
267
- var current = node;
268
- while (current && current.parentNode !== current) {
269
- if (ReactInstanceHandles.isRenderedByReact(current)) {
270
- return current;
271
- }
272
- current = current.parentNode;
273
- }
274
- return null;
275
- },
276
-
277
- /**
278
- * Finds a node with the supplied `id` inside of the supplied `ancestorNode`.
279
- * Exploits the ID naming scheme to perform the search quickly.
280
- *
281
- * @param {DOMEventTarget} ancestorNode Search from this root.
282
- * @pararm {string} id ID of the DOM representation of the component.
283
- * @return {DOMEventTarget} DOM node with the supplied `id`.
284
- * @internal
285
- */
286
- findComponentRoot: function(ancestorNode, id) {
287
- var firstChildren = [ancestorNode.firstChild];
288
- var childIndex = 0;
289
-
290
- while (childIndex < firstChildren.length) {
291
- var child = firstChildren[childIndex++];
292
- while (child) {
293
- var childID = ReactID.getID(child);
294
- if (childID) {
295
- if (id === childID) {
296
- return child;
297
- } else if (isAncestorIDOf(childID, id)) {
298
- // If we find a child whose ID is an ancestor of the given ID,
299
- // then we can be sure that we only want to search the subtree
300
- // rooted at this child, so we can throw out the rest of the
301
- // search state.
302
- firstChildren.length = childIndex = 0;
303
- firstChildren.push(child.firstChild);
304
- break;
305
- } else {
306
- // TODO This should not be necessary if the ID hierarchy is
307
- // correct, but is occasionally necessary if the DOM has been
308
- // modified in unexpected ways.
309
- firstChildren.push(child.firstChild);
310
- }
311
- } else {
312
- // If this child had no ID, then there's a chance that it was
313
- // injected automatically by the browser, as when a `<table>`
314
- // element sprouts an extra `<tbody>` child as a side effect of
315
- // `.innerHTML` parsing. Optimistically continue down this
316
- // branch, but not before examining the other siblings.
317
- firstChildren.push(child.firstChild);
318
- }
319
- child = child.nextSibling;
320
- }
321
- }
322
-
323
- if (__DEV__) {
324
- console.error(
325
- 'Error while invoking `findComponentRoot` with the following ' +
326
- 'ancestor node:',
327
- ancestorNode
328
- );
329
- }
330
- invariant(
331
- false,
332
- 'findComponentRoot(..., %s): Unable to find element. This probably ' +
333
- 'means the DOM was unexpectedly mutated (e.g. by the browser).',
334
- id,
335
- ReactID.getID(ancestorNode)
336
- );
337
- },
338
-
240
/**
241
* Gets the DOM ID of the React component that is the root of the tree that
242
* contains the React component with the supplied DOM ID.
@@ -400,7 +301,11 @@ var ReactInstanceHandles = {
301
* Exposed for unit testing.
302
* @private
303
*/
403
- _getNextDescendantID: getNextDescendantID
304
+ _getNextDescendantID: getNextDescendantID,
305
+
306
+ isAncestorIDOf: isAncestorIDOf,
307
+
308
+ SEPARATOR: SEPARATOR
309
310
};
311
src/core/ReactMount.js
+260
-17
@@ -22,8 +22,11 @@ var invariant = require('invariant');
22
var getReactRootElementInContainer = require('getReactRootElementInContainer');
23
var ReactEventEmitter = require('ReactEventEmitter');
24
var ReactInstanceHandles = require('ReactInstanceHandles');
25
-var ReactEventTopLevelCallback = require('ReactEventTopLevelCallback');
26
-var ReactID = require('ReactID');
25
+
26
+var SEPARATOR = ReactInstanceHandles.SEPARATOR;
27
+
28
+var ATTR_NAME = 'data-reactid';
29
+var nodeCache = {};
30
31
var $ = require('$');
32
@@ -44,7 +47,138 @@ if (__DEV__) {
47
*/
48
function getReactRootID(container) {
49
var rootElement = getReactRootElementInContainer(container);
47
- return rootElement && ReactID.getID(rootElement);
50
+ return rootElement && ReactMount.getID(rootElement);
51
+}
52
+
53
+/**
54
+ * Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
55
+ * element can return its control whose name or ID equals ATTR_NAME. All
56
+ * DOM nodes support `getAttributeNode` but this can also get called on
57
+ * other objects so just return '' if we're given something other than a
58
+ * DOM node (such as window).
59
+ *
60
+ * @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
61
+ * @return {string} ID of the supplied `domNode`.
62
+ */
63
+function getID(node) {
64
+ var id = internalGetID(node);
65
+ if (id) {
66
+ if (nodeCache.hasOwnProperty(id)) {
67
+ var cached = nodeCache[id];
68
+ if (cached !== node) {
69
+ invariant(
70
+ !isValid(cached, id),
71
+ 'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
72
+ ATTR_NAME, id
73
+ );
74
+
75
+ nodeCache[id] = node;
76
+ }
77
+ } else {
78
+ nodeCache[id] = node;
79
+ }
80
+ }
81
+
82
+ return id;
83
+}
84
+
85
+function internalGetID(node) {
86
+ // If node is something like a window, document, or text node, none of
87
+ // which support attributes or a .getAttribute method, gracefully return
88
+ // the empty string, as if the attribute were missing.
89
+ return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
90
+}
91
+
92
+/**
93
+ * Sets the React-specific ID of the given node.
94
+ *
95
+ * @param {DOMElement} node The DOM node whose ID will be set.
96
+ * @param {string} id The value of the ID attribute.
97
+ */
98
+function setID(node, id) {
99
+ var oldID = internalGetID(node);
100
+ if (oldID !== id) {
101
+ delete nodeCache[oldID];
102
+ }
103
+ node.setAttribute(ATTR_NAME, id);
104
+ nodeCache[id] = node;
105
+}
106
+
107
+/**
108
+ * Finds the node with the supplied React-generated DOM ID.
109
+ *
110
+ * @param {string} id A React-generated DOM ID.
111
+ * @return {DOMElement} DOM node with the suppled `id`.
112
+ * @internal
113
+ */
114
+function getNode(id) {
115
+ if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
116
+ nodeCache[id] = ReactMount.findReactNodeByID(id);
117
+ }
118
+ return nodeCache[id];
119
+}
120
+
121
+/**
122
+ * A node is "valid" if it is contained by a currently mounted container.
123
+ *
124
+ * This means that the node does not have to be contained by a document in
125
+ * order to be considered valid.
126
+ *
127
+ * @param {?DOMElement} node The candidate DOM node.
128
+ * @param {string} id The expected ID of the node.
129
+ * @return {boolean} Whether the node is contained by a mounted container.
130
+ */
131
+function isValid(node, id) {
132
+ if (node) {
133
+ invariant(
134
+ internalGetID(node) === id,
135
+ 'ReactMount: Unexpected modification of `%s`',
136
+ ATTR_NAME
137
+ );
138
+
139
+ var container = ReactMount.findReactContainerForID(id);
140
+ if (container && contains(container, node)) {
141
+ return true;
142
+ }
143
+ }
144
+
145
+ return false;
146
+}
147
+
148
+function contains(ancestor, descendant) {
149
+ if (ancestor.contains) {
150
+ // Supported natively in virtually all browsers, but not in jsdom.
151
+ return ancestor.contains(descendant);
152
+ }
153
+
154
+ if (descendant === ancestor) {
155
+ return true;
156
+ }
157
+
158
+ if (descendant.nodeType === 3) {
159
+ // If descendant is a text node, start from descendant.parentNode
160
+ // instead, so that we can assume all ancestors worth considering are
161
+ // element nodes with nodeType === 1.
162
+ descendant = descendant.parentNode;
163
+ }
164
+
165
+ while (descendant && descendant.nodeType === 1) {
166
+ if (descendant === ancestor) {
167
+ return true;
168
+ }
169
+ descendant = descendant.parentNode;
170
+ }
171
+
172
+ return false;
173
+}
174
+
175
+/**
176
+ * Causes the cache to forget about one React-specific ID.
177
+ *
178
+ * @param {string} id The ID to forget.
179
+ */
180
+function purgeID(id) {
181
+ delete nodeCache[id];
182
}
183
184
/**
@@ -89,14 +223,10 @@ var ReactMount = {
223
* Ensures that the top-level event delegation listener is set up. This will
224
* be invoked some time before the first time any React component is rendered.
225
*
92
- * @param {object} TopLevelCallbackCreator
226
* @private
227
*/
95
- prepareTopLevelEvents: function(TopLevelCallbackCreator) {
96
- ReactEventEmitter.ensureListening(
97
- ReactMount.useTouchEvents,
98
- TopLevelCallbackCreator
99
- );
228
+ prepareTopLevelEvents: function() {
229
+ ReactEventEmitter.ensureListening(ReactMount.useTouchEvents);
230
},
231
232
/**
@@ -132,7 +262,7 @@ var ReactMount = {
262
* @return {string} reactRoot ID prefix
263
*/
264
_registerComponent: function(nextComponent, container) {
135
- ReactMount.prepareTopLevelEvents(ReactEventTopLevelCallback);
265
+ ReactMount.prepareTopLevelEvents();
266
267
var reactRootID = ReactMount.registerContainer(container);
268
instanceByReactRootID[reactRootID] = nextComponent;
@@ -196,8 +326,7 @@ var ReactMount = {
326
327
var reactRootElement = getReactRootElementInContainer(container);
328
var containerHasReactMarkup =
199
- reactRootElement &&
200
- ReactInstanceHandles.isRenderedByReact(reactRootElement);
329
+ reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
330
331
var shouldReuseMarkup = containerHasReactMarkup && !registeredComponent;
332
@@ -295,15 +424,15 @@ var ReactMount = {
424
var rootElement = rootElementsByReactRootID[reactRootID];
425
if (rootElement && rootElement.parentNode !== container) {
426
invariant(
298
- // Call rawGetID here because getID calls isValid which calls
427
+ // Call internalGetID here because getID calls isValid which calls
428
// findReactContainerForID (this function).
300
- ReactID.rawGetID(rootElement) === reactRootID,
429
+ internalGetID(rootElement) === reactRootID,
430
'ReactMount: Root element ID differed from reactRootID.'
431
);
432
433
var containerChild = container.firstChild;
434
if (containerChild &&
306
- reactRootID === ReactID.rawGetID(containerChild)) {
435
+ reactRootID === internalGetID(containerChild)) {
436
// If the container has a new child with the same ID as the old
437
// root element, then rootElementsByReactRootID[reactRootID] is
438
// just stale and needs to be updated. The case that deserves a
@@ -329,8 +458,122 @@ var ReactMount = {
458
*/
459
findReactNodeByID: function(id) {
460
var reactRoot = ReactMount.findReactContainerForID(id);
332
- return ReactInstanceHandles.findComponentRoot(reactRoot, id);
333
- }
461
+ return ReactMount.findComponentRoot(reactRoot, id);
462
+ },
463
+
464
+ /**
465
+ * True if the supplied `node` is rendered by React.
466
+ *
467
+ * @param {*} node DOM Element to check.
468
+ * @return {boolean} True if the DOM Element appears to be rendered by React.
469
+ * @internal
470
+ */
471
+ isRenderedByReact: function(node) {
472
+ if (node.nodeType !== 1) {
473
+ // Not a DOMElement, therefore not a React component
474
+ return false;
475
+ }
476
+ var id = ReactMount.getID(node);
477
+ return id ? id.charAt(0) === SEPARATOR : false;
478
+ },
479
+
480
+ /**
481
+ * Traverses up the ancestors of the supplied node to find a node that is a
482
+ * DOM representation of a React component.
483
+ *
484
+ * @param {*} node
485
+ * @return {?DOMEventTarget}
486
+ * @internal
487
+ */
488
+ getFirstReactDOM: function(node) {
489
+ var current = node;
490
+ while (current && current.parentNode !== current) {
491
+ if (ReactMount.isRenderedByReact(current)) {
492
+ return current;
493
+ }
494
+ current = current.parentNode;
495
+ }
496
+ return null;
497
+ },
498
+
499
+ /**
500
+ * Finds a node with the supplied `id` inside of the supplied `ancestorNode`.
501
+ * Exploits the ID naming scheme to perform the search quickly.
502
+ *
503
+ * @param {DOMEventTarget} ancestorNode Search from this root.
504
+ * @pararm {string} id ID of the DOM representation of the component.
505
+ * @return {DOMEventTarget} DOM node with the supplied `id`.
506
+ * @internal
507
+ */
508
+ findComponentRoot: function(ancestorNode, id) {
509
+ var firstChildren = [ancestorNode.firstChild];
510
+ var childIndex = 0;
511
+
512
+ while (childIndex < firstChildren.length) {
513
+ var child = firstChildren[childIndex++];
514
+ while (child) {
515
+ var childID = ReactMount.getID(child);
516
+ if (childID) {
517
+ if (id === childID) {
518
+ return child;
519
+ } else if (ReactInstanceHandles.isAncestorIDOf(childID, id)) {
520
+ // If we find a child whose ID is an ancestor of the given ID,
521
+ // then we can be sure that we only want to search the subtree
522
+ // rooted at this child, so we can throw out the rest of the
523
+ // search state.
524
+ firstChildren.length = childIndex = 0;
525
+ firstChildren.push(child.firstChild);
526
+ break;
527
+ } else {
528
+ // TODO This should not be necessary if the ID hierarchy is
529
+ // correct, but is occasionally necessary if the DOM has been
530
+ // modified in unexpected ways.
531
+ firstChildren.push(child.firstChild);
532
+ }
533
+ } else {
534
+ // If this child had no ID, then there's a chance that it was
535
+ // injected automatically by the browser, as when a `<table>`
536
+ // element sprouts an extra `<tbody>` child as a side effect of
537
+ // `.innerHTML` parsing. Optimistically continue down this
538
+ // branch, but not before examining the other siblings.
539
+ firstChildren.push(child.firstChild);
540
+ }
541
+ child = child.nextSibling;
542
+ }
543
+ }
544
+
545
+ if (__DEV__) {
546
+ console.error(
547
+ 'Error while invoking `findComponentRoot` with the following ' +
548
+ 'ancestor node:',
549
+ ancestorNode
550
+ );
551
+ }
552
+ invariant(
553
+ false,
554
+ 'findComponentRoot(..., %s): Unable to find element. This probably ' +
555
+ 'means the DOM was unexpectedly mutated (e.g. by the browser).',
556
+ id,
557
+ ReactMount.getID(ancestorNode)
558
+ );
559
+ },
560
+
561
+
562
+ /**
563
+ * React ID utilities.
564
+ */
565
+
566
+ ATTR_NAME: ATTR_NAME,
567
+
568
+ getID: getID,
569
+
570
+ setID: setID,
571
+
572
+ getNode: getNode,
573
+
574
+ purgeID: purgeID,
575
+
576
+ injection: {}
577
};
578
579
module.exports = ReactMount;
src/core/ReactNativeComponent.js
+2
-2
@@ -25,7 +25,7 @@ var DOMPropertyOperations = require('DOMPropertyOperations');
25
var ReactComponent = require('ReactComponent');
26
var ReactEventEmitter = require('ReactEventEmitter');
27
var ReactMultiChild = require('ReactMultiChild');
28
-var ReactID = require('ReactID');
28
+var ReactMount = require('ReactMount');
29
30
var escapeTextForBrowser = require('escapeTextForBrowser');
31
var flattenChildren = require('flattenChildren');
@@ -136,7 +136,7 @@ ReactNativeComponent.Mixin = {
136
}
137
138
var escapedID = escapeTextForBrowser(this._rootNodeID);
139
- return ret + ' ' + ReactID.ATTR_NAME + '="' + escapedID + '">';
139
+ return ret + ' ' + ReactMount.ATTR_NAME + '="' + escapedID + '">';
140
},
141
142
/**
src/core/ReactTextComponent.js
+2
-2
@@ -20,7 +20,7 @@
20
"use strict";
21
22
var ReactComponent = require('ReactComponent');
23
-var ReactID = require('ReactID');
23
+var ReactMount = require('ReactMount');
24
25
var escapeTextForBrowser = require('escapeTextForBrowser');
26
var mixInto = require('mixInto');
@@ -58,7 +58,7 @@ mixInto(ReactTextComponent, {
58
mountComponent: function(rootID) {
59
ReactComponent.Mixin.mountComponent.call(this, rootID);
60
return (
61
- '<span ' + ReactID.ATTR_NAME + '="' + rootID + '">' +
61
+ '<span ' + ReactMount.ATTR_NAME + '="' + rootID + '">' +
62
escapeTextForBrowser(this.props.text) +
63
'</span>'
64
);
src/core/__tests__/ReactCompositeComponent-test.js
+3
-3
@@ -25,7 +25,7 @@ var React;
25
var ReactCurrentOwner;
26
var ReactPropTypes;
27
var ReactTestUtils;
28
-var ReactID;
28
+var ReactMount;
29
var ReactDoNotBindDeprecated;
30
31
var cx;
@@ -41,7 +41,7 @@ describe('ReactCompositeComponent', function() {
41
ReactDoNotBindDeprecated = require('ReactDoNotBindDeprecated');
42
ReactPropTypes = require('ReactPropTypes');
43
ReactTestUtils = require('ReactTestUtils');
44
- ReactID = require('ReactID');
44
+ ReactMount = require('ReactMount');
45
46
MorphingComponent = React.createClass({
47
getInitialState: function() {
@@ -129,7 +129,7 @@ describe('ReactCompositeComponent', function() {
129
// rerender
130
instance.setProps({renderAnchor: true, anchorClassOn: false});
131
var anchorID = instance.getAnchorID();
132
- var actualDOMAnchorNode = ReactID.getNode(anchorID);
132
+ var actualDOMAnchorNode = ReactMount.getNode(anchorID);
133
expect(actualDOMAnchorNode.className).toBe('');
134
});
135
src/core/__tests__/ReactDOM-test.js
+4
-4
@@ -25,7 +25,7 @@ var React = require('React');
25
var ReactDOM = require('ReactDOM');
26
var ReactTestUtils = require('ReactTestUtils');
27
var React = require('React');
28
-var ReactID = require('ReactID');
28
+var ReactMount = require('ReactMount');
29
30
describe('ref swapping', function() {
31
// TODO: uncomment this test once we can run in phantom, which
@@ -61,7 +61,7 @@ describe('ref swapping', function() {
61
var argDiv = ReactTestUtils.renderIntoDocument(
62
ReactDOM.div(null, 'child')
63
);
64
- var argNode = ReactID.getNode(argDiv._rootNodeID);
64
+ var argNode = ReactMount.getNode(argDiv._rootNodeID);
65
expect(argNode.innerHTML).toBe('child');
66
});
67
@@ -69,7 +69,7 @@ describe('ref swapping', function() {
69
var conflictDiv = ReactTestUtils.renderIntoDocument(
70
ReactDOM.div({children: 'fakechild'}, 'child')
71
);
72
- var conflictNode = ReactID.getNode(conflictDiv._rootNodeID);
72
+ var conflictNode = ReactMount.getNode(conflictDiv._rootNodeID);
73
expect(conflictNode.innerHTML).toBe('child');
74
});
75
@@ -111,7 +111,7 @@ describe('ref swapping', function() {
111
theBird: <div class="bird" />
112
}
113
});
114
- var root = ReactID.getNode(myDiv._rootNodeID);
114
+ var root = ReactMount.getNode(myDiv._rootNodeID);
115
var dog = root.childNodes[0];
116
expect(dog.className).toBe('bigdog');
117
});
src/core/__tests__/ReactDOMIDOperations-test.js
+5
-5
@@ -23,11 +23,11 @@
23
describe('ReactDOMIDOperations', function() {
24
var DOMPropertyOperations = require('DOMPropertyOperations');
25
var ReactDOMIDOperations = require('ReactDOMIDOperations');
26
- var ReactID = require('ReactID');
26
+ var ReactMount = require('ReactMount');
27
var keyOf = require('keyOf');
28
29
it('should disallow updating special properties', function() {
30
- spyOn(ReactID, "getNode");
30
+ spyOn(ReactMount, "getNode");
31
spyOn(DOMPropertyOperations, "setValueForProperty");
32
33
expect(function() {
@@ -39,7 +39,7 @@ describe('ReactDOMIDOperations', function() {
39
}).toThrow();
40
41
expect(
42
- ReactID.getNode.argsForCall[0][0]
42
+ ReactMount.getNode.argsForCall[0][0]
43
).toBe('testID');
44
45
expect(
@@ -49,7 +49,7 @@ describe('ReactDOMIDOperations', function() {
49
50
it('should update innerHTML and special-case whitespace', function() {
51
var stubNode = document.createElement('div');
52
- spyOn(ReactID, "getNode").andReturn(stubNode);
52
+ spyOn(ReactMount, "getNode").andReturn(stubNode);
53
54
ReactDOMIDOperations.updateInnerHTMLByID(
55
'testID',
@@ -57,7 +57,7 @@ describe('ReactDOMIDOperations', function() {
57
);
58
59
expect(
60
- ReactID.getNode.argsForCall[0][0]
60
+ ReactMount.getNode.argsForCall[0][0]
61
).toBe('testID');
62
63
expect(stubNode.innerHTML).toBe(' testContent');
src/core/__tests__/ReactEventEmitter-test.js
+7
-7
@@ -22,7 +22,7 @@ require('mock-modules')
22
.dontMock('BrowserScroll')
23
.dontMock('CallbackRegistry')
24
.dontMock('EventPluginHub')
25
- .dontMock('ReactID')
25
+ .dontMock('ReactMount')
26
.dontMock('ReactEventEmitter')
27
.dontMock('ReactInstanceHandles')
28
.dontMock('EventPluginHub')
@@ -35,9 +35,9 @@ var keyOf = require('keyOf');
35
var mocks = require('mocks');
36
37
var EventPluginHub;
38
-var ReactID = require('ReactID');
39
-var getID = ReactID.getID;
40
-var setID = ReactID.setID;
38
+var ReactMount = require('ReactMount');
39
+var getID = ReactMount.getID;
40
+var setID = ReactMount.setID;
41
var ReactEventEmitter;
42
var ReactEventTopLevelCallback;
43
var ReactTestUtils;
@@ -89,9 +89,9 @@ describe('ReactEventEmitter', function() {
89
require('mock-modules').dumpCache();
90
EventPluginHub = require('EventPluginHub');
91
TapEventPlugin = require('TapEventPlugin');
92
- ReactID = require('ReactID');
93
- getID = ReactID.getID;
94
- setID = ReactID.setID;
92
+ ReactMount = require('ReactMount');
93
+ getID = ReactMount.getID;
94
+ setID = ReactMount.setID;
95
ReactEventEmitter = require('ReactEventEmitter');
96
ReactTestUtils = require('ReactTestUtils');
97
ReactEventTopLevelCallback = require('ReactEventTopLevelCallback');
src/core/__tests__/ReactIdentity-test.js
+5
-5
@@ -22,7 +22,7 @@
22
var React;
23
var ReactTestUtils;
24
var reactComponentExpect;
25
-var ReactID;
25
+var ReactMount;
26
27
describe('ReactIdentity', function() {
28
@@ -31,12 +31,12 @@ describe('ReactIdentity', function() {
31
React = require('React');
32
ReactTestUtils = require('ReactTestUtils');
33
reactComponentExpect = require('reactComponentExpect');
34
- ReactID = require('ReactID');
34
+ ReactMount = require('ReactMount');
35
});
36
37
var idExp = /^\.r\[.+?\](.*)$/;
38
function checkId(child, expectedId) {
39
- var actual = idExp.exec(ReactID.getID(child));
39
+ var actual = idExp.exec(ReactMount.getID(child));
40
var expected = idExp.exec(expectedId);
41
expect(actual).toBeTruthy();
42
expect(expected).toBeTruthy();
@@ -281,11 +281,11 @@ describe('ReactIdentity', function() {
281
282
React.renderComponent(wrapped, document.createElement('div'));
283
284
- var beforeID = ReactID.getID(wrapped.getDOMNode().firstChild);
284
+ var beforeID = ReactMount.getID(wrapped.getDOMNode().firstChild);
285
286
wrapped.swap();
287
288
- var afterID = ReactID.getID(wrapped.getDOMNode().firstChild);
288
+ var afterID = ReactMount.getID(wrapped.getDOMNode().firstChild);
289
290
expect(beforeID).not.toEqual(afterID);
291
src/core/__tests__/ReactInstanceHandles-test.js
+17
-17
@@ -21,7 +21,7 @@
21
22
var React = require('React');
23
var ReactTestUtils = require('ReactTestUtils');
24
-var ReactID = require('ReactID');
24
+var ReactMount = require('ReactMount');
25
26
/**
27
* Ensure that all callbacks are invoked, passing this unique argument.
@@ -78,7 +78,7 @@ describe('ReactInstanceHandles', function() {
78
describe('isRenderedByReact', function() {
79
it('should not crash on text nodes', function() {
80
expect(function() {
81
- ReactInstanceHandles.isRenderedByReact(document.createTextNode('yolo'));
81
+ ReactMount.isRenderedByReact(document.createTextNode('yolo'));
82
}).not.toThrow();
83
});
84
});
@@ -91,14 +91,14 @@ describe('ReactInstanceHandles', function() {
91
parentNode.appendChild(childNodeA);
92
parentNode.appendChild(childNodeB);
93
94
- ReactID.setID(parentNode, '.react[0]');
95
- ReactID.setID(childNodeA, '.react[0].0');
96
- ReactID.setID(childNodeB, '.react[0].0:1');
94
+ ReactMount.setID(parentNode, '.react[0]');
95
+ ReactMount.setID(childNodeA, '.react[0].0');
96
+ ReactMount.setID(childNodeB, '.react[0].0:1');
97
98
expect(
99
- ReactInstanceHandles.findComponentRoot(
99
+ ReactMount.findComponentRoot(
100
parentNode,
101
- ReactID.getID(childNodeB)
101
+ ReactMount.getID(childNodeB)
102
)
103
).toBe(childNodeB);
104
});
@@ -110,14 +110,14 @@ describe('ReactInstanceHandles', function() {
110
parentNode.appendChild(childNodeA);
111
parentNode.appendChild(childNodeB);
112
113
- ReactID.setID(parentNode, '.react[0]');
113
+ ReactMount.setID(parentNode, '.react[0]');
114
// No ID on `childNodeA`.
115
- ReactID.setID(childNodeB, '.react[0].0:1');
115
+ ReactMount.setID(childNodeB, '.react[0].0:1');
116
117
expect(
118
- ReactInstanceHandles.findComponentRoot(
118
+ ReactMount.findComponentRoot(
119
parentNode,
120
- ReactID.getID(childNodeB)
120
+ ReactMount.getID(childNodeB)
121
)
122
).toBe(childNodeB);
123
});
@@ -129,22 +129,22 @@ describe('ReactInstanceHandles', function() {
129
parentNode.appendChild(childNodeA);
130
childNodeA.appendChild(childNodeB);
131
132
- ReactID.setID(parentNode, '.react[0]');
132
+ ReactMount.setID(parentNode, '.react[0]');
133
// No ID on `childNodeA`, it was "rendered by the browser".
134
- ReactID.setID(childNodeB, '.react[0].1:0');
134
+ ReactMount.setID(childNodeB, '.react[0].1:0');
135
136
- expect(ReactInstanceHandles.findComponentRoot(
136
+ expect(ReactMount.findComponentRoot(
137
parentNode,
138
- ReactID.getID(childNodeB)
138
+ ReactMount.getID(childNodeB)
139
)).toBe(childNodeB);
140
141
spyOn(console, 'error');
142
expect(console.error.argsForCall.length).toBe(0);
143
144
expect(function() {
145
- ReactInstanceHandles.findComponentRoot(
145
+ ReactMount.findComponentRoot(
146
parentNode,
147
- ReactID.getID(childNodeB) + ":junk"
147
+ ReactMount.getID(childNodeB) + ":junk"
148
);
149
}).toThrow(
150
'Invariant Violation: findComponentRoot(..., .react[0].1:0:junk): ' +
src/core/__tests__/ReactMultiChildReconcile-test.js
+2
-2
@@ -23,7 +23,7 @@ require('mock-modules');
23
24
var React = require('React');
25
var ReactTestUtils = require('ReactTestUtils');
26
-var ReactID = require('ReactID');
26
+var ReactMount = require('ReactMount');
27
28
var objMapKeyVal = require('objMapKeyVal');
29
@@ -191,7 +191,7 @@ function verifyDomOrderingAccurate(parentInstance, statusDisplays) {
191
var i;
192
var orderedDomIds = [];
193
for (i=0; i < statusDisplayNodes.length; i++) {
194
- orderedDomIds.push(ReactID.getID(statusDisplayNodes[i]));
194
+ orderedDomIds.push(ReactMount.getID(statusDisplayNodes[i]));
195
}
196
197
var orderedLogicalIds = [];
src/core/__tests__/ReactNativeComponent-test.js
+2
-2
@@ -317,7 +317,7 @@ describe('ReactNativeComponent', function() {
317
it("should clean up listeners", function() {
318
var React = require('React');
319
var ReactEventEmitter = require('ReactEventEmitter');
320
- var ReactID = require('ReactID');
320
+ var ReactMount = require('ReactMount');
321
322
var container = document.createElement('div');
323
document.documentElement.appendChild(container);
@@ -327,7 +327,7 @@ describe('ReactNativeComponent', function() {
327
React.renderComponent(instance, container);
328
329
var rootNode = instance.getDOMNode();
330
- var rootNodeID = ReactID.getID(rootNode);
330
+ var rootNodeID = ReactMount.getID(rootNode);
331
expect(
332
ReactEventEmitter.getListener(rootNodeID, 'onClick')
333
).toBe(callback);
src/environment/__tests__/ReactServerRendering-test.js
+11
-11
@@ -24,7 +24,7 @@
24
require('mock-modules')
25
.dontMock('ExecutionEnvironment')
26
.dontMock('React')
27
- .dontMock('ReactID')
27
+ .dontMock('ReactMount')
28
.dontMock('ReactServerRendering')
29
.dontMock('ReactTestUtils')
30
.dontMock('ReactMarkupChecksum');
@@ -32,7 +32,7 @@ require('mock-modules')
32
var mocks = require('mocks');
33
34
var React;
35
-var ReactID;
35
+var ReactMount;
36
var ReactTestUtils;
37
var ReactServerRendering;
38
var ReactMarkupChecksum;
@@ -42,7 +42,7 @@ describe('ReactServerRendering', function() {
42
beforeEach(function() {
43
require('mock-modules').dumpCache();
44
React = require('React');
45
- ReactID = require('ReactID');
45
+ ReactMount = require('ReactMount');
46
ReactTestUtils = require('ReactTestUtils');
47
ExecutionEnvironment = require('ExecutionEnvironment');
48
ExecutionEnvironment.canUseDOM = false;
@@ -59,7 +59,7 @@ describe('ReactServerRendering', function() {
59
}
60
);
61
expect(response).toMatch(
62
- '<span ' + ReactID.ATTR_NAME + '="[^"]+" ' +
62
+ '<span ' + ReactMount.ATTR_NAME + '="[^"]+" ' +
63
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">hello world</span>'
64
);
65
});
@@ -83,11 +83,11 @@ describe('ReactServerRendering', function() {
83
}
84
);
85
expect(response).toMatch(
86
- '<div ' + ReactID.ATTR_NAME + '="[^"]+" ' +
86
+ '<div ' + ReactMount.ATTR_NAME + '="[^"]+" ' +
87
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
88
- '<span ' + ReactID.ATTR_NAME + '="[^"]+">' +
89
- '<span ' + ReactID.ATTR_NAME + '="[^"]+">My name is </span>' +
90
- '<span ' + ReactID.ATTR_NAME + '="[^"]+">child</span>' +
88
+ '<span ' + ReactMount.ATTR_NAME + '="[^"]+">' +
89
+ '<span ' + ReactMount.ATTR_NAME + '="[^"]+">My name is </span>' +
90
+ '<span ' + ReactMount.ATTR_NAME + '="[^"]+">child</span>' +
91
'</span>' +
92
'</div>'
93
);
@@ -137,10 +137,10 @@ describe('ReactServerRendering', function() {
137
);
138
139
expect(response).toMatch(
140
- '<span ' + ReactID.ATTR_NAME + '="[^"]+" ' +
140
+ '<span ' + ReactMount.ATTR_NAME + '="[^"]+" ' +
141
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
142
- '<span ' + ReactID.ATTR_NAME + '="[^"]+">Component name: </span>' +
143
- '<span ' + ReactID.ATTR_NAME + '="[^"]+">TestComponent</span>' +
142
+ '<span ' + ReactMount.ATTR_NAME + '="[^"]+">Component name: </span>' +
143
+ '<span ' + ReactMount.ATTR_NAME + '="[^"]+">TestComponent</span>' +
144
'</span>'
145
);
146
expect(lifecycle).toEqual(
src/eventPlugins/EnterLeaveEventPlugin.js
+4
-5
@@ -22,14 +22,13 @@
22
var EventConstants = require('EventConstants');
23
var EventPropagators = require('EventPropagators');
24
var ExecutionEnvironment = require('ExecutionEnvironment');
25
-var ReactInstanceHandles = require('ReactInstanceHandles');
25
var SyntheticMouseEvent = require('SyntheticMouseEvent');
26
28
-var ReactID = require('ReactID');
27
+var ReactMount = require('ReactMount');
28
var keyOf = require('keyOf');
29
30
var topLevelTypes = EventConstants.topLevelTypes;
32
-var getFirstReactDOM = ReactInstanceHandles.getFirstReactDOM;
31
+var getFirstReactDOM = ReactMount.getFirstReactDOM;
32
33
var eventTypes = {
34
mouseEnter: {registrationName: keyOf({onMouseEnter: null})},
@@ -85,8 +84,8 @@ var EnterLeaveEventPlugin = {
84
return null;
85
}
86
88
- var fromID = from ? ReactID.getID(from) : '';
89
- var toID = to ? ReactID.getID(to) : '';
87
+ var fromID = from ? ReactMount.getID(from) : '';
88
+ var toID = to ? ReactMount.getID(to) : '';
89
90
var leave = SyntheticMouseEvent.getPooled(
91
eventTypes.mouseLeave,
src/test/ReactTestUtils.js
+3
-3
@@ -21,7 +21,7 @@ var React = require('React');
21
var ReactComponent = require('ReactComponent');
22
var ReactEventEmitter = require('ReactEventEmitter');
23
var ReactTextComponent = require('ReactTextComponent');
24
-var ReactID = require('ReactID');
24
+var ReactMount = require('ReactMount');
25
26
var mergeInto = require('mergeInto');
27
@@ -222,10 +222,10 @@ var ReactTestUtils = {
222
ReactEventEmitter.TopLevelCallbackCreator.createTopLevelCallback(
223
topLevelType
224
);
225
- var node = ReactID.getNode(reactRootID);
225
+ var node = ReactMount.getNode(reactRootID);
226
fakeNativeEvent.target = node;
227
/* jsdom is returning nodes without id's - fixing that issue here. */
228
- ReactID.setID(node, reactRootID);
228
+ ReactMount.setID(node, reactRootID);
229
virtualHandler(fakeNativeEvent);
230
},
231