File tree 3 files changed +15
-19
lines changed
3 files changed +15
-19
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ p.redirect = function (map) {
69
69
*/
70
70
p . go = function ( path ) {
71
71
if ( this . _pushstate ) {
72
+ // make it relative to root
73
+ path = this . _root
74
+ ? this . _root + '/' + path . replace ( / ^ \/ / , '' )
75
+ : path
72
76
history . pushState ( { } , '' , path )
73
77
this . _match ( path )
74
78
} else {
@@ -183,7 +187,11 @@ p._match = function (path) {
183
187
}
184
188
this . _currentPath = path
185
189
// normalize against root
186
- if ( this . _root && path . indexOf ( this . _root ) === 0 ) {
190
+ if (
191
+ this . _pushstate &&
192
+ this . _root &&
193
+ path . indexOf ( this . _root ) === 0
194
+ ) {
187
195
path = path . slice ( this . _root . length )
188
196
}
189
197
var matched = this . _recognizer . recognize ( path )
Original file line number Diff line number Diff line change @@ -7,15 +7,13 @@ module.exports = function (Vue) {
7
7
8
8
bind : function ( ) {
9
9
var vm = this . vm
10
- // normalize leading slash
11
- var href = '/' + this . expression . replace ( / ^ \/ / , '' )
10
+ var href = this . expression
12
11
if ( this . el . tagName === 'A' ) {
13
12
this . el . href = href
14
13
}
15
14
this . handler = function ( e ) {
16
15
e . preventDefault ( )
17
- var router = vm . route . _router
18
- router . go ( ( router . _root || '' ) + href )
16
+ router . go ( href )
19
17
}
20
18
this . el . addEventListener ( 'click' , this . handler )
21
19
} ,
Original file line number Diff line number Diff line change @@ -13,24 +13,14 @@ module.exports = function (Vue) {
13
13
_ . extend ( viewDef , {
14
14
15
15
bind : function ( ) {
16
- // implicitly pass down route context
17
- // using v-with
18
- this . el . setAttribute (
19
- Vue . config . prefix + 'with' ,
20
- 'route:route'
21
- )
22
- // set currentView ref
23
- this . el . setAttribute (
24
- Vue . config . prefix + 'ref' ,
25
- 'currentView'
26
- )
27
- // force dynamic directive
28
- this . _isDynamicLiteral = true
29
16
// react to route change
30
17
this . currentRoute = null
31
18
this . currentComponentId = null
32
19
this . onRouteChange = _ . bind ( this . onRouteChange , this )
33
20
this . unwatch = this . vm . $watch ( 'route' , this . onRouteChange )
21
+ // force dynamic directive so v-component doesn't
22
+ // attempt to build right now
23
+ this . _isDynamicLiteral = true
34
24
// finally, init by delegating to v-component
35
25
component . bind . call ( this )
36
26
if ( this . vm . route ) {
@@ -60,7 +50,7 @@ module.exports = function (Vue) {
60
50
this . currentComponentId = segment . handler . component
61
51
this . update ( segment . handler . component )
62
52
} else if ( this . childVM ) {
63
- // possible params change
53
+ // update route context
64
54
this . childVM . route = route
65
55
}
66
56
} ,
You can’t perform that action at this time.
0 commit comments