Skip to content

Commit

Permalink
Make proxied functions look nicely in Web Inspector "Event Listeners"…
Browse files Browse the repository at this point in the history
… pane.
  • Loading branch information
NV committed Jun 4, 2010
1 parent 1533bf7 commit 0c8b24e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/core.js
Expand Up @@ -697,6 +697,12 @@ jQuery.extend({
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
}

if ( proxy && fn ) {
proxy.toString = function() {
return fn.toString();
};
}

// So proxy can be declared as an argument
return proxy;
},
Expand Down
8 changes: 7 additions & 1 deletion test/unit/core.js
Expand Up @@ -794,7 +794,7 @@ test("jQuery.isEmptyObject", function(){
});

test("jQuery.proxy", function(){
expect(4);
expect(5);

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

// Use the string shortcut
jQuery.proxy( thisObject, "method" )();

function dummy(){
return this;
}
equals( jQuery.proxy( dummy, {} ).toString(), dummy.toString(), "Make sure the proxied function looks like the original one." );

});

test("jQuery.parseJSON", function(){
Expand Down

0 comments on commit 0c8b24e

Please sign in to comment.