bs-webapi-incubator icon indicating copy to clipboard operation
bs-webapi-incubator copied to clipboard

unsafeAsHtmlInputElement

Open mununki opened this issue 3 years ago • 0 comments

I have an issue to get a html input element. I can't find any method to convert Dom.element to Dom.htmlInputElement or Dom.htmlElement to Dom.htmlInputElement. I could make an identity binding to convert it as a workaround. Is there any other way to get an html input element from dom or convert it?

external unsafeAsHtmlInputElement: Dom.element => Dom.htmlInputElement = "%identity"

let inputFile = Dom.document |> Dom.Document.getElementById("input-file")
inputFile
->Belt.Option.map(inputFile' => {
  inputFile'->unsafeAsHtmlInputElement->Dom.HtmlInputElement.setValue("")
})

mununki avatar Jul 14 '21 04:07 mununki