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

clear old content on undefine #1431

Merged
merged 1 commit into from
Jun 6, 2024
Merged
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
4 changes: 2 additions & 2 deletions src/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const rootsById = findRoots(document.body);
export function define(cell) {
const {id, inline, inputs = [], outputs = [], body} = cell;
const variables = [];
cellsById.get(id)?.variables.forEach((v) => v.delete());
cellsById.set(id, {cell, variables});
const root = rootsById.get(id);
const loading = findLoading(root);
Expand Down Expand Up @@ -119,7 +118,8 @@ function displayBlock(root, value) {
}

export function undefine(id) {
cellsById.get(id)?.variables.forEach((v) => v.delete());
clear(rootsById.get(id));
cellsById.get(id).variables.forEach((v) => v.delete());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the optional chaining here because we should only be undefining cells that were defined (and we want to notice if our logic is broken).

cellsById.delete(id);
}

Expand Down