File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export default function (Vue) {
25
25
if ( e . metaKey || e . ctrlKey || e . shiftKey ) return
26
26
// don't redirect when preventDefault called
27
27
if ( e . defaultPrevented ) return
28
-
28
+ // don't redirect on right click
29
29
if ( e . button !== 0 ) return
30
30
31
31
if ( this . el . tagName === 'A' ) {
@@ -41,10 +41,9 @@ export default function (Vue) {
41
41
el = el . parentNode
42
42
}
43
43
if ( ! el || el . tagName !== 'A' || ! el . href ) return
44
-
45
44
if ( sameOrigin ( el ) ) {
46
45
e . preventDefault ( )
47
- router . go ( el . href )
46
+ router . go ( el . pathname )
48
47
}
49
48
}
50
49
}
Original file line number Diff line number Diff line change @@ -293,6 +293,9 @@ describe('Core', function () {
293
293
} )
294
294
295
295
it ( 'v-link delegate' , function ( done ) {
296
+ // Safari and PhantomJS only propagates events if the
297
+ // element is in the DOM!
298
+ document . body . appendChild ( el )
296
299
router = new Router ( { abstract : true } )
297
300
router . map ( {
298
301
'/' : {
@@ -318,14 +321,15 @@ describe('Core', function () {
318
321
router . go ( '/foo' )
319
322
nextTick ( function ( ) {
320
323
var wrap = el . querySelector ( '#wrap' )
321
- var e = document . createEvent ( 'HTMLEvents' )
322
- // target is read-only
323
- e . target = wrap . querySelector ( 'a' )
324
+ var e = document . createEvent ( 'Events' )
324
325
e . initEvent ( 'click' , true , true )
325
- wrap . dispatchEvent ( e )
326
+ e . button = 0
327
+ var target = wrap . querySelector ( 'a' )
328
+ target . dispatchEvent ( e )
326
329
nextTick ( function ( ) {
327
330
var text = router . app . $el . textContent
328
331
expect ( text ) . toBe ( 'Home' )
332
+ document . body . removeChild ( el )
329
333
done ( )
330
334
} )
331
335
} )
You can’t perform that action at this time.
0 commit comments