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

Skip to content

Commit 64395c2

Browse files
committed
v-bind: do not remove input value attributes
1 parent 6d64b36 commit 64395c2

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/directives/attr.js

Lines changed: 15 additions & 12 deletions
92
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,7 @@ module.exports = {
6868

6969
setAttr: function (attr, value) {
7070
if (inputProps[attr] && attr in this.el) {
71-
if (!this.valueRemoved) {
72-
this.el.removeAttribute(attr)
73-
this.valueRemoved = true
74-
}
7571
this.el[attr] = value
76-
} else if (value != null && value !== false) {
77-
if (xlinkRE.test(attr)) {
78-
this.el.setAttributeNS(xlinkNS, attr, value)
79-
} else {
80-
this.el.setAttribute(attr, value)
81-
}
82-
} else {
83-
this.el.removeAttribute(attr)
8472
}
8573
// set model props
8674
var modelProp = modelProps[attr]
@@ -92,5 +80,20 @@ module.exports = {
9280
model.listener()
9381
}
9482
}
83+
// do not set value attribute for textarea
84+
if (attr === 'value' && this.el.tagName === 'TEXTAREA') {
85+
this.el.removeAttribute(attr)
86+
return
87+
}
88+
// update attribute
89+
if (value != null && value !== false) {
90+
if (xlinkRE.test(attr)) {
91+
this.el.setAttributeNS(xlinkNS, attr, value)
+
} else {
93+
this.el.setAttribute(attr, value)
94+
}
95+
} else {
96+
this.el.removeAttribute(attr)
97+
}
9598
}
9699
}

test/unit/specs/directives/attr_spec.js

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

0 commit comments

Comments
 (0)
0