1

I'm working on an ExtJS application, and there is a compatibility problem with Internet Explorer. The app breaks and throws an error corresponding to this line of code :

execScript(code);

Using IE Developer Tools, I found out the code variable contains the class declaration for a custom-made component. I have no idea what is causing this error. I have checked this file 3 times already (1400 lines of code). For the record, this works perfectly on Firefox and Chrome...

So, I was wondering if there was a way of knowing more about what went wrong, and get like a line number, or a stack trace, so I can correct this.

Any help appreciated. Thanks !

3rgo
  • 3,115
  • 7
  • 31
  • 44
  • Yes, that's how I knew the application was breaking at execScript. But I could't go any deeper – 3rgo Jan 15 '13 at 15:49
  • What exactly does the string in "code" look like? – Pointy Jan 15 '13 at 15:54
  • It's a class declaration. It can be found here : https://github.com/JoeKuan/Highcharts_Sencha/blob/master/Chart/ux/Highcharts.js – 3rgo Jan 15 '13 at 16:03
  • 1
    it's weird that it works in Firefox considering `execScript` does not exist... – jbabey Jan 15 '13 at 16:06
  • What if you include a [`debugger;` statement](http://stackoverflow.com/questions/1265623/programmatically-stop-javascript-execution-in-firefox-firebug) in your code? That might allow you to step through the execution of your code string. – apsillers Jan 15 '13 at 16:06
  • @jbabey: In ExtJS definition the code is actually `Ext.globalEval = Ext.global.execScript ? function(code) { execScript(code); } : function($$code) { (function(){ eval($$code); }()); };` So it can work in all browsers – 3rgo Jan 15 '13 at 16:10
  • @apsillers : I don't need to add a breakpoint. I know where it breaks. I just want to know if there is a way to find out why execScript throws the error – 3rgo Jan 15 '13 at 16:12
  • @Squ36 Just to be totally clear: I meant to try running `execScript("debugger;" + code);` so your debugger will step though the execution of your *code string*. Looking at my previous comment, I realize that I wasn't totally clear on that point. How that I've clarified, does that help at all, or did you understand me the first time? (That is, when you say "I know where it breaks", you mean you know which line in the execution of `code` breaks, but you don't understand the nature of the error? Or do you only mean that you know that `execScript` breaks?) – apsillers Jan 15 '13 at 16:28
  • @apsillers : Ah sorry I misunderstood. I'll try that, and get back to you. I know that the errors is caused by execScript, but I don't know why it fails – 3rgo Jan 15 '13 at 16:36
  • @apsillers: It does not work as expected. I get a breakpoint for each loaded script file (and I could parse them line by line), but when the faulty file should come up, it just throws an error, gets me back to the ExtJS file (the one where execScript is called) and stops working... – 3rgo Jan 15 '13 at 17:05

1 Answers1

0

Had exactly the same problem.

It took a long time to figure out what the problem was, but in our case we were creating a double array, from two seperate object literals (Status and StatusElements). See below.

Status = {
    'new': 10,
    'automatic': 15}

StatusElements = {
    10: { name: 'new', color: 'black', bgcolor: '#ffd3cf'},
    15: { name: 'automatic', color: 'black', bgcolor: '#'}}

var y =  [
    [Status.new, StatusElements[Status.new].name],
    [Status.automatic, StatusElements[Status.automatic].name]
    ]

For some reason Internet Explorer blows up when trying to evalutate y above.

I honestly have no idea why execScript(code); fails with the above code in Internet Explorer. Maybe it is the order of evalutation. Maybe it tries to evalutate y before evaluating Status and StatusElements. Anyway we fixed it by reducing the complexity and just having y equal some raw values.

Oliver Watkins
  • 12,575
  • 33
  • 119
  • 225