-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autocomplete: Don't handle remote data if it's not the most recent re…
…quest. Fixes #5982 - Autocomplete: Race condition causes incorrect suggestions.
- Loading branch information
1 parent
1cca969
commit f115b48
Showing
1 changed file
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f115b48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An addition or instead of the check within the success-callback, we could abort any previous still-running requests (self.xhr.abort()). That prevents the callback from getting called, and could have positive effects on performance.
f115b48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bug where calling xhr.abort() triggers the success callback, so we should probably add the xhr.abort() call but leave the check.
f115b48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm speaking out of context here, if so please ignore my comment, but I don't believe xhr.abort() executing the success function is a bug, I believe that is the default behavior. I /think/ this change was added in 1.4.2. A simple test: http://badsyntax.co.uk/tests/jquery-xhr-abort.html and perhaps a bit of insight on why this is the default behavior. http://groups.google.com/group/jquery-dev/browse_thread/thread/3d8f7ac78c9b0117?pli=1
f115b48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the background, but it seems like there's still some debate about what the expected behavior should be. There's still an open ticket for this: http://dev.jquery.com/ticket/6060 (and there have been more that were closed duplicates). In any case, I've added the abort call and kept this check in da2be6a.
f115b48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the impression this behavior wasn't up for debate, certainly I'd prefer it if success wasn't executed on abort. Thanks for the link, keeping an eye on this.