Skip to content

Commit

Permalink
Removed unnecessary className on Link (#3288)
Browse files Browse the repository at this point in the history
  • Loading branch information
EloB authored and taion committed Apr 13, 2016
1 parent 46d29e6 commit 0a42723
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions modules/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const Link = React.createClass({
getDefaultProps() {
return {
onlyActiveOnIndex: false,
className: '',
style: {}
}
},
Expand Down Expand Up @@ -119,7 +118,7 @@ const Link = React.createClass({
if (activeClassName || (activeStyle != null && !isEmptyObject(activeStyle))) {
if (router.isActive(location, onlyActiveOnIndex)) {
if (activeClassName)
props.className += props.className === '' ? activeClassName : ` ${activeClassName}`
props.className = `${props.className || ''} ${activeClassName}`.trim()

if (activeStyle)
props.style = { ...props.style, ...activeStyle }
Expand Down
9 changes: 9 additions & 0 deletions modules/__tests__/Link-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ describe('A <Link>', function () {
node = document.createElement('div')
})

it('should not render unnecessary class=""', function () {
render((
<Link to="/something" />
), node, function () {
const a = node.querySelector('a')
expect(a.hasAttribute('class')).toBe(false)
})
})

it('knows how to make its href', function () {
class LinkWrapper extends Component {
render() {
Expand Down

0 comments on commit 0a42723

Please sign in to comment.