Skip to content

Commit

Permalink
perf: perf
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchangtao committed Mar 25, 2024
1 parent 1a00d6a commit 2ffb7da
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/runtime-dom/src/directives/vModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,15 @@ function setSelected(el: HTMLSelectElement, value: any, number: boolean) {
// fast path for string / number values
if (optionType === 'string' || optionType === 'number') {
option.selected = !!value.find(v => {
let value = optionValue
let val = optionValue
if (number) {
value = looseToNumber(optionValue)
val = looseToNumber(optionValue)
}
return looseEqual(value, v)
const valType = typeof v
if (valType === optionType) {
return val === v
}
return looseEqual(val, v)
})
} else {
option.selected = looseIndexOf(value, optionValue) > -1
Expand Down

0 comments on commit 2ffb7da

Please sign in to comment.