diff --git a/dom.bs b/dom.bs index e61c3fc0..13be0006 100644 --- a/dom.bs +++ b/dom.bs @@ -4,6 +4,7 @@ H1: DOM Shortname: dom Text Macro: TWITTER thedomstandard Text Macro: LATESTRD 2025-06 +Text Macro: COMMIT-SHA 0000000 Abstract: DOM defines a platform-neutral model for events, aborting activities, and node trees. Translation: ja https://triple-underscore.github.io/DOM4-ja.html Translation: zh-Hans https://htmlspecs.com/dom/ @@ -9892,6 +9893,176 @@ and {{Range/getBoundingClientRect()}} methods are defined in other specification [[CSSOM-VIEW]] +
+[Exposed=Window] +interface FormControlRange : AbstractRange { + constructor(); + + undefined setFormControlRange((HTMLInputElement or HTMLTextAreaElement) element, + unsigned long startOffset, + unsigned long endOffset + ); + + + DOMRectList getClientRects(); + DOMRect getBoundingClientRect(); + stringifier; +}; ++ +
Objects implementing the {{FormControlRange}} interface are known as {{FormControlRange}} objects. + +
formControlRange = new
+ FormControlRange()
+ formControlRange.
+ {{FormControlRange/setFormControlRange()}}(element,
+ startOffset, endOffset)
+ [startOffset, endOffset]
within element's
+value string. Throws {{NotSupportedError}} for
+unsupported elements and {{IndexSizeError}} for out-of-bounds offsets.
+A {{FormControlRange}} is a range whose boundary points are defined in the host text
+control's value string rather than in the node tree.
+Its start node and end node are always the host <input>
+or <textarea>
, and its offsets are indices into that string.
+
+
A {{FormControlRange}} has associated state: + +
control (null or an + {{HTMLInputElement}}/{{HTMLTextAreaElement}}). + +
start offset (a + non-negative integer). + +
end offset (a non-negative + integer). +
The startContainer getter steps are to return this's +control. + +
The endContainer getter steps are to return this's +control. + +
The startOffset getter steps are to return this's +start offset. + +
The endOffset getter steps are to return this's +end offset. + +
The collapsed getter steps are to return true if this's +start offset equals this's +end offset; otherwise false. + +
An {{Element}} el
+supports form control range if it is an
+{{HTMLTextAreaElement}}, or an {{HTMLInputElement}} whose type is one of
+"text
", "search
", "tel
", "url
", or
+"password
".
+
+
These are exactly the types for which the related selection APIs
+apply in HTML; see
+selection APIs applicability for input
types.
+This list is the complement of that section.
The
+new FormControlRange()
constructor steps are to set this's
+control to null and its start offset and
+end offset to 0.
+
+
For a supported host element el, its
+value string is the same string exposed by its IDL
+attribute {{HTMLInputElement/value}}/{{HTMLTextAreaElement/value}}. Offsets for {{FormControlRange}}
+are indices into this value string in the inclusive
+range [0, value.length
], matching
+{{HTMLInputElement/selectionStart}}/{{HTMLInputElement/selectionEnd}} and
+{{HTMLTextAreaElement/selectionStart}}/{{HTMLTextAreaElement/selectionEnd}} units.
The
+setFormControlRange(element, startOffset,
+endOffset)
method steps are:
+
+
If element does not support form control range, then throw a + "{{NotSupportedError!!exception}}" {{DOMException}}. + +
Let len be the length of element's +value string. + +
If startOffset > len or endOffset > len, + then throw an "{{IndexSizeError!!exception}}" {{DOMException}}. + +
If startOffset > endOffset, then set endOffset to + startOffset. + +
Set this's control to element, + this's start offset to startOffset, and + this's end offset to endOffset. +
If an {{HTMLInputElement}}'s type
changes to a type that does not
+support form control range (e.g., switching to date
), then each associated
+{{FormControlRange}} must set its control to null and set both its
+start offset and end offset to 0.
+
+
HTML will normatively call the associated range-adjustment algorithm wherever a +control’s value changes or its type ceases to support selection.
+ +A {{FormControlRange}} is live: when the control's value +string changes, the range's {{AbstractRange/startOffset}} and {{AbstractRange/endOffset}} are +updated automatically to preserve the same logical content. These behaviors mirror {{Range}} +boundary adjustments in the DOM, but are applied to the UTF-16 code units of a form control's value. + +
Edits before the range: Offsets shift by the net length change. + +
Edits after the range: Offsets remain unchanged. + +
Edits overlapping the range: If a boundary falls inside text that was removed, move it to the + start of the change. If the edit also inserted new text, remap the boundary into the inserted span + at the closest corresponding offset, not exceeding its end. + +
Insertion at the start boundary: A non-{{AbstractRange/collapsed}} range expands to include + the new text. A collapsed range (caret) moves after the insertion. + +
Insertion at the end boundary: A non-collapsed range does not expand to include the new text. + A collapsed range moves after the insertion. + +
Clamping and collapse: Offsets are clamped to the current value length. If the + {{AbstractRange/startOffset}} would exceed the {{AbstractRange/endOffset}}, set the end to the + start. +
The stringification +behavior must run these steps:
+ +Let value be this's control's + value string.
Let start be this's start offset, and let + end be this's end offset.
Return the substring of value from start to end.