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
…ay (#7814)

fix #7813
  • Loading branch information
jinzhubaofu authored and yyx990803 committed Mar 13, 2018
1 parent a6169d1 commit 1a979c4
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 1a979c4

Please sign in to comment.