]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
resolving conflict
authorrwldrn <waldron.rick@gmail.com>
Thu, 20 Jan 2011 02:14:28 +0000 (21:14 -0500)
committerrwldrn <waldron.rick@gmail.com>
Thu, 20 Jan 2011 02:14:28 +0000 (21:14 -0500)
1  2 
popcorn.js
test/popcorn.unit.js

diff --cc popcorn.js
index 017ddd3978157a067ad996128462e4b61da0cc89,c1957c35bbfddf9b5459f747e9c34c36045f1ed6..d05ef60e3d23b57ac65cc797f7cc4fcfb0c03409
    
    Popcorn.xhr = function ( options ) {
      
++<<<<<<< HEAD
 +    if ( ( options.dataType || "" ).toLowerCase() === "jsonp" ) {
++=======
+     if ( options.dataType && options.dataType.toLowerCase() === "jsonp" ) {
++>>>>>>> 742ed140bbafc94a08a0024346c62eeff8407d07
        
        Popcorn.xhr.getJSONP( 
          options.url,
        script = document.createElement("script"), 
        paramStr = url.split("?")[1], 
        fired = false, 
++<<<<<<< HEAD
 +      params, callback;
 +
 +    script.src = url; 
 +
 +    params = paramStr.split("&");
 +    
 +    callback = params.length ? params[ params.length - 1 ].split("=")[1] : Popcorn.guid("jsonp");
++=======
+       params = [], 
+       callback;
+ 
+     if ( paramStr ) {
+       params = paramStr.split("&");
+     }
+     
+     
+     callback = params.length ? params[ params.length - 1 ].split("=")[1] : "jsonp";
+     
+     
+     if ( !paramStr ) {
+       url += "?callback=" + callback;
+     }
+     
+     script.src = url;
+     
++>>>>>>> 742ed140bbafc94a08a0024346c62eeff8407d07
      
      if ( callback ) {
        //  define the jsonp success callback globally
  
      head.insertBefore( script, head.firstChild );
    
++<<<<<<< HEAD
 +  }
++=======
+   };
++>>>>>>> 742ed140bbafc94a08a0024346c62eeff8407d07
    
    
    //  Exposes Popcorn to global context
index ae85b812f879ba741d3c3de4148a6651d7852ecf,9f1062c01f29d3953c5b45ccaf150918ea68cc14..9288cc3c171006c17037725f77ff2ead152e1bac
@@@ -1071,9 -1102,45 +1102,44 @@@ test("JSON Response", function () 
  
  });
  
 -
+ test("dataType: JSON Response", function () {
+ 
+   var expects = 2, 
+       count = 0;
+       
+   function plus() {
+     if ( ++count === expects ) {
+       start();
+     }
+   }
+   
+   expect(expects);
+   
+   stop()
+ 
+ 
+   var testObj = { "data": {"lang": "en", "length": 25} };  
+ 
+   Popcorn.xhr({
+     url: 'data/test.js', 
+     dataType: "json",
+     success: function( data ) {
+       
+       ok(data, "xhr returns data");
+       plus();
+       
+       
+       ok( QUnit.equiv(data, testObj) , "dataType: 'json',  data returns an object of data");
+       plus();
+       
+     }
+   });
+ 
+ });
+ 
  test("JSONP Response", function () {
  
-   var expects = 4, 
+   var expects = 6, 
        count = 0;
        
    function plus() {
        plus();
        
        
-       console.log(data);
 -      
        ok( QUnit.equiv(data, testObj) , "Popcorn.xhr({}) data.json returns an object of data");
        plus();
        
    );
    
  
 -
+   Popcorn.xhr.getJSONP(
+     'data/jsonp.json',
+ 
+     function( data ) {
+       
+       ok(data, "xhr returns data");
+       plus();
+       
+       
+       
+       ok( QUnit.equiv(data, testObj) , "Popcorn.xhr.getJSONP data.json returns an object of data");
+       plus();
+       
+     }
+   );  
  });
  
  test("XML Response", function () {