fetch-jsonp
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -26,4 +26,2 @@ (function (global, factory) { | ||
// Known issue: Will throw 'Uncaught ReferenceError: callback_*** is not defined' | ||
// error if request timeout | ||
function clearFunction(functionName) { | ||
@@ -41,3 +39,5 @@ // IE8 throws an exception when you try to delete a property on window | ||
var script = document.getElementById(scriptId); | ||
document.getElementsByTagName('head')[0].removeChild(script); | ||
if (script) { | ||
document.getElementsByTagName('head')[0].removeChild(script); | ||
} | ||
} | ||
@@ -84,8 +84,2 @@ | ||
jsonpScript.id = scriptId; | ||
jsonpScript.onerror = function () { | ||
reject(new Error('JSONP request to ' + _url + ' failed')); | ||
clearFunction(callbackFunction); | ||
removeScript(scriptId); | ||
}; | ||
document.getElementsByTagName('head')[0].appendChild(jsonpScript); | ||
@@ -99,2 +93,11 @@ | ||
}, timeout); | ||
// Caught if got 404/500 | ||
jsonpScript.onerror = function () { | ||
reject(new Error('JSONP request to ' + _url + ' failed')); | ||
clearFunction(callbackFunction); | ||
removeScript(scriptId); | ||
if (timeoutId) clearTimeout(timeoutId); | ||
}; | ||
}); | ||
@@ -101,0 +104,0 @@ } |
@@ -0,1 +1,5 @@ | ||
1.1.1 / 2017-6-10 | ||
================== | ||
* Fix script error when script request error, thanks to @wheatma | ||
1.1.0 / 2017-6-7 | ||
@@ -2,0 +6,0 @@ ================== |
{ | ||
"name": "fetch-jsonp", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Fetch JSONP like a boss using Fetch API", | ||
"main": "build/fetch-jsonp.js", | ||
"scripts": { | ||
"prepublish": "npm run lint && npm run clean && npm run build", | ||
"test": "mocha --compilers js:babel/register --recursive --ui bdd --reporter spec", | ||
@@ -8,0 +9,0 @@ "build": "babel src/ --modules umd --out-dir build", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9922
113