The HTMLInputElement
doesn't have a class
or minlength
property. The reflected properties for those attributes are className
(inherited from Element
) and minLength
(note the capital L
). So you'd have to either use those names in your original object, or write your own assignment function that translates the names. (Or write your own assignment function that uses setAttribute
instead, but I wouldn't do that.)
In a comment you've said:
...good to remember that JS assigned attributes are not letter for letter what you see on the HTML
They are if you set attributes, via setAttribute
. For instance:
theElement.setAttribute("class", "new value");
That works correctly (on all but obsolete versions of the obsolete Internet Explorer).
What you're seeing is that the property that reflects an attribute doesn't always have exactly the same name as the attribute. (className
[class
] and htmlFor
[for
] are the classic examples.) This is because in JavaScript prior to ES5, you couldn't use class
or for
or other reserved words as literal property names (obj.class = "x"
), though the version using brackets notation was (obj["class"] = "x"
). So the reflected properties for class
and for
were made className
and htmlFor
(there's a third one at least on one of the element subtypes; it's not immediately coming to me).