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

fix(v-model): vModelSelect work with custom getter and setter edge case #12428

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yangxiuxiu1115
Copy link
Contributor

fix #12425

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB (+48 B) 38 kB (+29 B) 34.2 kB (+37 B)
vue.global.prod.js 158 kB (+48 B) 57.8 kB (+25 B) 51.5 kB (+67 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47.2 kB 18.3 kB 16.8 kB
createApp 55.2 kB 21.3 kB 19.5 kB
createSSRApp 59.3 kB 23.1 kB 21 kB
defineCustomElement 60.1 kB 22.9 kB 20.8 kB
overall 69.1 kB 26.5 kB 24.1 kB

Copy link

pkg-pr-new bot commented Nov 18, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12428

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12428

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12428

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12428

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12428

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12428

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12428

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12428

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12428

vue

pnpm add https://pkg.pr.new/vue@12428

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12428

commit: 7eab641

@yangxiuxiu1115 yangxiuxiu1115 changed the title feat: . fix(vModelSelect): vModelSelect supports custom setter Nov 18, 2024
@yangxiuxiu1115 yangxiuxiu1115 marked this pull request as draft November 18, 2024 09:28
@yangxiuxiu1115 yangxiuxiu1115 marked this pull request as ready for review November 18, 2024 09:37
@edison1105
Copy link
Member

edison1105 commented Nov 19, 2024

LGTM.

For sure this behavior is consistent with vue2

@edison1105 edison1105 added scope: v-model 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. labels Nov 19, 2024
@edison1105 edison1105 changed the title fix(vModelSelect): vModelSelect supports custom setter fix(v-model): vModelSelect work with custom getter and setter edge case Nov 19, 2024
@edison1105 edison1105 added the ready to merge The PR is ready to be merged. label Nov 19, 2024
@@ -233,7 +239,7 @@ export const vModelSelect: ModelDirective<HTMLSelectElement, 'number'> = {
el[assignKey] = getModelAssigner(vnode)
},
updated(el, { value }) {
if (!el._assigning) {
if (!el[assigningKey] || toRaw(value) !== el[assignValueKey]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an equality check might be problematic if the collection is modified, rather than replaced.

For example:

I'm not sure how important handling cases like these is. The change doesn't make them any worse.

@@ -202,24 +209,23 @@ export const vModelRadio: ModelDirective<HTMLInputElement> = {
export const vModelSelect: ModelDirective<HTMLSelectElement, 'number'> = {
// <select multiple> value need to be deep traversed
deep: true,
created(el, { value, modifiers: { number } }, vnode) {
created(el, { value, oldValue, modifiers: { number } }, vnode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think oldValue is unused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready to merge The PR is ready to be merged. scope: v-model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

the issue of reactivity on multiple select
3 participants