mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 18:55:29 -05:00
fixed REPL bugs (#372)
* fixed REPL play button alignment * fixed REPL auto-generate * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * changed nextExecId selector * added removeClasses to utils.ts * fixed visual bug after error output * changed play button alignment Co-authored-by: Mariano Weber <info@uiremotely.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { loadedEnvironments, mode, pyodideLoaded } from '../stores';
|
||||
import { guidGenerator, addClasses } from '../utils';
|
||||
import { guidGenerator, addClasses, removeClasses } from '../utils';
|
||||
// Premise used to connect to the first available pyodide interpreter
|
||||
let runtime;
|
||||
let environments;
|
||||
@@ -137,6 +137,19 @@ export class BaseEvalElement extends HTMLElement {
|
||||
this.outputElement.style.display = 'block';
|
||||
}
|
||||
|
||||
// check if this REPL contains errors, delete them and remove error classes
|
||||
const errorElements = document.querySelectorAll(`div[id^='${this.errorElement.id}'][error]`);
|
||||
if (errorElements.length > 0) {
|
||||
for (const errorElement of errorElements) {
|
||||
errorElement.classList.add('hidden');
|
||||
if(this.hasAttribute('std-err')) {
|
||||
this.errorElement.hidden = true;
|
||||
this.errorElement.style.removeProperty('display');
|
||||
}
|
||||
}
|
||||
removeClasses(this.errorElement, ['bg-red-200', 'p-2']);
|
||||
}
|
||||
|
||||
this.postEvaluate();
|
||||
} catch (err) {
|
||||
if (Element === undefined) {
|
||||
@@ -146,6 +159,8 @@ export class BaseEvalElement extends HTMLElement {
|
||||
|
||||
addClasses(this.errorElement, ['bg-red-200', 'p-2']);
|
||||
out.write.callKwargs(err, { append: true });
|
||||
|
||||
this.errorElement.children[this.errorElement.children.length - 1].setAttribute('error', '')
|
||||
this.errorElement.hidden = false;
|
||||
this.errorElement.style.display = 'block';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user