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

Reclaim element id for all removed nodes #3782

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/core/src/diff/node.rs
Original file line number Diff line number Diff line change
@@ -328,6 +328,9 @@ impl VNode {
to.remove_node(id);
}
dom.reclaim(id);
} else {
let id = dom.get_mounted_root_node(mount, idx);
dom.reclaim(id);
}
}
}
@@ -379,8 +382,8 @@ impl VNode {
} else {
to.remove_node(id);
}
dom.reclaim(id)
}
dom.reclaim(id)
}
Fragment(nodes) => {
for node in &nodes[..nodes.len() - 1] {
12 changes: 6 additions & 6 deletions packages/core/tests/diff_unkeyed_list.rs
Original file line number Diff line number Diff line change
@@ -149,13 +149,13 @@ fn removes_one_by_one() {
dom.render_immediate_to_vec().edits,
[
LoadTemplate { index: 0, id: ElementId(2) },
CreateTextNode { value: "0".to_string(), id: ElementId(6) },
CreateTextNode { value: "0".to_string(), id: ElementId(3) },
ReplacePlaceholder { path: &[0], m: 1 },
LoadTemplate { index: 0, id: ElementId(8) },
CreateTextNode { value: "1".to_string(), id: ElementId(9) },
LoadTemplate { index: 0, id: ElementId(5) },
CreateTextNode { value: "1".to_string(), id: ElementId(6) },
ReplacePlaceholder { path: &[0], m: 1 },
LoadTemplate { index: 0, id: ElementId(10) },
CreateTextNode { value: "2".to_string(), id: ElementId(11) },
LoadTemplate { index: 0, id: ElementId(7) },
CreateTextNode { value: "2".to_string(), id: ElementId(8) },
ReplacePlaceholder { path: &[0], m: 1 },
ReplaceWith { id: ElementId(4), m: 3 }
]
@@ -420,7 +420,7 @@ fn remove_many() {
edits.edits,
[
LoadTemplate { index: 0, id: ElementId(9,) },
CreateTextNode { value: "hello 0".to_string(), id: ElementId(7,) },
CreateTextNode { value: "hello 0".to_string(), id: ElementId(10,) },
ReplacePlaceholder { path: &[0,], m: 1 },
ReplaceWith { id: ElementId(11,), m: 1 },
]

Unchanged files with check annotations Beta

steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

Check warning on line 188 in .github/workflows/main.yml

GitHub Actions / nix (ubuntu-latest)

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... - uses: DeterminateSystems/magic-nix-cache-action@main ...with... - uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol

Check warning on line 188 in .github/workflows/main.yml

GitHub Actions / nix (macos-latest)

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... - uses: DeterminateSystems/magic-nix-cache-action@main ...with... - uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol
- name: Install omnix
run: nix --accept-flake-config profile install "github:juspay/omnix"
- name: Build all flake outputs