]> source.dussan.org Git - jquery.git/commitdiff
added: Backcompatibility with old proxy syntax. 133/head
authorGianni Chiappetta <gianni@runlevel6.org>
Fri, 21 Jan 2011 15:33:50 +0000 (10:33 -0500)
committerGianni Chiappetta <gianni@runlevel6.org>
Fri, 21 Jan 2011 15:33:50 +0000 (10:33 -0500)
src/core.js
test/unit/core.js

index 3bdedf53ff837b484c1bceb36800314787a1008d..ea3506a60a02af03063bfe2f899aa123222c4c1b 100644 (file)
@@ -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 ) ) {
index 7638554ac53796eff927daa3d383089746358994..332fc51e529c046717d0628318aa9c98bcbf207c 100644 (file)
@@ -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(){