Skip to content

Commit d831a43

Browse files
committed
fix #448 v-attr should remove attribute when value === false
1 parent fbd874f commit d831a43

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/directives/attr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
}
1717

1818
function defaultHandler (value) {
19-
if (value != null) {
19+
if (value || value === 0) {
2020
this.el.setAttribute(this.arg, value)
2121
} else {
2222
this.el.removeAttribute(this.arg)

test/unit/specs/directives/attr_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ if (_.inBrowser) {
2222
expect(el.getAttribute('test')).toBe('again')
2323
dir.update(null)
2424
expect(el.hasAttribute('test')).toBe(false)
25+
dir.update(false)
26+
expect(el.hasAttribute('test')).toBe(false)
27+
dir.update(0)
28+
expect(el.getAttribute('test')).toBe('0')
2529
})
2630

2731
it('xlink', function () {

0 commit comments

Comments
 (0)