chore: move DOM-related effect properties to effect.nodes
#17293
+105
−107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, an
Effecthas three properties that default tonull—nodes_start,nodes_end, andtransitions— and which are only used if the effect is abrancheffect (orhtml/headeffect, but you get the idea).Since smaller objects are faster to work with and take up less memory, it's almost certainly preferable to reduce that to a single property,
nodes, which is populated if it's the sort of effect that contains DOM.My real motivation is this, though: I'm working through the edge cases in #17258 and it's hellishly complicated, made doubly so by the fact that every
eachblock has two linked lists that resemble each other but don't fully match — a list of 'items' and a list of their effects. We only really need the second of these. Getting rid of the items list will reduce memory usage, and reduce the amount of work that needs to happen during reconciliation. But to get there, we need to move theAnimationManagerfromEachItemand ontoEffect. If it became a direct property ofEffectthat would add unnecessary overhead (animations are exceedingly rare, relative to effects as a whole). But if it's part ofnodes, it's fine. Hence the larger change.(It's possible that by putting animations on effects, we could eventually relax the restriction that says the
animate:directive has to be a direct child of a keyedeachblock, though that's a separate conversation that will probably be overtaken by a broader rethink of how animations and transitions work.)Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.packages/svelte/src, add a changeset (npx changeset).Tests and linting
pnpm testand lint the project withpnpm lint