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]] +

Interface {{FormControlRange}}

+ +
+[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() +
Returns a new {{FormControlRange}} that tracks text offsets in a text control's value as it + changes. + +
formControlRange. + {{FormControlRange/setFormControlRange()}}(element, + startOffset, endOffset) +
Sets the endpoints to [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: + +

+ +

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: + +

    +
  1. If element does not support form control range, then throw a + "{{NotSupportedError!!exception}}" {{DOMException}}. + +

  2. Let len be the length of element's +value string. + +

  3. If startOffset > len or endOffset > len, + then throw an "{{IndexSizeError!!exception}}" {{DOMException}}. + +

  4. If startOffset > endOffset, then set endOffset to + startOffset. + +

  5. 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. + +

+ + + +

The stringification +behavior must run these steps:

+ +
    +
  1. If this's control is null, then return the empty string.

  2. + +
  3. Let value be this's control's + value string.

  4. + +
  5. Let start be this's start offset, and let + end be this's end offset.

  6. + +
  7. Return the substring of value from start to end.

  8. +
+

Traversal