From: rwldrn Date: Thu, 20 Jan 2011 02:14:28 +0000 (-0500) Subject: resolving conflict X-Git-Tag: v0.3~25 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=c1c75b0a21fdaddff55717d3ca73ce09386b8a70;p=popcorn-js.git resolving conflict --- c1c75b0a21fdaddff55717d3ca73ce09386b8a70 diff --cc popcorn.js index 017ddd3,c1957c3..d05ef60 --- a/popcorn.js +++ b/popcorn.js @@@ -813,7 -813,7 +813,11 @@@ Popcorn.xhr = function ( options ) { ++<<<<<<< HEAD + if ( ( options.dataType || "" ).toLowerCase() === "jsonp" ) { ++======= + if ( options.dataType && options.dataType.toLowerCase() === "jsonp" ) { ++>>>>>>> 742ed140bbafc94a08a0024346c62eeff8407d07 Popcorn.xhr.getJSONP( options.url, @@@ -881,13 -892,23 +896,33 @@@ 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 @@@ -909,7 -930,7 +944,11 @@@ head.insertBefore( script, head.firstChild ); ++<<<<<<< HEAD + } ++======= + }; ++>>>>>>> 742ed140bbafc94a08a0024346c62eeff8407d07 // Exposes Popcorn to global context diff --cc test/popcorn.unit.js index ae85b81,9f1062c..9288cc3 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@@ -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() { @@@ -1099,7 -1166,7 +1165,6 @@@ plus(); - console.log(data); - ok( QUnit.equiv(data, testObj) , "Popcorn.xhr({}) data.json returns an object of data"); plus(); @@@ -1123,6 -1190,22 +1188,21 @@@ ); + 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 () {