Fix incorrect DOM order with conditional ContextProvider and inner keys by JoviDeCroock · Pull Request #5067 · preactjs/preact (original) (raw)

@JoviDeCroock

…ys (#5065)

When a VNode is moved via INSERT_VNODE during diffChildren, its old _dom pointer becomes a stale positional reference. Nested diffs that call getDomSibling would traverse the old VNode tree and find this stale _dom, causing subsequent DOM insertions at the wrong position.

Clear the old VNode's _dom after insert so getDomSibling skips moved VNodes and finds the correct insertion point.

marvinhagemeister

@JoviDeCroock JoviDeCroock deleted the fix/5065-dom-order-context-provider-keys branch

March 26, 2026 17:22

@rschristian rschristian linked an issue

Mar 26, 2026

that may beclosed by this pull request

JoviDeCroock added a commit that referenced this pull request

May 16, 2026

@JoviDeCroock

When a VNode is moved via INSERT_VNODE during diffChildren, its old _dom pointer becomes a stale positional reference. Nested diffs that call getDomSibling would traverse the old VNode tree and find this stale _dom, causing subsequent DOM insertions at the wrong position.

Clear the old VNode's _dom after insert so getDomSibling skips moved VNodes and finds the correct insertion point.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})