Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/platforms/web/runtime/node-ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export function createElement (tagName: string, vnode: VNode): Element {
if (tagName !== 'select') {
return elm
}
if (vnode.data && vnode.data.attrs && 'multiple' in vnode.data.attrs) {
// false or null will remove the attribute but undefined will not
if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
elm.setAttribute('multiple', 'multiple')
}
return elm
Expand Down
16 changes: 16 additions & 0 deletions test/unit/features/directives/model-select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ describe('Directive v-model select', () => {
}).then(done)
})

it('should not have multiple attr with falsy values except \'\'', () => {
const vm = new Vue({
template:
'<div>' +
'<select id="undefined" :multiple="undefined"></select>' +
'<select id="null" :multiple="null"></select>' +
'<select id="false" :multiple="false"></select>' +
'<select id="string" :multiple="\'\'"></select>' +
'</div>'
}).$mount()
expect(vm.$el.querySelector('#undefined').multiple).toEqual(false)
expect(vm.$el.querySelector('#null').multiple).toEqual(false)
expect(vm.$el.querySelector('#false').multiple).toEqual(false)
expect(vm.$el.querySelector('#string').multiple).toEqual(true)
})

it('multiple with static template', () => {
const vm = new Vue({
template:
Expand Down