Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Slider: On Opera Mobile event.which is undefined. Accept that and get…
Browse files Browse the repository at this point in the history
… slidin'. Fixes #5903.

(cherry picked from commit b90361b)
  • Loading branch information
Gabriel Schulhof committed Apr 18, 2013
1 parent 252634e commit 5ba1d42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/widgets/forms/slider.js
Expand Up @@ -261,7 +261,7 @@ $.widget( "mobile.slider", $.mobile.widget, $.extend( {
_sliderVMouseDown: function( event ) {
// NOTE: we don't do this in refresh because we still want to
// support programmatic alteration of disabled inputs
if ( this.options.disabled || !( event.which === 1 || event.which === 0 ) ) {
if ( this.options.disabled || !( event.which === 1 || event.which === 0 || event.which === undefined ) ) {
return false;
}
if ( this._trigger( "beforestart", event ) === false ) {
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/slider/slider_events.js
Expand Up @@ -375,7 +375,7 @@
});

asyncTest( "drag should start only when clicked with left button", function(){
expect( 4 );
expect( 5 );

var control = $( "#mousedown-which-events" ),
widget = control.data( "mobile-slider" ),
Expand Down Expand Up @@ -405,6 +405,15 @@
function( result ) {
deepEqual( result.slidestart.timedOut, false, "slider did emit 'slidestart' event upon left button press" );
event = $.Event( "mousedown", { target: handle[ 0 ] } );
event.which = undefined;
slider.trigger( event );
},
{
slidestart: { src: control, event: "slidestart" + eventNs + "1" }
},
function( result ) {
deepEqual( result.slidestart.timedOut, false, "slider did emit 'slidestart' event upon undefined button press" );
event = $.Event( "mousedown", { target: handle[ 0 ] } );
event.which = 2;
slider.trigger( event );
},
Expand Down

0 comments on commit 5ba1d42

Please sign in to comment.