Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,36 @@ <h3 id="editcontext-interface">EditContext Interface</h3>
<dt>characterBoundsRangeStart</dt>
<dd>The {{EditContext/characterBoundsRangeStart}} getter steps are to return [=this=]'s [=codepoint rects start index=].</dd>

<dt>EditContext() constructor</dt>
<dd>
<p>
The constructor must follow these steps:
</p>
<div class="algorithm">
<dl>
<dt>Input</dt>
<dd>|options|, an {{EditContextInit}}</dd>
<dt>Output</dt>
<dd>None</dd>
</dl>
<ol>
<li>
Set [=text=] to |options|["{{EditContextInit/text}}"].
</li>
<li>
If |options|["{{EditContextInit/selectionStart}}"] or |options|["{{EditContextInit/selectionEnd}}"]
is greater than the length of [=text=], throw a {{RangeError}}.
</li>
<li>
Set [=selection start=] to |options|["{{EditContextInit/selectionStart}}"].
</li>
<li>
Set [=selection end=] to |options|["{{EditContextInit/selectionStart}}"].
</li>
</ol>
</div>
</dd>

<dt>updateText() method</dt>
<dd>
<p>
Expand All @@ -1088,10 +1118,26 @@ <h3 id="editcontext-interface">EditContext Interface</h3>
<dd>None</dd>
</dl>
<ol>
<li>
If |rangeStart| is greater than the length of [=text=],
set |rangeStart| to the length of [=text=].

@ltenmoz ltenmoz Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, let's add steps here to make it clear that it's intended behaviour that these can be > text.length

</li>
<li>
If |rangeEnd| is greater than the length of [=text=],
set |rangeEnd| to the length of [=text=].
</li>
<li>
Replace the substring of [=text=] in the range of |rangeStart| and |rangeEnd| with |newText|
<div class="note">It's permissible that |rangeStart| > |rangeEnd|. The substring between the indices should be replaced in the same way as if |rangeStart| and |rangeEnd| were swapped.</div>
</li>
<li>
If [=selection start=] is greater than the length of [=text=], set
[=selection start=] to the length of [=text=].
</li>
<li>
If [=selection end=] is greater than the length of [=text=], set
[=selection end=] to the length of [=text=].
</li>
</ol>
</div>
</dd>
Expand All @@ -1109,6 +1155,10 @@ <h3 id="editcontext-interface">EditContext Interface</h3>
<dd>None</dd>
</dl>
<ol>
<li>
If |start| or |end| is greater than the length of [=text=],
throw a {{RangeError}}.
</li>
<li>
set [=selection start=] to |start|
</li>
Expand Down
Loading