You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<textarea>s have a default maxLength of 0, which is a valid maximum allowed value length indicating that users can't enter text. As a result, code that inspects maxLength (eg. testing libraries simulating user input which may restrict input events based on maxLength) may consider 0 to mean "no limit" to support jsdom, which makes support across both jsdom and browsers difficult.
In contrast, <input> elements have different behaviour, which will return a reasonably high value when no value has been set (while modern browsers tend to use -1, is still reasonable).
This is just a bug in jsdom, and in particular in our reflection support. The spec says
The maxLength IDL attribute must reflect the maxlength content attribute, limited to only non-negative numbers.
and
If a reflecting IDL attribute has a signed integer type (long) that is limited to only non-negative numbers then, on getting, the content attribute must be parsed according to the rules for parsing non-negative integers, and if that is successful, and the value is in the range of the IDL attribute's type, the resulting value must be returned. If, on the other hand, it fails or returns an out of range value, or if the attribute is absent, the default value must be returned instead, or −1 if there is no default value.
We should be able to fix this relatively easily with the new reflection infrastructure @TimothyGu has put in place. However, we should probably wait until #2926 lands first to avoid merge conflicts...
Basic info:
<textarea>
s have a defaultmaxLength
of 0, which is a valid maximum allowed value length indicating that users can't enter text. As a result, code that inspectsmaxLength
(eg. testing libraries simulating user input which may restrict input events based onmaxLength
) may consider0
to mean "no limit" to support jsdom, which makes support across both jsdom and browsers difficult.In contrast,
<input>
elements have different behaviour, which will return a reasonably high value when no value has been set (while modern browsers tend to use -1, is still reasonable).Minimal reproduction case
How does similar code behave in browsers?
https://jsfiddle.net/9sdzb2xc/
The text was updated successfully, but these errors were encountered: