Skip to content

EventTarget removeEventListener does not match all listeners #65244

Description

@achingbrain

Version

v26.7.0

Platform

Darwin Mac.localdomain 25.5.0 Darwin Kernel Version 25.5.0: Mon Apr 27 20:41:15 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T6041 arm64

Subsystem

events

What steps will reproduce the bug?

let invocations = 0
const listener = () => {
  invocations++
}

const target = new EventTarget()

// add the listener
target.addEventListener('test', listener, true)

// remove the listener
target.removeEventListener('test', listener, true)

// dispatch an event
target.dispatchEvent(new Event('test'))

// invocations should be 0
console.info('invocations', invocations)

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

All matching event listeners should be removed, invocations should be 0.

What do you see instead?

The event listener is not removed, invocations is 1.

Additional information

Running the code under Node.js and popular browsers results in differing output. Chrome, Firefox and Safari all print 0, Node.js prints 1.

This can cause memory leaks, unexpected application behaviour, etc.

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