]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#t465] DRY out repeated options.dataType.toLowerCase()
authorrwldrn <waldron.rick@gmail.com>
Tue, 5 Apr 2011 13:39:45 +0000 (09:39 -0400)
committerrwldrn <waldron.rick@gmail.com>
Tue, 5 Apr 2011 13:42:44 +0000 (09:42 -0400)
popcorn.js

index db7adef42a48a468b78837ed948ee7758c9b2258..43889ee9637ee78189002d85e51a17457262513f 100644 (file)
       return size;
     },
     isArray: Array.isArray || function( array ) {
-           return toString.call( array ) === "[object Array]";
+      return toString.call( array ) === "[object Array]";
     }, 
     nop: function () {}
   });
 
   Popcorn.xhr = function ( options ) {
 
+    options.dataType = options.dataType && options.dataType.toLowerCase() || null;
+    
     if ( options.dataType &&
-          ( options.dataType.toLowerCase() === "jsonp" ||
-              options.dataType.toLowerCase() === "script" ) ) {
+            ( options.dataType === "jsonp" ||
+                options.dataType === "script" ) ) {
 
       Popcorn.xhr.getJSONP(
         options.url,
         options.success,
-        options.dataType.toLowerCase() === "script"
+        options.dataType === "script"
       );
       return;
     }
     //  Create new XMLHttpRequest object
     settings.ajax  = settings.xhr();
 
-    //  Normalize dataType
-    settings.dataType  = settings.dataType.toLowerCase();
-
-
     if ( settings.ajax ) {
 
       if ( settings.type === "GET" && settings.data ) {