79760057

Date: 2025-09-09 15:47:37
Score: 2
Natty:
Report link

input's value attribute is defined as a DOMString attribute in the standard (1), meaning setting its value will stringify the passed value (2).

This explains why:

...except that's not what happens when you set it to null! This is because the value attribute also has the LegacyNullToEmptyString extended attribute (1), which states that null values must be stringified to '' intsead of 'null' (2, 3), and that's why you have the behavior you observed.

As for why is this extended attribute used here, given the name ("Legacy") I assume this is to maintain compatibility with an old specification or browser behavior. However, I cannot find a reference that explicitly states this.


  1. https://html.spec.whatwg.org/multipage/input.html#htmlinputelement
  2. https://webidl.spec.whatwg.org/#js-DOMString
  3. https://webidl.spec.whatwg.org/#LegacyNullToEmptyString
Reasons:
  • Blacklisted phrase (1.5): I cannot find
  • Blacklisted phrase (0.5): I cannot
  • RegEx Blacklisted phrase (0.5): why is this
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Violet Rosenzweig