Skip to content

Commit d386a7e

Browse files
committed
Merge pull request react-bootstrap#278 from jquense/NavItem-prop-fix
NavItem includes anchor attributes on the li tag
2 parents 0cf72c8 + 117d6c5 commit d386a7e

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

Gruntfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ module.exports = function (grunt) {
5959
},
6060

6161
react: {
62+
options: {
63+
harmony: true
64+
},
6265
src: {
6366
files: [
6467
{

src/NavItem.jsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,26 @@ var NavItem = React.createClass({
2222
},
2323

2424
render: function () {
25-
var classes = {
26-
'active': this.props.active,
27-
'disabled': this.props.disabled
28-
};
25+
var {
26+
disabled,
27+
active,
28+
href,
29+
title,
30+
children,
31+
...props } = this.props,
32+
classes = {
33+
'active': active,
34+
'disabled': disabled
35+
};
2936

3037
return (
31-
<li {...this.props} className={joinClasses(this.props.className, classSet(classes))}>
38+
<li {...props} className={joinClasses(props.className, classSet(classes))}>
3239
<a
33-
href={this.props.href}
34-
title={this.props.title}
40+
href={href}
41+
title={title}
3542
onClick={this.handleClick}
3643
ref="anchor">
37-
{this.props.children}
44+
{ children }
3845
</a>
3946
</li>
4047
);

test/NavItemSpec.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ describe('NavItem', function () {
3434
assert.equal(linkElement.title, 'content');
3535
});
3636

37+
it('Should not add anchor properties to li', function () {
38+
var instance = ReactTestUtils.renderIntoDocument(
39+
<NavItem href='/hi' title='boom!'>
40+
Item content
41+
</NavItem>
42+
);
43+
44+
assert.ok(!instance.getDOMNode().hasAttribute('href'));
45+
assert.ok(!instance.getDOMNode().hasAttribute('title'));
46+
});
47+
3748
it('Should call `onSelect` when item is selected', function (done) {
3849
function handleSelect(key) {
3950
assert.equal(key, '2');

0 commit comments

Comments
 (0)