Posts Tagged bug

Buggy FireBug

I have a page with Javascript loaded from different directories. For one reason, the Javascripts source loaded from one of the directories did not display. This means I could not use the debugger to insert break points directly. The Firbug version was 1.3.3. Initially, I was able to get the source code to show after randomly clicked around, i.e. click on Yslow and switch back to script tab. Unfortunately, it was not a reliable workaround. Eventually, an idea came to me to work around the issue: insert a runtime error. A runtime error can be as simple as referencing a non-existing function. Make sure you don’t introduce syntax error, which will stop the browser from reading the source code. With the new runtime error, Firebug will show an error in the console and provide a link to the source code. Once I could see the source code, I added break points at the lines that I was actually interested and removed the artificial runtime error from the source code before reloaded the page.

Leave a Comment

An IE 7 bug

Recently, I encountered an IE 7 bug and it’s documented at here. I try to see if I can workaround the issue next week.

Leave a Comment

Enabling use of “defaultValue” with JSON data source for Ext JS

I have a JSON response that has data in a nested object within a data entry. Mapping and reading the nested data is easy and straightforward. The interesting part is that the nested object is optional and therefore may not exist in the response sometimes. Unfortunately, JsonReader can’t handle this and would throw a silent exception that caused the whole UI initialization to halt. The API doc seem to suggest that the proper behavior is for the library to use pre-configured defaultValue when data doesn’t exist. Here is the original code from the readRecords function from JsonReader:

for(var j = 0; j < fl; j++){
  f = fi[j];
  var v = this.ef[j](n);
  values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, n);
}

Exception would occur at the point of calling this.ef[j](n) to access the data at field index j from the parameter n, which contains JSON fragment. This prevented the defaultValue ever being used in the next line.

What I did to work around this issue is to add a try-catch block around the line and set v to undefined in the catch clause. This allows the defaultValue to be used when data is missing.

Leave a Comment