From 1a979c44d6543d89f8a7e26ad7f995b1bf2aee3c Mon Sep 17 00:00:00 2001 From: leon Date: Tue, 13 Mar 2018 23:07:58 +0800 Subject: [PATCH] fix(ssr): fix v-show inline style rendering when style binding is array (#7814) fix #7813 --- src/platforms/web/server/directives/show.js | 6 +++++- test/ssr/ssr-string.spec.js | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/platforms/web/server/directives/show.js b/src/platforms/web/server/directives/show.js index 5473fb2bd4d..7493b27e087 100644 --- a/src/platforms/web/server/directives/show.js +++ b/src/platforms/web/server/directives/show.js @@ -3,6 +3,10 @@ export default function show (node: VNodeWithData, dir: VNodeDirective) { if (!dir.value) { const style: any = node.data.style || (node.data.style = {}) - style.display = 'none' + if (Array.isArray(style)) { + style.push({ display: 'none' }) + } else { + style.display = 'none' + } } } diff --git a/test/ssr/ssr-string.spec.js b/test/ssr/ssr-string.spec.js index 4d3ace46019..5300bbfefa5 100644 --- a/test/ssr/ssr-string.spec.js +++ b/test/ssr/ssr-string.spec.js @@ -267,6 +267,17 @@ describe('SSR: renderToString', () => { }) }) + it('v-show directive merge with style', done => { + renderVmWithOptions({ + template: '
inner
' + }, res => { + expect(res).toContain( + '
inner
' + ) + done() + }) + }) + it('v-show directive not passed to child', done => { renderVmWithOptions({ template: '',