Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

ReasonJs.Dom.HtmlElement.value (ReactEventRe.Form.target event) #11

Open
chenglou opened this issue Mar 20, 2017 · 2 comments
Open

ReasonJs.Dom.HtmlElement.value (ReactEventRe.Form.target event) #11

chenglou opened this issue Mar 20, 2017 · 2 comments

Comments

@chenglou
Copy link
Collaborator

@glennsl (since discord is down again. Also, I'm on freenode #reasonml)

Assuming ReactEventRe.Form.target event returns ReasonJs.Dom.element or ReasonJs.Dom.eventTarget, what reason-js function do I use to get the equivalent of myEvent.value? How would it work without unsafe cast to whatever type here?

@glennsl
Copy link
Member

glennsl commented Mar 20, 2017

Element has asHtmlElement and HtmlElement has value.

So if it returns an element:

event
|> ReacEventRe.Form.target
|> Element.asHtmlElement
|> Option.unwrapUnsafely
|> HtmlElement.value

Pretty smooth, huh :D

I'm on my way to bed. Talk to you tomorrow.

@glennsl
Copy link
Member

glennsl commented Mar 20, 2017

If it returns an eventTarget you're screwed. Unsafe way is only way. C'est la vie

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

No branches or pull requests

2 participants