Skip to content

stopPropagation on parent breaks all event listeners of same type for children #15343

@corneliusio

Description

@corneliusio

Describe the bug

Using stopPropagation on a parent element to create a boundary for event bubbling causes all of the event handlers for that event type (when attached directly with the onevent attribute) on children of that element to stop working.

This behavior only exists when using the Svelte 5 syntax for attaching events to elements (e.g. using on:event works, but onevent does not).

Reproduction

<script>
    function onClick() {
        console.log('CLICKED')
    }

    function stopPropagation(el, type) {
        el.addEventListener(type, event => event.stopPropagation())
    }
</script>

<div>
    <button onclick={onClick}>Click me, I work.</button>
</div>

<div use:stopPropagation={'click'}>
    <button onclick={onClick}>Click me, I don't work</button>
</div>

Logs

System Info

System:
    OS: macOS 15.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 561.53 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.13.0 - /opt/homebrew/bin/node
    npm: 11.0.0 - /opt/homebrew/bin/npm
    bun: 1.2.2 - ~/.bun/bin/bun
  Browsers:
    Chrome: 133.0.6943.100
    Safari: 18.3
  npmPackages:
    svelte: ^5.20.2 => 5.20.2

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions