alexgibson/tap.js — pull request #7 by x3ro (2013-07-26 13:12:27+00:00)
Title: Cache Tap.js instance creation to prevent duplicates

Previously it was easily possible to create multiple Tap instances
on the same element. This caused all event handlers to be registered
for both instances, and thus also dispatching events twice. In order
to avoid this behavior, I added a cache object that keeps track of
the created instances.

The public API is now no longer the Tap constructor, but kind of a
factory method to create instances. This has the additional advantage
that we can return the element for which the instance was created,
allowing for code like this:

Tap(element).addEventListener( ... )

Because `window.Tap` is still a function, the `new Tap(element)` style
will also continue to work.