Skip to content

Commit 0c8b24e

Browse files
committed
Make proxied functions look nicely in Web Inspector "Event Listeners" pane.
1 parent 1533bf7 commit 0c8b24e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/core.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,12 @@ jQuery.extend({
697697
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
698698
}
699699

700+
if ( proxy && fn ) {
701+
proxy.toString = function() {
702+
return fn.toString();
703+
};
704+
}
705+
700706
// So proxy can be declared as an argument
701707
return proxy;
702708
},

test/unit/core.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ test("jQuery.isEmptyObject", function(){
794794
});
795795

796796
test("jQuery.proxy", function(){
797-
expect(4);
797+
expect(5);
798798

799799
var test = function(){ equals( this, thisObject, "Make sure that scope is set properly." ); };
800800
var thisObject = { foo: "bar", method: test };
@@ -810,6 +810,12 @@ test("jQuery.proxy", function(){
810810

811811
// Use the string shortcut
812812
jQuery.proxy( thisObject, "method" )();
813+
814+
function dummy(){
815+
return this;
816+
}
817+
equals( jQuery.proxy( dummy, {} ).toString(), dummy.toString(), "Make sure the proxied function looks like the original one." );
818+
813819
});
814820

815821
test("jQuery.parseJSON", function(){

0 commit comments

Comments
 (0)