Skip to content

Commit 3d2719a

Browse files
committed
Clamp selection and text entry cursor position on value changes
Fixes whatwg#2424. Fixes whatwg#2411. Fixes whatwg#3468.
1 parent a4cc068 commit 3d2719a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

source

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54750,6 +54750,43 @@ MIT Room 32-G524
5475054750
data-x="">replacedB</code>".</p>
5475154751
</div>
5475254752

54753+
<p>Whenever the <span data-x="concept-textarea/input-relevant-value">relevant value</span> changes
54754+
for an element to which these APIs apply, run these steps:</p>
54755+
54756+
<ol>
54757+
<li>
54758+
<p>If the element has a <span data-x="concept-textarea/input-selection">selection</span>:</p>
54759+
54760+
<ol>
54761+
<li><p>If the start of the selection is now past the end of the <span
54762+
data-x="concept-textarea/input-relevant-value">relevant value</span>, set it to the end of the
54763+
<span data-x="concept-textarea/input-relevant-value">relevant value</span>.</p></li>
54764+
54765+
<li><p>If the end of the selection is now past the end of the <span
54766+
data-x="concept-textarea/input-relevant-value">relevant value</span>, set it to the end of the
54767+
<span data-x="concept-textarea/input-relevant-value">relevant value</span>.</p></li>
54768+
54769+
<li><p>If the user agent does not support empty selection, and both the start and end of the
54770+
selection are now pointing to the end of the <span
54771+
data-x="concept-textarea/input-relevant-value">relevant value</span>, then instead set the
54772+
element's <span data-x="concept-textarea/input-cursor">text entry cursor position</span> to the
54773+
end of the <span data-x="concept-textarea/input-relevant-value">relevant value</span>, removing
54774+
any selection.</p></li>
54775+
</ol>
54776+
</li>
54777+
54778+
<li><p>Otherwise, the element must have a <span data-x="concept-textarea/input-cursor">text entry
54779+
cursor position</span> position. If it is now past the end of the <span
54780+
data-x="concept-textarea/input-relevant-value">relevant value</span>, set it to the end of the
54781+
<span data-x="concept-textarea/input-relevant-value">relevant value</span>.</p></li>
54782+
</ol>
54783+
54784+
<p class="note">In some cases where the <span
54785+
data-x="concept-textarea/input-relevant-value">relevant value</span> changes, other parts of the
54786+
specification will also modify the <span data-x="concept-textarea/input-cursor">text entry cursor
54787+
position</span>, beyond just the clamping steps above. For example, see the <code
54788+
data-x="dom-textarea-value">value</code> setter for <code>textarea</code>.</p>
54789+
5475354790
<p>Characters with no visible rendering, such as U+200D ZERO WIDTH JOINER, still count as
5475454791
characters. Thus, for instance, the selection can include just an invisible character, and the
5475554792
text insertion cursor can be placed to one side or another of such a character.</p>

0 commit comments

Comments
 (0)