Skip to content

Commit 1a979c4

Browse files
jinzhubaofuyyx990803
authored andcommitted
fix(ssr): fix v-show inline style rendering when style binding is array (vuejs#7814)
fix vuejs#7813
1 parent a6169d1 commit 1a979c4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/platforms/web/server/directives/show.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
export default function show (node: VNodeWithData, dir: VNodeDirective) {
44
if (!dir.value) {
55
const style: any = node.data.style || (node.data.style = {})
6-
style.display = 'none'
6+
if (Array.isArray(style)) {
7+
style.push({ display: 'none' })
8+
} else {
9+
style.display = 'none'
10+
}
711
}
812
}

test/ssr/ssr-string.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,17 @@ describe('SSR: renderToString', () => {
267267
})
268268
})
269269

270+
it('v-show directive merge with style', done => {
271+
renderVmWithOptions({
272+
template: '<div :style="[{lineHeight: 1}]" v-show="false"><span>inner</span></div>'
273+
}, res => {
274+
expect(res).toContain(
275+
'<div data-server-rendered="true" style="line-height:1;display:none;"><span>inner</span></div>'
276+
)
277+
done()
278+
})
279+
})
280+
270281
it('v-show directive not passed to child', done => {
271282
renderVmWithOptions({
272283
template: '<foo v-show="false"></foo>',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy