]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Maintain stack when a method returns a jQuery object. Fixes #5732 - Widget...
authorScott González <scott.gonzalez@gmail.com>
Tue, 22 Mar 2011 18:35:18 +0000 (14:35 -0400)
committerScott González <scott.gonzalez@gmail.com>
Tue, 22 Mar 2011 18:35:18 +0000 (14:35 -0400)
tests/unit/widget/widget_core.js
ui/jquery.ui.widget.js

index 31942379712b8073f45f4669f2785a9416ff6084..300acd0d8bdb7f6878b81ec2cc37f3e8e294c85b 100644 (file)
@@ -74,7 +74,7 @@ test( "element normalization", function() {
 });
 
 test( "jQuery usage", function() {
-       expect( 11 );
+       expect( 13 );
 
        var shouldCreate = false;
 
@@ -98,6 +98,9 @@ test( "jQuery usage", function() {
                        } else {
                                return this.getterSetterVal;
                        }
+               },
+               jQueryObject: function() {
+                       return $( "body" );
                }
        });
 
@@ -120,6 +123,9 @@ test( "jQuery usage", function() {
        ret = elem.testWidget( "getterSetterMethod", 30 );
        equals( ret, elem, "getter/setter method can be chainable" );
        equals( instance.getterSetterVal, 30, "getter/setter can act as setter" );
+       ret = elem.testWidget( "jQueryObject" );
+       equal( ret[ 0 ], document.body, "returned jQuery object" );
+       equal( ret.end(), elem, "stack preserved" );
 });
 
 test( "direct usage", function() {
@@ -765,7 +771,7 @@ test( "._trigger() - provide event and ui", function() {
        .testWidget( "testEvent" );
 });
 
-test( "._triger() - instance as element", function() {
+test( "._trigger() - instance as element", function() {
        expect( 4 );
        $.widget( "ui.testWidget", {
                defaultElement: null,
index 6c6ba3864cf3a02cc17a719c9cb6a58baac7699d..7c8567ced214d49817cc89a49de300b997961e46 100644 (file)
@@ -116,7 +116,9 @@ $.widget.bridge = function( name, object ) {
                                }
                                var methodValue = instance[ options ].apply( instance, args );
                                if ( methodValue !== instance && methodValue !== undefined ) {
-                                       returnValue = methodValue;
+                                       returnValue = methodValue.jquery ?
+                                               returnValue.pushStack( methodValue.get() ) :
+                                               methodValue;
                                        return false;
                                }
                        });