diff --git a/pyscript.core/src/plugins/py-editor.js b/pyscript.core/src/plugins/py-editor.js
index f8d4c5bc..ba4fdcb6 100644
--- a/pyscript.core/src/plugins/py-editor.js
+++ b/pyscript.core/src/plugins/py-editor.js
@@ -91,9 +91,12 @@ async function execute({ currentTarget }) {
return envs.get(env).then((xworker) => {
xworker.onerror = ({ error }) => {
if (hasRunButton) {
- outDiv.innerHTML += `${
- error.message || error
- }\n`;
+ outDiv.insertAdjacentHTML(
+ "beforeend",
+ `${
+ error.message || error
+ }\n`,
+ );
}
console.error(error);
};
@@ -108,7 +111,10 @@ async function execute({ currentTarget }) {
};
sync.writeErr = (str) => {
if (hasRunButton) {
- outDiv.innerHTML += `${str}\n`;
+ outDiv.insertAdjacentHTML(
+ "beforeend",
+ `${str}\n`,
+ );
} else {
notify(str);
console.error(str);