-
- Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Description
Describe the bug
When creating a component with multiple root elements, Svelte currently checks detaching for every single root element. IE:
// Truncated for brevity, see REPL // ... function create_fragment(ctx) { // ... return { // ... d(detaching) { if (detaching) detach(h1); if (detaching) detach(t1); if (detaching) detach(h2); if (detaching) detach(t3); if (detaching) detach(h3); } }; } // ...When ran through Terser, that roughly becomes:
detaching && detach(h1), detaching && detach(t1), detaching && detach(h2), detaching && detach(t2), detaching && detach(h3);This should be fairly simple to cut down to this:
if (detaching) { detach(h1); detach(t1); detach(h2); detach(t3); detach(h3); }... which roughly becomes this:
detaching && ( detach(h1), detach(t1), detach(h2), detach(t3), detach(h3) );This is a really minor thing, but it should lead to slightly better bundle sizes for some users.
I'd be happy to fix this as a first pull request 😄
Reproduction
Logs
No response
System Info
I encountered this on the playground, so I suppose 3.42.3?Severity
annoyance