Skip to content

Conversation

@karlseguin
Copy link
Collaborator

Instead of taking a callback function, addEventListener can take an object that exposes a handleEvent function. When used this way, this is automatically bound. I don't think the current behavior is correct when handleEvent is defined as a property (getter), but I couldn't figure out how to make it work the way WPT expects, and it hopefully isn't a common usage pattern.

Also added option support to removeEventListener.

Instead of taking a callback function, addEventListener can take an object
that exposes a `handleEvent` function. When used this way, `this` is
automatically bound. I don't think the current behavior is correct when
`handleEvent` is defined as a property (getter), but I couldn't figure out how
to make it work the way WPT expects, and it hopefully isn't a common usage
pattern.

Also added option support to removeEventListener.
This is a hint to the brower that the listener won't call preventDefault. In
theory, we should enforce this. But in practice, ignoring it should be ok.
Removes some duplication between xhr/event_target and dom/event_target.

Implement 'once' option of addEventListener.
@karlseguin karlseguin force-pushed the add_event_listener_object branch from 974b75d to 9ce3fc9 Compare May 27, 2025 13:05
@karlseguin karlseguin merged commit d7a3e2f into main May 27, 2025
5 checks passed
@karlseguin karlseguin deleted the add_event_listener_object branch May 27, 2025 13:05
@github-actions github-actions bot locked and limited conversation to collaborators May 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants