From fb44c2eb8e606739f038a7871f332d175348bf0a Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 18:30:15 +0100 Subject: [PATCH] fix: Fix Layouts transitions --- lib/app/App.js | 10 +++++++--- lib/app/components/nuxt-child.js | 21 ++------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/app/App.js b/lib/app/App.js index d4725ee730..dd52c9d252 100644 --- a/lib/app/App.js +++ b/lib/app/App.js @@ -18,16 +18,20 @@ export default { head: <%= serialize(head).replace('titleTemplate(', 'function(') %>, render(h, props) { <% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %> - const layoutEl = h(this.nuxt.err ? 'nuxt' : this.layout, { + const layoutEl = h(this.layout || 'nuxt') + const templateEl = h('div', { + domProps: { + id: '__layout' + }, key: this.layoutName - }) + }, [ layoutEl ]) const transitionEl = h('transition', { props: { name: '<%= layoutTransition.name %>', mode: '<%= layoutTransition.mode %>' } - }, [ layoutEl ]) + }, [ templateEl ]) return h('div',{ domProps: { diff --git a/lib/app/components/nuxt-child.js b/lib/app/components/nuxt-child.js index 9fc6f6a8ed..52b5c2a78b 100644 --- a/lib/app/components/nuxt-child.js +++ b/lib/app/components/nuxt-child.js @@ -2,26 +2,11 @@ export default { name: 'nuxt-child', functional: true, render (h, { parent, data }) { - const nuxt = parent.$root.nuxt - const component = parent.$route.matched[0].components.default - - const layoutUid = parent._uid - const layoutName = component.options ? component.options.layout : null - - // If we're changing layout render the stored vnode - if (nuxt._layoutUid === layoutUid && - nuxt._layoutName !== layoutName - ) { - return nuxt._childVnode - } - - nuxt._layoutUid = layoutUid - nuxt._layoutName = layoutName - data.nuxtChild = true const _parent = parent const transitions = parent.$nuxt.nuxt.transitions const defaultTransition = parent.$nuxt.nuxt.defaultTransition + let depth = 0 while (parent) { if (parent.$vnode && parent.$vnode.data.nuxtChild) { @@ -44,14 +29,12 @@ export default { } }) - nuxt._childVnode = h('transition', { + return h('transition', { props: transitionProps, on: listeners }, [ h('router-view', data) ]) - - return nuxt._childVnode } }