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): ensure only symbols are explicitly stringified during attribute patching #11182

Merged
merged 3 commits into from
Jun 22, 2024

Conversation

LinusBorg
Copy link
Member

@LinusBorg LinusBorg commented Jun 20, 2024

This covers an edge case where a web component actually overrides el.setAttribute and thus is able to receive non-string values as attribute values (appareantly, extJS web components do this).

This patch ensures that we leave stringification to the browser when patching an element attribute except for the case of symbols, where we need to explicitly stringify it ourselves as the browser would throw an error.

fix: #11177

Copy link

github-actions bot commented Jun 20, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 89.6 kB (+7 B) 34.2 kB (+4 B) 30.9 kB (+8 B)
vue.global.prod.js 146 kB (+7 B) 53.6 kB (+5 B) 47.8 kB (-9 B)

Usages

Name Size Gzip Brotli
createApp 51.6 kB (+7 B) 20.2 kB (+5 B) 18.3 kB (-4 B)
createSSRApp 54.9 kB (+7 B) 21.5 kB (+7 B) 19.6 kB (+13 B)
defineCustomElement 53.9 kB (+7 B) 20.9 kB (+5 B) 19 kB (+5 B)
overall 65.3 kB (+7 B) 25.2 kB (+7 B) 22.8 kB (+2 B)

@LinusBorg LinusBorg marked this pull request as ready for review June 20, 2024 09:34
@LinusBorg LinusBorg added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: custom elements labels Jun 20, 2024
@LinusBorg
Copy link
Member Author

I think this patch is worthwhile, but I want to mention that this is an edge case for specific web component implementations, and the typeof might add a (small, likely neglectable) perf overhead when patching a lot of attributes.

@yyx990803 yyx990803 merged commit a2e35d6 into main Jun 22, 2024
15 checks passed
@yyx990803 yyx990803 deleted the linusborg/avoid-manual-attr-stringification-fix-11177 branch June 22, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: custom elements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attribute stringification
2 participants