File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -666,6 +666,40 @@ 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+ var that = this ;
674+ this . element = {
675+ bind : function ( event , handler ) {
676+ equal ( event , "click.testWidget" ) ;
677+ ok ( $ . isFunction ( handler ) ) ;
678+ } ,
679+ delegate : function ( selector , event , handler ) {
680+ equal ( selector , "a" ) ;
681+ equal ( event , "click.testWidget" ) ;
682+ ok ( $ . isFunction ( handler ) ) ;
683+ } ,
684+ trigger : $ . noop
685+ }
686+ this . _bind ( {
687+ "click" : "handler" ,
688+ "click a" : "handler" ,
689+ } ) ;
690+ this . element . delegate = function ( selector , event , handler ) {
691+ equal ( selector , "form fieldset > input" ) ;
692+ equal ( event , "change.testWidget" ) ;
693+ ok ( $ . isFunction ( handler ) ) ;
694+ } ;
695+ this . _bind ( {
696+ "change form fieldset > input" : "handler"
697+ } ) ;
698+ }
699+ } ) ;
700+ $ . ui . testWidget ( ) ;
701+ } )
702+
669703test ( "._hoverable()" , function ( ) {
670704 $ . widget ( "ui.testWidget" , {
671705 _create : function ( ) {
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ $.Widget.prototype = {
319319 return ( typeof handler === "string" ? instance [ handler ] : handler )
320320 . apply ( instance , arguments ) ;
321321 }
322- var match = key . match ( / ^ ( \w + ) \s * ( .* ) $ / ) ;
322+ var match = event . match ( / ^ ( \w + ) \s * ( .* ) $ / ) ;
323323 var eventName = match [ 1 ] + "." + instance . widgetName ,
324324 selector = match [ 2 ] ;
325325 if ( selector === '' ) {
You can’t perform that action at this time.
0 commit comments