-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change minlength/maxlength behavior around linebreaks #1712
Conversation
As discussed in #1467, the current situation around these attributes is not very interoperable. Some browsers count line breaks as two characters (per the spec before this change), others as one character. Per discussions, this updates minlength and maxlength to count line breaks as one character. We believe this is the most developer-friendly approach, as evidenced in part by repeated complaints against Chromium for its behavior following the previous standard. While here, updated the textLength property to return the code-point length of the element's API value, instead of the element's value, since as per http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4304 that is what browsers actually do. Fixes part of #1467, but the debate remains about code-unit length vs. code-point length vs. number of grapheme clusters.
lgtm though I'm not sure if we should convert "normalize" to "normalise" in this change. |
Yeah, treating CRLF as a single character for the purpose of applying max/minlength seems like a good idea and it will improve the interoperability of browsers. |
transformation applied:</p> | ||
<p>The algorithm for obtaining the element's <span data-x="concept-fe-api-value">API value</span> | ||
is to return the element's <span data-x="concept-textarea-raw-value">raw value</span> with the | ||
<span>textarea linebreak normalisation transformation</span> applied. The <dfn>textarea linebreak |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
24 hits for "line break" in HTML, 0 for "linebreak"
Updated linebreak vs. line break. New suggested commit message including the bit about the conformance requirement:
|
Thanks @domenic! |
This is a successor to #1517 which concentrates on the less-controversial part of the change, of changing linebreaks to count as 1 character (aligning with Edge and Firefox and with @tkent-google's suggestion for Chrome).
/cc @tkent-google, @rniwa, @kojiishi. In particular I'm hoping to hear from @rniwa if he is willing to change this aspect of the behavior. Let's mark this as "do not merge yet" until he weighs in.
As discussed in #1467, the current situation around these attributes is
not very interoperable. Some browsers count line breaks as two
characters (per the spec before this change), others as one character.
Per discussions, this updates minlength and maxlength to count line
breaks as one character. We believe this is the most developer-friendly
approach, as evidenced in part by repeated complaints against Chromium
for its behavior following the previous standard.
While here, updated the textLength property to return the code-point
length of the element's API value, instead of the element's value, since
as per http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4304
that is what browsers actually do.
Fixes part of #1467, but the debate remains about code-unit length vs.
code-point length vs. number of grapheme clusters.