Skip to content

fix: create offscreen effects with correct anchor#18086

Draft
Rich-Harris wants to merge 10 commits into
mainfrom
fragmentless-branches
Draft

fix: create offscreen effects with correct anchor#18086
Rich-Harris wants to merge 10 commits into
mainfrom
fragmentless-branches

Conversation

@Rich-Harris
Copy link
Copy Markdown
Member

This is another take on #18079. The symbol thing felt like a bit of a kludge, so I started poking about at possible alternatives and this is where I landed.

Having done so I think maybe @dummdidumm was right the first time (many such cases) — without the symbol, the only way to get the HMR wrapper to send the right anchor to its component is to create the effect onscreen and then remove it if we want to defer it, which is extra work. Still, there might be some merit in only storing the offscreen effects rather than fragments — not sure — so I figured I'd create a PR for posterity.

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

  • 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 with feat:, fix:, chore:, or docs:.
  • 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 within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: 1d93465

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

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

@svelte-docs-bot
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

Playground

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

@dummdidumm
Copy link
Copy Markdown
Member

Interesting approach!
I guess another approach to fix the issue would be to not just pass the anchor along when creating a dynamic component, and instead create a intermediate comment (like it's done for if blocks) which the HMR wrapper then prepends to. We could make it dev-only to not pollute prod with even more comments than we already do (conversely there's probably a lot of potential of getting rid of some unnecessary comments in prod by detecting sole children; but that's a different task)

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.

2 participants