Side navigation
#5275 closed enhancement (wontfix)
Opened September 21, 2009 08:56AM UTC
Closed November 19, 2010 10:14AM UTC
jquery.extend should set displayName on functions
| Reported by: | dwt | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.4 |
| Component: | core | Version: | 1.3.2 |
| Keywords: | Cc: | felix.schwarz@agile42.com | |
| Blocked by: | Blocking: |
Description
Both Firebug and the Safari debugger support the convention that if a function has the displayName propperty set, that will be used to display it's name in the debugger.
(see : http://www.alertdebugging.com/2009/04/29/building-a-better-javascript-profiler-with-webkit/)
This is mightily usefull as one doesn't get as many 'anonymous functions) in the stacktrace which makes it much easier to work with it.
Here's a monkey-patched version that does enough to make it useful for me - but this should really be in the core of jQuery Extend:
(function() {
var oldExtend = $.fn.extend;
function isSecondArgumentDictionary(arguments) {
var methodDict = arguments[1];
return (2 === arguments.length)
&& (null !== methodDict || 'object' === typeof(methodDict));
}
$.extend = function namingExtend() {
if (isSecondArgumentDictionary(arguments)) {
var methodDict = arguments[1];
for (var key in arguments[1]) {
if ($.isFunction(methodDict[key])
&& ! methodDict[key].displayName)
methodDict[key].displayName = key;
}
}
return oldExtend.apply(this, arguments);
};
}());
Attachments (0)
Change History (3)
Changed September 24, 2009 02:32AM UTC by comment:1
| priority: | major → minor |
|---|---|
| type: | bug → enhancement |
Changed November 24, 2009 10:58AM UTC by comment:2
Does this have any chance of getting into core? I gather it is very usefull to all users while not having any incompatibility problems at all.
Changed November 19, 2010 10:14AM UTC by comment:3
| resolution: | → wontfix |
|---|---|
| status: | new → closed |
This should go into a debug plugin, not core.