Skip to content

Commit 9cb4646

Browse files
committed
Added 'target' attribute to NavItem
1 parent 5c72ab0 commit 9cb4646

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/NavItem.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ var NavItem = React.createClass({
1212
active: React.PropTypes.bool,
1313
disabled: React.PropTypes.bool,
1414
href: React.PropTypes.string,
15-
title: React.PropTypes.string
15+
title: React.PropTypes.string,
16+
target: React.PropTypes.string
1617
},
1718

1819
getDefaultProps: function () {
@@ -32,6 +33,7 @@ var NavItem = React.createClass({
3233
<a
3334
href={this.props.href}
3435
title={this.props.title}
36+
target={this.props.target}
3537
onClick={this.handleClick}
3638
ref="anchor">
3739
{this.props.children}

test/NavItemSpec.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,12 @@ describe('NavItem', function () {
4747
var instance = ReactTestUtils.renderIntoDocument(<NavItem disabled={true} onSelect={handleSelect}>{content}</NavItem>);
4848
ReactTestUtils.Simulate.click(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'span'));
4949
});
50+
51+
it('Should set target attribute on anchor', function () {
52+
var instance = ReactTestUtils.renderIntoDocument(
53+
<NavItem href="/some/unique-thing/" target="_blank">Item content</NavItem>
54+
);
55+
var linkElement = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'a').getDOMNode();
56+
assert.equal(linkElement.target, '_blank');
57+
});
5058
});

0 commit comments

Comments
 (0)