Skip to content

fix(runtime-dom): ensure only symbols are explicitly stringified during attribute patching#11182

Merged
yyx990803 merged 3 commits intomainfrom
linusborg/avoid-manual-attr-stringification-fix-11177
Jun 22, 2024
Merged

fix(runtime-dom): ensure only symbols are explicitly stringified during attribute patching#11182
yyx990803 merged 3 commits intomainfrom
linusborg/avoid-manual-attr-stringification-fix-11177

Conversation

@LinusBorg
Copy link
Copy Markdown
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

@github-actions
Copy link
Copy Markdown

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
Copy Markdown
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.

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