Evren Kuzucuoglu
Evren Kuzucuoglu

Reputation: 3885

Firefox javascript interpreter or Firebug skipping lines

Here is a piece of jquery/javascript code I didn't write but I am trying to debug on Firebug (I copy/pasted it as is, just adding some spaces for good alineation):

 if (control == "#testTakerSearchSource" && object !== undefined && object[key] !== undefined && key == "datasets" && object[key].length >= 3) {
    var afterValues = [];
    if (object[key].length == 3 && object[key][0] == "1") {
        afterValues[0] = "1,2,3";
        object[key] = afterValues;
    }
    else {
        var beforeValues = object[key];
        afterValues[0] = "1,2,3";
        for (var i = 3; i < beforeValues.length; i++) {
            afterValues[i - 2] = beforeValues[i];
        }
        object[key] = afterValues;
    }
} 

I set a breakpoint of the first line. It stops as it should. When I hit F10, it just goes straight to the afterValues[i - 2] = beforeValues[i]; line, jumping several brackets right into a for loop... I tried restarting FF of course, but the bug happens again, and as far as I can tell it happens on at least an other machine.

My guess is I'm using a reserved keyword or something. I'm going to rewrite this as I don't like the way it looks anyway, but does anyone have an idea why it happens?

Firefox 14.0.1

Firebug 1.10.3

jQuery 1.8.0

jQuery-ui 1.8.23

Edit:

I tried this:

 try {
    if (control == "#testTakerSearchSource" && object !== undefined && object[key] !== undefined && key == "datasets" && object[key].length >= 3) {
        var afterValues = [];
        if (object[key].length == 3 && object[key][0] == "1") {
            afterValues[0] = "1,2,3";
            object[key] = afterValues;
        }
        else {
            var beforeValues = object[key];
            afterValues[0] = "1,2,3";
            for (var i = 3; i < beforeValues.length; i++) {
                afterValues[i - 2] = beforeValues[i];
            }
            object[key] = afterValues;
        }
    }
}
catch (err) {
    alert(err);
} 

Now if I set a breakpoint on the same line, it jumps to the object[key] = afterValues; line instead. If I continue, no exception is catched...

Edit2: other hypothesis: Firefox has a somehow different version of my js file somewhere than the one it's actually showing me. Would that make sense? I restarted the whole thing though so I don't know how that would happen...

Upvotes: 3

Views: 605

Answers (2)

Evren Kuzucuoglu
Evren Kuzucuoglu

Reputation: 3885

I ended up rewriting that part, I have no clue why it happened and Firebug was updated since then

Upvotes: 1

Abhi
Abhi

Reputation: 6588

I think this may be due to some exception in the code . My suggesstion is to modify you code with error handling

try
  {
   //your code if (control == "#testTakerSearchSource" && .........
  }
catch(err)
  {
   alert(err);
  }

Upvotes: 2

Related Questions