From 3a1a23c9716775eb08d628018a9441b53787d1dd Mon Sep 17 00:00:00 2001 From: lupengyu Date: Tue, 13 Mar 2018 12:31:19 +0800 Subject: [PATCH] fix: add v-show style in ssr if style is binding to an array web/server/directives/show just add style.display='none', no matter style is object or array; If style is an array, it will lost additional property while tranformed into object in shared/utils#toObject; 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: '',