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.
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.