Echo JS 0.11.0

<~>
jmrog 2774 days ago. link parent 1 point
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)).

Replies