Skip to content

Commit

Permalink
[fixed] react-bootstrap#597 able to set ID on ListGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
apkiernan committed May 1, 2015
1 parent 779365c commit fef8984
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 fef8984

Please sign in to comment.