foo.getDOMNode => React.findDOMNode(foo)
cpojer committed
Mar 9, 2015 at 20:39 UTC
ae7da3aadd70b96e6a750e2659180645255b2591
30 files changed
+181
-170
src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js
+20
-20
@@ -36,7 +36,7 @@ describe('ReactCSSTransitionGroup', function() {
36
</ReactCSSTransitionGroup>,
37
container
38
);
39
- expect(a.getDOMNode().childNodes.length).toBe(1);
39
+ expect(React.findDOMNode(a).childNodes.length).toBe(1);
40
41
setTimeout.mock.calls.length = 0;
42
@@ -46,9 +46,9 @@ describe('ReactCSSTransitionGroup', function() {
46
</ReactCSSTransitionGroup>,
47
container
48
);
49
- expect(a.getDOMNode().childNodes.length).toBe(2);
50
- expect(a.getDOMNode().childNodes[0].id).toBe('two');
51
- expect(a.getDOMNode().childNodes[1].id).toBe('one');
49
+ expect(React.findDOMNode(a).childNodes.length).toBe(2);
50
+ expect(React.findDOMNode(a).childNodes[0].id).toBe('two');
51
+ expect(React.findDOMNode(a).childNodes[1].id).toBe('one');
52
53
// For some reason jst is adding extra setTimeout()s and grunt test isn't,
54
// so we need to do this disgusting hack.
@@ -59,7 +59,7 @@ describe('ReactCSSTransitionGroup', function() {
59
}
60
}
61
62
- expect(a.getDOMNode().childNodes.length).toBe(2);
62
+ expect(React.findDOMNode(a).childNodes.length).toBe(2);
63
expect(console.warn.argsForCall.length).toBe(1);
64
});
65
@@ -70,16 +70,16 @@ describe('ReactCSSTransitionGroup', function() {
70
</ReactCSSTransitionGroup>,
71
container
72
);
73
- expect(a.getDOMNode().childNodes.length).toBe(1);
73
+ expect(React.findDOMNode(a).childNodes.length).toBe(1);
74
React.render(
75
<ReactCSSTransitionGroup transitionName="yolo">
76
<span key="two" id="two" />
77
</ReactCSSTransitionGroup>,
78
container
79
);
80
- expect(a.getDOMNode().childNodes.length).toBe(2);
81
- expect(a.getDOMNode().childNodes[0].id).toBe('two');
82
- expect(a.getDOMNode().childNodes[1].id).toBe('one');
80
+ expect(React.findDOMNode(a).childNodes.length).toBe(2);
81
+ expect(React.findDOMNode(a).childNodes[0].id).toBe('two');
82
+ expect(React.findDOMNode(a).childNodes[1].id).toBe('one');
83
});
84
85
it('should switch transitionLeave from false to true', function() {
@@ -92,7 +92,7 @@ describe('ReactCSSTransitionGroup', function() {
92
</ReactCSSTransitionGroup>,
93
container
94
);
95
- expect(a.getDOMNode().childNodes.length).toBe(1);
95
+ expect(React.findDOMNode(a).childNodes.length).toBe(1);
96
React.render(
97
<ReactCSSTransitionGroup
98
transitionName="yolo"
@@ -102,7 +102,7 @@ describe('ReactCSSTransitionGroup', function() {
102
</ReactCSSTransitionGroup>,
103
container
104
);
105
- expect(a.getDOMNode().childNodes.length).toBe(1);
105
+ expect(React.findDOMNode(a).childNodes.length).toBe(1);
106
React.render(
107
<ReactCSSTransitionGroup
108
transitionName="yolo"
@@ -112,9 +112,9 @@ describe('ReactCSSTransitionGroup', function() {
112
</ReactCSSTransitionGroup>,
113
container
114
);
115
- expect(a.getDOMNode().childNodes.length).toBe(2);
116
- expect(a.getDOMNode().childNodes[0].id).toBe('three');
117
- expect(a.getDOMNode().childNodes[1].id).toBe('two');
115
+ expect(React.findDOMNode(a).childNodes.length).toBe(2);
116
+ expect(React.findDOMNode(a).childNodes[0].id).toBe('three');
117
+ expect(React.findDOMNode(a).childNodes[1].id).toBe('two');
118
});
119
120
it('should work with no children', function() {
@@ -141,7 +141,7 @@ describe('ReactCSSTransitionGroup', function() {
141
</ReactCSSTransitionGroup>,
142
container
143
);
144
- expect(a.getDOMNode().childNodes.length).toBe(1);
144
+ expect(React.findDOMNode(a).childNodes.length).toBe(1);
145
React.render(
146
<ReactCSSTransitionGroup transitionName="yolo">
147
{null}
@@ -150,8 +150,8 @@ describe('ReactCSSTransitionGroup', function() {
150
);
151
// (Here, we expect the original child to stick around but test that no
152
// exception is thrown)
153
- expect(a.getDOMNode().childNodes.length).toBe(1);
154
- expect(a.getDOMNode().childNodes[0].id).toBe('one');
153
+ expect(React.findDOMNode(a).childNodes.length).toBe(1);
154
+ expect(React.findDOMNode(a).childNodes[0].id).toBe('one');
155
});
156
157
it('should transition from false to one', function() {
@@ -161,15 +161,15 @@ describe('ReactCSSTransitionGroup', function() {
161
</ReactCSSTransitionGroup>,
162
container
163
);
164
- expect(a.getDOMNode().childNodes.length).toBe(0);
164
+ expect(React.findDOMNode(a).childNodes.length).toBe(0);
165
React.render(
166
<ReactCSSTransitionGroup transitionName="yolo">
167
<span key="one" id="one" />
168
</ReactCSSTransitionGroup>,
169
container
170
);
171
- expect(a.getDOMNode().childNodes.length).toBe(1);
172
- expect(a.getDOMNode().childNodes[0].id).toBe('one');
171
+ expect(React.findDOMNode(a).childNodes.length).toBe(1);
172
+ expect(React.findDOMNode(a).childNodes[0].id).toBe('one');
173
});
174
175
});
src/browser/__tests__/ReactDOM-test.js
+5
-5
@@ -38,7 +38,7 @@ describe('ReactDOM', function() {
38
return <form><input type="submit" value="Submit" /></form>;
39
},
40
componentDidMount: function() {
41
- form = this.getDOMNode();
41
+ form = React.findDOMNode(this);
42
}
43
});
44
var instance = ReactTestUtils.renderIntoDocument(<Parent />);
@@ -50,14 +50,14 @@ describe('ReactDOM', function() {
50
it("allows a DOM element to be used with a string", function() {
51
var element = React.createElement('div', {className: 'foo'});
52
var instance = ReactTestUtils.renderIntoDocument(element);
53
- expect(instance.getDOMNode().tagName).toBe('DIV');
53
+ expect(React.findDOMNode(instance).tagName).toBe('DIV');
54
});
55
56
it("should allow children to be passed as an argument", function() {
57
var argDiv = ReactTestUtils.renderIntoDocument(
58
div(null, 'child')
59
);
60
- var argNode = argDiv.getDOMNode();
60
+ var argNode = React.findDOMNode(argDiv);
61
expect(argNode.innerHTML).toBe('child');
62
});
63
@@ -65,7 +65,7 @@ describe('ReactDOM', function() {
65
var conflictDiv = ReactTestUtils.renderIntoDocument(
66
div({children: 'fakechild'}, 'child')
67
);
68
- var conflictNode = conflictDiv.getDOMNode();
68
+ var conflictNode = React.findDOMNode(conflictDiv);
69
expect(conflictNode.innerHTML).toBe('child');
70
});
71
@@ -107,7 +107,7 @@ describe('ReactDOM', function() {
107
<div key="theBird" className="bird" />
108
]
109
});
110
- var root = myDiv.getDOMNode();
110
+ var root = React.findDOMNode(myDiv);
111
var dog = root.childNodes[0];
112
expect(dog.className).toBe('bigdog');
113
});
src/browser/eventPlugins/__tests__/EnterLeaveEventPlugin-test.js
+1
-1
@@ -44,7 +44,7 @@ describe('EnterLeaveEventPlugin', function() {
44
iframeDocument.close();
45
46
var component = React.render(<div />, iframeDocument.body);
47
- var div = component.getDOMNode();
47
+ var div = React.findDOMNode(component);
48
49
var extracted = EnterLeaveEventPlugin.extractEvents(
50
topLevelTypes.topMouseOver,
src/browser/server/__tests__/ReactServerRendering-test.js
+1
-1
@@ -225,7 +225,7 @@ describe('ReactServerRendering', function() {
225
226
// Ensure the events system works
227
expect(numClicks).toEqual(0);
228
- ReactTestUtils.Simulate.click(instance.refs.span.getDOMNode());
228
+ ReactTestUtils.Simulate.click(React.findDOMNode(instance.refs.span));
229
expect(numClicks).toEqual(1);
230
});
231
src/browser/ui/__tests__/ReactDOMComponent-test.js
+1
-1
@@ -581,7 +581,7 @@ describe('ReactDOMComponent', function() {
581
var instance = <div onClick={callback} />;
582
instance = React.render(instance, container);
583
584
- var rootNode = instance.getDOMNode();
584
+ var rootNode = React.findDOMNode(instance);
585
var rootNodeID = ReactMount.getID(rootNode);
586
expect(
587
ReactBrowserEventEmitter.getListener(rootNodeID, 'onClick')
src/browser/ui/__tests__/ReactDOMTextComponent-test.js
+4
-4
@@ -31,15 +31,15 @@ describe('ReactDOMTextComponent', function() {
31
var el = document.createElement('div');
32
var inst = React.render(<div>{'foo'}{'bar'}</div>, el);
33
34
- var foo = inst.getDOMNode().children[0];
35
- var bar = inst.getDOMNode().children[1];
34
+ var foo = React.findDOMNode(inst).children[0];
35
+ var bar = React.findDOMNode(inst).children[1];
36
expect(foo.tagName).toBe('SPAN');
37
expect(bar.tagName).toBe('SPAN');
38
39
inst = React.render(<div>{'baz'}{'qux'}</div>, el);
40
// After the update, the spans should have stayed in place (as opposed to
41
// getting unmounted and remounted)
42
- expect(inst.getDOMNode().children[0]).toBe(foo);
43
- expect(inst.getDOMNode().children[1]).toBe(bar);
42
+ expect(React.findDOMNode(inst).children[0]).toBe(foo);
43
+ expect(React.findDOMNode(inst).children[1]).toBe(bar);
44
});
45
});
src/browser/ui/__tests__/ReactEventListener-test.js
+23
-17
@@ -45,17 +45,19 @@ describe('ReactEventListener', function() {
45
childControl = ReactMount.render(childControl, childContainer);
46
parentControl =
47
ReactMount.render(parentControl, parentContainer);
48
- parentControl.getDOMNode().appendChild(childContainer);
48
+ React.findDOMNode(parentControl).appendChild(childContainer);
49
50
var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
51
callback({
52
- target: childControl.getDOMNode()
52
+ target: React.findDOMNode(childControl)
53
});
54
55
var calls = handleTopLevel.mock.calls;
56
expect(calls.length).toBe(2);
57
- expect(calls[0][EVENT_TARGET_PARAM]).toBe(childControl.getDOMNode());
58
- expect(calls[1][EVENT_TARGET_PARAM]).toBe(parentControl.getDOMNode());
57
+ expect(calls[0][EVENT_TARGET_PARAM])
58
+ .toBe(React.findDOMNode(childControl));
59
+ expect(calls[1][EVENT_TARGET_PARAM])
60
+ .toBe(React.findDOMNode(parentControl));
61
});
62
63
it('should propagate events two levels down', function() {
@@ -70,20 +72,22 @@ describe('ReactEventListener', function() {
72
ReactMount.render(parentControl, parentContainer);
73
grandParentControl =
74
ReactMount.render(grandParentControl, grandParentContainer);
73
- parentControl.getDOMNode().appendChild(childContainer);
74
- grandParentControl.getDOMNode().appendChild(parentContainer);
75
+ React.findDOMNode(parentControl).appendChild(childContainer);
76
+ React.findDOMNode(grandParentControl).appendChild(parentContainer);
77
78
var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
79
callback({
78
- target: childControl.getDOMNode()
80
+ target: React.findDOMNode(childControl)
81
});
82
83
var calls = handleTopLevel.mock.calls;
84
expect(calls.length).toBe(3);
83
- expect(calls[0][EVENT_TARGET_PARAM]).toBe(childControl.getDOMNode());
84
- expect(calls[1][EVENT_TARGET_PARAM]).toBe(parentControl.getDOMNode());
85
+ expect(calls[0][EVENT_TARGET_PARAM])
86
+ .toBe(React.findDOMNode(childControl));
87
+ expect(calls[1][EVENT_TARGET_PARAM])
88
+ .toBe(React.findDOMNode(parentControl));
89
expect(calls[2][EVENT_TARGET_PARAM])
86
- .toBe(grandParentControl.getDOMNode());
90
+ .toBe(React.findDOMNode(grandParentControl));
91
});
92
93
it('should not get confused by disappearing elements', function() {
@@ -94,13 +98,13 @@ describe('ReactEventListener', function() {
98
childControl = ReactMount.render(childControl, childContainer);
99
parentControl =
100
ReactMount.render(parentControl, parentContainer);
97
- parentControl.getDOMNode().appendChild(childContainer);
101
+ React.findDOMNode(parentControl).appendChild(childContainer);
102
103
// ReactBrowserEventEmitter.handleTopLevel might remove the
104
// target from the DOM. Here, we have handleTopLevel remove the
105
// node when the first event handlers are called; we'll still
106
// expect to receive a second call for the parent control.
103
- var childNode = childControl.getDOMNode();
107
+ var childNode = React.findDOMNode(childControl);
108
handleTopLevel.mockImplementation(
109
function(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
110
if (topLevelTarget === childNode) {
@@ -117,7 +121,8 @@ describe('ReactEventListener', function() {
121
var calls = handleTopLevel.mock.calls;
122
expect(calls.length).toBe(2);
123
expect(calls[0][EVENT_TARGET_PARAM]).toBe(childNode);
120
- expect(calls[1][EVENT_TARGET_PARAM]).toBe(parentControl.getDOMNode());
124
+ expect(calls[1][EVENT_TARGET_PARAM])
125
+ .toBe(React.findDOMNode(parentControl));
126
});
127
128
it('should batch between handlers from different roots', function() {
@@ -131,11 +136,11 @@ describe('ReactEventListener', function() {
136
<div>Parent</div>,
137
parentContainer
138
);
134
- parentControl.getDOMNode().appendChild(childContainer);
139
+ React.findDOMNode(parentControl).appendChild(childContainer);
140
141
// Suppose an event handler in each root enqueues an update to the
142
// childControl element -- the two updates should get batched together.
138
- var childNode = childControl.getDOMNode();
143
+ var childNode = React.findDOMNode(childControl);
144
handleTopLevel.mockImplementation(
145
function(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
146
ReactMount.render(
@@ -177,11 +182,12 @@ describe('ReactEventListener', function() {
182
183
var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
184
callback({
180
- target: instance.getInner().getDOMNode()
185
+ target: React.findDOMNode(instance.getInner())
186
});
187
188
var calls = handleTopLevel.mock.calls;
189
expect(calls.length).toBe(1);
185
- expect(calls[0][EVENT_TARGET_PARAM]).toBe(instance.getInner().getDOMNode());
190
+ expect(calls[0][EVENT_TARGET_PARAM])
191
+ .toBe(React.findDOMNode(instance.getInner()));
192
});
193
});
src/browser/ui/__tests__/ReactRenderDocument-test.js
+2
-2
@@ -246,7 +246,7 @@ describe('rendering React components at document', function() {
246
);
247
});
248
249
- it('supports getDOMNode on full-page components', function() {
249
+ it('supports findDOMNode on full-page components', function() {
250
var tree =
251
<html>
252
<head>
@@ -261,6 +261,6 @@ describe('rendering React components at document', function() {
261
testDocument = getTestDocument(markup);
262
var component = React.render(tree, testDocument);
263
expect(testDocument.body.innerHTML).toBe('Hello world');
264
- expect(component.getDOMNode().tagName).toBe('HTML');
264
+ expect(React.findDOMNode(component).tagName).toBe('HTML');
265
});
266
});
src/browser/ui/dom/components/AutoFocusMixin.js
+2
-1
@@ -12,12 +12,13 @@
12
13
'use strict';
14
15
+var findDOMNode = require('findDOMNode');
16
var focusNode = require('focusNode');
17
18
var AutoFocusMixin = {
19
componentDidMount: function() {
20
if (this.props.autoFocus) {
20
- focusNode(this.getDOMNode());
21
+ focusNode(findDOMNode(this));
22
}
23
}
24
};
src/browser/ui/dom/components/LocalEventTrapMixin.js
+2
-1
@@ -14,6 +14,7 @@
14
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
15
16
var accumulateInto = require('accumulateInto');
17
+var findDOMNode = require('findDOMNode');
18
var forEachAccumulated = require('forEachAccumulated');
19
var invariant = require('invariant');
20
@@ -26,7 +27,7 @@ var LocalEventTrapMixin = {
27
invariant(this.isMounted(), 'Must be mounted to trap events');
28
// If a component renders to null or if another component fatals and causes
29
// the state of the tree to be corrupted, `node` here can be null.
29
- var node = this.getDOMNode();
30
+ var node = findDOMNode(this);
31
invariant(
32
node,
33
'LocalEventTrapMixin.trapBubbledEvent(...): Requires node to be rendered.'
src/browser/ui/dom/components/ReactDOMInput.js
+5
-4
@@ -21,6 +21,7 @@ var ReactMount = require('ReactMount');
21
var ReactUpdates = require('ReactUpdates');
22
23
var assign = require('Object.assign');
24
+var findDOMNode = require('findDOMNode');
25
var invariant = require('invariant');
26
27
var input = ReactElement.createFactory('input');
@@ -83,18 +84,18 @@ var ReactDOMInput = ReactClass.createClass({
84
},
85
86
componentDidMount: function() {
86
- var id = ReactMount.getID(this.getDOMNode());
87
+ var id = ReactMount.getID(findDOMNode(this));
88
instancesByReactID[id] = this;
89
},
90
91
componentWillUnmount: function() {
91
- var rootNode = this.getDOMNode();
92
+ var rootNode = findDOMNode(this);
93
var id = ReactMount.getID(rootNode);
94
delete instancesByReactID[id];
95
},
96
97
componentDidUpdate: function(prevProps, prevState, prevContext) {
97
- var rootNode = this.getDOMNode();
98
+ var rootNode = findDOMNode(this);
99
if (this.props.checked != null) {
100
DOMPropertyOperations.setValueForProperty(
101
rootNode,
@@ -124,7 +125,7 @@ var ReactDOMInput = ReactClass.createClass({
125
126
var name = this.props.name;
127
if (this.props.type === 'radio' && name != null) {
127
- var rootNode = this.getDOMNode();
128
+ var rootNode = findDOMNode(this);
129
var queryRoot = rootNode;
130
131
while (queryRoot.parentNode) {
src/browser/ui/dom/components/ReactDOMSelect.js
+2
-1
@@ -19,6 +19,7 @@ var ReactElement = require('ReactElement');
19
var ReactUpdates = require('ReactUpdates');
20
21
var assign = require('Object.assign');
22
+var findDOMNode = require('findDOMNode');
23
24
var select = ReactElement.createFactory('select');
25
@@ -65,7 +66,7 @@ function selectValueType(props, propName, componentName) {
66
*/
67
function updateOptions(component, propValue) {
68
var selectedValue, i, l;
68
- var options = component.getDOMNode().options;
69
+ var options = findDOMNode(component).options;
70
71
if (component.props.multiple) {
72
selectedValue = {};
src/browser/ui/dom/components/ReactDOMTextarea.js
+2
-1
@@ -20,6 +20,7 @@ var ReactElement = require('ReactElement');
20
var ReactUpdates = require('ReactUpdates');
21
22
var assign = require('Object.assign');
23
+var findDOMNode = require('findDOMNode');
24
var invariant = require('invariant');
25
26
var warning = require('warning');
@@ -114,7 +115,7 @@ var ReactDOMTextarea = ReactClass.createClass({
115
componentDidUpdate: function(prevProps, prevState, prevContext) {
116
var value = LinkedValueUtils.getValue(this);
117
if (value != null) {
117
- var rootNode = this.getDOMNode();
118
+ var rootNode = findDOMNode(this);
119
// Cast `value` to a string to ensure the value is set correctly. While
120
// browsers typically do this as necessary, jsdom doesn't.
121
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
src/browser/ui/dom/components/__tests__/ReactDOMButton-test.js
+2
-2
@@ -23,13 +23,13 @@ describe('ReactDOMButton', function() {
23
24
function expectClickThru(button) {
25
onClick.mockClear();
26
- ReactTestUtils.Simulate.click(button.getDOMNode());
26
+ ReactTestUtils.Simulate.click(React.findDOMNode(button));
27
expect(onClick.mock.calls.length).toBe(1);
28
}
29
30
function expectNoClickThru(button) {
31
onClick.mockClear();
32
- ReactTestUtils.Simulate.click(button.getDOMNode());
32
+ ReactTestUtils.Simulate.click(React.findDOMNode(button));
33
expect(onClick.mock.calls.length).toBe(0);
34
}
35
src/browser/ui/dom/components/__tests__/ReactDOMIframe-test.js
+1
-1
@@ -28,7 +28,7 @@ describe('ReactDOMIframe', function() {
28
var loadEvent = document.createEvent('Event');
29
loadEvent.initEvent('load', false, false);
30
31
- iframe.getDOMNode().dispatchEvent(loadEvent);
31
+ React.findDOMNode(iframe).dispatchEvent(loadEvent);
32
33
expect(onLoadSpy).toHaveBeenCalled();
34
});
src/browser/ui/dom/components/__tests__/ReactDOMInput-test.js
+19
-19
@@ -32,7 +32,7 @@ describe('ReactDOMInput', function() {
32
it('should display `defaultValue` of number 0', function() {
33
var stub = <input type="text" defaultValue={0} />;
34
stub = ReactTestUtils.renderIntoDocument(stub);
35
- var node = stub.getDOMNode();
35
+ var node = React.findDOMNode(stub);
36
37
expect(node.value).toBe('0');
38
});
@@ -40,7 +40,7 @@ describe('ReactDOMInput', function() {
40
it('should display "true" for `defaultValue` of `true`', function() {
41
var stub = <input type="text" defaultValue={true} />;
42
stub = ReactTestUtils.renderIntoDocument(stub);
43
- var node = stub.getDOMNode();
43
+ var node = React.findDOMNode(stub);
44
45
expect(node.value).toBe('true');
46
});
@@ -48,7 +48,7 @@ describe('ReactDOMInput', function() {
48
it('should display "false" for `defaultValue` of `false`', function() {
49
var stub = <input type="text" defaultValue={false} />;
50
stub = ReactTestUtils.renderIntoDocument(stub);
51
- var node = stub.getDOMNode();
51
+ var node = React.findDOMNode(stub);
52
53
expect(node.value).toBe('false');
54
});
@@ -62,7 +62,7 @@ describe('ReactDOMInput', function() {
62
63
var stub = <input type="text" defaultValue={objToString} />;
64
stub = ReactTestUtils.renderIntoDocument(stub);
65
- var node = stub.getDOMNode();
65
+ var node = React.findDOMNode(stub);
66
67
expect(node.value).toBe('foobar');
68
});
@@ -70,7 +70,7 @@ describe('ReactDOMInput', function() {
70
it('should display `value` of number 0', function() {
71
var stub = <input type="text" value={0} />;
72
stub = ReactTestUtils.renderIntoDocument(stub);
73
- var node = stub.getDOMNode();
73
+ var node = React.findDOMNode(stub);
74
75
expect(node.value).toBe('0');
76
});
@@ -78,7 +78,7 @@ describe('ReactDOMInput', function() {
78
it('should allow setting `value` to `true`', function() {
79
var stub = <input type="text" value="yolo" onChange={emptyFunction} />;
80
stub = ReactTestUtils.renderIntoDocument(stub);
81
- var node = stub.getDOMNode();
81
+ var node = React.findDOMNode(stub);
82
83
expect(node.value).toBe('yolo');
84
@@ -89,7 +89,7 @@ describe('ReactDOMInput', function() {
89
it("should allow setting `value` to `false`", function() {
90
var stub = <input type="text" value="yolo" onChange={emptyFunction} />;
91
stub = ReactTestUtils.renderIntoDocument(stub);
92
- var node = stub.getDOMNode();
92
+ var node = React.findDOMNode(stub);
93
94
expect(node.value).toBe('yolo');
95
@@ -100,7 +100,7 @@ describe('ReactDOMInput', function() {
100
it('should allow setting `value` to `objToString`', function() {
101
var stub = <input type="text" value="foo" onChange={emptyFunction} />;
102
stub = ReactTestUtils.renderIntoDocument(stub);
103
- var node = stub.getDOMNode();
103
+ var node = React.findDOMNode(stub);
104
105
expect(node.value).toBe('foo');
106
@@ -117,7 +117,7 @@ describe('ReactDOMInput', function() {
117
it('should properly control a value of number `0`', function() {
118
var stub = <input type="text" value={0} onChange={emptyFunction} />;
119
stub = ReactTestUtils.renderIntoDocument(stub);
120
- var node = stub.getDOMNode();
120
+ var node = React.findDOMNode(stub);
121
122
node.value = 'giraffe';
123
ReactTestUtils.Simulate.change(node);
@@ -127,7 +127,7 @@ describe('ReactDOMInput', function() {
127
it('should not set a value for submit buttons unnecessarily', function() {
128
var stub = <input type="submit" />;
129
stub = ReactTestUtils.renderIntoDocument(stub);
130
- var node = stub.getDOMNode();
130
+ var node = React.findDOMNode(stub);
131
132
// The value shouldn't be '', or else the button will have no text; it
133
// should have the default "Submit" or "Submit Query" label. Most browsers
@@ -172,9 +172,9 @@ describe('ReactDOMInput', function() {
172
});
173
174
var stub = ReactTestUtils.renderIntoDocument(<RadioGroup />);
175
- var aNode = stub.refs.a.getDOMNode();
176
- var bNode = stub.refs.b.getDOMNode();
177
- var cNode = stub.refs.c.getDOMNode();
175
+ var aNode = React.findDOMNode(stub.refs.a);
176
+ var bNode = React.findDOMNode(stub.refs.b);
177
+ var cNode = React.findDOMNode(stub.refs.c);
178
179
expect(aNode.checked).toBe(true);
180
expect(bNode.checked).toBe(false);
@@ -202,12 +202,12 @@ describe('ReactDOMInput', function() {
202
203
instance = ReactTestUtils.renderIntoDocument(instance);
204
205
- expect(instance.getDOMNode().value).toBe('yolo');
205
+ expect(React.findDOMNode(instance).value).toBe('yolo');
206
expect(link.value).toBe('yolo');
207
expect(link.requestChange.mock.calls.length).toBe(0);
208
209
- instance.getDOMNode().value = 'test';
210
- ReactTestUtils.Simulate.change(instance.getDOMNode());
209
+ React.findDOMNode(instance).value = 'test';
210
+ ReactTestUtils.Simulate.change(React.findDOMNode(instance));
211
212
expect(link.requestChange.mock.calls.length).toBe(1);
213
expect(link.requestChange.mock.calls[0][0]).toEqual('test');
@@ -270,12 +270,12 @@ describe('ReactDOMInput', function() {
270
271
instance = ReactTestUtils.renderIntoDocument(instance);
272
273
- expect(instance.getDOMNode().checked).toBe(true);
273
+ expect(React.findDOMNode(instance).checked).toBe(true);
274
expect(link.value).toBe(true);
275
expect(link.requestChange.mock.calls.length).toBe(0);
276
277
- instance.getDOMNode().checked = false;
278
- ReactTestUtils.Simulate.change(instance.getDOMNode());
277
+ React.findDOMNode(instance).checked = false;
278
+ ReactTestUtils.Simulate.change(React.findDOMNode(instance));
279
280
expect(link.requestChange.mock.calls.length).toBe(1);
281
expect(link.requestChange.mock.calls[0][0]).toEqual(false);
src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js
+13
-13
@@ -34,7 +34,7 @@ describe('ReactDOMSelect', function() {
34
<option value="gorilla">A gorilla!</option>
35
</select>;
36
stub = ReactTestUtils.renderIntoDocument(stub);
37
- var node = stub.getDOMNode();
37
+ var node = React.findDOMNode(stub);
38
39
expect(node.value).toBe('giraffe');
40
@@ -51,7 +51,7 @@ describe('ReactDOMSelect', function() {
51
<option value="gorilla">A gorilla!</option>
52
</select>;
53
stub = ReactTestUtils.renderIntoDocument(stub);
54
- var node = stub.getDOMNode();
54
+ var node = React.findDOMNode(stub);
55
56
expect(node.value).toBe('giraffe');
57
@@ -69,7 +69,7 @@ describe('ReactDOMSelect', function() {
69
<option value="gorilla">A gorilla!</option>
70
</select>;
71
stub = ReactTestUtils.renderIntoDocument(stub);
72
- var node = stub.getDOMNode();
72
+ var node = React.findDOMNode(stub);
73
74
expect(node.options[0].selected).toBe(false); // monkey
75
expect(node.options[1].selected).toBe(true); // giraffe
@@ -91,7 +91,7 @@ describe('ReactDOMSelect', function() {
91
<option value="gorilla">A gorilla!</option>
92
</select>;
93
stub = ReactTestUtils.renderIntoDocument(stub);
94
- var node = stub.getDOMNode();
94
+ var node = React.findDOMNode(stub);
95
96
expect(node.value).toBe('giraffe');
97
@@ -108,7 +108,7 @@ describe('ReactDOMSelect', function() {
108
<option value="gorilla">A gorilla!</option>
109
</select>;
110
stub = ReactTestUtils.renderIntoDocument(stub);
111
- var node = stub.getDOMNode();
111
+ var node = React.findDOMNode(stub);
112
113
expect(node.options[0].selected).toBe(false); // monkey
114
expect(node.options[1].selected).toBe(true); // giraffe
@@ -130,7 +130,7 @@ describe('ReactDOMSelect', function() {
130
<option value="12">twelve</option>
131
</select>;
132
stub = ReactTestUtils.renderIntoDocument(stub);
133
- var node = stub.getDOMNode();
133
+ var node = React.findDOMNode(stub);
134
135
expect(node.options[0].selected).toBe(false); // one
136
expect(node.options[1].selected).toBe(false); // two
@@ -149,7 +149,7 @@ describe('ReactDOMSelect', function() {
149
]
150
});
151
152
- var node = stub.getDOMNode();
152
+ var node = React.findDOMNode(stub);
153
154
expect(node.options[0].selected).toBe(true); // a
155
expect(node.options[1].selected).toBe(true); // b
@@ -171,7 +171,7 @@ describe('ReactDOMSelect', function() {
171
<option value="gorilla">A gorilla!</option>
172
</select>;
173
stub = ReactTestUtils.renderIntoDocument(stub);
174
- var node = stub.getDOMNode();
174
+ var node = React.findDOMNode(stub);
175
176
expect(node.options[0].selected).toBe(false); // monkey
177
expect(node.options[1].selected).toBe(true); // giraffe
@@ -194,7 +194,7 @@ describe('ReactDOMSelect', function() {
194
<option value="gorilla">A gorilla!</option>
195
</select>;
196
stub = ReactTestUtils.renderIntoDocument(stub);
197
- var node = stub.getDOMNode();
197
+ var node = React.findDOMNode(stub);
198
199
expect(node.options[0].selected).toBe(false); // monkey
200
expect(node.options[1].selected).toBe(true); // giraffe
@@ -216,7 +216,7 @@ describe('ReactDOMSelect', function() {
216
<option value="gorilla">A gorilla!</option>
217
</select>;
218
stub = ReactTestUtils.renderIntoDocument(stub);
219
- var node = stub.getDOMNode();
219
+ var node = React.findDOMNode(stub);
220
221
expect(node.options[0].selected).toBe(false); // monkey
222
expect(node.options[1].selected).toBe(true); // giraffe
@@ -239,7 +239,7 @@ describe('ReactDOMSelect', function() {
239
<option value="gorilla">A gorilla!</option>
240
</select>;
241
stub = ReactTestUtils.renderIntoDocument(stub);
242
- var node = stub.getDOMNode();
242
+ var node = React.findDOMNode(stub);
243
244
expect(node.options[0].selected).toBe(false); // monkey
245
expect(node.options[1].selected).toBe(true); // giraffe
@@ -260,7 +260,7 @@ describe('ReactDOMSelect', function() {
260
<option value="gorilla">A gorilla!</option>
261
</select>;
262
stub = ReactTestUtils.renderIntoDocument(stub);
263
- var node = stub.getDOMNode();
263
+ var node = React.findDOMNode(stub);
264
265
stub.setProps({value: 'gorilla'});
266
@@ -284,7 +284,7 @@ describe('ReactDOMSelect', function() {
284
<option value="gorilla">A gorilla!</option>
285
</select>;
286
stub = ReactTestUtils.renderIntoDocument(stub);
287
- var node = stub.getDOMNode();
287
+ var node = React.findDOMNode(stub);
288
289
expect(node.options[0].selected).toBe(false); // monkey
290
expect(node.options[1].selected).toBe(true); // giraffe
src/browser/ui/dom/components/__tests__/ReactDOMTextarea-test.js
+20
-20
@@ -28,7 +28,7 @@ describe('ReactDOMTextarea', function() {
28
29
renderTextarea = function(component) {
30
var stub = ReactTestUtils.renderIntoDocument(component);
31
- var node = stub.getDOMNode();
31
+ var node = React.findDOMNode(stub);
32
// Fixing jsdom's quirky behavior -- in reality, the parser should strip
33
// off the leading newline but we need to do it by hand here.
34
node.value = node.innerHTML.replace(/^\n/, '');
@@ -39,7 +39,7 @@ describe('ReactDOMTextarea', function() {
39
it('should allow setting `defaultValue`', function() {
40
var stub = <textarea defaultValue="giraffe" />;
41
stub = renderTextarea(stub);
42
- var node = stub.getDOMNode();
42
+ var node = React.findDOMNode(stub);
43
44
expect(node.value).toBe('giraffe');
45
@@ -51,7 +51,7 @@ describe('ReactDOMTextarea', function() {
51
it('should display `defaultValue` of number 0', function() {
52
var stub = <textarea defaultValue={0} />;
53
stub = renderTextarea(stub);
54
- var node = stub.getDOMNode();
54
+ var node = React.findDOMNode(stub);
55
56
expect(node.value).toBe('0');
57
});
@@ -59,7 +59,7 @@ describe('ReactDOMTextarea', function() {
59
it('should display "false" for `defaultValue` of `false`', function() {
60
var stub = <textarea type="text" defaultValue={false} />;
61
stub = renderTextarea(stub);
62
- var node = stub.getDOMNode();
62
+ var node = React.findDOMNode(stub);
63
64
expect(node.value).toBe('false');
65
});
@@ -73,7 +73,7 @@ describe('ReactDOMTextarea', function() {
73
74
var stub = <textarea type="text" defaultValue={objToString} />;
75
stub = renderTextarea(stub);
76
- var node = stub.getDOMNode();
76
+ var node = React.findDOMNode(stub);
77
78
expect(node.value).toBe('foobar');
79
});
@@ -81,7 +81,7 @@ describe('ReactDOMTextarea', function() {
81
it('should not render value as an attribute', function() {
82
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
83
stub = renderTextarea(stub);
84
- var node = stub.getDOMNode();
84
+ var node = React.findDOMNode(stub);
85
86
expect(node.getAttribute('value')).toBe(null);
87
});
@@ -89,7 +89,7 @@ describe('ReactDOMTextarea', function() {
89
it('should display `value` of number 0', function() {
90
var stub = <textarea value={0} />;
91
stub = renderTextarea(stub);
92
- var node = stub.getDOMNode();
92
+ var node = React.findDOMNode(stub);
93
94
expect(node.value).toBe('0');
95
});
@@ -97,7 +97,7 @@ describe('ReactDOMTextarea', function() {
97
it('should allow setting `value` to `giraffe`', function() {
98
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
99
stub = renderTextarea(stub);
100
- var node = stub.getDOMNode();
100
+ var node = React.findDOMNode(stub);
101
102
expect(node.value).toBe('giraffe');
103
@@ -108,7 +108,7 @@ describe('ReactDOMTextarea', function() {
108
it('should allow setting `value` to `true`', function() {
109
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
110
stub = renderTextarea(stub);
111
- var node = stub.getDOMNode();
111
+ var node = React.findDOMNode(stub);
112
113
expect(node.value).toBe('giraffe');
114
@@ -119,7 +119,7 @@ describe('ReactDOMTextarea', function() {
119
it('should allow setting `value` to `false`', function() {
120
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
121
stub = renderTextarea(stub);
122
- var node = stub.getDOMNode();
122
+ var node = React.findDOMNode(stub);
123
124
expect(node.value).toBe('giraffe');
125
@@ -130,7 +130,7 @@ describe('ReactDOMTextarea', function() {
130
it('should allow setting `value` to `objToString`', function() {
131
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
132
stub = renderTextarea(stub);
133
- var node = stub.getDOMNode();
133
+ var node = React.findDOMNode(stub);
134
135
expect(node.value).toBe('giraffe');
136
@@ -146,7 +146,7 @@ describe('ReactDOMTextarea', function() {
146
it('should properly control a value of number `0`', function() {
147
var stub = <textarea value={0} onChange={emptyFunction} />;
148
stub = renderTextarea(stub);
149
- var node = stub.getDOMNode();
149
+ var node = React.findDOMNode(stub);
150
151
node.value = 'giraffe';
152
ReactTestUtils.Simulate.change(node);
@@ -158,7 +158,7 @@ describe('ReactDOMTextarea', function() {
158
159
var stub = <textarea>giraffe</textarea>;
160
stub = renderTextarea(stub);
161
- var node = stub.getDOMNode();
161
+ var node = React.findDOMNode(stub);
162
163
expect(console.warn.argsForCall.length).toBe(1);
164
expect(node.value).toBe('giraffe');
@@ -170,14 +170,14 @@ describe('ReactDOMTextarea', function() {
170
171
it('should allow numbers as children', function() {
172
spyOn(console, 'warn');
173
- var node = renderTextarea(<textarea>{17}</textarea>).getDOMNode();
173
+ var node = React.findDOMNode(renderTextarea(<textarea>{17}</textarea>));
174
expect(console.warn.argsForCall.length).toBe(1);
175
expect(node.value).toBe('17');
176
});
177
178
it('should allow booleans as children', function() {
179
spyOn(console, 'warn');
180
- var node = renderTextarea(<textarea>{false}</textarea>).getDOMNode();
180
+ var node = React.findDOMNode(renderTextarea(<textarea>{false}</textarea>));
181
expect(console.warn.argsForCall.length).toBe(1);
182
expect(node.value).toBe('false');
183
});
@@ -189,7 +189,7 @@ describe('ReactDOMTextarea', function() {
189
return "sharkswithlasers";
190
}
191
};
192
- var node = renderTextarea(<textarea>{obj}</textarea>).getDOMNode();
192
+ var node = React.findDOMNode(renderTextarea(<textarea>{obj}</textarea>));
193
expect(console.warn.argsForCall.length).toBe(1);
194
expect(node.value).toBe('sharkswithlasers');
195
});
@@ -207,7 +207,7 @@ describe('ReactDOMTextarea', function() {
207
208
var node;
209
expect(function() {
210
- node = renderTextarea(<textarea><strong /></textarea>).getDOMNode();
210
+ node = React.findDOMNode(renderTextarea(<textarea><strong /></textarea>));
211
}).not.toThrow();
212
213
expect(node.value).toBe('[object Object]');
@@ -221,12 +221,12 @@ describe('ReactDOMTextarea', function() {
221
222
instance = renderTextarea(instance);
223
224
- expect(instance.getDOMNode().value).toBe('yolo');
224
+ expect(React.findDOMNode(instance).value).toBe('yolo');
225
expect(link.value).toBe('yolo');
226
expect(link.requestChange.mock.calls.length).toBe(0);
227
228
- instance.getDOMNode().value = 'test';
229
- ReactTestUtils.Simulate.change(instance.getDOMNode());
228
+ React.findDOMNode(instance).value = 'test';
229
+ ReactTestUtils.Simulate.change(React.findDOMNode(instance));
230
231
expect(link.requestChange.mock.calls.length).toBe(1);
232
expect(link.requestChange.mock.calls[0][0]).toEqual('test');
src/classic/element/__tests__/ReactElement-test.js
+5
-5
@@ -283,7 +283,7 @@ describe('ReactElement', function() {
283
}
284
});
285
var outer = ReactTestUtils.renderIntoDocument(<Outer color="orange" />);
286
- expect(outer.getDOMNode().className).toBe('quack');
286
+ expect(React.findDOMNode(outer).className).toBe('quack');
287
288
expect(console.warn.argsForCall.length).toBe(1);
289
expect(console.warn.argsForCall[0][0]).toContain(
@@ -324,8 +324,8 @@ describe('ReactElement', function() {
324
}
325
});
326
var outer = React.render(<Outer />, el);
327
- expect(outer.getDOMNode().textContent).toBe('meow');
328
- expect(outer.getDOMNode().className).toBe('quack');
327
+ expect(React.findDOMNode(outer).textContent).toBe('meow');
328
+ expect(React.findDOMNode(outer).className).toBe('quack');
329
330
expect(console.warn.argsForCall.length).toBe(1);
331
expect(console.warn.argsForCall[0][0]).toContain(
@@ -340,8 +340,8 @@ describe('ReactElement', function() {
340
var newOuterEl = <Outer />;
341
newOuterEl.props.sound = 'oink';
342
outer = React.render(newOuterEl, el);
343
- expect(outer.getDOMNode().textContent).toBe('oink');
344
- expect(outer.getDOMNode().className).toBe('quack');
343
+ expect(React.findDOMNode(outer).textContent).toBe('oink');
344
+ expect(React.findDOMNode(outer).className).toBe('quack');
345
346
expect(console.warn.argsForCall.length).toBe(1);
347
expect(console.warn.argsForCall[0][0]).toContain(
src/classic/element/__tests__/ReactElementClone-test.js
+2
-2
@@ -41,7 +41,7 @@ describe('ReactElementClone', function() {
41
}
42
});
43
var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
44
- expect(component.getDOMNode().childNodes[0].className).toBe('xyz');
44
+ expect(React.findDOMNode(component).childNodes[0].className).toBe('xyz');
45
});
46
47
it('should clone a composite component with new props', function() {
@@ -65,7 +65,7 @@ describe('ReactElementClone', function() {
65
}
66
});
67
var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
68
- expect(component.getDOMNode().childNodes[0].className).toBe('xyz');
68
+ expect(React.findDOMNode(component).childNodes[0].className).toBe('xyz');
69
});
70
71
it('should keep the original ref if it is not overridden', function() {
src/core/__tests__/ReactComponentLifeCycle-test.js
+2
-2
@@ -287,7 +287,7 @@ describe('ReactComponentLifeCycle', function() {
287
);
288
});
289
290
- it('warns if getDOMNode is used inside render', function() {
290
+ it('warns if findDOMNode is used inside render', function() {
291
spyOn(console, 'warn');
292
var Component = React.createClass({
293
getInitialState: function() {
@@ -298,7 +298,7 @@ describe('ReactComponentLifeCycle', function() {
298
},
299
render: function() {
300
if (this.state.isMounted) {
301
- expect(this.getDOMNode().tagName).toBe('DIV');
301
+ expect(React.findDOMNode(this).tagName).toBe('DIV');
302
}
303
return <div/>;
304
}
src/core/__tests__/ReactCompositeComponent-test.js
+11
-11
@@ -152,7 +152,7 @@ describe('ReactCompositeComponent', function() {
152
// rerender
153
instance.setProps({renderAnchor: true, anchorClassOn: false});
154
var anchor = instance.getAnchor();
155
- var actualDOMAnchorNode = anchor.getDOMNode();
155
+ var actualDOMAnchorNode = React.findDOMNode(anchor);
156
expect(actualDOMAnchorNode.className).toBe('');
157
});
158
@@ -451,10 +451,10 @@ describe('ReactCompositeComponent', function() {
451
});
452
var Inner = React.createClass({
453
componentWillUnmount: function() {
454
- // It's important that ReactMount.purgeID be called after any component
454
+ // It's important that ReactMount.purgeID is called after any component
455
// lifecycle methods, because a componentWillMount implementation is
456
- // likely call this.getDOMNode(), which will repopulate the node cache
457
- // after it's been cleared, causing a memory leak.
456
+ // likely to call React.findDOMNode(this), which will repopulate the
457
+ // node cache after it's been cleared, causing a memory leak.
458
expect(ReactMount.purgeID.calls.length).toBe(0);
459
innerUnmounted = true;
460
},
@@ -923,25 +923,25 @@ describe('ReactCompositeComponent', function() {
923
});
924
925
var comp = ReactTestUtils.renderIntoDocument(<Component flipped={false} />);
926
- expect(comp.refs.static0.getDOMNode().textContent).toBe('A');
927
- expect(comp.refs.static1.getDOMNode().textContent).toBe('B');
926
+ expect(React.findDOMNode(comp.refs.static0).textContent).toBe('A');
927
+ expect(React.findDOMNode(comp.refs.static1).textContent).toBe('B');
928
929
// When flipping the order, the refs should update even though the actual
930
// contents do not
931
comp.setProps({flipped: true});
932
- expect(comp.refs.static0.getDOMNode().textContent).toBe('B');
933
- expect(comp.refs.static1.getDOMNode().textContent).toBe('A');
932
+ expect(React.findDOMNode(comp.refs.static0).textContent).toBe('B');
933
+ expect(React.findDOMNode(comp.refs.static1).textContent).toBe('A');
934
});
935
936
- it('should allow access to getDOMNode in componentWillUnmount', function() {
936
+ it('should allow access to findDOMNode in componentWillUnmount', function() {
937
var a = null;
938
var b = null;
939
var Component = React.createClass({
940
componentDidMount: function() {
941
- a = this.getDOMNode();
941
+ a = React.findDOMNode(this);
942
},
943
componentWillUnmount: function() {
944
- b = this.getDOMNode();
944
+ b = React.findDOMNode(this);
945
},
946
render: function() {
947
return <div />;
src/core/__tests__/ReactEmptyComponent-test.js
+7
-7
@@ -33,11 +33,11 @@ describe('ReactEmptyComponent', function() {
33
return {component: this.props.firstComponent};
34
},
35
componentDidMount: function() {
36
- console.log(this.getDOMNode());
36
+ console.log(React.findDOMNode(this));
37
this.setState({component: this.props.secondComponent});
38
},
39
componentDidUpdate: function() {
40
- console.log(this.getDOMNode());
40
+ console.log(React.findDOMNode(this));
41
},
42
render: function() {
43
var Component = this.state.component;
@@ -188,13 +188,13 @@ describe('ReactEmptyComponent', function() {
188
componentDidMount: function() {
189
// Make sure the DOM node resolves properly even if we're replacing a
190
// `null` component
191
- expect(this.getDOMNode()).not.toBe(null);
191
+ expect(React.findDOMNode(this)).not.toBe(null);
192
assertions++;
193
},
194
componentWillUnmount: function() {
195
// Even though we're getting replaced by `null`, we haven't been
196
// replaced yet!
197
- expect(this.getDOMNode()).not.toBe(null);
197
+ expect(React.findDOMNode(this)).not.toBe(null);
198
assertions++;
199
}
200
});
@@ -209,15 +209,15 @@ describe('ReactEmptyComponent', function() {
209
210
// Render the <Inner /> component...
211
component = React.render(<Wrapper showInner={true} />, el);
212
- expect(component.getDOMNode()).not.toBe(null);
212
+ expect(React.findDOMNode(component)).not.toBe(null);
213
214
// Switch to null...
215
component = React.render(<Wrapper showInner={false} />, el);
216
- expect(component.getDOMNode()).toBe(null);
216
+ expect(React.findDOMNode(component)).toBe(null);
217
218
// ...then switch back.
219
component = React.render(<Wrapper showInner={true} />, el);
220
- expect(component.getDOMNode()).not.toBe(null);
220
+ expect(React.findDOMNode(component)).not.toBe(null);
221
222
expect(assertions).toBe(3);
223
});
src/core/__tests__/ReactIdentity-test.js
+9
-9
@@ -51,7 +51,7 @@ describe('ReactIdentity', function() {
51
</div>;
52
53
instance = React.render(instance, document.createElement('div'));
54
- var node = instance.getDOMNode();
54
+ var node = React.findDOMNode(instance);
55
reactComponentExpect(instance).toBeDOMComponentWithChildCount(2);
56
checkId(node.childNodes[0], '.0.$first:0');
57
checkId(node.childNodes[1], '.0.$second:0');
@@ -67,7 +67,7 @@ describe('ReactIdentity', function() {
67
</div>;
68
69
instance = React.render(instance, document.createElement('div'));
70
- var node = instance.getDOMNode();
70
+ var node = React.findDOMNode(instance);
71
reactComponentExpect(instance).toBeDOMComponentWithChildCount(4);
72
checkId(node.childNodes[0], '.0.$apple');
73
checkId(node.childNodes[1], '.0.$banana');
@@ -91,7 +91,7 @@ describe('ReactIdentity', function() {
91
</div>;
92
93
instance = React.render(instance, document.createElement('div'));
94
- var node = instance.getDOMNode();
94
+ var node = React.findDOMNode(instance);
95
reactComponentExpect(instance).toBeDOMComponentWithChildCount(3);
96
97
checkId(node.childNodes[0], '.0.$wrap1');
@@ -121,13 +121,13 @@ describe('ReactIdentity', function() {
121
var span1 = instance.refs.span1;
122
var span2 = instance.refs.span2;
123
124
- expect(span1.getDOMNode()).not.toBe(null);
125
- expect(span2.getDOMNode()).not.toBe(null);
124
+ expect(React.findDOMNode(span1)).not.toBe(null);
125
+ expect(React.findDOMNode(span2)).not.toBe(null);
126
127
key = key.replace(/=/g, '=0');
128
129
- checkId(span1.getDOMNode(), '.0.$' + key);
130
- checkId(span2.getDOMNode(), '.0.1:$' + key + ':0');
129
+ checkId(React.findDOMNode(span1), '.0.$' + key);
130
+ checkId(React.findDOMNode(span2), '.0.1:$' + key + ':0');
131
}
132
133
it('should allow any character as a key, in a detached parent', function() {
@@ -292,11 +292,11 @@ describe('ReactIdentity', function() {
292
293
wrapped = React.render(wrapped, document.createElement('div'));
294
295
- var beforeID = ReactMount.getID(wrapped.getDOMNode().firstChild);
295
+ var beforeID = ReactMount.getID(React.findDOMNode(wrapped).firstChild);
296
297
wrapped.swap();
298
299
- var afterID = ReactMount.getID(wrapped.getDOMNode().firstChild);
299
+ var afterID = ReactMount.getID(React.findDOMNode(wrapped).firstChild);
300
301
expect(beforeID).not.toEqual(afterID);
302
src/core/__tests__/ReactMultiChildReconcile-test.js
+1
-1
@@ -188,7 +188,7 @@ function verifyStatesPreserved(lastInternalStates, statusDisplays) {
188
* accurately reflects what is in the DOM.
189
*/
190
function verifyDomOrderingAccurate(parentInstance, statusDisplays) {
191
- var containerNode = parentInstance.getDOMNode();
191
+ var containerNode = React.findDOMNode(parentInstance);
192
var statusDisplayNodes = containerNode.childNodes;
193
var i;
194
var orderedDomIds = [];
src/core/__tests__/ReactMultiChildText-test.js
+8
-9
@@ -55,7 +55,7 @@ var updateChildren = function(d, children) {
55
var expectChildren = function(d, children) {
56
var textNode;
57
if (typeof children === 'string') {
58
- textNode = d.getDOMNode().firstChild;
58
+ textNode = React.findDOMNode(d).firstChild;
59
60
if (children === '') {
61
expect(textNode != null).toBe(false);
@@ -65,7 +65,7 @@ var expectChildren = function(d, children) {
65
expect(textNode.data).toBe('' + children);
66
}
67
} else {
68
- expect(d.getDOMNode().childNodes.length).toBe(children.length);
68
+ expect(React.findDOMNode(d).childNodes.length).toBe(children.length);
69
70
for (var i = 0; i < children.length; i++) {
71
var child = children[i];
@@ -75,7 +75,7 @@ var expectChildren = function(d, children) {
75
.expectRenderedChildAt(i)
76
.toBeTextComponentWithValue(child);
77
78
- textNode = d.getDOMNode().childNodes[i].firstChild;
78
+ textNode = React.findDOMNode(d).childNodes[i].firstChild;
79
80
if (child === '') {
81
expect(textNode != null).toBe(false);
@@ -85,12 +85,11 @@ var expectChildren = function(d, children) {
85
expect(textNode.data).toBe('' + child);
86
}
87
} else {
88
- var elementDOMNode =
89
- reactComponentExpect(d)
90
- .expectRenderedChildAt(i)
91
- .toBeComponentOfType('div')
92
- .instance()
93
- .getDOMNode();
88
+ var elementDOMNode = React.findDOMNode(reactComponentExpect(d)
89
+ .expectRenderedChildAt(i)
90
+ .toBeComponentOfType('div')
91
+ .instance()
92
+ );
93
94
expect(elementDOMNode.tagName).toBe('DIV');
95
}
src/core/__tests__/ReactUpdates-test.js
+5
-5
@@ -530,7 +530,7 @@ describe('ReactUpdates', function() {
530
return {x: 0};
531
},
532
componentDidUpdate: function() {
533
- expect(b.getDOMNode().textContent).toBe("B1");
533
+ expect(React.findDOMNode(b).textContent).toBe("B1");
534
aUpdated = true;
535
},
536
render: function() {
@@ -646,7 +646,7 @@ describe('ReactUpdates', function() {
646
depth={this.props.depth + 1}
647
count={this.props.count}
648
/>,
649
- this.getDOMNode()
649
+ React.findDOMNode(this)
650
);
651
}
652
}
@@ -709,10 +709,10 @@ describe('ReactUpdates', function() {
709
710
x = ReactTestUtils.renderIntoDocument(<X />);
711
y = ReactTestUtils.renderIntoDocument(<Y />);
712
- expect(x.getDOMNode().textContent).toBe('0');
712
+ expect(React.findDOMNode(x).textContent).toBe('0');
713
714
y.forceUpdate();
715
- expect(x.getDOMNode().textContent).toBe('1');
715
+ expect(React.findDOMNode(x).textContent).toBe('1');
716
});
717
718
it('should queue updates from during mount', function() {
@@ -750,7 +750,7 @@ describe('ReactUpdates', function() {
750
});
751
752
expect(a.state.x).toBe(1);
753
- expect(a.getDOMNode().textContent).toBe('A1');
753
+ expect(React.findDOMNode(a).textContent).toBe('A1');
754
});
755
756
it('calls componentWillReceiveProps setState callback properly', function() {
src/test/ReactTestUtils.js
+3
-2
@@ -26,6 +26,7 @@ var ReactUpdates = require('ReactUpdates');
26
var SyntheticEvent = require('SyntheticEvent');
27
28
var assign = require('Object.assign');
29
+var findDOMNode = require('findDOMNode');
30
31
var topLevelTypes = EventConstants.topLevelTypes;
32
@@ -293,7 +294,7 @@ var ReactTestUtils = {
294
fakeNativeEvent) {
295
ReactTestUtils.simulateNativeEventOnNode(
296
topLevelType,
296
- comp.getDOMNode(),
297
+ findDOMNode(comp),
298
fakeNativeEvent
299
);
300
},
@@ -405,7 +406,7 @@ function makeSimulator(eventType) {
406
return function(domComponentOrNode, eventData) {
407
var node;
408
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
408
- node = domComponentOrNode.getDOMNode();
409
+ node = findDOMNode(domComponentOrNode);
410
} else if (domComponentOrNode.tagName) {
411
node = domComponentOrNode;
412
}
src/test/__tests__/ReactTestUtils-test.js
+1
-1
@@ -173,7 +173,7 @@ describe('ReactTestUtils', function() {
173
174
var log = [];
175
ReactTestUtils.findAllInRenderedTree(tree, function(child) {
176
- log.push(child.getDOMNode().textContent);
176
+ log.push(React.findDOMNode(child).textContent);
177
});
178
179
// Should be document order, not mount order (which would be purple, orange)
src/utils/__tests__/cloneWithProps-test.js
+2
-2
@@ -50,7 +50,7 @@ describe('cloneWithProps', function() {
50
}
51
});
52
var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
53
- expect(component.getDOMNode().childNodes[0].className)
53
+ expect(React.findDOMNode(component).childNodes[0].className)
54
.toBe('xyz child');
55
});
56
@@ -77,7 +77,7 @@ describe('cloneWithProps', function() {
77
}
78
});
79
var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
80
- expect(component.getDOMNode().childNodes[0].className)
80
+ expect(React.findDOMNode(component).childNodes[0].className)
81
.toBe('xyz child');
82
});
83