W3C home > Mailing lists > Public > public-webevents@w3.org > April to June 2014

Touch events on removed element

From: Ben Alpert <ben@benalpert.com>
Date: Fri, 4 Apr 2014 16:26:27 -0700
Message-ID: <CAM5ME0Qmun7GM0o9e4KYaR9bX9jLeyac62GqBvsoo4mmaSa-5w@mail.gmail.com>
To: public-webevents@w3.org
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) {
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. :)

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:03:56 UTC