@@ -74,39 +74,31 @@ const Link = React.createClass({
74
74
} ,
75
75
76
76
handleClick ( event ) {
77
+ if ( this . props . onClick )
78
+ this . props . onClick ( event )
79
+
80
+ if ( event . defaultPrevented )
81
+ return
82
+
77
83
invariant (
78
84
this . context . router ,
79
- '<Link>s rendered outside of a router context cannot handle clicks .'
85
+ '<Link>s rendered outside of a router context cannot navigate .'
80
86
)
81
-
82
- let allowTransition = true
83
-
84
- if ( this . props . onClick )
85
- this . props . onClick ( event )
86
87
87
88
if ( isModifiedEvent ( event ) || ! isLeftClickEvent ( event ) )
88
89
return
89
90
90
- if ( event . defaultPrevented === true )
91
- allowTransition = false
92
-
93
- // If target prop is set (e.g. to "_blank") let browser handle link.
91
+ // If target prop is set (e.g. to "_blank"), let browser handle link.
94
92
/* istanbul ignore if: untestable with Karma */
95
- if ( this . props . target ) {
96
- if ( ! allowTransition )
97
- event . preventDefault ( )
98
-
93
+ if ( this . props . target )
99
94
return
100
- }
101
95
102
96
event . preventDefault ( )
103
97
104
- if ( allowTransition ) {
105
- const { to, query, hash, state } = this . props
106
- const location = createLocationDescriptor ( to , { query, hash, state } )
98
+ const { to, query, hash, state } = this . props
99
+ const location = createLocationDescriptor ( to , { query, hash, state } )
107
100
108
- this . context . router . push ( location )
109
- }
101
+ this . context . router . push ( location )
110
102
} ,
111
103
112
104
render ( ) {
0 commit comments