From 55003631fce0b6f31515cb3a45e7da98fceb68a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Sun, 29 Jan 2017 07:49:36 +0100 Subject: [PATCH] Fix calling data on hash changes --- lib/app/client.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 11a45f26f2..3b5e5567b1 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -18,7 +18,7 @@ function mapTransitions(Components, to, from) { }) } -function loadAsyncComponents (to, ___, next) { +function loadAsyncComponents (to, from, next) { const resolveComponents = flatMapComponents(to, (Component, _, match, key) => { if (typeof Component === 'function' && !Component.options) { return new Promise(function (resolve, reject) { @@ -38,7 +38,10 @@ function loadAsyncComponents (to, ___, next) { } return Component }) - <%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %> + this._hashChanged = (from.path === to.path) + if (!this._hashChanged) { + <%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %> + } Promise.all(resolveComponents) .then(() => next()) .catch((err) => { @@ -49,6 +52,7 @@ function loadAsyncComponents (to, ___, next) { } function render (to, from, next) { + if (this._hashChanged) return next() let Components = getMatchedComponents(to) this._dateLastError = this.$options._nuxt.dateErr this._hadError = !!this.$options._nuxt.err @@ -166,6 +170,7 @@ function normalizeComponents (to, ___) { // When navigating on a different route but the same component is used, Vue.js // will not update the instance data, so we have to update $data ourselves function fixPrepatch (to, ___) { + if (this._hashChanged) return Vue.nextTick(() => { let instances = getMatchedComponentsInstances(to) _lastComponentsFiles = instances.map((instance, i) => {