-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
feat: simpler effect DOM boundaries #12258
Conversation
🦋 Changeset detectedLatest commit: 58f136f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if (DEV) ..
hack inside svelte-component.js
can be removed as a result of this, which then fixes #12259
Whilst this makes sense, it also brings back the performance issues and also why I removed the anchor node in my PR to begin with, especially for the common case of: {#each items as item}
{@render children(item)}
{/each} The extra comment node makes large lists much slower during unmount. |
I'm not overly concerned about that, because I'm implementing the optimisation I described above — so far just for components, but I think it should work for other things too. In most cases, there'll be fewer redundant comment nodes. The additional comment node will only be required in comparatively rare cases where you have multiple items inside a fragment... {#each things as thing}
<Foo {thing} />
<Bar {thing} />
{/each} ...and I think it's okay to sacrifice a little bit of performance in those cases for a) increased performance in common cases, b) more correctness, and c) much simpler code. |
I assume that optimisation is true for this too? {#each things as thing}
<div>{…}</div>
{/each} |
That was already the case. See for yourself: $.each(node, 1, () => things, $.index, ($$anchor, thing, $$index) => {
var div = root_1();
$.append($$anchor, div);
}); |
For now the optimisation only applies to render tags and components. I'm pretty sure it can apply to other items as well, but I wanted to do some more testing first — in the meantime it seems like a sensible balance of priorities to get this released to fix #12259 |
Follow-up to #12215. We can make life a lot easier for ourselves by ensuring that branch effects always have a
start
andend
node. In the case of an effect that begins with a non-text/element item, that just means inserting an extra comment node at the front.Things get simpler as a result. We no longer need a recursive
get_first_node
function, we no longer need to worry about assigning toeffect.nodes.start
aftereffect.nodes
has already been created, we no longer need to storenodes
object on block effects.It does mean extra comment nodes in the DOM in some cases. I'd like to try mitigating that by simplifying the common case where a component is the sole child of a block:
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint