Appreciate the detailed response!
Mohamed Amin
11

No problem! Yeah, it looks like the bug in Firefox — if in fact there is a bug here — is pretty quirky.

I had a follow-up comment on EchoJS, but I’ll also post it here (having comments in two places is tricky):

Just a quick addition: one thing that would work in most cases to get around the third issue is to use a check along the lines of `if (typeof window.ontouchstart !== 'undefined')`. That may even work just as well as `'ontouchstart' in window` in practice, though whether it's better is debatable. The `in` check really checks for the existence of the key/property on the object or somewhere in the prototype chain, and, given that this check is the test that browser vendors seem to have supported for feature detection here, it's probably a little safer in this case. I fear the possibility that a vendor might some day make it so that the key, 'ontouchstart', exists on `window` when touch events are supported, but has the initial value of `undefined`, with the result that the `in` check evaluates to `true` but the `typeof` check evaluates to `false`! (And, in fact, the `typeof` check would have the same result in the author's case that the `in` check had for him in the first place: it would evaluate to `true` for him in Chrome, but `false` in Firefox. So, it wouldn't resolve the author's issue (which may result from a Firefox bug)).
Show your support

Clapping shows how much you appreciated Jason Rogers’s story.