Commit Graph

6 Commits

Author SHA1 Message Date
darrenburns
df37a9b90a Add get_child_by_id and get_widget_by_id (#1146)
* Add get_child_by_id and get_widget_by_id

* Remove redundant code

* Add unit tests for app-level get_child_by_id and get_widget_by_id

* Remove redundant test fixture injection

* Update CHANGELOG

* Enforce uniqueness of ID amongst widget children

* Enforce unique widget IDs amongst widgets mounted together

* Update CHANGELOG.md

* Ensuring unique IDs in a more logical place

* Add docstring to NodeList._get_by_id

* Dont use duplicate IDs in tests, dont mount 2000 widgets

* Mounting less widgets in a unit test

* Reword error message

* Use lower-level depth first search in get_widget_by_id to break out early
2022-11-16 15:29:59 +00:00
Dave Pearson
32e6f71856 Be 100% sure all removals take place 2022-11-10 20:41:11 +00:00
Dave Pearson
d3e7f5ad99 Add a unit test for removal ordering via DOMQuery.remove 2022-11-10 20:36:57 +00:00
Dave Pearson
9748850657 Add a unit test for removal ordering via Widget.remove 2022-11-10 20:34:51 +00:00
Dave Pearson
4dbb1f8e20 AwaitRemove work-in-progress
Initial work on #1094 -- this implements the core idea; lots of tidying up
to do but saving for the end of the week.
2022-11-10 16:54:44 +00:00
Dave Pearson
d73d4e898f Add unit tests for App._on_remove
These tests are designed to give 100% coverage to the App._on_remove method,
which is the heart of the widget removal system. This is done in
anticipation to some reworking as part of #1094.

Note that, for the moment, there's a bit of a hack in here. These tests need
the pilot. The pilot would need that we await changes to the DOM. Removing
things from the DOM changes the DOM. Remove can't be awaited (see above
change that's coming). So... until such a time as we can await a remove, we
go with a simple await of asyncio.sleep to get things started.

Once #1094 has been done these tests should all still work fine *and* we
should be able to await the removes rather than use the sleeps.
2022-11-10 13:13:15 +00:00