Touch events on removed element

Hi all,

(Hope this is the right list, please redirect me if not.)

The touch events spec doesn't seem to be completely clear on what happens
when a dragging interaction happens on an element that gets removed. With
this code...

<div id="monkey"></div>

monkey.addEventListener("touchstart", function(e) {
  if (e.target.parentNode) {
    e.target.parentNode.removeChild(e.target);
  }
});
monkey.addEventListener("touchmove", function(e) {
  alert('touchmove on removed element');
});

(Live demo: http://jsbin.com/gocuhifa/1)

....is the touchmove handler guaranteed to be called even though the element
is removed? It's not obvious from the spec that (a) removed elements are
even capable of receiving events and (b) that the browser shouldn't GC the
removed element and its handlers. Receiving this event is useful for
certain draggable interactions (such as a sortable where the
currently-dragging element is replaced with a placeholder element).

Thankfully, it seems that in latest Chrome, Firefox, and iOS Safari the
alert is fired. I'd be grateful if someone could clarify this in the spec
or point me to where I blindly missed it. :)

Thanks,
Ben

Received on Sunday, 6 April 2014 20:49:30 UTC