TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Chrome 133 Supports DOM State-Preserving Move with moveBefore()

226 pointsby AshleysBrain3 months ago

16 comments

btown3 months ago
FYI a quick search shows that React has already integrated this on its main branch!<p><a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;react&#x2F;pull&#x2F;32036">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;react&#x2F;pull&#x2F;32036</a><p>I&#x27;m not exactly sure what the developer experience of this would be, but I expect it would make Portals significantly more powerful and able to be hot-swapped into different containers without disrupting either their internal state or even things like loaded iFrames. I expect others will be experimenting heavily with this now that there&#x27;s platform support.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;react&#x2F;issues&#x2F;12247">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;react&#x2F;issues&#x2F;12247</a> (2018-2020) describes some of the use cases, with one partial solution being <a href="https:&#x2F;&#x2F;github.com&#x2F;httptoolkit&#x2F;react-reverse-portal">https:&#x2F;&#x2F;github.com&#x2F;httptoolkit&#x2F;react-reverse-portal</a> - the conversation around caveats of these approaches would be entirely different now!
评论 #42950686 未加载
评论 #42990840 未加载
recursivedoubts3 months ago
htmx has supported moveBefore() since 2.0.3 in October of last year:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;bigskysoftware&#x2F;htmx&#x2F;blob&#x2F;master&#x2F;CHANGELOG.md#203---2024-10-03">https:&#x2F;&#x2F;github.com&#x2F;bigskysoftware&#x2F;htmx&#x2F;blob&#x2F;master&#x2F;CHANGELOG...</a><p><a href="https:&#x2F;&#x2F;htmx.org&#x2F;examples&#x2F;move-before&#x2F;" rel="nofollow">https:&#x2F;&#x2F;htmx.org&#x2F;examples&#x2F;move-before&#x2F;</a><p>We initially asked for this new feature about two years ago and have worked with the Chrome team as they have implemented it. It is going to be a huge step forward for the web!
评论 #42966773 未加载
评论 #42968116 未加载
评论 #42959902 未加载
wlib3 months ago
The biggest benefit to this is that it makes one of the slowest parts of virtual DOM diffing (longest common subsequence) no longer required. After this becomes supported in the mainstream, not even signal-based frameworks will have to include VDOM algorithms. I know this because I remember pushing for this to be supported a few years ago — a nice reminder that the standards are evolving and that nothing stops you from being a small part of the effort.<p>Next up — DOM parts and standardized signals, unified.
评论 #42952819 未加载
评论 #42953107 未加载
评论 #42952915 未加载
评论 #42977324 未加载
spankalee3 months ago
This is going to be great for rendering libraries that do keyed loops and for some portal systems.<p>You&#x27;ll be able to reorder items in a list while preserving focus, without reloading iframes, and keeping audio and video playing.<p>We have a draft PR for support in Lit, and will try to ship that as soon as possible.
评论 #42950277 未加载
salve-for-tears3 months ago
Wow! This is actually an amazing feature. Rendering a list of items in which the order can change has always been annoying. I can see this feature greatly improving the situation.
评论 #42949000 未加载
e403 months ago
Any idea how long before this makes it into Firefox?
评论 #42948516 未加载
评论 #42949502 未加载
评论 #42949975 未加载
评论 #42951921 未加载
评论 #42967073 未加载
paradox4603 months ago
This is one of those little changes that just quietly drops, and winds up having tremendous impact. Like XMLHttpRequest back in the day
cetinsert3 months ago
<a href="https:&#x2F;&#x2F;dom.rt.ht&#x2F;moveBefore" rel="nofollow">https:&#x2F;&#x2F;dom.rt.ht&#x2F;moveBefore</a> is a playground with 2-way I-O sync!<p>The editor of the playground shows you the live DOM in its editor.
评论 #42961750 未加载
tommiegannert3 months ago
Why isn&#x27;t it better to redefine insertBefore of an already inserted element to being state-preserving? If I want to kill state, I can do a remove first.
评论 #42959966 未加载
etchalon3 months ago
This is one of those things you&#x27;re shocked to find out didn&#x27;t exist before.
sureIy3 months ago
In typical Chrome fashion, they shipped an API that is in status &quot;Specification currently under development in a Working Group&quot;<p>I don&#x27;t understand the need for this awkward API.<p>Ok, `otherParent.append(existingIframe)` reloads the iframe, but that&#x27;s just a legacy behavior. Why not toggle the new behavior by calling `existingIframe.holdMyBeer()`? This way I could just continue using .prepend&#x2F;.append&#x2F;.before&#x2F;.after et — which by the way support multiple elements at once, unlike moveBefore.<p>Ridiculous choice, but I&#x27;m not even surprised anymore.
评论 #42954102 未加载
评论 #42954281 未加载
评论 #42957229 未加载
XCSme3 months ago
Nice, I was just adding <a href="https:&#x2F;&#x2F;github.com&#x2F;react-grid-layout&#x2F;react-grid-layout">https:&#x2F;&#x2F;github.com&#x2F;react-grid-layout&#x2F;react-grid-layout</a> to a dashboard, where you can drag&#x2F;re-order charts. I assume this would make the implementation better.
klinch3 months ago
Honestly curious - Does anyone have a use case for this? I tried hard to figure out what this could be used for, but couldn&#x27;t come up with anything.
评论 #42947945 未加载
评论 #42947615 未加载
评论 #42948043 未加载
评论 #42949815 未加载
评论 #42956375 未加载
评论 #42947429 未加载
评论 #42950001 未加载
评论 #42947656 未加载
评论 #42948709 未加载
评论 #42947734 未加载
knowitnone3 months ago
Have we seen any drops in Chrome marketshare?
tengbretson3 months ago
I haven&#x27;t thought through how, but being able to move an element that has focus just has the feeling of something that could be exploited.
qwertox3 months ago
If they could only fix the issue where resizing a text box almost grinds the entire OS to a halt, that would be nice.