File tree Expand file tree Collapse file tree 2 files changed +52
-3
lines changed
Expand file tree Collapse file tree 2 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -662,6 +662,46 @@ test( "._on() to element (default)", function() {
662662 . trigger ( "keydown" ) ;
663663} ) ;
664664
665+ test ( "._on() to element with suppressDisabledCheck" , function ( ) {
666+ expect ( 18 ) ;
667+ var that , widget ;
668+ $ . widget ( "ui.testWidget" , {
669+ _create : function ( ) {
670+ that = this ;
671+ this . _on ( true , {
672+ keyup : this . keyup ,
673+ keydown : "keydown"
674+ } ) ;
675+ } ,
676+ keyup : function ( event ) {
677+ equal ( that , this ) ;
678+ equal ( that . element [ 0 ] , event . currentTarget ) ;
679+ equal ( "keyup" , event . type ) ;
680+ } ,
681+ keydown : function ( event ) {
682+ equal ( that , this ) ;
683+ equal ( that . element [ 0 ] , event . currentTarget ) ;
684+ equal ( "keydown" , event . type ) ;
685+ }
686+ } ) ;
687+ widget = $ ( "<div></div>" )
688+ . testWidget ( )
689+ . trigger ( "keyup" )
690+ . trigger ( "keydown" ) ;
691+ widget
692+ . testWidget ( "disable" )
693+ . trigger ( "keyup" )
694+ . trigger ( "keydown" ) ;
695+ widget
696+ . testWidget ( "enable" )
697+ . trigger ( "keyup" )
698+ . trigger ( "keydown" ) ;
699+ widget
700+ . testWidget ( "destroy" )
701+ . trigger ( "keyup" )
702+ . trigger ( "keydown" ) ;
703+ } ) ;
704+
665705test ( "._on() to descendent" , function ( ) {
666706 expect ( 12 ) ;
667707 var that , widget , descendant ;
Original file line number Diff line number Diff line change @@ -361,9 +361,17 @@ $.Widget.prototype = {
361361 return this . _setOption ( "disabled" , true ) ;
362362 } ,
363363
364- _on : function ( element , handlers ) {
364+ _on : function ( suppressDisabledCheck , element , handlers ) {
365365 var delegateElement ,
366366 instance = this ;
367+
368+ // no suppressDisabledCheck flag, shuffle arguments
369+ if ( typeof suppressDisabledCheck !== "boolean" ) {
370+ handlers = element ;
371+ element = suppressDisabledCheck ;
372+ suppressDisabledCheck = false ;
373+ }
374+
367375 // no element argument, shuffle and use this.element
368376 if ( ! handlers ) {
369377 handlers = element ;
@@ -380,8 +388,9 @@ $.Widget.prototype = {
380388 // allow widgets to customize the disabled handling
381389 // - disabled as an array instead of boolean
382390 // - disabled class as method for disabling individual parts
383- if ( instance . options . disabled === true ||
384- $ ( this ) . hasClass ( "ui-state-disabled" ) ) {
391+ if ( ! suppressDisabledCheck &&
392+ ( instance . options . disabled === true ||
393+ $ ( this ) . hasClass ( "ui-state-disabled" ) ) ) {
385394 return ;
386395 }
387396 return ( typeof handler === "string" ? instance [ handler ] : handler )
You can’t perform that action at this time.
0 commit comments