Skip to content

Commit

Permalink
chore: remove unused argument
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 authored and OnlyWick committed Feb 27, 2024
1 parent fe5d919 commit 52844f6
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions packages/runtime-dom/src/directives/vModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,20 @@ export const vModelSelect: ModelDirective<HTMLSelectElement> = {
},
// set value in mounted & updated because <select> relies on its children
// <option>s.
mounted(el, { value, oldValue, modifiers: { number } }) {
setSelected(el, value, oldValue, number)
mounted(el, { value, modifiers: { number } }) {
setSelected(el, value, number)
},
beforeUpdate(el, _binding, vnode) {
el[assignKey] = getModelAssigner(vnode)
},
updated(el, { value, oldValue, modifiers: { number } }) {
updated(el, { value, modifiers: { number } }) {
if (!el._assigning) {
setSelected(el, value, oldValue, number)
setSelected(el, value, number)
}
},
}

function setSelected(
el: HTMLSelectElement,
value: any,
oldValue: any,
number: boolean,
) {
function setSelected(el: HTMLSelectElement, value: any, number: boolean) {
const isMultiple = el.multiple
const isArrayValue = isArray(value)
if (isMultiple && !isArrayValue && !isSet(value)) {
Expand Down Expand Up @@ -256,11 +251,9 @@ function setSelected(
} else {
option.selected = value.has(optionValue)
}
} else {
if (looseEqual(getValue(option), value)) {
if (el.selectedIndex !== i) el.selectedIndex = i
return
}
} else if (looseEqual(getValue(option), value)) {
if (el.selectedIndex !== i) el.selectedIndex = i
return
}
}
if (!isMultiple && el.selectedIndex !== -1) {
Expand Down

0 comments on commit 52844f6

Please sign in to comment.