Refactor @when and add Event (#2239)

* Add two unit tests for illustrative purposes.

* Radical simplification of @when, more tests and some minor refactoring.
Handle ElementCollections, tests for ElementCollection, make serve for running tests locally.

* Skip flakey Pyodide in worker test (it works 50/50 and appears to be a timing issue).

* Ensure onFOO relates to an underlying FOO event in an Element.

* Minor comment cleanup.

* Add async test for Event listeners.

* Handlers no longer require an event parameter.

* Add tests for async handling via when.

* Docstring cleanup.

* Refactor onFOO to on_FOO.

* Minor typo tidy ups.

* Use correct check for MicroPython.

---------

Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
This commit is contained in:
Nicholas Tollervey
2024-11-05 13:55:28 +00:00
committed by GitHub
parent 4ff02a24d1
commit 56c64cbee7
16 changed files with 749 additions and 357 deletions

View File

@@ -1,6 +1,6 @@
{
"files": {
"https://raw.githubusercontent.com/ntoll/upytest/1.0.8/upytest.py": "",
"https://raw.githubusercontent.com/ntoll/upytest/1.0.9/upytest.py": "",
"./tests/test_config.py": "tests/test_config.py",
"./tests/test_current_target.py": "tests/test_current_target.py",
"./tests/test_display.py": "tests/test_display.py",
@@ -12,7 +12,7 @@
"./tests/test_running_in_worker.py": "tests/test_running_in_worker.py",
"./tests/test_web.py": "tests/test_web.py",
"./tests/test_websocket.py": "tests/test_websocket.py",
"./tests/test_when.py": "tests/test_when.py",
"./tests/test_events.py": "tests/test_events.py",
"./tests/test_window.py": "tests/test_window.py"
},
"js_modules": {