Skip to content

Commit

Permalink
Fix error callback with custom transport (select2#5981)
Browse files Browse the repository at this point in the history
If custom transport does not return any object 
then calling error callback would result in `Uncaught TypeError: right-hand side of 'in' should be an object, got undefined`.
This patch adds check if $request evaluates to something.
  • Loading branch information
KrzysztofBogdan authored Mar 4, 2021
1 parent 04042e1 commit 0a30b0b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/select2/data/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ define([
}, function () {
// Attempt to detect if a request was aborted
// Only works if the transport exposes a status property
if ('status' in $request &&
if ($request && 'status' in $request &&
($request.status === 0 || $request.status === '0')) {
return;
}
Expand Down

0 comments on commit 0a30b0b

Please sign in to comment.