Skip to content

Commit a4cc068

Browse files
committed
Change textarea's relevant value to its API value
Per the test case included as an example in the spec, this is more in line with browser behavior, and makes more sense. A similar conclusion was reached on related matters in whatwg#2424, and also in whatwg#2437.
1 parent 2e8be71 commit a4cc068

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

source

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54726,10 +54726,30 @@ MIT Room 32-G524
5472654726

5472754727
<p>For <code>input</code> elements, these APIs must operate on the element's <span
5472854728
data-x="concept-fe-value">value</span>. For <code>textarea</code> elements, these APIs must
54729-
operate on the element's <span data-x="concept-textarea-raw-value">raw value</span>. In the below
54729+
operate on the element's <span data-x="concept-fe-api-value">API value</span>. In the below
5473054730
algorithms, we call the value string being operated on the <dfn
5473154731
data-x="concept-textarea/input-relevant-value">relevant value</dfn>.</p>
5473254732

54733+
<div class="example">
54734+
<p>The use of <span data-x="concept-fe-api-value">API value</span> instead of <span
54735+
data-x="concept-textarea-raw-value">raw value</span> for <code>textarea</code> elements means
54736+
that U+000D (CR) characters are normalized away. For example,
54737+
54738+
<pre>&lt;textarea id="demo">&lt;/textarea>
54739+
&lt;script>
54740+
demo.value = "A\r\nB";
54741+
demo.setRangeText("replaced", 0, 2);
54742+
assert(demo.value === "replacedB");
54743+
&lt;/script></pre>
54744+
54745+
<p>If we had operated on the <span data-x="concept-textarea-raw-value">raw value</span> of "<code
54746+
data-x="">A\r\nB</code>", then we would have replaced the characters "<code
54747+
data-x="">A\r</code>", ending up with a result of "<code data-x="">replaced\nB</code>". But since
54748+
we used the <span data-x="concept-fe-api-value">API value</span> of "<code
54749+
data-x="">A\nB</code>", we replaced the characters "<code data-x="">A\n</code>", giving "<code
54750+
data-x="">replacedB</code>".</p>
54751+
</div>
54752+
5473354753
<p>Characters with no visible rendering, such as U+200D ZERO WIDTH JOINER, still count as
5473454754
characters. Thus, for instance, the selection can include just an invisible character, and the
5473554755
text insertion cursor can be placed to one side or another of such a character.</p>

0 commit comments

Comments
 (0)