Skip to content

Integrate OpaqueRange hooks into text controls (input/textarea)#11741

Open
stephanieyzhang wants to merge 17 commits intowhatwg:mainfrom
stephanieyzhang:stzhang-addfcr
Open

Integrate OpaqueRange hooks into text controls (input/textarea)#11741
stephanieyzhang wants to merge 17 commits intowhatwg:mainfrom
stephanieyzhang:stzhang-addfcr

Conversation

@stephanieyzhang
Copy link
Copy Markdown

@stephanieyzhang stephanieyzhang commented Oct 2, 2025

OpaqueRange is a specialized, live AbstractRange subtype whose boundary points reference internal nodes within host-defined elements (e.g., <input>/<textarea> today, with a path to custom elements in the future). It enables range-based operations over encapsulated content while avoiding exposure of internal DOM nodes.

(See WHATWG Working Mode: Changes for more details.)


/form-control-infrastructure.html ( diff )
/form-elements.html ( diff )
/infrastructure.html ( diff )
/input.html ( diff )

@stephanieyzhang stephanieyzhang changed the title Add FormControlRange hooks [DO NOT REVIEW] FormControlRange hooks Oct 2, 2025
@stephanieyzhang stephanieyzhang changed the title [DO NOT REVIEW] FormControlRange hooks Integrate FormControlRange hooks into text controls (input/textarea) Oct 9, 2025
@stephanieyzhang stephanieyzhang changed the title Integrate FormControlRange hooks into text controls (input/textarea) Integrate PlainTextRange hooks into text controls (input/textarea) Dec 4, 2025
@stephanieyzhang stephanieyzhang changed the title Integrate PlainTextRange hooks into text controls (input/textarea) Integrate OpaqueRange hooks into text controls (input/textarea) Jan 14, 2026
Copy link
Copy Markdown
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Where is "supports opaque ranges" defined?

Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
@stephanieyzhang
Copy link
Copy Markdown
Author

Where is "supports opaque ranges" defined?

Whoops, forgot to define that 🤦. Added it to the "APIs for the text control selections" section. Let me know if you'd prefer it placed elsewhere as I wasn't sure where the best spot for it was.

Comment thread source Outdated
Comment thread source Outdated
@annevk annevk linked an issue Feb 12, 2026 that may be closed by this pull request
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Feb 26, 2026
The new name makes it explicitly clear that a new range is created each
time, as suggested in HTML spec PR discussion:
whatwg/html#11741 (comment)

Updates the OpaqueRangeCreation mixin and IDL, all implementing classes
(TextControlElement, HTMLInputElement), and test files.

Low-Coverage-Reason: COVERAGE_UNDERREPORTED
Bug: 421421332
Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Feb 26, 2026
The new name makes it explicitly clear that a new range is created each
time, as suggested in HTML spec PR discussion:
whatwg/html#11741 (comment)

Updates the OpaqueRangeCreation mixin and IDL, all implementing classes
(TextControlElement, HTMLInputElement), and test files.

Low-Coverage-Reason: COVERAGE_UNDERREPORTED
Bug: 421421332
Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86
beckysiegel pushed a commit to chromium/chromium that referenced this pull request Feb 26, 2026
The new name makes it explicitly clear that a new range is created each
time, as suggested in HTML spec PR discussion:
whatwg/html#11741 (comment)

Updates the OpaqueRangeCreation mixin and IDL, all implementing classes
(TextControlElement, HTMLInputElement), and test files.

Low-Coverage-Reason: COVERAGE_UNDERREPORTED
Bug: 421421332
Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7595653
Reviewed-by: Dan Clark <daniec@microsoft.com>
Commit-Queue: Stephanie Zhang <stephanie.zhang@microsoft.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Reviewed-by: Ana Sollano Kim <ansollan@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1591036}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Feb 26, 2026
The new name makes it explicitly clear that a new range is created each
time, as suggested in HTML spec PR discussion:
whatwg/html#11741 (comment)

Updates the OpaqueRangeCreation mixin and IDL, all implementing classes
(TextControlElement, HTMLInputElement), and test files.

Low-Coverage-Reason: COVERAGE_UNDERREPORTED
Bug: 421421332
Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7595653
Reviewed-by: Dan Clark <daniec@microsoft.com>
Commit-Queue: Stephanie Zhang <stephanie.zhang@microsoft.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Reviewed-by: Ana Sollano Kim <ansollan@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1591036}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Feb 26, 2026
The new name makes it explicitly clear that a new range is created each
time, as suggested in HTML spec PR discussion:
whatwg/html#11741 (comment)

Updates the OpaqueRangeCreation mixin and IDL, all implementing classes
(TextControlElement, HTMLInputElement), and test files.

