Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert #2713 #2723

Merged
merged 2 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion examples/basic/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const router = new VueRouter({
// Route components will be rendered inside <router-view>.
new Vue({
router,
data: () => ({ n: 0 }),
template: `
<div id="app">
<h1>Basic</h1>
Expand All @@ -43,9 +44,22 @@ new Vue({
<li><router-link to="/é?t=%25ñ">/é?t=%ñ</router-link></li>
<li><router-link to="/é#%25ñ">/é#%25ñ</router-link></li>
</ul>
<button id="navigate-btn" @click="navigateAndIncrement">On Success</button>
<pre id="counter">{{ n }}</pre>
<pre id="query-t">{{ $route.query.t }}</pre>
<pre id="hash">{{ $route.hash }}</pre>
<router-view class="view"></router-view>
</div>
`
`,

methods: {
navigateAndIncrement () {
const increment = () => this.n++
if (this.$route.path === '/') {
this.$router.push('/foo', increment)
} else {
this.$router.push('/', increment)
}
}
}
}).$mount('#app')
4 changes: 3 additions & 1 deletion examples/lazy-loading-before-mount/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const router = new VueRouter({
]
})

router.push('/async')
router.onReady(() => {
router.push('/async')
})

document.getElementById('load-button').addEventListener('click', (event) => {
new Vue({
Expand Down
13 changes: 13 additions & 0 deletions examples/lazy-loading/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ const router = new VueRouter({
{ path: '/', component: Home },
// Just use them normally in the route config
{ path: '/foo', component: Foo },
// mulitple parameters, `/` should not be encoded. The name is also important
// https://github.com/vuejs/vue-router/issues/2719
{ path: '/a/:tags*', name: 'tagged', component: () => new Promise(resolve => {
setTimeout(() => {
resolve({
template: `<div>
<h2>Lazy with params</h2>
<pre id="tagged-path">{{ $route.path }}</pre>
</div>`
})
}, 200)
}) },
// Bar and Baz belong to the same root route
// and grouped in the same async chunk.
{ path: '/bar', component: Bar,
Expand All @@ -63,6 +75,7 @@ new Vue({
<li><router-link to="/foo">/foo</router-link></li>
<li><router-link to="/bar">/bar</router-link></li>
<li><router-link to="/bar/baz">/bar/baz</router-link></li>
<li><router-link to="/a/b/c">/a/b/c</router-link></li>
</ul>
<router-view class="view"></router-view>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/util/resolve-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function resolveAsyncComponents (matched: Array<RouteRecord>): Function {
match.components[key] = resolvedDef
pending--
if (pending <= 0) {
next(to)
next()
}
})

Expand Down
9 changes: 9 additions & 0 deletions test/e2e/specs/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ module.exports = {
.url('http://localhost:8080/basic/%C3%A9')
.waitForElementVisible('#app', 1000)
.assert.containsText('.view', 'unicode')

// regression onComplete
// https://github.com/vuejs/vue-router/issues/2721
.assert.containsText('#counter', '0')
.click('#navigate-btn')
.assert.containsText('#counter', '1')
.click('#navigate-btn')
.assert.containsText('#counter', '2')

.end()
}
}
14 changes: 13 additions & 1 deletion test/e2e/specs/lazy-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
browser
.url('http://localhost:8080/lazy-loading/')
.waitForElementVisible('#app', 1000)
.assert.count('li a', 4)
.assert.count('li a', 5)
.assert.containsText('.view', 'home')

.click('li:nth-child(2) a')
Expand All @@ -28,6 +28,18 @@ module.exports = {
.waitForElementVisible('#app', 1000)
.assert.containsText('.view', 'This is Bar!')
.assert.containsText('.view h3', 'Baz')

// lazy loading with dynamic params: https://github.com/vuejs/vue-router/issues/2719
// direct visit
.url('http://localhost:8080/lazy-loading/a/b/c')
.waitForElementVisible('#app', 1000)
.assert.containsText('.view', '/a/b/c')
// coming from another url
.url('http://localhost:8080/lazy-loading/')
.waitForElementVisible('#app', 1000)
.click('li:nth-child(5) a')
.waitForElementVisible('#tagged-path', 1000)
.assert.containsText('.view', '/a/b/c')
.end()
}
}