This took a bit of digging, but it looks like you can cast nodes to different 
types (not sure if this is the best way):
    
    
    include karax / prelude
    import karax / kdom
    
    proc createDom(): VNode =
      result = buildHtml(tdiv):
        h1:
          text "hello world"
        input(`type`="file"):
          text "click here"
          proc onchange(ev: Event, n: VNode) =
            let element = cast[InputElement](ev.target)
            let file = cast[kdom.File](element.files[0])
            echo file.size
            echo file.`type`
            echo file.name
    
    setRenderer createDom
    
    
    Run

I found the definitions of the DOM objects here: 
[https://github.com/nim-lang/Nim/blob/version-1-0/lib/js/dom.nim#L242](https://github.com/nim-lang/Nim/blob/version-1-0/lib/js/dom.nim#L242)

Reply via email to