Browse Source

Fix error callback with custom transport (#5981)

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.
Krzysztof Bogdan 4 years ago
parent
commit
0a30b0b3e6
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/js/select2/data/ajax.js

+ 1 - 1
src/js/select2/data/ajax.js

@@ -82,7 +82,7 @@ define([
       }, function () {
       }, function () {
         // Attempt to detect if a request was aborted
         // Attempt to detect if a request was aborted
         // Only works if the transport exposes a status property
         // Only works if the transport exposes a status property
-        if ('status' in $request &&
+        if ($request && 'status' in $request &&
             ($request.status === 0 || $request.status === '0')) {
             ($request.status === 0 || $request.status === '0')) {
           return;
           return;
         }
         }