Object identity

Should the Touch Events standard specify whether certain operations 
return the same object?


Example 1: Should changedTouches and targetTouches refer to the same 
objects as the "touches" attribute for the same event?

window.addEventListener("touchstart", function(e) {
   var changedTouch = e.changedTouches[0];
   var id = changedTouch.identifier;

   var touch       = e.touches.identifiedPoint(id);
   var targetTouch = e.targetTouches.identifiedPoint(id);

   // Should these be true?
   assert(touch == changedTouch);
   assert(touch == targetTouch);
});


Example 2: Should different touch events refer to the same objects?

window.addEventListener("touchstart", function(e0) {
   var touch0 = e0.touches[0];
   var id = touch.identifier;

   window.addEventListener("touchmove", function(e1) {
     var touch1 = e1.touches.identifiedPoint(id);
     assert(touch0 == touch1); // Should this be true?
   });
});


Leaving these implementation-defined might lead to content depending on 
one behavior, and breaking if the implementation changes.  For a similar 
example, see:
http://www.quirksmode.org/blog/archives/2010/02/persistent_touc.html

Received on Tuesday, 26 April 2011 17:39:38 UTC