Skip to content

Commit ab2ff32

Browse files
committed
allow empty/falsy values in v-bind:class array syntax
1 parent b7bc6e6 commit ab2ff32

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/directives/internal/class.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ module.exports = {
3232
handleArray: function (value) {
3333
this.cleanup(value)
3434
for (var i = 0, l = value.length; i < l; i++) {
35-
addClass(this.el, value[i])
35+
if (value[i]) {
36+
addClass(this.el, value[i])
37+
}
3638
}
3739
this.prevKeys = value
3840
},

test/unit/specs/directives/internal/class_spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ if (_.inBrowser) {
4747
expect(el.className).toBe('a c d')
4848
dir.update()
4949
expect(el.className).toBe('a')
50+
dir.update(['e', ''])
51+
expect(el.className).toBe('a e')
5052
})
5153

5254
})

0 commit comments

Comments
 (0)