Skip to content

Commit

Permalink
Merge pull request react-bootstrap#601 from apkiernan/listGroupItemID
Browse files Browse the repository at this point in the history
[fixed] react-bootstrap#597 able to set ID on ListGroup
  • Loading branch information
mtscout6 committed May 1, 2015
2 parents c508699 + fef8984 commit 6b130f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ListGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,28 @@ class ListGroup extends React.Component {
);

return (
<ul className={classNames(this.props.className, 'list-group')}>
<ul
{...this.props}
className={classNames(this.props.className, 'list-group')}>
{listItems}
</ul>
);
}

renderDiv(items) {
return (
<div className={classNames(this.props.className, 'list-group')}>
<div
{...this.props}
className={classNames(this.props.className, 'list-group')}>
{items}
</div>
);
}
}

ListGroup.propTypes = {
className: React.PropTypes.string
className: React.PropTypes.string,
id: React.PropTypes.string
};

export default ListGroup;
11 changes: 11 additions & 0 deletions test/ListGroupSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,15 @@ describe('ListGroup', function () {
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'list-group'));
});

it('Should support an element id through "id" prop', function () {
let instance = ReactTestUtils.renderIntoDocument(
<ListGroup id="testItem">
<ListGroupItem>Child</ListGroupItem>
</ListGroup>
);
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'list-group'));
assert.equal(React.findDOMNode(instance).nodeName, 'UL');
assert.equal(React.findDOMNode(instance).id, 'testItem');
});

});

0 comments on commit 6b130f5

Please sign in to comment.