Skip to content

Commit

Permalink
fix: revert #2713
Browse files Browse the repository at this point in the history
Closes #2719
  • Loading branch information
posva committed Apr 17, 2019
1 parent 8e55ae1 commit 4fbcd5e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
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
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()
}
}

0 comments on commit 4fbcd5e

Please sign in to comment.