Ticket #2529742 (closed enhancement)
ReporterMichael Hasenstein |
Opened: 01/5/11 Last modified: 08/1/12 Status: closed Type: enhancement Resolution: fixed |
Owner Dav Glass |
Target Release: 3.6.0 Priority: P3 (normal) |
|---|---|---|---|
| Summary: | Y[UI()].use() callback's 2nd parameter: 2 issues | ||
| Description: | When performing a Y.use(modules, callback) the callback gets TWO parameters: The YUI instance, AND a response object from the loader. Issues: - That 2nd parameter is not documented. - The response is "success" when I try to load a module that the loader does not know about: Y.use('no-such-module', function (Y, result) {console.dir(result);}) Hoowever, when I have a group-configuration for my own modules and try to load a non-existing module matching that group's pattern the loader goes out and trys to load it, and in this case I DO get In general, I think having the response object is MOST helpful. I know in the YUI-configuration I can specify onsuccess and onfailure handlers, but the disadvantage of them is they are global and I So I would like to vote for making it "offical" by adding it to the documentation, and for making it work consistently (returning an error in the above example where there is no XHR call going on |
||
| Type: | enhancement | Observed in Version: | development master |
| Component: | YUI Global Object | Severity: | S3 (normal) |
| Assigned To: | Dav Glass | Target Release: | 3.6.0 |
| Location: | Library Code | Priority: | P3 (normal) |
| Tags: | Relates To: | ||
| Browsers: | N/A | ||
| URL: | |||
| Test Information: | |||
Change History
|
Posted: 01/5/11
|
|
Posted: 01/5/11
One more update: When I force the loader to try to load a module (by specifying a group and a pattern for it, and using a module name matching that pattern, so that the loader cannot decide if it's a valid module without trying to load it from the server) I get a (correct) error (success:false) in the response. However, when I perform the call a second time I also get {success:true}, so it seems if there is a cache hit one always gets the same response. |
|
Posted: 01/5/11
'no-such-module' is a dev-time problem. Use the -debug version of the seed file during development and the console log will let you know you have a problem. Missing modules are currently messaged even when you use the -min file. Success is reported because these mistakes are normally typos, and YUI will attach what it can and try to continue -- I'll look at this part. Regarding the error response you saw with pattern matched modules, you must be using firefox -- other browsers will report success even though there was a 404 error, or they will just hang until a timeout if defined. This is a general problem with script loading that I'm in the process of making easier to deal with. |
|
Posted: 01/5/11
> 'no-such-module' is a dev-time problem I beg to differ - slightly :-) You're thinking of "closed" apps. I have generic application code which depending on the URL of the link clicked loads a module with the appropriate name. If the link is /items/12 it loads "mysite-items", etc. So on the one hand yes, that COULD be considered dev. issue - but not if I don't control everything, all modules, all links and all pages. I would like to be able to live with an error introduced by one of many people or entities, for which no one would be personally responsible, it just happens that there's a link that SHOULD lead to loading the appropriate module, but there is no module. You guys make sure everything in YUI is sooo generic, modular, ready for distributed modular apps - living with fallability is one aspect. Background: I have written (based on Dav Glass's work) a site that works with or without Javascript, all rendering is done on the server by node.js if necessary. Also, if there IS Javascript, I don't let the browser change the page - only the homepage is loaded and ALL links are intercepted, a URL which normally is /items/12 is translated to /#/items/12, so that my client side app keeps the original real URL (path) in the hash and history and bookmarks work. For any clicks on links that client side code loads a module "mysite-firstPartOfLink" (example as above) and let's it render into the content container of the page. It works! But I don't see how I can check in advance that every link will always have the appropriate module. Or, better, why I even should. Sure it's an error, but with the same argument you could say 404/Not Found pages are unnecessary because they should never happen. What if a user enters a link manually and mistypes it? What if a bookmarked link is no longer valid and now leads to the attempt to load a module that no longer exists? Anyway, this way the website's CSS and JS are loaded *and parsed* by the browser only ONCE in addition to all the other niceties of having the same code on client and server and of having it work with or without client-side JS. It works! Okay, that's not quite a necessary part of the bug report, just some background. |
|
Posted: 04/20/11
|
|
Posted: 04/26/11
|
|
Posted: 03/30/12
|
|
Posted: 04/5/12
|
|
Posted: 05/21/12
|
|
Posted: 05/21/12
Fixes #2529742 - Better messaging in status object of use callback |
|
Posted: 08/1/12
Shipped in 3.6.0. Marking closed/fixed. |
George
I just found that when I do the same (definitely failing) call twice I get different results (and both are wrong as stated above):
CODE: Y.use('no-such-module', function (Y, result) {console.dir(result);})
RESULT 1: {data:["no-such-module"], msg:"success", success:true}
RESULT 2: {success:true}