Skip to content

Commit

Permalink
fix doc console error
Browse files Browse the repository at this point in the history
  • Loading branch information
bugzpodder committed Sep 24, 2023
1 parent ed4f10b commit b1f1941
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/src/components/PySandboxExample.astro
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ const { code, target, worker, restricted } = Astro.props;
}

async function run(code) {
document.getElementById(target).replaceChildren();
if (target) {
document.getElementById(target).replaceChildren();
}
try {
const imports = await sandbox.findImports(code);
await sandbox.installPackages(imports, { keep_going: true });
await sandbox.exec(code, target);
} catch (e) {
console.error(e);
document.getElementById(target).innerText = String(e);
if (target) {
document.getElementById(target).innerText = String(e);
}
}
}

Expand Down

0 comments on commit b1f1941

Please sign in to comment.