Comments (5)
Hey @azazel75,
There's definitely some anomalies in the logic in this plugin. For instance, I noticed that the success path is different if the strictJSONParse config property is truthy. (e.g. strictJSONParse: true
). If you have a minutes and can try setting that in a curl() or curl.config() call, that would be helpful.
I will continue to research and add tests...
-- J
from curl.
Nm. I cloned your example repo and tried it. This looks like a problem with all plugins specified in a call to curl([]).
from curl.
Actually, it seems like it's just a problem with json!, style!, and locale! plugins. Each of these plugins catches errors that are thrown from the success callbacks (which ultimately call the bootstrap success callback). The plugins send the error back into curl's loading mechanics which detects and suppresses multiple callbacks/errbacks. In short, the error is suppressed on purpose. The fix is to stop catching errors that happen in callbacks -- only catch errors that throw during fetch/processing of resources.
from curl.
Here's the updated curl/plugin/json.js if you want to proceed. I'll continue to fix & test the other plugins.
/** MIT License (c) copyright 2010-2013 B Cavalier & J Hann */
/**
* curl json! plugin
*
* Like the text! plugin, will only load same-domain resources.
*/
(function (globalEval) {
define(/*=='curl/plugin/json',==*/ ['./_fetchText'], function (fetchText) {
var hasJsonParse, missingJsonMsg;
hasJsonParse = typeof JSON != 'undefined' && JSON.parse;
missingJsonMsg = 'Cannot use strictJSONParse without JSON.parse';
return {
load: function (absId, require, loaded, config) {
var evaluator, errback;
errback = loaded['error'] || error;
// create a json evaluator function
evaluator = config.strictJSONParse
? guard(parseSource, loaded, errback)
: guard(evalSource, loaded, errback);
// get the text, then eval it
fetchText(require['toUrl'](absId), evaluator, errback);
},
'cramPlugin': '../cram/json'
};
function error (ex) {
throw ex;
}
function evalSource (source) {
return globalEval('(' + source + ')');
}
function parseSource (source) {
if (!hasJsonParse) throw new Error(missingJsonMsg);
return JSON.parse(source);
}
function guard (evaluator, success, fail) {
return function (source) {
var value;
try {
value = evaluator(source);
}
catch (ex) {
return fail(ex);
}
return success(value);
}
}
});
}(
function () {/*jshint evil:true*/ return (1,eval)(arguments[0]); }
));
from curl.
It works!
from curl.
Related Issues (20)
- curl-css shouldn't wait for readystate == 'complete' HOT 7
- What if the module is a function? HOT 1
- Similar functionality of curl with require.js map config? HOT 1
- Using domReady! as a dependency argument causes an error HOT 4
- dealing with the window object HOT 7
- For anyone facing the error : Multiple anonymous defines encountered HOT 1
- Multiple bundles HOT 17
- Remove old IE event listeners in domReady HOT 1
- License for curl HOT 4
- "undefined" from import when define function throws an exception HOT 8
- Modules "undefined" when error occurs HOT 1
- "new Promise()" syntax non-standard? HOT 1
- Promise.then doesn't wait HOT 5
- Add build with js plugin
- multiple anonymous defines HOT 2
- How to help curl guess the right plugin? (e.g. json! for *.json) HOT 8
- Feature Request: Add syntax to bypass plugins
- cjsm11 loader hides a TypeError and falsely reports success
- ε¦δΉ HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curl.