This commit is contained in:
Sébastien Chopin 2018-05-04 10:32:26 +02:00
parent 25d752630a
commit c6553a39cd

View File

@ -196,6 +196,12 @@ function callMiddleware (Components, context, layout) {
async function render (to, from, next) { async function render (to, from, next) {
if (this._pathChanged === false && this._queryChanged === false) return next() if (this._pathChanged === false && this._queryChanged === false) return next()
// Handle first render on SPA mode
if (to === from) _lastPaths = []
else {
const fromMatches = []
_lastPaths = getMatchedComponents(from, fromMatches).map((Component, i) => compile(from.matched[fromMatches[i]].path)(from.params))
}
// nextCalled is true when redirected // nextCalled is true when redirected
let nextCalled = false let nextCalled = false
@ -204,8 +210,6 @@ async function render (to, from, next) {
<% if(loading) { %>if (from.path !== path.path && this.$loading.pause) this.$loading.pause()<% } %> <% if(loading) { %>if (from.path !== path.path && this.$loading.pause) this.$loading.pause()<% } %>
if (nextCalled) return if (nextCalled) return
nextCalled = true nextCalled = true
const matches = []
_lastPaths = getMatchedComponents(from, matches).map((Component, i) => compile(from.matched[matches[i]].path)(from.params))
next(path) next(path)
} }
@ -333,7 +337,6 @@ async function render (to, from, next) {
// If not redirected // If not redirected
if (!nextCalled) { if (!nextCalled) {
<% if (loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %> <% if (loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %>
_lastPaths = Components.map((Component, i) => compile(to.matched[matches[i]].path)(to.params))
next() next()
} }