Skip to content

Commit 86bf3da

Browse files
committed
fix flow error for #3393
1 parent 837b0b2 commit 86bf3da

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function locateNode (vnode: VNode): VNodeWithData {
1111
}
1212

1313
export default {
14-
bind (el: HTMLElement, { value }: VNodeDirective, vnode: VNodeWithData) {
14+
bind (el: any, { value }: VNodeDirective, vnode: VNodeWithData) {
1515
vnode = locateNode(vnode)
1616
const transition = vnode.data && vnode.data.transition
1717
if (value && transition && transition.appear && !isIE9) {
@@ -21,7 +21,7 @@ export default {
2121
el.style.display = value ? originalDisplay : 'none'
2222
el.__vOriginalDisplay = originalDisplay
2323
},
24-
update (el: HTMLElement, { value, oldValue }: VNodeDirective, vnode: VNodeWithData) {
24+
update (el: any, { value, oldValue }: VNodeDirective, vnode: VNodeWithData) {
2525
/* istanbul ignore if */
2626
if (value === oldValue) return
2727
vnode = locateNode(vnode)

test/unit/features/directives/show.spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,18 @@ describe('Directive v-show', () => {
5050
}).then(done)
5151
})
5252

53-
it('should respect display value in style attribute', () => {
53+
it('should respect display value in style attribute', done => {
5454
const vm = new Vue({
5555
template: '<div><span v-show="foo" style="display:block">hello</span></div>',
5656
data: { foo: true }
5757
}).$mount()
5858
expect(vm.$el.firstChild.style.display).toBe('block')
59+
vm.foo = false
60+
waitForUpdate(() => {
61+
expect(vm.$el.firstChild.style.display).toBe('none')
62+
vm.foo = true
63+
}).then(() => {
64+
expect(vm.$el.firstChild.style.display).toBe('block')
65+
}).then(done)
5966
})
6067
})

0 commit comments

Comments
 (0)