Reputation: 10658
I'm trying to understand why changedTouches is NOT an testable property of an event. For instance, if I listen to a touchstart event (via Chrome->inspect and simulate a mobile device), such as
$(document).on('touchstart', function(event){
console.log(event.hasOwnProperty('originalEvent')) //logs true
As expected.
Now, If I log the whole event, I can clearly see it has originalEvent.changedTouches but testing the property will fail
console.log(event.originalEvent.hasOwnProperty('changedTouches')) //logs false
But I can list the changedTouches by doing
console.log(event.originalEvent.changedTouches);
/*
logs:
hangedTouches: TouchList(1)
0: Touch { identifier: 0, screenX: 753, screenY: 746, … }
length: 1
*/
Also I can test that both properties are objects
console.log(typeof(event.originalEvent), typeof(event.originalEvent.changedTouches)); //logs object object
The question is, why can't I test this property with hasOwnProperty?
Upvotes: 0
Views: 167