From 4abbb4eb9cb6c46a1dc3ce632698dc5de6366b74 Mon Sep 17 00:00:00 2001 From: Wu Haotian Date: Mon, 7 Aug 2017 14:21:03 +0800 Subject: [PATCH 1/5] cache resolved layouts in resolvedLayouts --- lib/app/App.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/app/App.vue b/lib/app/App.vue index d2e9f8a163..9febdf0078 100644 --- a/lib/app/App.vue +++ b/lib/app/App.vue @@ -19,6 +19,8 @@ layoutsKeys.forEach(function (key, i) { %> <% }) %> } +let resolvedLayouts = {} + export default { head: <%= JSON.stringify(head) %>, data: () => ({ @@ -42,13 +44,14 @@ export default { loadLayout (layout) { if (!layout || !layouts['_' + layout]) layout = 'default' let _layout = '_' + layout - if (typeof layouts[_layout] !== 'function') { - return Promise.resolve(layouts[_layout]) + if (resolvedLayouts[_layout]) { + return Promise.resolve(resolvedLayouts[_layout]) } return layouts[_layout]() .then((Component) => { - layouts[_layout] = Component - return layouts[_layout] + resolvedLayouts[_layout] = Component + delete layouts[_layout] + return resolvedLayouts[_layout] }) .catch((e) => { if (this.$nuxt) { From e686844b036dfd50f77dd56641ecc9203e7eb3d6 Mon Sep 17 00:00:00 2001 From: Wu Haotian Date: Mon, 7 Aug 2017 15:11:47 +0800 Subject: [PATCH 2/5] App.vue: check `resolvedLayouts` in `setLayout` --- lib/app/App.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/app/App.vue b/lib/app/App.vue index 9febdf0078..aa5edcde53 100644 --- a/lib/app/App.vue +++ b/lib/app/App.vue @@ -35,14 +35,14 @@ export default { <% } %> methods: { setLayout (layout) { - if (!layout || !layouts['_' + layout]) layout = 'default' + if (!layout || !resolvedLayouts['_' + layout]) layout = 'default' this.layoutName = layout let _layout = '_' + layout - this.layout = layouts[_layout] + this.layout = resolvedLayouts[_layout] return this.layout }, loadLayout (layout) { - if (!layout || !layouts['_' + layout]) layout = 'default' + if (!layout || !(layouts['_' + layout] || resolvedLayouts['_' + layout])) layout = 'default' let _layout = '_' + layout if (resolvedLayouts[_layout]) { return Promise.resolve(resolvedLayouts[_layout]) From 221bb8800f4d3aefc9ddc8fa5435ae8ab8f2a151 Mon Sep 17 00:00:00 2001 From: Wu Haotian Date: Fri, 11 Aug 2017 17:36:05 +0800 Subject: [PATCH 3/5] Fix class component checks for extended components --- lib/app/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/server.js b/lib/app/server.js index 11f011ea0b..b45c4dad79 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -79,7 +79,7 @@ export default async context => { let Components = [] try { Components = await Promise.all(getMatchedComponents(router.match(context.url)).map(Component => { - if (typeof Component !== 'function' || Component.super === Vue) { + if (typeof Component !== 'function' || Component.cid) { return sanitizeComponent(Component) } return Component().then(Component => sanitizeComponent(Component)) From 97076fa64961ee69ada9f2fafd17b88aa52604e7 Mon Sep 17 00:00:00 2001 From: Dax Chen Date: Sun, 13 Aug 2017 17:00:05 +0800 Subject: [PATCH 4/5] Add better support for pug When using `lang="pug"`, passing Boolean `true` as prop and using directives will case errors. See: https://github.com/vuejs/vue-loader/issues/693 https://github.com/vuejs/vue-loader/issues/55 For example: ```html ``` This will be rendered as `` and cause errors such as `bar expected Boolean but got String` and `v`/`baz`/`directive` not defined. --- lib/builder/webpack/vue-loader.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/builder/webpack/vue-loader.config.js b/lib/builder/webpack/vue-loader.config.js index 659eded04b..d840434f46 100644 --- a/lib/builder/webpack/vue-loader.config.js +++ b/lib/builder/webpack/vue-loader.config.js @@ -20,6 +20,10 @@ export default function ({ isClient }) { 'stylus': styleLoader.call(this, 'stylus', 'stylus-loader'), 'styl': styleLoader.call(this, 'stylus', 'stylus-loader') }, + template: { + // for pug, see https://github.com/vuejs/vue-loader/issues/55 + doctype: "html" + }, preserveWhitespace: false, extractCSS: extractStyles.call(this) } From 90b19e098a8596ee13f8472578cfa01e9357df1c Mon Sep 17 00:00:00 2001 From: Dax Chen Date: Sun, 13 Aug 2017 17:03:34 +0800 Subject: [PATCH 5/5] use single quotes --- lib/builder/webpack/vue-loader.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder/webpack/vue-loader.config.js b/lib/builder/webpack/vue-loader.config.js index d840434f46..385fa49425 100644 --- a/lib/builder/webpack/vue-loader.config.js +++ b/lib/builder/webpack/vue-loader.config.js @@ -22,7 +22,7 @@ export default function ({ isClient }) { }, template: { // for pug, see https://github.com/vuejs/vue-loader/issues/55 - doctype: "html" + doctype: 'html' }, preserveWhitespace: false, extractCSS: extractStyles.call(this)