(bug 41342) jquery.suggestions: Call cancel before fetching.
authorMatmaRex <matma.rex@gmail.com>
Sun, 9 Dec 2012 20:08:49 +0000 (21:08 +0100)
committerTimo Tijhof <ttijhof@wikimedia.org>
Sun, 16 Dec 2012 20:34:37 +0000 (21:34 +0100)
commit01c2ca3612256f43ab3e53c3542a05845d92d75f
tree74e6ac21b8906dfd7582b841e09377301bd0c977
parentc219e4640f5ca5c260df20ba5384867773da291a
(bug 41342) jquery.suggestions: Call cancel before fetching.

This caused race conditions in the calling code, if it used AJAX
and they completed in different order than they were started.

For example in mediawiki.searchSuggest, when one slowly types
"wikipedia", 9 requests get sent (suggestions for "w", "wi",
"wik", etc.), but they might not necessarily arrive in the same
order, especially on slow (e.g. mobile) connections.

Then you get the race condition effect - suggestions for
"wikipedia" flash briefly and then are replaced by suggestions for
"wik", even though the bolding is correct.

This commit fixes the issue by using a function that was already
present, that calls the callback as well as clearing the internal
timeout, which for some reason wasn't used in this code path.

Change-Id: I880a61e5e45a64bea6d679ed160c4be3da085dfa
RELEASE-NOTES-1.21
resources/jquery/jquery.suggestions.js