Skip to content

Compatibility of Dom.eventTarget with Dom.node_like<'a>? #130

Answered by TheSpyder
Zeta611 asked this question in Q&A
Discussion options

You must be logged in to vote

Even in JS, assuming the shape of event.target can be unsafe. So in that spirit there are built-in unsafe identity functions:

external unsafeAsDocument: Dom.eventTarget => Dom.document = "%identity"
external unsafeAsElement: Dom.eventTarget => Dom.element = "%identity"
external unsafeAsWindow: Dom.eventTarget => Dom.window = "%identity"

Which, in your case, I think translates to event->Event.target->EventTarget.unsafeAsElement.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Zeta611
Comment options

Answer selected by Zeta611
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants