Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0] allow to initialize value attribute to 0 #3334

Merged
merged 1 commit into from
Jul 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/platforms/web/runtime/modules/dom-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
// non-string values will be stringified
elm._value = cur
// avoid resetting cursor position when value is the same
if (elm.value != cur) { // eslint-disable-line
elm.value = cur
const strCur = cur == null ? '' : String(cur)
if (elm.value !== strCur) {
elm.value = strCur
}
} else {
elm[key] = cur
Expand Down
6 changes: 6 additions & 0 deletions test/unit/modules/vdom/modules/props.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ describe('vdom domProps module', () => {
const elm = patch(vnode1, vnode2)
expect(elm.src).toBeUndefined()
})

it('should initialize the elements value to zero', () => {
const vnode = new VNode('input', { domProps: { value: 0 }})
const elm = patch(null, vnode)
expect(elm.value).toBe('0')
})
})