Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor rendering and transitions #10594

Closed
wants to merge 111 commits into from
Closed

chore: refactor rendering and transitions #10594

wants to merge 111 commits into from

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Feb 21, 2024

Track progress here


This is very WIP, and lots of tests are failing.

Right now, there's a lot of complexity around rendering and transitions that I'm very confident is unnecessary. For each thing like {#if ...}, {#each ...} etc we have a corresponding block type, each with a different shape, and when we interact with the tree in some way we need to lots of type === IF_BLOCK checks and suchlike. Similarly, we have different kinds of transitions for different kinds of blocks.

We don't need any of this — we just need the effect tree, and a single type of block:

<!-- this is a render effect -->
{#if condition}
  <!-- this is a block -->
{:else}
  <!-- this is also a block -->
{/if}

Here, a 'block' is technically a 'managed render effect' — the terminology could probably be improved somewhat, since the consequent/alternate functions don't re-run autonomously. They're managed, but they're not effects. Nonetheless, they are part of the effect tree insofar as they contain effects and are contained by effects, so for now we'll gloss over it.

Transitions belong to their immediate block (i.e. to the consequent or the alternate rather than the {#if ...}, or the pending block rather than the {#await ...}). This PR introduces the idea of pausing and resuming these blocks; the logic is shared between if and each and await and key and everything else.

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.

Tests and linting

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

Copy link

changeset-bot bot commented Feb 21, 2024

⚠️ No Changeset found

Latest commit: ca6ba9b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@Rich-Harris
Copy link
Member Author

I'm declaring bankruptcy on this branch, but will keep it around as a convenient reference. The ideas are sound, but it became too unwieldy to land. Going to try and reimplement it more incrementally.

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