diff --git a/examples/lazy-loading-before-mount/app.js b/examples/lazy-loading-before-mount/app.js
new file mode 100644
index 000000000..a588a10c5
--- /dev/null
+++ b/examples/lazy-loading-before-mount/app.js
@@ -0,0 +1,39 @@
+import Vue from 'vue'
+import VueRouter from 'vue-router'
+
+Vue.use(VueRouter)
+
+const Home = { template: '
Home
' }
+const Foo = () =>
+ new Promise(resolve => {
+ setTimeout(() =>
+ resolve({
+ template: `This is Foo
`
+ })
+ , 10)
+ })
+
+const router = new VueRouter({
+ mode: 'history',
+ base: __dirname,
+ routes: [
+ { path: '/', component: Home },
+ // Just use them normally in the route config
+ { path: '/async', component: Foo }
+ ]
+})
+
+router.push('/async')
+
+document.getElementById('load-button').addEventListener('click', (event) => {
+ new Vue({
+ router,
+ template: `
+
+
Async
+
+
+ `
+ }).$mount('#app')
+ event.target.remove()
+})
diff --git a/examples/lazy-loading-before-mount/index.html b/examples/lazy-loading-before-mount/index.html
new file mode 100644
index 000000000..23a13d577
--- /dev/null
+++ b/examples/lazy-loading-before-mount/index.html
@@ -0,0 +1,8 @@
+
+
+← Examples index
+
+
+
+
+
diff --git a/src/util/resolve-components.js b/src/util/resolve-components.js
index 3f7608cd5..c6a2927c1 100644
--- a/src/util/resolve-components.js
+++ b/src/util/resolve-components.js
@@ -30,7 +30,7 @@ export function resolveAsyncComponents (matched: Array): Function {
match.components[key] = resolvedDef
pending--
if (pending <= 0) {
- next()
+ next(to)
}
})
diff --git a/test/e2e/specs/lazy-loading-before-mount.js b/test/e2e/specs/lazy-loading-before-mount.js
new file mode 100644
index 000000000..444dff33b
--- /dev/null
+++ b/test/e2e/specs/lazy-loading-before-mount.js
@@ -0,0 +1,11 @@
+module.exports = {
+ 'lazy loading before mount': function (browser) {
+ browser
+ .url('http://localhost:8080/lazy-loading-before-mount/')
+ // wait for the Foo component to be resolved
+ .click('#load-button')
+ .waitForElementVisible('.foo', 1000)
+ .assert.containsText('.view', 'This is Foo')
+ .end()
+ }
+}