Skip to content

Commit b31b459

Browse files
committed
[build] 2.0.0-rc.2
1 parent eb53ee4 commit b31b459

File tree

2 files changed

+40
-55
lines changed

2 files changed

+40
-55
lines changed

dist/vue-router.js

Lines changed: 38 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-router v2.0.0-rc.1
2+
* vue-router v2.0.0-rc.2
33
* (c) 2016 Evan You
44
* @license MIT
55
*/
@@ -1061,7 +1061,7 @@
10611061
redirectedFrom
10621062
) {
10631063
var route = {
1064-
name: location.name,
1064+
name: location.name || (record && record.name),
10651065
path: location.path || '/',
10661066
hash: location.hash || '',
10671067
query: location.query || {},
@@ -1179,18 +1179,13 @@
11791179
}
11801180

11811181
var History = function History (router , base ) {
1182-
var this$1 = this;
1183-
11841182
this.router = router
11851183
this.base = normalizeBase(base)
11861184
// start with a route object that stands for "nowhere"
11871185
this.current = createRoute(null, {
11881186
path: '__vue_router_init__'
11891187
})
11901188
this.pending = null
1191-
this.transitionTo(this.getLocation(), function (route) {
1192-
this$1.onInit(route)
1193-
})
11941189
};
11951190

11961191
History.prototype.listen = function listen (cb ) {
@@ -1378,11 +1373,20 @@
13781373

13791374
History.call(this, router, base)
13801375

1376+
var initialLocation = getLocation(this.base)
1377+
this.transitionTo(initialLocation, function (route) {
1378+
// possible redirect on start
1379+
var url = cleanPath(this$1.base + this$1.current.fullPath)
1380+
if (initialLocation !== url) {
1381+
replaceState(url)
1382+
}
1383+
})
1384+
13811385
var expectScroll = router.options.scrollBehavior
13821386
window.addEventListener('popstate', function (e) {
13831387
_key = e.state && e.state.key
13841388
var current = this$1.current
1385-
this$1.transitionTo(this$1.getLocation(), function (next) {
1389+
this$1.transitionTo(getLocation(this$1.base), function (next) {
13861390
if (expectScroll) {
13871391
this$1.handleScroll(next, current, true)
13881392
}
@@ -1400,14 +1404,6 @@
14001404
HTML5History.prototype = Object.create( History && History.prototype );
14011405
HTML5History.prototype.constructor = HTML5History;
14021406

1403-
HTML5History.prototype.onInit = function onInit () {
1404-
// possible redirect on start
1405-
var url = cleanPath(this.base + this.current.fullPath)
1406-
if (this.getLocation() !== url) {
1407-
replaceState(url)
1408-
}
1409-
};
1410-
14111407
HTML5History.prototype.go = function go (n ) {
14121408
window.history.go(n)
14131409
};
@@ -1432,10 +1428,6 @@
14321428
})
14331429
};
14341430

1435-
HTML5History.prototype.getLocation = function getLocation$1 () {
1436-
return getLocation(this.base)
1437-
};
1438-
14391431
HTML5History.prototype.handleScroll = function handleScroll (to , from , isPop ) {
14401432
var router = this.router
14411433
if (!router.app) {
@@ -1510,11 +1502,20 @@
15101502
var this$1 = this;
15111503

15121504
History.call(this, router, base)
1505+
15131506
// check history fallback deeplinking
15141507
if (fallback && this.checkFallback()) {
15151508
return
15161509
}
1510+
15171511
ensureSlash()
1512+
this.transitionTo(getHash(), function (route) {
1513+
// possible redirect on start
1514+
if (getHash() !== route.fullPath) {
1515+
replaceHash(route.fullPath)
1516+
}
1517+
})
1518+
15181519
window.addEventListener('hashchange', function () {
15191520
this$1.onHashChange()
15201521
})
@@ -1524,13 +1525,6 @@
15241525
HashHistory.prototype = Object.create( History && History.prototype );
15251526
HashHistory.prototype.constructor = HashHistory;
15261527

1527-
HashHistory.prototype.onInit = function onInit () {
1528-
// possible redirect on start
1529-
if (getHash() !== this.current.fullPath) {
1530-
replaceHash(this.current.fullPath)
1531-
}
1532-
};
1533-
15341528
HashHistory.prototype.checkFallback = function checkFallback () {
15351529
var location = getLocation(this.base)
15361530
if (!/^\/#/.test(location)) {
@@ -1545,7 +1539,7 @@
15451539
if (!ensureSlash()) {
15461540
return
15471541
}
1548-
this.transitionTo(this.getLocation(), function (route) {
1542+
this.transitionTo(getHash(), function (route) {
15491543
replaceHash(route.fullPath)
15501544
})
15511545
};
@@ -1566,10 +1560,6 @@
15661560
window.history.go(n)
15671561
};
15681562

1569-
HashHistory.prototype.getLocation = function getLocation$1 () {
1570-
return getHash()
1571-
};
1572-
15731563
return HashHistory;
15741564
}(History));
15751565

@@ -1612,10 +1602,6 @@
16121602
AbstractHistory.prototype = Object.create( History && History.prototype );
16131603
AbstractHistory.prototype.constructor = AbstractHistory;
16141604

1615-
AbstractHistory.prototype.onInit = function onInit () {
1616-
this.stack = [this.current]
1617-
};
1618-
16191605
AbstractHistory.prototype.push = function push (location ) {
16201606
var this$1 = this;
16211607

@@ -1648,16 +1634,6 @@
16481634
})
16491635
};
16501636

1651-
AbstractHistory.prototype.setInitialRoute = function setInitialRoute (route ) {
1652-
this.current = route
1653-
this.stack = [this.current]
1654-
this.index = 0
1655-
};
1656-
1657-
AbstractHistory.prototype.getLocation = function getLocation () {
1658-
return '/'
1659-
};
1660-
16611637
return AbstractHistory;
16621638
}(History));
16631639

@@ -1681,6 +1657,12 @@
16811657
this.mode = mode
16821658
};
16831659

1660+
var prototypeAccessors = { currentRoute: {} };
1661+
1662+
prototypeAccessors.currentRoute.get = function () {
1663+
return this.history && this.history.current
1664+
};
1665+
16841666
VueRouter.prototype.init = function init (app /* Vue component instance */) {
16851667
var this$1 = this;
16861668

@@ -1742,16 +1724,19 @@
17421724
this.go(1)
17431725
};
17441726

1745-
VueRouter.prototype.setInitialLocation = function setInitialLocation (location ) {
1746-
var route = this.match(location)
1747-
if (this.history instanceof AbstractHistory) {
1748-
this.history.setInitialRoute(route)
1749-
}
1750-
if (this.app) {
1751-
this.app._route = route
1727+
VueRouter.prototype.getMatchedComponents = function getMatchedComponents () {
1728+
if (!this.currentRoute) {
1729+
return []
17521730
}
1731+
return [].concat.apply([], this.currentRoute.matched.map(function (m) {
1732+
return Object.keys(m.components).map(function (key) {
1733+
return m.components[key]
1734+
})
1735+
}))
17531736
};
17541737

1738+
Object.defineProperties( VueRouter.prototype, prototypeAccessors );
1739+
17551740
VueRouter.install = install
17561741

17571742
if (inBrowser && window.Vue) {

0 commit comments

Comments
 (0)