aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGianni Chiappetta <gianni@runlevel6.org>2011-01-21 10:33:50 -0500
committerGianni Chiappetta <gianni@runlevel6.org>2011-01-21 10:33:50 -0500
commit574ae3b1be555dbd5242532739cd8e0a34e0569c (patch)
tree4bcfbf7322d331f83161e3b5953e361824e08b10
parenta03f040dbfb12da6409e31cb5923550d4be4a99e (diff)
downloadjquery-574ae3b1be555dbd5242532739cd8e0a34e0569c.tar.gz
jquery-574ae3b1be555dbd5242532739cd8e0a34e0569c.zip
added: Backcompatibility with old proxy syntax.
-rw-r--r--src/core.js6
-rw-r--r--test/unit/core.js6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/core.js b/src/core.js
index 3bdedf53f..ea3506a60 100644
--- a/src/core.js
+++ b/src/core.js
@@ -739,6 +739,12 @@ jQuery.extend({
proxy: function( fn, context ) {
var args, proxy;
+ // XXX BACKCOMPAT: Support old string method.
+ if ( typeof context === "string" ) {
+ fn = fn[ context ];
+ context = arguments[0];
+ }
+
// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
if ( ! jQuery.isFunction( fn ) ) {
diff --git a/test/unit/core.js b/test/unit/core.js
index 7638554ac..332fc51e5 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -869,7 +869,7 @@ test("jQuery.isEmptyObject", function(){
});
test("jQuery.proxy", function(){
- expect(5);
+ expect(6);
var test = function(){ equals( this, thisObject, "Make sure that scope is set properly." ); };
var thisObject = { foo: "bar", method: test };
@@ -890,6 +890,10 @@ test("jQuery.proxy", function(){
// Partial application w/ normal arguments
var test3 = function( a, b ){ equals( b, "normal", "Ensure arguments can be pre-applied and passed as usual." ); };
jQuery.proxy( test3, null, "pre-applied" )( "normal" );
+
+ // Test old syntax
+ var test4 = { meth: function( a ){ equals( a, "boom", "Ensure old syntax works." ); } };
+ jQuery.proxy( test4, "meth" )( "boom" );
});
test("jQuery.parseJSON", function(){