Skip to content

Commit

Permalink
[build] 2.0.0-rc.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 5, 2016
1 parent eb53ee4 commit b31b459
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 55 deletions.
91 changes: 38 additions & 53 deletions dist/vue-router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* vue-router v2.0.0-rc.1
* vue-router v2.0.0-rc.2
* (c) 2016 Evan You
* @license MIT
*/
Expand Down Expand Up @@ -1061,7 +1061,7 @@
redirectedFrom
) {
var route = {
name: location.name,
name: location.name || (record && record.name),
path: location.path || '/',
hash: location.hash || '',
query: location.query || {},
Expand Down Expand Up @@ -1179,18 +1179,13 @@
}

var History = function History (router , base ) {
var this$1 = this;

this.router = router
this.base = normalizeBase(base)
// start with a route object that stands for "nowhere"
this.current = createRoute(null, {
path: '__vue_router_init__'
})
this.pending = null
this.transitionTo(this.getLocation(), function (route) {
this$1.onInit(route)
})
};

History.prototype.listen = function listen (cb ) {
Expand Down Expand Up @@ -1378,11 +1373,20 @@

History.call(this, router, base)

var initialLocation = getLocation(this.base)
this.transitionTo(initialLocation, function (route) {
// possible redirect on start
var url = cleanPath(this$1.base + this$1.current.fullPath)
if (initialLocation !== url) {
replaceState(url)
}
})

var expectScroll = router.options.scrollBehavior
window.addEventListener('popstate', function (e) {
_key = e.state && e.state.key
var current = this$1.current
this$1.transitionTo(this$1.getLocation(), function (next) {
this$1.transitionTo(getLocation(this$1.base), function (next) {
if (expectScroll) {
this$1.handleScroll(next, current, true)
}
Expand All @@ -1400,14 +1404,6 @@
HTML5History.prototype = Object.create( History && History.prototype );
HTML5History.prototype.constructor = HTML5History;

HTML5History.prototype.onInit = function onInit () {
// possible redirect on start
var url = cleanPath(this.base + this.current.fullPath)
if (this.getLocation() !== url) {
replaceState(url)
}
};

HTML5History.prototype.go = function go (n ) {
window.history.go(n)
};
Expand All @@ -1432,10 +1428,6 @@
})
};

HTML5History.prototype.getLocation = function getLocation$1 () {
return getLocation(this.base)
};

HTML5History.prototype.handleScroll = function handleScroll (to , from , isPop ) {
var router = this.router
if (!router.app) {
Expand Down Expand Up @@ -1510,11 +1502,20 @@
var this$1 = this;

History.call(this, router, base)

// check history fallback deeplinking
if (fallback && this.checkFallback()) {
return
}

ensureSlash()
this.transitionTo(getHash(), function (route) {
// possible redirect on start
if (getHash() !== route.fullPath) {
replaceHash(route.fullPath)
}
})

window.addEventListener('hashchange', function () {
this$1.onHashChange()
})
Expand All @@ -1524,13 +1525,6 @@
HashHistory.prototype = Object.create( History && History.prototype );
HashHistory.prototype.constructor = HashHistory;

HashHistory.prototype.onInit = function onInit () {
// possible redirect on start
if (getHash() !== this.current.fullPath) {
replaceHash(this.current.fullPath)
}
};

HashHistory.prototype.checkFallback = function checkFallback () {
var location = getLocation(this.base)
if (!/^\/#/.test(location)) {
Expand All @@ -1545,7 +1539,7 @@
if (!ensureSlash()) {
return
}
this.transitionTo(this.getLocation(), function (route) {
this.transitionTo(getHash(), function (route) {
replaceHash(route.fullPath)
})
};
Expand All @@ -1566,10 +1560,6 @@
window.history.go(n)
};

HashHistory.prototype.getLocation = function getLocation$1 () {
return getHash()
};

return HashHistory;
}(History));

Expand Down Expand Up @@ -1612,10 +1602,6 @@
AbstractHistory.prototype = Object.create( History && History.prototype );
AbstractHistory.prototype.constructor = AbstractHistory;

AbstractHistory.prototype.onInit = function onInit () {
this.stack = [this.current]
};

AbstractHistory.prototype.push = function push (location ) {
var this$1 = this;

Expand Down Expand Up @@ -1648,16 +1634,6 @@
})
};

AbstractHistory.prototype.setInitialRoute = function setInitialRoute (route ) {
this.current = route
this.stack = [this.current]
this.index = 0
};

AbstractHistory.prototype.getLocation = function getLocation () {
return '/'
};

return AbstractHistory;
}(History));

Expand All @@ -1681,6 +1657,12 @@
this.mode = mode
};

var prototypeAccessors = { currentRoute: {} };

prototypeAccessors.currentRoute.get = function () {
return this.history && this.history.current
};

VueRouter.prototype.init = function init (app /* Vue component instance */) {
var this$1 = this;

Expand Down Expand Up @@ -1742,16 +1724,19 @@
this.go(1)
};

VueRouter.prototype.setInitialLocation = function setInitialLocation (location ) {
var route = this.match(location)
if (this.history instanceof AbstractHistory) {
this.history.setInitialRoute(route)
}
if (this.app) {
this.app._route = route
VueRouter.prototype.getMatchedComponents = function getMatchedComponents () {
if (!this.currentRoute) {
return []
}
return [].concat.apply([], this.currentRoute.matched.map(function (m) {
return Object.keys(m.components).map(function (key) {
return m.components[key]
})
}))
};

Object.defineProperties( VueRouter.prototype, prototypeAccessors );

VueRouter.install = install

if (inBrowser && window.Vue) {
Expand Down
Loading

0 comments on commit b31b459

Please sign in to comment.