Skip to content

Commit 6d4ddd6

Browse files
committed
fix v-attr property setting (should be input.value only) (fix #1104 & #1105)
1 parent 3200487 commit 6d4ddd6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/directives/attr.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
},
3636

3737
setAttr: function (attr, value) {
38-
if (value || value === 0) {
38+
if (value != null && value !== false) {
3939
if (xlinkRE.test(attr)) {
4040
this.el.setAttributeNS(xlinkNS, attr, value)
4141
} else {
@@ -44,9 +44,8 @@ module.exports = {
4444
} else {
4545
this.el.removeAttribute(attr)
4646
}
47-
if (attr in this.el) {
48-
this.el[attr] = value
47+
if (attr === 'value' && 'value' in this.el) {
48+
this.el.value = value
4949
}
5050
}
51-
5251
}

test/unit/specs/directives/attr_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (_.inBrowser) {
2626
expect(el.getAttribute('test')).toBe('0')
2727
})
2828

29-
it('should set property', function () {
29+
it('should set property for input value', function () {
3030
dir.el = document.createElement('input')
3131
dir.arg = 'value'
3232
dir.update('what')

0 commit comments

Comments
 (0)