mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 02:37:41 -05:00
fix exception thrown but not shown in DOM in event handler (#1131)
* fix exception not thrown in event handler * fix implicit display test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { htmlDecode, ensureUniqueId, createDeprecationWarning } from '../utils';
|
||||
import type { Interpreter } from '../interpreter';
|
||||
import { getLogger } from '../logger';
|
||||
import { pyExec } from '../pyexec';
|
||||
import { pyExec, displayPyException } from '../pyexec';
|
||||
import { _createAlertBanner } from '../exceptions';
|
||||
import { robustFetch } from '../fetch';
|
||||
import { PyScriptApp } from '../main';
|
||||
@@ -183,7 +183,12 @@ function createElementsWithEventListeners(interpreter: Interpreter, pyAttribute:
|
||||
}
|
||||
} else {
|
||||
el.addEventListener(event, () => {
|
||||
interpreter.run(handlerCode);
|
||||
try {
|
||||
interpreter.run(handlerCode)
|
||||
}
|
||||
catch (err) {
|
||||
displayPyException(err, el.parentElement);
|
||||
}
|
||||
});
|
||||
}
|
||||
// TODO: Should we actually map handlers in JS instead of Python?
|
||||
|
||||
Reference in New Issue
Block a user