mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-04 21:17:55 +08:00
Merge branch 'bugfix/v-show-not-respecting-orig-display' of git://github.com/chrisvfritz/vue into show-display
This commit is contained in:
commit
837b0b224b
@ -17,7 +17,9 @@ export default {
|
||||
if (value && transition && transition.appear && !isIE9) {
|
||||
enter(vnode)
|
||||
}
|
||||
el.style.display = value ? '' : 'none'
|
||||
const originalDisplay = el.style.display
|
||||
el.style.display = value ? originalDisplay : 'none'
|
||||
el.__vOriginalDisplay = originalDisplay
|
||||
},
|
||||
update (el: HTMLElement, { value, oldValue }: VNodeDirective, vnode: VNodeWithData) {
|
||||
/* istanbul ignore if */
|
||||
@ -27,14 +29,14 @@ export default {
|
||||
if (transition && !isIE9) {
|
||||
if (value) {
|
||||
enter(vnode)
|
||||
el.style.display = ''
|
||||
el.style.display = el.__vOriginalDisplay
|
||||
} else {
|
||||
leave(vnode, () => {
|
||||
el.style.display = 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
el.style.display = value ? '' : 'none'
|
||||
el.style.display = value ? el.__vOriginalDisplay : 'none'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,4 +49,12 @@ describe('Directive v-show', () => {
|
||||
expect(vm.$el.firstChild.style.display).toBe('')
|
||||
}).then(done)
|
||||
})
|
||||
|
||||
it('should respect display value in style attribute', () => {
|
||||
const vm = new Vue({
|
||||
template: '<div><span v-show="foo" style="display:block">hello</span></div>',
|
||||
data: { foo: true }
|
||||
}).$mount()
|
||||
expect(vm.$el.firstChild.style.display).toBe('block')
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user