File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ const Link = React.createClass({
66
66
getDefaultProps ( ) {
67
67
return {
68
68
onlyActiveOnIndex : false ,
69
- className : '' ,
70
69
style : { }
71
70
}
72
71
} ,
@@ -119,7 +118,7 @@ const Link = React.createClass({
119
118
if ( activeClassName || ( activeStyle != null && ! isEmptyObject ( activeStyle ) ) ) {
120
119
if ( router . isActive ( location , onlyActiveOnIndex ) ) {
121
120
if ( activeClassName )
122
- props . className += props . className === '' ? activeClassName : ` ${ activeClassName } `
121
+ props . className = ` ${ props . className || '' } ${ activeClassName } `. trim ( )
123
122
124
123
if ( activeStyle )
125
124
props . style = { ...props . style , ...activeStyle }
Original file line number Diff line number Diff line change @@ -29,6 +29,15 @@ describe('A <Link>', function () {
29
29
node = document . createElement ( 'div' )
30
30
} )
31
31
32
+ it ( 'should not render unnecessary class=""' , function ( ) {
33
+ render ( (
34
+ < Link to = "/something" />
35
+ ) , node , function ( ) {
36
+ const a = node . querySelector ( 'a' )
37
+ expect ( a . hasAttribute ( 'class' ) ) . toBe ( false )
38
+ } )
39
+ } )
40
+
32
41
it ( 'knows how to make its href' , function ( ) {
33
42
class LinkWrapper extends Component {
34
43
render ( ) {
You can’t perform that action at this time.
0 commit comments