harvesthq/chosen — pull request #1461 by pfiller (2013-08-08 15:36:10+00:00)
Title: Single select results in sync

@harvesthq/chosen-developers

This fixes some issues in single selects that come when the data and DOM get out of sync. The trouble comes from relying on the `results-selected` class for tracking selected results. Since our results list now gets rebuilt with every winnow, `results-selected` doesn't always reflect an item that actually exists (or sometimes reflects old selections).

Two issues I saw

- When no placeholder is present, the first item never loses its `results-selected` class (#1458)
- When deselecting a single select, the previous result stays highlighted. You can see this one in the docs pages. Click the `x` in the example and re-open the list. "Sloth bear" is still highlighted.

This PR fixes both of those. I still need to do some performance testing in IE8 with thousands of options, but I don't think this is going to be a problem. Looping through an array of thousands of items in IE8 is surprisingly quick.

Fixes #1458