Skip to content

Commit eeb7796

Browse files
committed
Merge pull request react-bootstrap#789 from AlexKVal/getDOMNode
Use React.findDOMNode()
2 parents 5177602 + 31d9eb2 commit eeb7796

34 files changed

+229
-231
lines changed

test/AlertSpec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Alert', function () {
1818
Message
1919
</Alert>
2020
);
21-
assert.ok(instance.getDOMNode().className.match(/\balert\b/));
21+
assert.ok(React.findDOMNode(instance).className.match(/\balert\b/));
2222
});
2323

2424
it('Should have dismissable style with onDismiss', function () {
@@ -28,7 +28,7 @@ describe('Alert', function () {
2828
Message
2929
</Alert>
3030
);
31-
assert.ok(instance.getDOMNode().className.match(/\balert-dismissable\b/));
31+
assert.ok(React.findDOMNode(instance).className.match(/\balert-dismissable\b/));
3232
});
3333

3434
it('Should call onDismiss callback on dismiss click', function (done) {
@@ -40,7 +40,7 @@ describe('Alert', function () {
4040
Message
4141
</Alert>
4242
);
43-
ReactTestUtils.Simulate.click(instance.getDOMNode().children[0]);
43+
ReactTestUtils.Simulate.click(React.findDOMNode(instance).children[0]);
4444
});
4545

4646
it('Should call onDismiss callback on dismissAfter time', function (done) {
@@ -60,7 +60,7 @@ describe('Alert', function () {
6060
Message
6161
</Alert>
6262
);
63-
assert.ok(instance.getDOMNode().className.match(/\balert-\w+\b/));
63+
assert.ok(React.findDOMNode(instance).className.match(/\balert-\w+\b/));
6464
});
6565

6666
it('Should have use bsStyle class', function () {
@@ -69,6 +69,6 @@ describe('Alert', function () {
6969
Message
7070
</Alert>
7171
);
72-
assert.ok(instance.getDOMNode().className.match(/\balert-danger\b/));
72+
assert.ok(React.findDOMNode(instance).className.match(/\balert-danger\b/));
7373
});
7474
});

test/BadgeSpec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Badge', function () {
1818
Content
1919
</Badge>
2020
);
21-
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
21+
assert.ok(React.findDOMNode(instance).className.match(/\bbadge\b/));
2222
});
2323

2424
it('Should have a badge using a number', function () {
@@ -28,7 +28,7 @@ describe('Badge', function () {
2828
{count}
2929
</Badge>
3030
);
31-
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
31+
assert.ok(React.findDOMNode(instance).className.match(/\bbadge\b/));
3232
});
3333

3434
it('Should have a badge using a a mix of content', function () {
@@ -38,7 +38,7 @@ describe('Badge', function () {
3838
£{count}
3939
</Badge>
4040
);
41-
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
41+
assert.ok(React.findDOMNode(instance).className.match(/\bbadge\b/));
4242
});
4343

4444
it('Should have a badge class pulled right', function () {
@@ -47,13 +47,13 @@ describe('Badge', function () {
4747
Content
4848
</Badge>
4949
);
50-
assert.ok(instance.getDOMNode().className.match(/\bpull-right\b/));
50+
assert.ok(React.findDOMNode(instance).className.match(/\bpull-right\b/));
5151
});
5252

5353
it('Should not have a badge class when empty', function () {
5454
let instance = ReactTestUtils.renderIntoDocument(
5555
<Badge />
5656
);
57-
assert.notOk(instance.getDOMNode().className.match(/\bbadge\b/));
57+
assert.notOk(React.findDOMNode(instance).className.match(/\bbadge\b/));
5858
});
5959
});

test/ButtonGroupSpec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe('ButtonGroup', function () {
1313
</Button>
1414
</ButtonGroup>
1515
);
16-
assert.equal(instance.getDOMNode().nodeName, 'DIV');
17-
assert.ok(instance.getDOMNode().className.match(/\bbtn-group\b/));
16+
assert.equal(React.findDOMNode(instance).nodeName, 'DIV');
17+
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-group\b/));
1818
});
1919

