Ticket #9375 (assigned defect)

Opened 8 months ago

Last modified 4 months ago

support for WebKit's displayName feature of naming anonymous functions

Reported by: pmuellr Owned by: alex
Priority: normal Milestone: future
Component: General Version: 1.3.0
Severity: normal Keywords:
Cc:

Description

See:

http://www.alertdebugging.com/2009/04/29/building-a-better-javascript-profiler-with-webkit/

I suspect it would be possible to enable dojo to do some automatic naming of functions on behalf of the user. For instance, when defining classes, iterating through the properties looking for functions, associating the property name with the function name. Also on event handlers.

The logic should probably involve checking the "name" property of the function first, and if undefined, then setting displayName as appropriate.

The name doesn't have to be just the name of the function. I've played around a bit with some other frameworks where I tack on "class" names before the function name, and distinguish "class" methods from "instance" methods by separating the class and function name with different characters. eg, SomeClass?.classMethod and SomeClass::instanceMethod.

Change History

Changed 8 months ago by jburke

We have something in the build tool that will add names:

symbol= Inserts function symbols as global references so that anonymous functions will show up in all debuggers (esp. IE which does not attempt to infer function names from the context of their definition). Valid values are "long" and "short". If "short" is used, then a symboltables.txt file will be generated in each module prefix's release directory which maps the short symbol names to more descriptive names.

Any suggestions on how to do this effectively at runtime without needing a build is appreciated. My first thought would be using some regexp goo before we eval the module (or in xdomain, before calling the function to define the module). Maybe we only do this kind of work if djConfig.isDebug is true or more likely if djConfig.debugAtAllCosts is true.

Changed 8 months ago by alex

james:

for stuff that's declare()'d, I think we can probably go the distance by changing how declare() handles this stuff in debug mode. For other things (module-level stuff), I think we'll probably need toe extend the loader.

Changed 7 months ago by alex

  • owner changed from anonymous to alex
  • status changed from new to assigned

Changed 4 months ago by jburke

  • milestone changed from tbd to future
Note: See TracTickets for help on using tickets.