Skip to content

Only drop the insertion cursor when it's detached - #5273

Merged
JoviDeCroock merged 2 commits into
mainfrom
JoviDeCroock/detached-cursor
Sep 28, 2026
Merged

JoviDeCroock merged 2 commits into
mainfrom
JoviDeCroock/detached-cursor

Conversation

@JoviDeCroock

Copy link
Copy Markdown
Member

Note

Co-Authored with Claude

The #5251 fix (b3ea099) drops the insertion cursor whenever oldDom.parentNode != parentDom. Containers that aren't the real parent of their children never pass that check: createRootFragment() from preact-root-fragment (the upgrade guide's replacement for replaceNode), Fresh islands and partials, and WordPress Interactivity regions. Every insert then appends to the end, so prepends, middle inserts and keyed reorders come out in the wrong order, and hydration removes and re-inserts every root node (iframes reload, focus is lost).

The only cursor #5251 needs to drop is one that a parked Suspense subtree detached (parentNode == null), so this checks for that inside the existing getDomSibling() retry instead. The #5251 test stays green, and a root-fragment style container gets its own test.

-5 B brotli on preact.mjs.

Fake containers still need to implement moveBefore() in browsers that support it; preactjs/preact-root-fragment#4 adds that.

The #5251 fix dropped the cursor whenever its parentNode wasn't the container. Containers that aren't the real parent of their children, like createRootFragment() from preact-root-fragment, are never that parentNode, so every insert appended: prepends and reorders came out in the wrong order and hydration re-inserted every root node. Only a cursor that a parked Suspense subtree detached needs dropping.
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

📊 Tachometer Benchmark Results

Summary

⏳ Benchmarks are currently running. Results below are out of date.

duration

  • create10k: unsure 🔍 -0% - +1% (-3.94ms - +6.76ms)
    preact-local vs preact-main
  • filter-list: faster ✔ 0% - 1% (0.01ms - 0.13ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -4% - +1% (-2.00ms - +0.45ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -2% - +1% (-0.36ms - +0.13ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -3% - +2% (-2.28ms - +1.35ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -5% - +5% (-0.09ms - +0.09ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -0% - +2% (-0.06ms - +0.68ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -5% - +3% (-1.44ms - +1.09ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -5% - +5% (-0.24ms - +0.25ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -3% - +2% (-0.03ms - +0.02ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main

Results

⏳ Benchmarks are currently running. Results below are out of date.
create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local837.70ms - 846.28ms-unsure 🔍
-0% - +1%
-3.94ms - +6.76ms
preact-main837.38ms - 843.77msunsure 🔍
-1% - +0%
-6.76ms - +3.94ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.08ms - 19.08ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main19.08ms - 19.08msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.51ms - 16.57ms-faster ✔
0% - 1%
0.01ms - 0.13ms
preact-main16.56ms - 16.66msslower ❌
0% - 1%
0.01ms - 0.13ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.56ms - 1.56ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.56ms - 1.56msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local51.96ms - 53.67ms-unsure 🔍
-4% - +1%
-2.00ms - +0.45ms
preact-main52.71ms - 54.46msunsure 🔍
-1% - +4%
-0.45ms - +2.00ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.98ms - 5.36ms-unsure 🔍
-5% - +5%
-0.24ms - +0.25ms
preact-main5.01ms - 5.31msunsure 🔍
-5% - +5%
-0.25ms - +0.24ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.18ms - 16.50ms-unsure 🔍
-2% - +1%
-0.36ms - +0.13ms
preact-main16.26ms - 16.64msunsure 🔍
-1% - +2%
-0.13ms - +0.36ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.74ms - 3.75ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.74ms - 3.75msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #5998
  • Commit: b5b558b

duration

VersionAvg timevs preact-localvs preact-main
preact-local86.65ms - 88.91ms-unsure 🔍
-3% - +2%
-2.28ms - +1.35ms
preact-main86.82ms - 89.67msunsure 🔍
-2% - +3%
-1.35ms - +2.28ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.01ms - 3.02ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.01ms - 3.01msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local25.90ms - 26.55ms-unsure 🔍
-3% - +1%
-0.88ms - +0.22ms
preact-main26.12ms - 27.00msunsure 🔍
-1% - +3%
-0.22ms - +0.88ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local31.75ms - 32.68ms-unsure 🔍
-3% - +1%
-1.06ms - +0.29ms
preact-main32.11ms - 33.08msunsure 🔍
-1% - +3%
-0.29ms - +1.06ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local31.95ms - 33.39ms-unsure 🔍
-1% - +5%
-0.31ms - +1.61ms
preact-main31.39ms - 32.65msunsure 🔍
-5% - +1%
-1.61ms - +0.31ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local29.56ms - 30.28ms-unsure 🔍
-3% - +1%
-0.77ms - +0.34ms
preact-main29.71ms - 30.57msunsure 🔍
-1% - +3%
-0.34ms - +0.77ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local20.77ms - 20.95ms-unsure 🔍
-1% - +1%
-0.25ms - +0.13ms
preact-main20.75ms - 21.08msunsure 🔍
-1% - +1%
-0.13ms - +0.25ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local27.06ms - 27.80ms-unsure 🔍
-2% - +2%
-0.58ms - +0.52ms
preact-main27.06ms - 27.86msunsure 🔍
-2% - +2%
-0.52ms - +0.58ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 200
  • Built by: CI #5998
  • Commit: b5b558b

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.78ms - 1.91ms-unsure 🔍
-5% - +5%
-0.09ms - +0.09ms
preact-main1.79ms - 1.91msunsure 🔍
-5% - +5%
-0.09ms - +0.09ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.00ms - 1.03ms-unsure 🔍
-3% - +2%
-0.03ms - +0.02ms
preact-main1.00ms - 1.04msunsure 🔍
-2% - +3%
-0.02ms - +0.03ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local31.51ms - 32.20ms-unsure 🔍
-0% - +2%
-0.06ms - +0.68ms
preact-main31.40ms - 31.69msunsure 🔍
-2% - +0%
-0.68ms - +0.06ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.27ms - 1.27ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.27ms - 1.27msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local30.22ms - 32.11ms-unsure 🔍
-5% - +3%
-1.44ms - +1.09ms
preact-main30.50ms - 32.18msunsure 🔍
-4% - +5%
-1.09ms - +1.44ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.97ms - 2.99ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-main2.97ms - 2.98msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-

tachometer-reporter-action v2 for CI

@github-actions

Copy link
Copy Markdown

Size Change: -4 B (-0.03%)

Total Size: 15.9 kB

📦 View Changed
Filename Size Change
dist/preact.mjs 4.95 kB -4 B (-0.08%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.mjs 3.92 kB
debug/dist/debug.mjs 3.88 kB
devtools/dist/devtools.mjs 273 B
hooks/dist/hooks.mjs 1.58 kB
jsx-runtime/dist/jsxRuntime.mjs 868 B
test-utils/dist/testUtils.mjs 473 B

compressed-size-action

@coveralls

coveralls commented Sep 28, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 99.853%. remained the same — JoviDeCroock/detached-cursor into main

@JoviDeCroock
JoviDeCroock merged commit 8fb4403 into main Sep 28, 2026
4 checks passed
@JoviDeCroock
JoviDeCroock deleted the JoviDeCroock/detached-cursor branch September 28, 2026 08:35
@JoviDeCroock JoviDeCroock mentioned this pull request Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants