Is the Visual Studio 2008 Javascript debugger crippled?
Sadly, it appears the answer is "yes". Specifically, the debugger has a huge limitation - one that's been there since Visual Studio 2005 (maybe even 2003). You can't set a breakpoint on the first line of an anonymous function. Consider, for example, the following:
1: <script type="text/javascript">
2: function aFunc()
3: {
4: alert("hi");
5: }
6:
7: var aFunc2 = function()
8: {
9: alert("hi, yourself");
10: alert("what's your problem?");
11: }
12:
13: aFunc();
14: aFunc2();
15: </script>
Here aFunc is a named function, and aFunc2 is a variable that points to an anonymous function. With the Visual Studio debugger, you can set a breakpoint on line 4, and line 10, but not line 9.
Why is this such a problem? Because most all the major Javascript libraries (at least Prototype, YUI, JQuery, and even, to a lesser extent, Microsoft's own ASP.NET AJAX) use anonymous functions up the ying yang - mostly for object methods. In other words, you can't set a breakpoint on the first line of most functions in most AJAX libraries. And if the function has only one line, yeah, you're screwed - no break-ey break-ey for you.
When I learned that this bug wasn't fixed in Visual Studio 2008 I was, in a word, dumbfounded. Isn't improved Javascript development one of the primary new features of VS2008?
Now, when I characterized the problem as being related to anonymous functions, that isn't quite right. In the above code, even if you give the aFunc2 function a name - "var aFunct2 = function theFunc()..."- the problem remains. There's a brief discussion of this issue on the ASP.NET forums here (note the date - March 2007), but the explanation rather nebulous. Whatever the root cause, it's a horrible limitation that I'm stunned wasn't addressed for RTM.
Guess it's back to Firebug for me. Or maybe it's time for another look at Aptana.