Skip to content

Commit 44e8dcd

Browse files
committed
[build] 2.1.1
1 parent b710b2e commit 44e8dcd

File tree

3 files changed

+60
-52
lines changed

3 files changed

+60
-52
lines changed

dist/vue-router.common.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-router v2.1.0
2+
* vue-router v2.1.1
33
* (c) 2016 Evan You
44
* @license MIT
55
*/
@@ -1343,24 +1343,25 @@ History.prototype.listen = function listen (cb) {
13431343
this.cb = cb
13441344
};
13451345

1346-
History.prototype.transitionTo = function transitionTo (location, cb) {
1346+
History.prototype.transitionTo = function transitionTo (location, onComplete, onAbort) {
13471347
var this$1 = this;
13481348

13491349
var route = this.router.match(location, this.current)
13501350
this.confirmTransition(route, function () {
13511351
this$1.updateRoute(route)
1352-
cb && cb(route)
1352+
onComplete && onComplete(route)
13531353
this$1.ensureURL()
1354-
})
1354+
}, onAbort)
13551355
};
13561356

1357-
History.prototype.confirmTransition = function confirmTransition (route, cb) {
1357+
History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
13581358
var this$1 = this;
13591359

13601360
var current = this.current
1361+
var abort = function () { onAbort && onAbort() }
13611362
if (isSameRoute(route, current)) {
13621363
this.ensureURL()
1363-
return
1364+
return abort()
13641365
}
13651366

13661367
var ref = resolveQueue(this.current.matched, route.matched);
@@ -1380,14 +1381,18 @@ History.prototype.confirmTransition = function confirmTransition (route, cb) {
13801381

13811382
this.pending = route
13821383
var iterator = function (hook, next) {
1383-
if (this$1.pending !== route) { return }
1384+
if (this$1.pending !== route) {
1385+
return abort()
1386+
}
13841387
hook(route, current, function (to) {
13851388
if (to === false) {
13861389
// next(false) -> abort navigation, ensure current URL
13871390
this$1.ensureURL(true)
1391+
abort()
13881392
} else if (typeof to === 'string' || typeof to === 'object') {
13891393
// next('/') or next({ path: '/' }) -> redirect
13901394
(typeof to === 'object' && to.replace) ? this$1.replace(to) : this$1.push(to)
1395+
abort()
13911396
} else {
13921397
// confirm transition and pass on the value
13931398
next(to)
@@ -1403,14 +1408,15 @@ History.prototype.confirmTransition = function confirmTransition (route, cb) {
14031408
// wait until async components are resolved before
14041409
// extracting in-component enter guards
14051410
runQueue(enterGuards, iterator, function () {
1406-
if (this$1.pending === route) {
1407-
this$1.pending = null
1408-
cb(route)
1409-
if (this$1.router.app) {
1410-
this$1.router.app.$nextTick(function () {
1411-
postEnterCbs.forEach(function (cb) { return cb(); })
1412-
})
1413-
}
1411+
if (this$1.pending !== route) {
1412+
return abort()
1413+
}
1414+
this$1.pending = null
1415+
onComplete(route)
1416+
if (this$1.router.app) {
1417+
this$1.router.app.$nextTick(function () {
1418+
postEnterCbs.forEach(function (cb) { return cb(); })
1419+
})
14141420
}
14151421
})
14161422
})
@@ -1772,18 +1778,11 @@ function replaceState (url) {
17721778

17731779
var HashHistory = (function (History) {
17741780
function HashHistory (router, base, fallback) {
1775-
var this$1 = this;
1776-
17771781
History.call(this, router, base)
1778-
window.addEventListener('hashchange', function () {
1779-
this$1.onHashChange()
1780-
})
1781-
17821782
// check history fallback deeplinking
17831783
if (fallback && this.checkFallback()) {
17841784
return
17851785
}
1786-
17871786
ensureSlash()
17881787
}
17891788

@@ -1974,7 +1973,12 @@ VueRouter.prototype.init = function init (app /* Vue component instance */) {
19741973
if (history instanceof HTML5History) {
19751974
history.transitionTo(getLocation(history.base))
19761975
} else if (history instanceof HashHistory) {
1977-
history.transitionTo(getHash())
1976+
var setupHashListener = function () {
1977+
window.addEventListener('hashchange', function () {
1978+
history.onHashChange()
1979+
})
1980+
}
1981+
history.transitionTo(getHash(), setupHashListener, setupHashListener)
19781982
}
19791983

19801984
history.listen(function (route) {
@@ -2044,8 +2048,8 @@ VueRouter.prototype.resolve = function resolve (
20442048
Object.defineProperties( VueRouter.prototype, prototypeAccessors );
20452049

20462050
function createHref (base, fullPath, mode) {
2047-
var path = mode === 'hash' ? '/#' + fullPath : fullPath
2048-
return base ? cleanPath(base + path) : path
2051+
var path = mode === 'hash' ? '#' + fullPath : fullPath
2052+
return base ? cleanPath(base + '/' + path) : path
20492053
}
20502054

20512055
VueRouter.install = install

dist/vue-router.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-router v2.1.0
2+
* vue-router v2.1.1
33
* (c) 2016 Evan You
44
* @license MIT
55
*/
@@ -1347,24 +1347,25 @@ History.prototype.listen = function listen (cb) {
13471347
this.cb = cb
13481348
};
13491349

1350-
History.prototype.transitionTo = function transitionTo (location, cb) {
1350+
History.prototype.transitionTo = function transitionTo (location, onComplete, onAbort) {
13511351
var this$1 = this;
13521352

13531353
var route = this.router.match(location, this.current)
13541354
this.confirmTransition(route, function () {
13551355
this$1.updateRoute(route)
1356-
cb && cb(route)
1356+
onComplete && onComplete(route)
13571357
this$1.ensureURL()
1358-
})
1358+
}, onAbort)
13591359
};
13601360

1361-
History.prototype.confirmTransition = function confirmTransition (route, cb) {
1361+
History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
13621362
var this$1 = this;
13631363

13641364
var current = this.current
1365+
var abort = function () { onAbort && onAbort() }
13651366
if (isSameRoute(route, current)) {
13661367
this.ensureURL()
1367-
return
1368+
return abort()
13681369
}
13691370

13701371
var ref = resolveQueue(this.current.matched, route.matched);
@@ -1384,14 +1385,18 @@ History.prototype.confirmTransition = function confirmTransition (route, cb) {
13841385

13851386
this.pending = route
13861387
var iterator = function (hook, next) {
1387-
if (this$1.pending !== route) { return }
1388+
if (this$1.pending !== route) {
1389+
return abort()
1390+
}
13881391
hook(route, current, function (to) {
13891392
if (to === false) {
13901393
// next(false) -> abort navigation, ensure current URL
13911394
this$1.ensureURL(true)
1395+
abort()
13921396
} else if (typeof to === 'string' || typeof to === 'object') {
13931397
// next('/') or next({ path: '/' }) -> redirect
13941398
(typeof to === 'object' && to.replace) ? this$1.replace(to) : this$1.push(to)
1399+
abort()
13951400
} else {
13961401
// confirm transition and pass on the value
13971402
next(to)
@@ -1407,14 +1412,15 @@ History.prototype.confirmTransition = function confirmTransition (route, cb) {
14071412
// wait until async components are resolved before
14081413
// extracting in-component enter guards
14091414
runQueue(enterGuards, iterator, function () {
1410-
if (this$1.pending === route) {
1411-
this$1.pending = null
1412-
cb(route)
1413-
if (this$1.router.app) {
1414-
this$1.router.app.$nextTick(function () {
1415-
postEnterCbs.forEach(function (cb) { return cb(); })
1416-
})
1417-
}
1415+
if (this$1.pending !== route) {
1416+
return abort()
1417+
}
1418+
this$1.pending = null
1419+
onComplete(route)
1420+
if (this$1.router.app) {
1421+
this$1.router.app.$nextTick(function () {
1422+
postEnterCbs.forEach(function (cb) { return cb(); })
1423+
})
14181424
}
14191425
})
14201426
})
@@ -1776,18 +1782,11 @@ function replaceState (url) {
17761782

17771783
var HashHistory = (function (History) {
17781784
function HashHistory (router, base, fallback) {
1779-
var this$1 = this;
1780-
17811785
History.call(this, router, base)
1782-
window.addEventListener('hashchange', function () {
1783-
this$1.onHashChange()
1784-
})
1785-
17861786
// check history fallback deeplinking
17871787
if (fallback && this.checkFallback()) {
17881788
return
17891789
}
1790-
17911790
ensureSlash()
17921791
}
17931792

@@ -1978,7 +1977,12 @@ VueRouter.prototype.init = function init (app /* Vue component instance */) {
19781977
if (history instanceof HTML5History) {
19791978
history.transitionTo(getLocation(history.base))
19801979
} else if (history instanceof HashHistory) {
1981-
history.transitionTo(getHash())
1980+
var setupHashListener = function () {
1981+
window.addEventListener('hashchange', function () {
1982+
history.onHashChange()
1983+
})
1984+
}
1985+
history.transitionTo(getHash(), setupHashListener, setupHashListener)
19821986
}
19831987

19841988
history.listen(function (route) {
@@ -2048,8 +2052,8 @@ VueRouter.prototype.resolve = function resolve (
20482052
Object.defineProperties( VueRouter.prototype, prototypeAccessors );
20492053

20502054
function createHref (base, fullPath, mode) {
2051-
var path = mode === 'hash' ? '/#' + fullPath : fullPath
2052-
return base ? cleanPath(base + path) : path
2055+
var path = mode === 'hash' ? '#' + fullPath : fullPath
2056+
return base ? cleanPath(base + '/' + path) : path
20532057
}
20542058

20552059
VueRouter.install = install

0 commit comments

Comments
 (0)