Ticket #7082 (closed defect: fixed)
Dojo 1.0.2 to Dojo 1.1/1.1.1 migration - dojo.fromJson
| Reported by: | guest | Owned by: | peller |
|---|---|---|---|
| Priority: | high | Milestone: | 1.2 |
| Component: | General | Version: | 1.1.1 |
| Severity: | minor | Keywords: | Dojo 1.1.1 migration from Dojo 1.0 |
| Cc: | yazad3@… |
Description
Hi,
We are trying to migrate our application from Dojo 1.0.2 to Dojo 1.1.1. We came across the error Syntax Error () on dojo.js line 20 ie line 2707 in dojo.js.uncompressed.js. The line is return eval("(" + json + ")"); // Object
I acknowledge that this is discussed in the release note of Dojo 1.1. However the error is not from any of the files that we are using but in fact seems to come from an internal call from Dojo API itself.
I got this error in 2 out of some 10 odd screens in our application and the patter of files loaded before the error was (from FireBug?): GET http://localhost:8080/itaacOnline/js/dojo/dijit/TitlePane.js (16ms)dojo.js (line 1406) GET http://localhost:8080/itaacOnline/js/dojo/dojo/fx.js (16ms)dojo.js (line 1406) GET http://localhost:8080/itaacOnline/js/dojo/dijit/layout/ContentPane.js (15ms)dojo.js (line 1406) GET http://localhost:8080/itaacOnline/js/dojo/dijit/layout/_LayoutWidget.js (15ms)dojo.js (line 1406) GET http://localhost:8080/itaacOnline/js/dojo/dijit/nls/loading.js (15ms)dojo.js (line 1406) the issue comes after these 5 files are loaded...
I am unable to find the root cause of the issue.
I made a change in the code such that a NULL is returned whenever an empty string or null is received as input and the application seems to work fine.
dojo.fromJson = function(/*String*/ json){
if (json != null && json != "") {
return eval("(" + json + ")"); // Object
} else {
console.debug("Returning NULL..."); return null;
}
}
I understand throwing errors from invalid strings is the right thing to do but shouldn't this method return a null when an EMPTY (""/null) string is encountered?
Because of this issue my pages were getting distorted (esp. the menu) and did NOT function at all... If you have another 1.1.x release, I request you to consider looking at this issue at higest priority.
Also please let me know if there is anything I can do to help. I am not a dojo champ, but will try my best. Thank you in advance.
Regards, Yazad Khambata