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(runtime-dom): cache event handlers by key/modifiers (fix #9849) #9851

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

LinusBorg
Copy link
Member

@LinusBorg LinusBorg commented Dec 16, 2023

Problem

When an event handler is used multiple times in a template, for events with different key modifiers, the first wrapped handler that gets created first is being cached and re-used as the handler for all further uses, which breaks the other listeners.

Solution

Cache the created wrapped handler functions in a map object keyed by the specific modifier(s) they were created for

fix #9849

Alternative PR: #9850. That PR's author opted to remove the caching altogether which I think is not what we want. Also the problem needs to be fixed for both withKeys() and withModifiers(), which my PR does.

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 87.1 kB (+94 B) 33.1 kB (+17 B) 29.9 kB (+37 B)
vue.global.prod.js 133 kB (+94 B) 50 kB (+21 B) 44.8 kB (+60 B)

Usages

Name Size Gzip Brotli
createApp 48.4 kB 19 kB 17.4 kB
createSSRApp 51.6 kB 20.3 kB 18.5 kB
defineCustomElement 50.7 kB 19.8 kB 18.1 kB
overall 61.7 kB 23.9 kB 21.7 kB

@LinusBorg
Copy link
Member Author

@RicardoErii Sorry for opening this after you sent #9850. I started my PR a couple hours ago and only submitted it now, before I checked for other PRs arriving meanwhile.

@yyx990803 yyx990803 merged commit 04d2c05 into main Dec 16, 2023
18 checks passed
@yyx990803 yyx990803 deleted the linusborg/fix-9849 branch December 16, 2023 13:54
yyx990803 pushed a commit to smallnine9/core that referenced this pull request Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nested elements with key event+modifiers do not call listener function
2 participants