mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-23 06:41:32 +03:00
Only look upwards for handlers if the event bubbles
This commit is contained in:
parent
38dcdde2b9
commit
cfe4104b6f
@ -609,9 +609,10 @@ class NodeInfo(Container):
|
|||||||
handler_name = message_class.handler_name
|
handler_name = message_class.handler_name
|
||||||
handler_names = [handler_name, f"_{handler_name}"]
|
handler_names = [handler_name, f"_{handler_name}"]
|
||||||
# Find any listeners for this event
|
# Find any listeners for this event
|
||||||
# TODO: only look upwards if the event bubbles
|
# Only look upwards if the event bubbles
|
||||||
|
potential_handlers = dom_node.ancestors_with_self if message_class.bubble else [dom_node]
|
||||||
usages: list[Text] = []
|
usages: list[Text] = []
|
||||||
for ancestor in dom_node.ancestors_with_self:
|
for ancestor in potential_handlers:
|
||||||
for handler_name in handler_names:
|
for handler_name in handler_names:
|
||||||
if hasattr(ancestor, handler_name):
|
if hasattr(ancestor, handler_name):
|
||||||
# Record which class the handler is defined on
|
# Record which class the handler is defined on
|
||||||
|
Loading…
Reference in New Issue
Block a user