Yes, it should continue to propagate. Events have no real attachment to the event they fired on, except for the target
property. When you remove the element, the internal code propagating the event should not have any "awareness" that the original element has gone from the visible document.
As an aside, using removeChild
will not delete an element right away, it just detaches it from the document tree. An element should only be deleted/garbage collected when there are no references to it. Therefore, it's possible that the element could still be referred to via the event.target
property and even re-inserted before being garbage collected. I haven't tried it though, so it's just speculation.
T.J. Crowder's comment made me decide to knock up a quick example. I was right on both counts, it does bubble and you can still get a reference to the removed node using
event.target
.
http://jsbin.com/ofese/2/
As T.J. discovered, that is not the case in IE. But the DOM Level 2 Events specification
does define it as correct behavior [emphasis mine]:.
Events which are designated as bubbling will initially proceed with the same event flow as non-bubbling events. The event is dispatched to its target EventTarget and any event listeners found there are triggered. Bubbling events will then trigger any additional event listeners found by following the EventTarget's parent chain upward, checking for any event listeners registered on each successive EventTarget. This upward propagation will continue up to and including the Document. EventListeners registered as capturers will not be triggered during this phase. The chain of EventTargets from the event target to the top of the tree is determined before the initial dispatch of the event. If modifications occur to the tree during event processing, event flow will proceed based on the initial state of the tree.