Change ondrag event interface back to DragEvent #1254
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My previous PR #1244 accidentally replaced a few of the event handler types with less specific types. Most notably it changed the event interfaces for the
ondrag
handlers fromDragEvent
toMouseEvent
.The only other place where a previous type was replaced is
onscroll
which had its interface changed fromUiEvent
toEvent
. This struck me as odd because I explicitly remember copying the onscroll event type. So I looked into it and there's a lot of conflicting information on which interface it takes.The MDN page for the global event handler claims that "The function receives a UIEvent object as its sole argument" but the page for the
scroll
event listsEvent
as the interface.I remembered that there's already a source of types for these events out there in the wild: TypeScript!
I found a PR which changes the interface from
UiEvent
toEvent
so I decided to leave it asEvent
.I went through the new additions as well and I found another event handler with conflicting information.
onresize
also has multiple mentions of usingUiEvent
but the CSSOM (which is what was used in the previously mentioned TypeScript) mentions thatonresize
also takes theEvent
interface.The
UiEvent
is still being re-exported by Yew so that it's easy to cast to it if necessary.This is all incredibly confusing and it takes a lot of time to research.
It is very possible - even likely - that other mistakes slipped in and I'm very sorry for that.
At least it should be possible to use
JsCast
so even if an event handler has the wrong type it should be possible to use it.