From c5797e8dc17a08f5aa01c9797013be243a72266a Mon Sep 17 00:00:00 2001 From: Mathias Schreck Date: Mon, 22 Jun 2015 22:25:26 +0200 Subject: [PATCH] [added] componentClass prop to Jumbotron --- src/Jumbotron.js | 14 ++++++++++++-- test/JumbotronSpec.js | 11 +++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Jumbotron.js b/src/Jumbotron.js index 41af93dd0a..2aacb10dfe 100644 --- a/src/Jumbotron.js +++ b/src/Jumbotron.js @@ -2,11 +2,21 @@ import React from 'react'; import classNames from 'classnames'; const Jumbotron = React.createClass({ + propTypes: { + componentClass: React.PropTypes.any.isRequired + }, + + getDefaultProps() { + return { componentClass: 'div' }; + }, + render() { + const ComponentClass = this.props.componentClass; + return ( -
+ {this.props.children} -
+ ); } }); diff --git a/test/JumbotronSpec.js b/test/JumbotronSpec.js index b0749c1939..460b43153f 100644 --- a/test/JumbotronSpec.js +++ b/test/JumbotronSpec.js @@ -9,6 +9,8 @@ describe('Jumbotron', function () { Content ); + + assert.equal(React.findDOMNode(instance).nodeName, 'DIV'); assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'strong')); }); @@ -20,4 +22,13 @@ describe('Jumbotron', function () { ); assert.ok(React.findDOMNode(instance).className.match(/\bjumbotron\b/)); }); + + it('Should override node class', function () { + let instance = ReactTestUtils.renderIntoDocument( + + Content + + ); + assert.equal(React.findDOMNode(instance).nodeName, 'SECTION'); + }); });