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

fix(render): remove overlapping nodes + old connected nodes #702

Merged
merged 27 commits into from
Jan 7, 2025

Conversation

aralroca
Copy link
Collaborator

@aralroca aralroca commented Jan 4, 2025

Fixes #686

This PR fixes bugs encountered with different reactive parts sharing nodes of the same element.

Example:

Signal 1 -> when true -> fragment -> Signal 2 -> when true -> render
                                                          -> render sibling

In this scenario, when Signal 2 changes, it updates the local refs of this reactivity part but does not communicate with Signal 1 to update this ref (so hard to do this...). So after this PR, when Signal 1 needs to update the nodes without this ref, it cleans the overlapped nodes first to do the job correctly. Then, instead of removing the referenced nodes, it removes the real ones, doing nextSibling until the last ref.

For me, the ideal solution would be not to depend on these local references. But, at least, with this solution we avoid doing a reconciler for it or adding markers to the HTML. 😅

Caution

Bad part: It increases 110 bytes the client code, (still 3kb but rounded is 4kb). At least in a previous PR I reduce 26 bytes this code, so the total new bytes in the next release will be +84 bytes.

@aralroca aralroca self-assigned this Jan 4, 2025
Copy link

pkg-pr-new bot commented Jan 4, 2025

Open in Stackblitz

brisa-adapter-vercel

npm i https://pkg.pr.new/brisa-build/brisa/brisa-adapter-vercel@702

brisa

npm i https://pkg.pr.new/brisa-build/brisa@702

brisa-pandacss

npm i https://pkg.pr.new/brisa-build/brisa/brisa-pandacss@702

brisa-tailwindcss

npm i https://pkg.pr.new/brisa-build/brisa/brisa-tailwindcss@702

create-brisa

npm i https://pkg.pr.new/brisa-build/brisa/create-brisa@702

www

npm i https://pkg.pr.new/brisa-build/brisa/www@702

commit: 55a6a48

@aralroca
Copy link
Collaborator Author

aralroca commented Jan 4, 2025

We can golfing bytes in future PRs to keep Web Components to 3kb

@aralroca aralroca merged commit a8b0eac into canary Jan 7, 2025
8 of 11 checks passed
@aralroca aralroca deleted the aralroca/issue-render branch January 7, 2025 16:03
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.

Some nodes are not removed correctly after reactivity, wrong references
1 participant