2020
it('Should add size', function () {
@@ -25,7 +25,7 @@ describe('ButtonGroup', function () {
2525
</Button>
2626
</ButtonGroup>
2727
);
28-
assert.ok(instance.getDOMNode().className.match(/\bbtn-group-lg\b/));
28+
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-group-lg\b/));
2929
});
3030

3131
it('Should add vertical variation', function () {
@@ -36,7 +36,7 @@ describe('ButtonGroup', function () {
3636
</Button>
3737
</ButtonGroup>
3838
);
39-
assert.equal(instance.getDOMNode().className.trim(), 'btn-group-vertical');
39+
assert.equal(React.findDOMNode(instance).className.trim(), 'btn-group-vertical');
4040
});
4141

4242
it('Should add block variation', function () {
@@ -47,7 +47,7 @@ describe('ButtonGroup', function () {
4747
</Button>
4848
</ButtonGroup>
4949
);
50-
assert.ok(instance.getDOMNode().className.match(/\bbtn-block\b/));
50+
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-block\b/));
5151
});
5252

5353
it('Should warn about block without vertical', function () {
@@ -69,6 +69,6 @@ describe('ButtonGroup', function () {
6969
</Button>
7070
</ButtonGroup>
7171
);
72-
assert.ok(instance.getDOMNode().className.match(/\bbtn-group-justified\b/));
72+
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-group-justified\b/));
7373
});
7474
});

test/ButtonInputSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('ButtonInput', () =>{
99
<ButtonInput value="button" bsStyle="danger" wrapperClassName="test" />
1010
);
1111

12-
const node = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input').getDOMNode();
12+
const node = React.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input'));
1313
assert.equal(node.getAttribute('type'), 'button');
1414
assert.equal(node.getAttribute('class'), 'btn btn-danger');
1515
});
@@ -19,14 +19,14 @@ describe('ButtonInput', () =>{
1919
<ButtonInput value="button" type="reset" />
2020
);
2121

22-
let node = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input').getDOMNode();
22+
let node = React.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input'));
2323
assert.equal(node.getAttribute('type'), 'reset');
2424

2525
instance = ReactTestUtils.renderIntoDocument(
2626
<ButtonInput value="button" type="submit" />
2727
);
2828

29-
node = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input').getDOMNode();
29+
node = React.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input'));
3030
assert.equal(node.getAttribute('type'), 'submit');
3131
});
3232

test/ButtonSpec.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('Button', function () {
99
Title
1010
</Button>
1111
);
12-
assert.equal(instance.getDOMNode().nodeName, 'BUTTON');
12+
assert.equal(React.findDOMNode(instance).nodeName, 'BUTTON');
1313
});
1414

