Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: use moveBefore on supported browsers#15512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
adiguba wants to merge3 commits intosveltejs:mainfromadiguba:dev/move_before

Conversation

adiguba
Copy link
Contributor

@adigubaadiguba commentedMar 14, 2025
edited
Loading

Before submitting the PR, please make sure you do the following

The PR change the API used in{#each} block to move existing node.

Currently it usebefore(). Now it use the new APImoveBefore() when the browser support it, or fallback toinsertBefore().

moveBefore() allow to move a node without losing state.
The feature is stiff experimental but I don't think there a problem using it (with a fallback)

Sources :

Notes :

  • I don't know how to create a test for this !
  • Some functions in operations.js are annotated with/*@__NO_SIDE_EFFECTS__*/.
    I don't know what this does exactly or if I should put it on the function I added

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC:https://github.com/sveltejs/rfcs
  • Prefix your PR title withfeat:,fix:,chore:, ordocs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code withinpackages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests withpnpm test and lint the project withpnpm lint

Ocean-OS and Serator reacted with thumbs up emoji
@changeset-botchangeset-bot
Copy link

🦋 Changeset detected

Latest commit:555321f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
sveltePatch

Not sure what this means?Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actionsGitHub Actions
Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@15512

@dummdidumm
Copy link
Member

Will this have any unwanted impact on transitions? (TBH I'm not even sure if we want to run transitions on moved within an array, or if they do right now)

@adiguba
Copy link
ContributorAuthor

I don't think this will impact transitions, since they are executed before/after the node is deleted/added.
I made some stuff on playground without impact...

But, I also tested the demo-site :https://state-preserving-atomic-move.glitch.me/
And the "popover" scenario crashes Chrome... :/

Maybe it would be better to wait until it is a little more stable.

@trueadm
Copy link
Contributor

trueadm commentedMar 14, 2025
edited
Loading

We only want to usemoveBefore on post mount operations. Otherwise, there are issues with web component FWIW where they don't fire the connected callback if used on mount. Context:facebook/react#32567

@Ocean-OS
Copy link
Contributor

The "no side effects" comment is an indicator for bundlers that a function is pure.

@adiguba
Copy link
ContributorAuthor

We only want to usemoveBefore on post mount operations.

I think it's fine : if I'm not mistaken it's only used on thereconcille() of {#each}` blocks to move existing element.

The "no side effects" comment is an indicator for bundlers that a function is pure.

So I suppose this is not the case here, since the DOM is modified...

@Rich-Harris
Copy link
Member

I'm going to close this because I'm quite certain we shouldn't do this. It will make bugsmore likely, not less, because it means that people will see stuff working in Chrome and assume it works everywhere. It's much better if people are forced to solve these issues in a cross-browser way — Svelte should avoid having different behaviour between different browsers.

adiguba, Ocean-OS, gterras, and Prinzhorn reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Modal Dialog Backdrop lost on re-render
5 participants
@adiguba@dummdidumm@trueadm@Ocean-OS@Rich-Harris

[8]ページ先頭

©2009-2025 Movatter.jp