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(vMemo): prevent unexpected render in v-for + v-memo #10431

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

Conversation

Doctor-wu
Copy link
Member

@Doctor-wu Doctor-wu commented Feb 29, 2024

This PR fixes the unexpected render when v-memo is used in a keyed v-for list. In the past, we just used an array as the renderCache of a list whatever if it is keyed. This PR adds a map that uses nodes.key as key and node as the value to the cache. When updates, if a list is keyed, it will check the cache from the map, so that can prevent unexpected render.

close #10392

Copy link

github-actions bot commented Feb 29, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB (+230 B) 38 kB (+91 B) 34.3 kB (+81 B)
vue.global.prod.js 158 kB (+385 B) 57.9 kB (+148 B) 51.6 kB (+133 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

@baiwusanyu-c
Copy link
Member

/ecosystem-ci run

@Doctor-wu Doctor-wu marked this pull request as draft February 29, 2024 09:22
@vue-bot
Copy link
Contributor

vue-bot commented Feb 29, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success failure
nuxt success success
pinia success success
quasar failure success
radix-vue failure success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@Doctor-wu Doctor-wu marked this pull request as ready for review February 29, 2024 10:13
@Doctor-wu
Copy link
Member Author

@baiwusanyu-c could you help to re-run the ecosystem-ci?

@baiwusanyu-c
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Feb 29, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success failure
nuxt success success
pinia success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@edison1105 edison1105 changed the title fix(compiler-core, runtime-core): fix unexpected render in v-for & v-memo fix(vMemo): prevent unexpected render in v-for + v-memo Oct 16, 2024
@edison1105 edison1105 added 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready for review This PR requires more reviews labels Oct 16, 2024
@edison1105
Copy link
Member

Could you please resolve the conflicts?

@Doctor-wu
Copy link
Member Author

Could you please resolve the conflicts?

Sure, glad to see this PR finally noticed by others😁

Copy link

pkg-pr-new bot commented Oct 16, 2024

Open in Stackblitz

@vue/compiler-core

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/compiler-dom

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 5167f16

@Doctor-wu
Copy link
Member Author

I also added corresponding test case

@Doctor-wu
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Oct 16, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools failure success
nuxt success success
pinia success success
primevue success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@Doctor-wu
Copy link
Member Author

language-tools failed seems not related to this PR

@edison1105
Copy link
Member

/ecosystem-ci run language-tools

@vue-bot
Copy link
Contributor

vue-bot commented Oct 16, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success

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 for review This PR requires more reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v-memo in v-for, only memoize until the first changed item
4 participants