fix(ssr): fix v-show inline style rendering when style binding is array (#7814)

fix #7813
This commit is contained in:
leon 2018-03-13 23:07:58 +08:00 committed by Evan You
parent a6169d1eb7
commit 1a979c44d6
2 changed files with 16 additions and 1 deletions

View File

@ -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'
}
}
}

View File

@ -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>',