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
2 changes: 1 addition & 1 deletion src/core/vdom/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function createPatchFunction (backend) {
}
vnode.elm = vnode.ns
? nodeOps.createElementNS(vnode.ns, tag)
: nodeOps.createElement(tag)
: nodeOps.createElement(tag, vnode)
setScope(vnode)
createChildren(vnode, children, insertedVnodeQueue)
if (isDef(data)) {
Expand Down
11 changes: 9 additions & 2 deletions src/platforms/web/runtime/node-ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

import { namespaceMap } from 'web/util/index'

export function createElement (tagName: string): Element {
return document.createElement(tagName)
export function createElement (tagName: string, vnode: VNode): Element {
const elm = document.createElement(tagName)
if (tagName !== 'select') {
return elm
}
if (vnode.data && vnode.data.attrs && 'multiple' in vnode.data.attrs) {
elm.setAttribute('multiple', 'multiple')
}
return elm
}

export function createElementNS (namespace: string, tagName: string): Element {
Expand Down
15 changes: 15 additions & 0 deletions test/unit/features/directives/model-select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,21 @@ describe('Directive v-model select', () => {
}).then(done)
})

it('multiple with static template', () => {
const vm = new Vue({
template:
'<select multiple>' +
'<option selected>a</option>' +
'<option selected>b</option>' +
'<option selected>c</option>' +
'</select>'
}).$mount()
var opts = vm.$el.options
expect(opts[0].selected).toBe(true)
expect(opts[1].selected).toBe(true)
expect(opts[2].selected).toBe(true)
})

it('multiple + v-for', done => {
const vm = new Vue({
data: {
Expand Down