twitter/bootstrap — pull request #4348 by achur (2012-08-11 01:33:29+00:00)
Title: Typeahead: only accept array return vals from source

Typeahead's source option can be an array that returns
a list of completions, but we should check to guarantee the
return value is actually an array before forwarding it.

---

This is particularly a problem for CoffeeScript users, who might write the following:

$('#user-input').typeahead
source: (query, process) ->
process [query + query]

Expected behavior: a user types "abc" and the typeahead popup shows "abcabc". Actual behavior: the typeahead popup has nothing.

This is because CoffeeScript implicitly returns the last value (here an instance of `Typeahead`). Unless that value is actually an array, we shouldn't try to use it.