// NewInput creates a new Input object from the given html input element. func NewInput(el *dom.HTMLInputElement) *Input { // Attempt to determine the type by first getting the type attribute // directly. This is more reliable as some browsers will always return // "text" as the type if the type attribute is not recognized/supported. // If the type attribute is missing, fallback to using what the browser // thinks the type is (which is probably "text"). inputType := InputType(el.GetAttribute("type")) if inputType == "" { inputType = InputType(el.Type) } return &Input{ El: el, Name: el.Name, RawValue: el.Value, Type: inputType, } }