Skip to content

Commit c5797e8

Browse files
committed
[added] componentClass prop to Jumbotron
1 parent daa21f2 commit c5797e8

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Jumbotron.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@ import React from 'react';
22
import classNames from 'classnames';
33

44
const Jumbotron = React.createClass({
5+
propTypes: {
6+
componentClass: React.PropTypes.any.isRequired
7+
},
8+
9+
getDefaultProps() {
10+
return { componentClass: 'div' };
11+
},
12+
513
render() {
14+
const ComponentClass = this.props.componentClass;
15+
616
return (
7-
<div {...this.props} className={classNames(this.props.className, 'jumbotron')}>
17+
<ComponentClass {...this.props} className={classNames(this.props.className, 'jumbotron')}>
818
{this.props.children}
9-
</div>
19+
</ComponentClass>
1020
);
1121
}
1222
});

test/JumbotronSpec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ describe('Jumbotron', function () {
99
<strong>Content</strong>
1010
</Jumbotron>
1111
);
12+
13+
assert.equal(React.findDOMNode(instance).nodeName, 'DIV');
1214
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'strong'));
1315
});
1416

@@ -20,4 +22,13 @@ describe('Jumbotron', function () {
2022
);
2123
assert.ok(React.findDOMNode(instance).className.match(/\bjumbotron\b/));
2224
});
25+
26+
it('Should override node class', function () {
27+
let instance = ReactTestUtils.renderIntoDocument(
28+
<Jumbotron componentClass='section'>
29+
<strong>Content</strong>
30+
</Jumbotron>
31+
);
32+
assert.equal(React.findDOMNode(instance).nodeName, 'SECTION');
33+
});
2334
});

0 commit comments

Comments
 (0)