8000 v-bind: do not remove input value attributes · justnull/vue@17833f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17833f9

Browse files
committed
v-bind: do not remove input value attributes
1 parent 3d8c102 commit 17833f9

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/directives/public/bind.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,7 @@ module.exports = {
8484
}
8585
var attr = this.arg
8686
if (inputProps[attr] && attr in this.el) {
87-
if (!this.valueRemoved) {
88-
this.el.removeAttribute(attr)
89-
this.valueRemoved = true
90-
}
9187
this.el[attr] = value
92-
} else if (value != null && value !== false) {
93-
if (xlinkRE.test(attr)) {
94-
this.el.setAttributeNS(xlinkNS, attr, value)
95-
} else {
96-
this.el.setAttribute(attr, value)
97-
}
98-
} else {
99-
this.el.removeAttribute(attr)
10088
}
10189
// set model props
10290
var modelProp = modelProps[attr]
@@ -108,5 +96,20 @@ module.exports = {
10896
model.listener()
10997
}
11098
}
99+
// do not set value attribute for textarea
100+
if (attr === 'value' && this.el.tagName === 'TEXTAREA') {
101+
this.el.removeAttribute(attr)
102+
return
103+
}
104+
// update attribute
105+
if (value != null && value !== false) {
106+
if (xlinkRE.test(attr)) {
107+
this.el.setAttributeNS(xlinkNS, attr, value)
108+
} else {
109+
this.el.setAttribute(attr, value)
110+
}
111+
} else {
112+
this.el.removeAttribute(attr)
113+
}
111114
}
112115
}

test/unit/specs/directives/public/bind_spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ if (_.inBrowser) {
2929
dir.el = document.createElement('input')
3030
dir.arg = 'value'
3131
dir.update('what')
32-
expect(dir.el.hasAttribute('value')).toBe(false)
3332
expect(dir.el.value).toBe('what')
3433
dir.el = document.createElement('input')
3534
dir.el.type = 'checkbox'

0 commit comments

Comments
 (0)
0