Buttons should also be accessible by "value"

The “input” tag is only accessible by “value” since it has nothing between the opening and the closing tags.

The "textarea" tag is accessible by “innerHTML”. Which makes sense since the text is contained between the opening and the closing tag.

But the “textarea” tag is also accessible by “value” which makes it convenient (for example you could switch between and in your program and not even notice the difference.

But the “button” tag can only be accessed by “innerHTML” or “innerText”- it cannot be accessed by “value”.

In my opinion this does not make sense. We primarily use buttons with the purpose of having text on them. So they should be accessible according to the same logics.

I suggest that we could make it so that if the “button” tag has no “value” property then by accessing “value” you get “innerHTML” or “innerText”.

You may want the WHATWG, since HTML isn't specified by TC39.

2 Likes

Like Jordan says, this is the wrong group. Those aren’t ECMAScript features.

But I would caution against suggesting this to WHATWG too because you’re misunderstanding what value represents for an <input> or <textarea>.

value is the value that goes on the wire in a form submission. The children of a <button>, in contrast, are not submitted.

JavaScript can make it’s own rules how it deals with HTML objects. Why should it delegate it entirely to the HTML?

Because the specifications are layered.

The core language specification is not aware of HTML objects.

Somewhat similar to how TCP is not aware of HTML.

It would be a layering violation for the 262 specification to have this specified.

1 Like

Also consider that Node supports the JavaScript language, but has no notion of HTML.

1 Like

Isn't it strange to set the label of the "button" tag to value...? Are you saying that if it's multilingualized, the value of "value" will change for each language...?