Low-Coverage-Reason: COVERAGE_UNDERREPORTED
Bug: 421421332
Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7595653
Reviewed-by: Dan Clark <daniec@microsoft.com>
Commit-Queue: Stephanie Zhang <stephanie.zhang@microsoft.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Reviewed-by: Ana Sollano Kim <ansollan@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1591036}
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Mar 4, 2026
…eateValueRange(), a=testonly

Automatic update from web-platform-tests
Rename OpaqueRange getValueRange() to createValueRange()

The new name makes it explicitly clear that a new range is created each
time, as suggested in HTML spec PR discussion:
whatwg/html#11741 (comment)

Updates the OpaqueRangeCreation mixin and IDL, all implementing classes
(TextControlElement, HTMLInputElement), and test files.

Low-Coverage-Reason: COVERAGE_UNDERREPORTED
Bug: 421421332
Change-Id: Iec9572c470443e85d2a38ecd978bd7c78e8c5a86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7595653
Reviewed-by: Dan Clark <daniec@microsoft.com>
Commit-Queue: Stephanie Zhang <stephanie.zhang@microsoft.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Reviewed-by: Ana Sollano Kim <ansollan@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1591036}

--

wpt-commits: 4c5d702b40927803c1024376687a6ca84e877720
wpt-pr: 58079
@stephanieyzhang stephanieyzhang marked this pull request as ready for review April 23, 2026 15:57
Comment thread source
Comment on lines +55448 to +55450
<p>Before queuing that task, if the element <span>supports opaque ranges</span>, then run the
<span>opaque range replacement steps</span> with the element, the edit's code unit offset, the
number of code units removed, and the number of code units inserted.</p>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Before queuing that task" doesn't seem right.

I think this requires more substantial editing to ensure the steps are in order, so it goes:

  • Any time the user causes change...
  • Update opaque ranges
  • Queue a task.

It might be worth breaking this out into an algorithm so it's easier to follow, rather than a dense paragraph though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This says to run opaque range replacement steps, and then queue a task to fire the input event. Is that correct? Or should the checking of "supports opaque ranges" and running "opaque range replacement steps" happen in the same task as firing the input event?

Comment thread source
interaction before queuing the task; for example, a user agent could wait for the user to have not
hit a key for 100ms, so as to only fire the event when the user pauses, instead of continuously
for each keystroke.</p>
<p>Before queuing that task, if the element <span>supports opaque ranges</span>, then run the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here, these steps should be in order.

Comment thread source
Comment on lines +62474 to +62479
<p>A <code>textarea</code> element, or an <code>input</code> element whose <code
data-x="attr-input-type">type</code> attribute is in the <span
data-x="attr-input-type-text">Text</span>, <span data-x="attr-input-type-search">Search</span>,
<span data-x="attr-input-type-tel">Telephone</span>, <span
data-x="attr-input-type-url">URL</span>, or <span
data-x="attr-input-type-password">Password</span> state, <span>supports opaque ranges</span>.</p>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not input type="number"? Seems like it could be useful there too. I guess because setRangeText doesn't apply... which is a much bigger change. Worth thinking about perhaps?

Comment thread source
Comment on lines +57784 to +57785
data-x="concept-textarea-raw-value">raw value</span>, and the element <span>supports opaque
ranges</span>, then run the <span>opaque range full replacement steps</span> with the element,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All textareas seem to support opaque ranges so this if seems unnecessary.

Comment thread source
Comment on lines +57795 to +57796
content</span>. If this changes the element's <span data-x="concept-fe-api-value">API
value</span>, and the element <span>supports opaque ranges</span>, then run the <span>opaque
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Likewise here; textareas support opaque ranges so this seems unnecessary.

Comment thread source
true.</p></li>
<li><p>Set this element's <span data-x="concept-fe-dirty">dirty value flag</span> to true.</p></li>

<li><p>If this changes the element's <span data-x="concept-fe-api-value">API value</span>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And again here; textareas support opaque ranges so this seems unnecessary.

Comment thread source
Comment on lines +62474 to +62479
<p>A <code>textarea</code> element, or an <code>input</code> element whose <code
data-x="attr-input-type">type</code> attribute is in the <span
data-x="attr-input-type-text">Text</span>, <span data-x="attr-input-type-search">Search</span>,
<span data-x="attr-input-type-tel">Telephone</span>, <span
data-x="attr-input-type-url">URL</span>, or <span
data-x="attr-input-type-password">Password</span> state, <span>supports opaque ranges</span>.</p>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given this is always true for textarea, this could be a concept of input elements only, and perhaps could be a flag (or algo) on input elements. It seems input elements have this concept twice: They have "supports opaque ranges" and also "createValueRange() does not apply" - AIUI these are the same concept?

Unless I'm mistaken in the belief that textareas always support opaque ranges?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

OpaqueRange Interface

5 participants