Skip to content

Commit

Permalink
fix(vue-app): error page layout not correctly applied in client rende…
Browse files Browse the repository at this point in the history
…ring (#6479)
  • Loading branch information
clarkdo authored and pi0 committed Sep 30, 2019
1 parent 950b48f commit 578d5d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/vue-app/template/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
globalHandleError
} from './utils'
<% } %>
<% if (features.layouts && components.ErrorPage) { %>import NuxtError from '<%= components.ErrorPage %>'<% } %>
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
<% if (buildIndicator) { %>import NuxtBuildIndicator from './components/nuxt-build-indicator'<% } %>
<% css.forEach((c) => { %>
Expand Down Expand Up @@ -35,6 +36,15 @@ export default {
render (h, props) {
<% if (loading) { %>const loadingEl = h('NuxtLoading', { ref: 'loading' })<% } %>
<% if (features.layouts) { %>
<% if (components.ErrorPage) { %>
if (this.nuxt.err && NuxtError.layout) {
this.setLayout(
typeof NuxtError.layout === 'function'
? NuxtError.layout(this.context)
: NuxtError.layout
)
}
<% } %>
const layoutEl = h(this.layout || 'nuxt')
const templateEl = h('div', {
domProps: {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('basic browser', () => {
test('/squared doesnt loop due to error on error page', async () => {
await page.nuxt.navigate('/squared')

expect(await page.$text('header')).toBe('Error layout')
expect(await page.$text('h2')).toBe('An error occured while showing the error page')
})

Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/error/layouts/error-layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<div>
<header>Error layout</header>
<nuxt />
</div>
</template>

<script>
export default {
name: 'ErrorLayout'
}
</script>
1 change: 1 addition & 0 deletions test/fixtures/error/layouts/error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<script>
export default {
layout: 'error-layout',
// eslint-disable-next-line vue/require-prop-types
props: ['error']
}
Expand Down

0 comments on commit 578d5d4

Please sign in to comment.