fix: Don't call fixPrepatch on non-dynamic routes

This commit is contained in:
Sébastien Chopin 2018-01-04 16:40:34 +01:00
parent 6f6a184f92
commit 39ef28ca2a
3 changed files with 27 additions and 0 deletions

View File

@ -389,6 +389,7 @@ function fixPrepatch(to, ___) {
instances.forEach((instance, i) => {
if (!instance) return
if (to.matched[i].path.indexOf(':') === -1) return // If not a dyanmic route, skip
if (instance.constructor._dataRefresh && _lastPaths[i] === instance.constructor._path && typeof instance.constructor.options.data === 'function') {
const newData = instance.constructor.options.data.call(instance)
for (let key in newData) {

20
test/fixtures/spa/pages/mounted.vue vendored Normal file
View File

@ -0,0 +1,20 @@
<template>
<h1>Test: {{ test.text }}</h1>
</template>
<script>
export default {
data() {
return {
test: {
text: null
}
}
},
mounted() {
this.test = {
text: 'updated'
}
}
}
</script>

View File

@ -66,6 +66,12 @@ test.serial('/custom (call mounted and created once)', async t => {
t.true(logSpy.withArgs('mounted').calledOnce)
})
test.serial('/mounted', async t => {
const { html } = await renderRoute('/mounted')
t.true(html.includes('<h1>Test: updated</h1>'))
})
test('/_nuxt/ (access publicPath in spa mode)', async t => {
const { response: { statusCode, statusMessage } } = await t.throws(renderRoute('/_nuxt/'))
t.is(statusCode, 404)