@@ -89,7 +89,7 @@ test( "jQuery usage", function() {
89
89
"parameter passed via .pluginName(methodName, param)" ) ;
90
90
equals ( param2 , "value2" ,
91
91
"multiple parameters passed via .pluginName(methodName, param, param)" ) ;
92
-
92
+
93
93
return this ;
94
94
} ,
95
95
getterSetterMethod : function ( val ) {
@@ -153,17 +153,17 @@ test( "direct usage", function() {
153
153
}
154
154
}
155
155
} ) ;
156
-
156
+
157
157
var elem = $ ( "<div>" ) [ 0 ] ;
158
-
158
+
159
159
shouldCreate = true ;
160
160
var instance = new $ . ui . testWidget ( { } , elem ) ;
161
161
shouldCreate = false ;
162
162
163
163
equals ( $ ( elem ) . data ( "testWidget" ) , instance ,
164
164
"instance stored in .data(pluginName)" ) ;
165
165
equals ( instance . element [ 0 ] , elem , "element stored on widget" ) ;
166
-
166
+
167
167
var ret = instance . methodWithParams ( "value1" , "value2" ) ;
168
168
equals ( ret , instance , "plugin returned from method call" ) ;
169
169
@@ -193,7 +193,7 @@ test( "error handling", function() {
193
193
equal ( msg , "no such method '_privateMethod' for testWidget widget instance" ,
194
194
"invalid method call on widget instance" ) ;
195
195
} ;
196
- $ ( "<div>" ) . testWidget ( ) . testWidget ( "_privateMethod" ) ;
196
+ $ ( "<div>" ) . testWidget ( ) . testWidget ( "_privateMethod" ) ;
197
197
$ . error = error ;
198
198
} ) ;
199
199
@@ -463,7 +463,7 @@ test( ".option() - delegate to ._setOptions()", function() {
463
463
calls = [ ] ;
464
464
div . testWidget ( "option" , "foo" , "bar" ) ;
465
465
same ( calls , [ { foo : "bar" } ] , "_setOptions called for single option" ) ;
466
-
466
+
467
467
calls = [ ] ;
468
468
div . testWidget ( "option" , {
469
469
bar : "qux" ,
@@ -490,7 +490,7 @@ test( ".option() - delegate to ._setOption()", function() {
490
490
div . testWidget ( "option" , "foo" , "bar" ) ;
491
491
same ( calls , [ { key : "foo" , val : "bar" } ] ,
492
492
"_setOption called for single option" ) ;
493
-
493
+
494
494
calls = [ ] ;
495
495
div . testWidget ( "option" , {
496
496
bar : "qux" ,
@@ -666,6 +666,39 @@ test( "._bind() to descendent", function() {
666
666
. trigger ( "keydown" ) ;
667
667
} ) ;
668
668
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
+
669
702
test ( "._hoverable()" , function ( ) {
670
703
$ . widget ( "ui.testWidget" , {
671
704
_create : function ( ) {
@@ -703,14 +736,14 @@ test( "._focusable()", function() {
703
736
this . _focusable ( this . element . children ( ) ) ;
704
737
}
705
738
} ) ;
706
-
739
+
707
740
var div = $ ( "#widget" ) . testWidget ( ) . children ( ) ;
708
741
ok ( ! div . hasClass ( "ui-state-focus" ) , "not focused on init" ) ;
709
742
div . trigger ( "focusin" ) ;
710
743
ok ( div . hasClass ( "ui-state-focus" ) , "focused after explicit focus" ) ;
711
744
div . trigger ( "focusout" ) ;
712
745
ok ( ! div . hasClass ( "ui-state-focus" ) , "not focused after blur" ) ;
713
-
746
+
714
747
div . trigger ( "focusin" ) ;
715
748
ok ( div . hasClass ( "ui-state-focus" ) , "focused after explicit focus" ) ;
716
749
$ ( "#widget" ) . testWidget ( "disable" ) ;
@@ -719,7 +752,7 @@ test( "._focusable()", function() {
719
752
ok ( ! div . hasClass ( "ui-state-focus" ) , "can't focus while disabled" ) ;
720
753
$ ( "#widget" ) . testWidget ( "enable" ) ;
721
754
ok ( ! div . hasClass ( "ui-state-focus" ) , "enabling doesn't reset focus" ) ;
722
-
755
+
723
756
div . trigger ( "focusin" ) ;
724
757
ok ( div . hasClass ( "ui-state-focus" ) , "focused after explicit focus" ) ;
725
758
$ ( "#widget" ) . testWidget ( "destroy" ) ;
0 commit comments