Browse files

Slider: On Opera Mobile event.which is undefined. Accept that and get…

… slidin'. Fixes #5903.

(cherry picked from commit b90361b)
  • Loading branch information...
1 parent 252634e commit 5ba1d42ec132b9f16cb88131566dbe281e854128 @gabrielschulhof gabrielschulhof committed Apr 18, 2013
Showing with 11 additions and 2 deletions.
  1. +1 −1 js/widgets/forms/slider.js
  2. +10 −1 tests/unit/slider/slider_events.js
View
2 js/widgets/forms/slider.js
@@ -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 ) {
View
11 tests/unit/slider/slider_events.js
@@ -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" ),
@@ -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 );
},

0 comments on commit 5ba1d42

Please sign in to comment.