Skip to content
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

Merged
merged 2 commits into from
Aug 26, 2016

Conversation

domenic
Copy link
Member

@domenic domenic commented Aug 24, 2016

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.

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.
@tkent-google
Copy link
Contributor

lgtm though I'm not sure if we should convert "normalize" to "normalise" in this change.

@rniwa
Copy link

rniwa commented Aug 25, 2016

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
Copy link
Member

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"

@domenic
Copy link
Member Author

domenic commented Aug 25, 2016

Updated linebreak vs. line break. New suggested commit message including the bit about the conformance requirement:

Change minlength/maxlength behavior around linebreaks 

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. Similarly, updated the conformance
requirement on the text content of the textarea element to match
maxlength's actually-implemented behavior.

Fixes part of #1467, but the debate remains about code-unit length vs.
code-point length vs. number of grapheme clusters.

@domenic domenic removed the do not merge yet Pull request must not be merged per rationale in comment label Aug 25, 2016
@annevk annevk merged commit 1637031 into master Aug 26, 2016
@annevk
Copy link
Member

annevk commented Aug 26, 2016

Thanks @domenic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants