<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/avoid-these-mistakes-with-svelte-events-tp0zyyqhi" -->

---
title: Avoid These Mistakes With Svelte Events | daily.dev
description: Svelte uses event delegation rather than attaching listeners directly to elements, which can cause subtle bugs when mixing declarative and manual event...
canonical: https://daily.dev/posts/avoid-these-mistakes-with-svelte-events-tp0zyyqhi
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Avoid These Mistakes With Svelte Events | daily.dev
og:description: Svelte uses event delegation rather than attaching listeners directly to elements, which can cause subtle bugs when mixing declarative and manual event...
og:url: https://daily.dev/posts/avoid-these-mistakes-with-svelte-events-tp0zyyqhi
og:image: https://api.daily.dev/og/posts/tp0zyyqHi.png
og:image:alt: Avoid These Mistakes With Svelte Events
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Avoid These Mistakes With Svelte Events

**[Joy of Code](https://daily.dev/sources/joyofcode)** · 13 min read · 1 upvotes · 0 comments

## Summary

Svelte uses event delegation rather than attaching listeners directly to elements, which can cause subtle bugs when mixing declarative and manual event listeners. Two common pitfalls are covered: custom events not bubbling (fix: add `bubbles: true`) and manual event listeners firing in the wrong order or ignoring `stopPropagation` (fix: use the `on` function from `svelte/events`). The post also dives into Svelte's compiled source code to show how `handleEventPropagation` and the `on` function work internally, explaining why using `on` ensures correct event ordering and cleanup.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=7mQCRxdIPJg>

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#svelte](https://daily.dev/tags/svelte)

[View this post on daily.dev](https://daily.dev/posts/avoid-these-mistakes-with-svelte-events-tp0zyyqhi)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Avoid These Mistakes With Svelte Events","url":"https://daily.dev/posts/avoid-these-mistakes-with-svelte-events-tp0zyyqhi","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/avoid-these-mistakes-with-svelte-events-tp0zyyqhi"},"datePublished":"2026-03-13T19:20:25.865Z","dateModified":"2026-03-13T19:20:44.552Z","description":"Svelte uses event delegation rather than attaching listeners directly to elements, which can cause subtle bugs when mixing declarative and manual event...","image":"https://i.ytimg.com/vi/7mQCRxdIPJg/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/7mQCRxdIPJg/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Joy of Code","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Joy of Code","logo":"https://media.daily.dev/image/upload/s--_wpnboLQ--/f_auto/v1726499659/logos/joyofcode","url":"https://daily.dev/sources/joyofcode"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/avoid-these-mistakes-with-svelte-events-tp0zyyqhi","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,svelte","timeRequired":"PT13M","video":{"@type":"VideoObject","name":"Avoid These Mistakes With Svelte Events","description":"Svelte uses event delegation rather than attaching listeners directly to elements, which can cause subtle bugs when mixing declarative and manual event...","thumbnailUrl":"https://i.ytimg.com/vi/7mQCRxdIPJg/sddefault.jpg","uploadDate":"2026-03-13T19:20:25.865Z","duration":"PT13M","url":"https://api.daily.dev/r/tp0zyyqHi","embedUrl":"https://www.youtube.com/embed/7mQCRxdIPJg"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Joy of Code","item":"https://daily.dev/sources/joyofcode"},{"@type":"ListItem","position":3,"name":"Avoid These Mistakes With Svelte Events"}]}
```

