Skip to content

Commit

Permalink
fix(ssr): fix v-show inline style rendering when style binding is arr…
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhubaofu authored and aJean committed Aug 19, 2020
1 parent 228d1ca commit 8196a00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/platforms/web/server/directives/show.js
Expand Up @@ -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'
}
}
}
11 changes: 11 additions & 0 deletions test/ssr/ssr-string.spec.js
Expand Up @@ -267,6 +267,17 @@ describe('SSR: renderToString', () => {
})
})

it('v-show directive merge with style', done => {
renderVmWithOptions({
template: '<div :style="[{lineHeight: 1}]" v-show="false"><span>inner</span></div>'
}, res => {
expect(res).toContain(
'<div data-server-rendered="true" style="line-height:1;display:none;"><span>inner</span></div>'
)
done()
})
})

it('v-show directive not passed to child', done => {
renderVmWithOptions({
template: '<foo v-show="false"></foo>',
Expand Down

0 comments on commit 8196a00

Please sign in to comment.