Skip to content

Commit 893a5cf

Browse files
committed
Added 'target' attribute to onSelect handler
1 parent 97acf8d commit 893a5cf

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/NavItem.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var NavItem = React.createClass({
5555
e.preventDefault();
5656

5757
if (!this.props.disabled) {
58-
this.props.onSelect(this.props.eventKey, this.props.href);
58+
this.props.onSelect(this.props.eventKey, this.props.href, this.props.target);
5959
}
6060
}
6161
}

test/NavItemSpec.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,17 @@ describe('NavItem', function () {
7777
var linkElement = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'a').getDOMNode();
7878
assert.equal(linkElement.target, '_blank');
7979
});
80+
81+
it('Should call `onSelect` with target attribute', function (done) {
82+
function handleSelect(key, href, target) {
83+
assert.equal(target, '_blank');
84+
done();
85+
}
86+
var instance = ReactTestUtils.renderIntoDocument(
87+
<NavItem onSelect={handleSelect} target="_blank">
88+
<span>Item content</span>
89+
</NavItem>
90+
);
91+
ReactTestUtils.Simulate.click(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'span'));
92+
});
8093
});

0 commit comments

Comments
 (0)