From dac47d43bf65122a299b358f013a12a9763da14a Mon Sep 17 00:00:00 2001 From: Daniel Post Date: Tue, 21 Nov 2017 12:13:35 +0000 Subject: [PATCH 1/2] Update no-ssr to v0.2.1 --- lib/app/components/no-ssr.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/app/components/no-ssr.js b/lib/app/components/no-ssr.js index 9dbc5bcbf..637e828ab 100644 --- a/lib/app/components/no-ssr.js +++ b/lib/app/components/no-ssr.js @@ -5,24 +5,31 @@ export default { name: 'no-ssr', props: ['placeholder'], - data () { + data() { return { canRender: false } }, - mounted () { + mounted() { this.canRender = true }, - render (h) { + render(h) { if (this.canRender) { if ( process.env.NODE_ENV === 'development' && + this.$slots.default && this.$slots.default.length > 1 ) { - throw new Error(' You cannot use multiple child components') + throw new Error('[vue-no-ssr] You cannot use multiple child components') } - return this.$slots.default[0] + return this.$slots.default && this.$slots.default[0] } - return h('div', { class: { 'no-ssr-placeholder': true } }, this.placeholder) + return h( + 'div', + { + class: ['no-ssr-placeholder'] + }, + this.placeholder + ) } } From aab684f8a8afce7ea247a1556a0fada5e924de70 Mon Sep 17 00:00:00 2001 From: Daniel Post Date: Tue, 21 Nov 2017 12:15:11 +0000 Subject: [PATCH 2/2] Fix coding style --- lib/app/components/no-ssr.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/app/components/no-ssr.js b/lib/app/components/no-ssr.js index 637e828ab..6f6934152 100644 --- a/lib/app/components/no-ssr.js +++ b/lib/app/components/no-ssr.js @@ -5,31 +5,25 @@ export default { name: 'no-ssr', props: ['placeholder'], - data() { + data () { return { canRender: false } }, - mounted() { + mounted () { this.canRender = true }, - render(h) { + render (h) { if (this.canRender) { if ( process.env.NODE_ENV === 'development' && this.$slots.default && this.$slots.default.length > 1 ) { - throw new Error('[vue-no-ssr] You cannot use multiple child components') + throw new Error(' You cannot use multiple child components') } return this.$slots.default && this.$slots.default[0] } - return h( - 'div', - { - class: ['no-ssr-placeholder'] - }, - this.placeholder - ) + return h('div', { class: { 'no-ssr-placeholder': true } }, this.placeholder) } }