- From: Steven Obiajulu <notifications@github.com>
- Date: Mon, 23 Feb 2026 20:35:43 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/pull/1452@github.com>
Collapse range before mutations in deleteContents and extract
Move the step that sets the range's start and end to (newNode, newOffset) from after DOM mutations to before them, in both `deleteContents()` and the `extract` algorithm. The DOM's built-in live range maintenance mechanisms (`live range pre-remove steps` and `replace data` range adjustments) keep the range valid through subsequent operations. Collapsing after mutations is unreliable because script can run during removal (via removing steps) and modify the DOM, invalidating the pre-computed values.
Fixes #1446.
---
- [ ] At least two implementers are interested (and none opposed):
* …
* …
- [x] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
* https://github.com/web-platform-tests/wpt/pull/58008
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
* Chromium: https://issues.chromium.org/issues/486922855
* Gecko: https://bugzilla.mozilla.org/show_bug.cgi?id=2018839
* WebKit: pending (account approval required on bugs.webkit.org)
- [x] [MDN issue](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) is filed: https://github.com/mdn/content/issues/43230
- [x] The top of this comment includes a [clear commit message](https://github.com/whatwg/meta/blob/main/COMMITTING.md) to use.
(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)
You can view, comment on, or merge this pull request online at:
https://github.com/whatwg/dom/pull/1452
-- Commit Summary --
* Collapse range before mutations in deleteContents and extract
-- File Changes --
M dom.bs (30)
-- Patch Links --
https://github.com/whatwg/dom/pull/1452.patch
https://github.com/whatwg/dom/pull/1452.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1452
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/pull/1452@github.com>
Received on Tuesday, 24 February 2026 04:35:47 UTC