1515
it('Should output a component with button classes', function () {
@@ -18,8 +18,8 @@ describe('Button', function () {
1818
Title
1919
</Button>
2020
);
21-
assert.equal(instance.getDOMNode().nodeName, 'INPUT');
22-
assert.equal(instance.getDOMNode().getAttribute('class'), 'btn btn-default');
21+
assert.equal(React.findDOMNode(instance).nodeName, 'INPUT');
22+
assert.equal(React.findDOMNode(instance).getAttribute('class'), 'btn btn-default');
2323
});
2424

2525
it('Should have type=button by default', function () {
@@ -28,7 +28,7 @@ describe('Button', function () {
2828
Title
2929
</Button>
3030
);
31-
assert.equal(instance.getDOMNode().getAttribute('type'), 'button');
31+
assert.equal(React.findDOMNode(instance).getAttribute('type'), 'button');
3232
});
3333

3434
it('Should show the type if passed one', function () {
@@ -37,7 +37,7 @@ describe('Button', function () {
3737
Title
3838
</Button>
3939
);
40-
assert.equal(instance.getDOMNode().getAttribute('type'), 'submit');
40+
assert.equal(React.findDOMNode(instance).getAttribute('type'), 'submit');
4141
});
4242

4343
it('Should output an anchor if called with a href', function () {
@@ -47,8 +47,8 @@ describe('Button', function () {
4747
Title
4848
</Button>
4949
);
50-
assert.equal(instance.getDOMNode().nodeName, 'A');
51-
assert.equal(instance.getDOMNode().getAttribute('href'), href);
50+
assert.equal(React.findDOMNode(instance).nodeName, 'A');
51+
assert.equal(React.findDOMNode(instance).getAttribute('href'), href);
5252
});
5353

5454
it('Should output an input if called with a href and an input component', function () {
@@ -58,8 +58,8 @@ describe('Button', function () {
5858
Title
5959
</Button>
6060
);
61-
assert.equal(instance.getDOMNode().nodeName, 'INPUT');
62-
assert.equal(instance.getDOMNode().getAttribute('href'), href);
61+
assert.equal(React.findDOMNode(instance).nodeName, 'INPUT');
62+
assert.equal(React.findDOMNode(instance).getAttribute('href'), href);
6363
});
6464

6565
it('Should output an anchor if called with a target', function () {
@@ -69,8 +69,8 @@ describe('Button', function () {
6969
Title
7070
</Button>
7171
);
72-
assert.equal(instance.getDOMNode().nodeName, 'A');
73-
assert.equal(instance.getDOMNode().getAttribute('target'), target);
72+
assert.equal(React.findDOMNode(instance).nodeName, 'A');
73+
assert.equal(React.findDOMNode(instance).getAttribute('target'), target);
7474
});
7575

7676
it('Should call onClick callback', function (done) {
@@ -82,7 +82,7 @@ describe('Button', function () {
8282
Title
8383
</Button>
8484
);
85-
ReactTestUtils.Simulate.click(instance.getDOMNode());
85+
ReactTestUtils.Simulate.click(React.findDOMNode(instance));
8686
});
8787

8888
it('Should be disabled', function () {
@@ -91,7 +91,7 @@ describe('Button', function () {
9191
Title
9292
</Button>
9393
);
94-
assert.ok(instance.getDOMNode().disabled);
94+
assert.ok(React.findDOMNode(instance).disabled);
9595
});
9696

9797
it('Should be disabled link', function () {
@@ -100,7 +100,7 @@ describe('Button', function () {
100100
Title
101101
</Button>
102102
);
103-
assert.ok(instance.getDOMNode().className.match(/\bdisabled\b/));
103+
assert.ok(React.findDOMNode(instance).className.match(/\bdisabled\b/));
104104
});
105105

106106
it('Should have block class', function () {
@@ -109,7 +109,7 @@ describe('Button', function () {
109109
Title
110110
</Button>
111111
);
112-
assert.ok(instance.getDOMNode().className.match(/\bbtn-block\b/));
112+
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-block\b/));
113113
});
114114

115115
it('Should apply bsStyle class', function () {
@@ -118,7 +118,7 @@ describe('Button', function () {
118118
Title
119119
</Button>
120120
);
121-
assert.ok(instance.getDOMNode().className.match(/\bbtn-danger\b/));
121+
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-danger\b/));
122122
});
123123

124124
it('Should honour additional classes passed in, adding not overriding', function () {
@@ -127,8 +127,8 @@ describe('Button', function () {
127127
Title
128128
</Button>
129129
);
130-
assert.ok(instance.getDOMNode().className.match(/\bbob\b/));
131-
assert.ok(instance.getDOMNode().className.match(/\bbtn-danger\b/));
130+
assert.ok(React.findDOMNode(instance).className.match(/\bbob\b/));
131+
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-danger\b/));
132132
});
133133

134134
it('Should default to bsStyle="default"', function () {
@@ -146,7 +146,7 @@ describe('Button', function () {
146146
Title
147147
</Button>
148148
);
149-
assert.ok(instance.getDOMNode().className.match(/\bactive\b/));
149+
assert.ok(React.findDOMNode(instance).className.match(/\bactive\b/));
150150
});
151151

152152
it('Should render an anchor in a list item when in a nav', function () {
@@ -156,7 +156,7 @@ describe('Button', function () {
156156
</Button>
157157
);
158158

159-
let li = instance.getDOMNode();
159+
let li = React.findDOMNode(instance);
160160
let anchor = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'a');
161161
assert.equal(li.nodeName, 'LI');
162162
assert.ok(li.className.match(/\bactive\b/));
@@ -170,7 +170,7 @@ describe('Button', function () {
170170
</Button>
171171
);
172172

173-
let anchor = instance.getDOMNode();
173+
let anchor = React.findDOMNode(instance);
174174
assert.equal(anchor.nodeName, 'A');
175175
assert.ok(anchor.getAttribute('href'), '#');
176176
});

test/ButtonToolbarSpec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ describe('ButtonToolbar', function () {
1515
</ButtonGroup>
1616
</ButtonToolbar>
1717
);
18-
assert.equal(instance.getDOMNode().nodeName, 'DIV');
19-
assert.ok(instance.getDOMNode().className.match(/\bbtn-toolbar\b/));
20-
assert.equal(instance.getDOMNode().getAttribute('role'), 'toolbar');
18+
let node = React.findDOMNode(instance);
19+
assert.equal(node.nodeName, 'DIV');
20+
assert.ok(node.className.match(/\bbtn-toolbar\b/));
21+
assert.equal(node.getAttribute('role'), 'toolbar');
2122
});
2223
});

test/ColSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('Col', function () {
88
<Col xsOffset={0} smOffset={0} mdOffset={0} lgOffset={0} />
99
);
1010

11-
let instanceClassName = instance.getDOMNode().className;
11+
let instanceClassName = React.findDOMNode(instance).className;
1212
assert.ok(instanceClassName.match(/\bcol-xs-offset-0\b/));
1313
assert.ok(instanceClassName.match(/\bcol-sm-offset-0\b/));
1414
assert.ok(instanceClassName.match(/\bcol-md-offset-0\b/));
@@ -20,7 +20,7 @@ describe('Col', function () {
2020
<Col xsPull={0} smPull={0} mdPull={0} lgPull={0} />
2121
);
2222

23-
let instanceClassName = instance.getDOMNode().className;
23+
let instanceClassName = React.findDOMNode(instance).className;
2424
assert.ok(instanceClassName.match(/\bcol-xs-pull-0\b/));
2525
assert.ok(instanceClassName.match(/\bcol-sm-pull-0\b/));
2626
assert.ok(instanceClassName.match(/\bcol-md-pull-0\b/));
@@ -32,7 +32,7 @@ describe('Col', function () {
3232
<Col xsPush={0} smPush={0} mdPush={0} lgPush={0} />
3333
);
3434

35-
let instanceClassName = instance.getDOMNode().className;
35+
let instanceClassName = React.findDOMNode(instance).className;
3636
assert.ok(instanceClassName.match(/\bcol-xs-push-0\b/));
3737
assert.ok(instanceClassName.match(/\bcol-sm-push-0\b/));
3838
assert.ok(instanceClassName.match(/\bcol-md-push-0\b/));

test/CollapsibleMixinSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('CollapsibleMixin', function () {
1212
mixins: [CollapsibleMixin],
1313

1414
getCollapsibleDOMNode(){
15-
return this.refs.panel.getDOMNode();
15+
return React.findDOMNode(this.refs.panel);
1616
},
1717

1818
getCollapsibleDimensionValue(){

0 commit comments

Comments
 (0)