Skip to content

Use MessageEvent in EventSource#addEventListener #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 23, 2021

Conversation

Alexendoo
Copy link
Contributor

Fixes #736

The event listeners are removed and then recreated to avoid having the
existing add/removeEventListeners in addition to the new ones

@ghost
Copy link

ghost commented Oct 20, 2021

CLA assistant check
All CLA requirements met.

@github-actions
Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

@saschanaz
Copy link
Contributor

saschanaz commented Oct 20, 2021

This is redefining too many things. Since this case is special enough I would just hardcode the event type in the function generating addEventListener.

If you prefer not to hardcode, you can maybe add some field defaultEventInterface and use that.

@Alexendoo
Copy link
Contributor Author

Thanks, made that change. That is nicer indeed

const listener =
i.name === "EventSource"
? "(this: EventSource, event: MessageEvent) => any"
: "EventListenerOrEventListenerObject";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this potentially breaks compatibility with { handleEvent: () =>{} }. Could you add another signature that accepts EventListenerObject, and add a unit test in unittests/files/?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right. I thought it would take the definition from the extends EventTarget. I'll make it purely additive

@saschanaz
Copy link
Contributor

Looks great, thank you! Just waiting for the tests to pass...

@saschanaz
Copy link
Contributor

LGTM

@github-actions github-actions bot merged commit 20c1354 into microsoft:main Oct 23, 2021
@github-actions
Copy link
Contributor

Merging because @saschanaz is a code-owner of all the changes - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EventSource events are always provided a MessageEvent
2 participants