@@ -89,7 +89,7 @@ test( "jQuery usage", function() {
8989 "parameter passed via .pluginName(methodName, param)" ) ;
9090 equals ( param2 , "value2" ,
9191 "multiple parameters passed via .pluginName(methodName, param, param)" ) ;
92-
92+
9393 return this ;
9494 } ,
9595 getterSetterMethod : function ( val ) {
@@ -153,17 +153,17 @@ test( "direct usage", function() {
153153 }
154154 }
155155 } ) ;
156-
156+
157157 var elem = $ ( "<div>" ) [ 0 ] ;
158-
158+
159159 shouldCreate = true ;
160160 var instance = new $ . ui . testWidget ( { } , elem ) ;
161161 shouldCreate = false ;
162162
163163 equals ( $ ( elem ) . data ( "testWidget" ) , instance ,
164164 "instance stored in .data(pluginName)" ) ;
165165 equals ( instance . element [ 0 ] , elem , "element stored on widget" ) ;
166-
166+
167167 var ret = instance . methodWithParams ( "value1" , "value2" ) ;
168168 equals ( ret , instance , "plugin returned from method call" ) ;
169169
@@ -193,7 +193,7 @@ test( "error handling", function() {
193193 equal ( msg , "no such method '_privateMethod' for testWidget widget instance" ,
194194 "invalid method call on widget instance" ) ;
195195 } ;
196- $ ( "<div>" ) . testWidget ( ) . testWidget ( "_privateMethod" ) ;
196+ $ ( "<div>" ) . testWidget ( ) . testWidget ( "_privateMethod" ) ;
197197 $ . error = error ;
198198} ) ;
199199
@@ -463,7 +463,7 @@ test( ".option() - delegate to ._setOptions()", function() {
463463 calls = [ ] ;
464464 div . testWidget ( "option" , "foo" , "bar" ) ;
465465 same ( calls , [ { foo : "bar" } ] , "_setOptions called for single option" ) ;
466-
466+
467467 calls = [ ] ;
468468 div . testWidget ( "option" , {
469469 bar : "qux" ,
@@ -490,7 +490,7 @@ test( ".option() - delegate to ._setOption()", function() {
490490 div . testWidget ( "option" , "foo" , "bar" ) ;
491491 same ( calls , [ { key : "foo" , val : "bar" } ] ,
492492 "_setOption called for single option" ) ;
493-
493+
494494 calls = [ ] ;
495495 div . testWidget ( "option" , {
496496 bar : "qux" ,
@@ -666,6 +666,39 @@ test( "._bind() to descendent", function() {
666666 . trigger ( "keydown" ) ;
667667} ) ;
668668
669+ test ( "_bind() with delegate" , function ( ) {
670+ expect ( 8 ) ;
671+ $ . widget ( "ui.testWidget" , {
672+ _create : function ( ) {
673+ this . element = {
674+ bind : function ( event , handler ) {
675+ equal ( event , "click.testWidget" ) ;
676+ ok ( $ . isFunction ( handler ) ) ;
677+ } ,
678+ delegate : function ( selector , event , handler ) {
679+ equal ( selector , "a" ) ;
680+ equal ( event , "click.testWidget" ) ;
681+ ok ( $ . isFunction ( handler ) ) ;
682+ } ,
683+ trigger : $ . noop
684+ } ;
685+ this . _bind ( {
686+ "click" : "handler" ,
687+ "click a" : "handler" ,
688+ } ) ;
689+ this . element . delegate = function ( selector , event , handler ) {
690+ equal ( selector , "form fieldset > input" ) ;
691+ equal ( event , "change.testWidget" ) ;
692+ ok ( $ . isFunction ( handler ) ) ;
693+ } ;
694+ this . _bind ( {
695+ "change form fieldset > input" : "handler"
696+ } ) ;
697+ }
698+ } ) ;
699+ $ . ui . testWidget ( ) ;
700+ } ) ;
701+
669702test ( "._hoverable()" , function ( ) {
670703 $ . widget ( "ui.testWidget" , {
671704 _create : function ( ) {
@@ -703,14 +736,14 @@ test( "._focusable()", function() {
703736 this . _focusable ( this . element . children ( ) ) ;
704737 }
705738 } ) ;
706-
739+
707740 var div = $ ( "#widget" ) . testWidget ( ) . children ( ) ;
708741 ok ( ! div . hasClass ( "ui-state-focus" ) , "not focused on init" ) ;
709742 div . trigger ( "focusin" ) ;
710743 ok ( div . hasClass ( "ui-state-focus" ) , "focused after explicit focus" ) ;
711744 div . trigger ( "focusout" ) ;
712745 ok ( ! div . hasClass ( "ui-state-focus" ) , "not focused after blur" ) ;
713-
746+
714747 div . trigger ( "focusin" ) ;
715748 ok ( div . hasClass ( "ui-state-focus" ) , "focused after explicit focus" ) ;
716749 $ ( "#widget" ) . testWidget ( "disable" ) ;
@@ -719,7 +752,7 @@ test( "._focusable()", function() {
719752 ok ( ! div . hasClass ( "ui-state-focus" ) , "can't focus while disabled" ) ;
720753 $ ( "#widget" ) . testWidget ( "enable" ) ;
721754 ok ( ! div . hasClass ( "ui-state-focus" ) , "enabling doesn't reset focus" ) ;
722-
755+
723756 div . trigger ( "focusin" ) ;
724757 ok ( div . hasClass ( "ui-state-focus" ) , "focused after explicit focus" ) ;
725758 $ ( "#widget" ) . testWidget ( "destroy" ) ;
0 commit comments