Skip to content

Commit 6d4bdb5

Browse files
committed
fix style binding for falsy numbers (fix #3816)
1 parent 8298323 commit 6d4bdb5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/platforms/web/runtime/modules/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
5757
cur = style[name]
5858
if (cur !== oldStyle[name]) {
5959
// ie9 setting to null has no effect, must use empty string
60-
el.style[normalize(name)] = cur || ''
60+
el.style[normalize(name)] = cur == null ? '' : cur
6161
}
6262
}
6363
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ describe('Directive v-bind:style', () => {
3737
}).then(done)
3838
})
3939

40+
it('falsy number', done => {
41+
vm.styles = { opacity: 0 }
42+
waitForUpdate(() => {
43+
expect(vm.$el.style.opacity).toBe('0')
44+
}).then(done)
45+
})
46+
4047
it('plain object', done => {
4148
vm.styles = { color: 'red' }
4249
waitForUpdate(() => {

0 commit comments

Comments
 (0)