Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event bubbling can cause problem if elements are deleted. #16

Open
PaulMansour opened this issue Feb 26, 2024 · 0 comments
Open

Event bubbling can cause problem if elements are deleted. #16

PaulMansour opened this issue Feb 26, 2024 · 0 comments

Comments

@PaulMansour
Copy link
Contributor

PaulMansour commented Feb 26, 2024

Consider a KeyDown event listener attached to two elements, a <body> and some child <table> ("Current Targets"), and the KeyDown event fired by a key press on a <td> element (the "Target"). If this key down event deletes the contents of the table, then the <td> element no longer exists. The browser, however has processed the <body> event listener before the delete has happened in the APLDOM and the browser DOM synchronized. So when the <body> event listener is sent to the APLDOM, the expected <td> target element is not found.

In the use-case that uncovered this issue, in the higher level event handler, the target is immaterial and unreferenced anyway. This may virtually always be the case. If a lower level event handler is deleting elements, an upper level event handler should not reference them. It may be safe to simply set target to zero if not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant