clearstorydata/jquery-powertip — pull request #4 by jnu (2014-04-01 18:19:14+00:00)
Title: Edge case: multiple instantiations

@nrabinowitz

This was an issue with the order things were getting called in the constructor, which I was a little worried about yesterday when I was working on #3. PowerTip had a reasonable idea of destroying the previous instance when it's recreated, but it wasn't doing it in the right place:

* Since `destroy` has the potential to remove the tooltip, it can't be called after `TooltipController`, which is where tooltips are created if necessary, is instantiated.
* Since `destroy` resets elements (resets their title attribute if possible and clears data attributes used by PT), this has to be done before the constructor sets itself up - otherwise it will have both a `data-powertip` attribute and a `title` attribute and an `data-originalTitle` attribute ... in other words, things are a mess.

Right now I'm using two loops through the elements, one to destroy, then one to recreate. This is the simplest way, it can be optimized ... I think it makes sense to fix this when the `$.add` stuff is taken care of, since that will also need to be put into this loop (to prevent inadvertent tooltip destruction).

I also fixed some lingering jshint and test lack-of-teardown issues from #2 and #3. Now the build passes, which is nice ...