From 0904adc2aedf2c0c0c0f8ba00eefce426c3d2e2a Mon Sep 17 00:00:00 2001 From: Tim Banks Date: Sat, 16 May 2015 17:02:24 -0500 Subject: [PATCH] [added] Active property to MenuItem component --- docs/examples/DropdownButtonBasic.js | 2 +- src/MenuItem.js | 9 ++++++--- test/MenuItemSpec.js | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/examples/DropdownButtonBasic.js b/docs/examples/DropdownButtonBasic.js index 66fb3ef4de..ea851b88e6 100644 --- a/docs/examples/DropdownButtonBasic.js +++ b/docs/examples/DropdownButtonBasic.js @@ -5,7 +5,7 @@ function renderDropdownButton (title, i) { Action Another action - Something else here + Active Item Separated link diff --git a/src/MenuItem.js b/src/MenuItem.js index 8c0f7c9f56..d5bdce7a89 100644 --- a/src/MenuItem.js +++ b/src/MenuItem.js @@ -9,12 +9,14 @@ const MenuItem = React.createClass({ title: React.PropTypes.string, target: React.PropTypes.string, onSelect: React.PropTypes.func, - eventKey: React.PropTypes.any + eventKey: React.PropTypes.any, + active: React.PropTypes.bool }, getDefaultProps() { return { - href: '#' + href: '#', + active: false }; }, @@ -36,7 +38,8 @@ const MenuItem = React.createClass({ render() { let classes = { 'dropdown-header': this.props.header, - 'divider': this.props.divider + 'divider': this.props.divider, + 'active': this.props.active }; let children = null; diff --git a/test/MenuItemSpec.js b/test/MenuItemSpec.js index 7570060d53..703a1f63d9 100644 --- a/test/MenuItemSpec.js +++ b/test/MenuItemSpec.js @@ -18,7 +18,8 @@ describe('MenuItem', function () { + title="hi mom!" + active={true}> Title ); @@ -27,6 +28,7 @@ describe('MenuItem', function () { assert(node.className.match(/\btest-class\b/)); assert.equal(node.getAttribute('href'), null); assert.equal(node.getAttribute('title'), null); + assert.ok(node.className.match(/\bactive\b/)); let anchorNode = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'a').getDOMNode(); assert.notOk(anchorNode.className.match(/\btest-class\b/));