Skip to content

Commit

Permalink
Core: Only use mousedown to prevent text selection in browsers that d…
Browse files Browse the repository at this point in the history
…on't support selectstart. Fixes #6080 - Core: disableSelection() disables select elements in Chrome.
  • Loading branch information
scottgonzalez committed Sep 20, 2010
1 parent f04a25f commit 47e312b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ui/jquery.ui.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ $.fn.extend({
},

disableSelection: function() {
return this.bind(
"mousedown.ui-disableSelection selectstart.ui-disableSelection",
function( event ) {
return this.bind( $.support.selectstart ? "selectstart" : "mousedown" +
".ui-disableSelection", function( event ) {
event.preventDefault();
});
},
Expand Down Expand Up @@ -217,8 +216,8 @@ $.extend( $.expr[ ":" ], {

// support
$(function() {
var div = document.createElement( "div" ),
body = document.body;
var body = document.body,
div = body.appendChild( div = document.createElement( "div" ) );

$.extend( div.style, {
minHeight: "100px",
Expand All @@ -227,7 +226,9 @@ $(function() {
borderWidth: 0
});

$.support.minHeight = body.appendChild( div ).offsetHeight === 100;
$.support.minHeight = div.offsetHeight === 100;
$.support.selectstart = "onselectstart" in div;

// set display to none to avoid a layout bug in IE
// http://dev.jquery.com/ticket/4014
body.removeChild( div ).style.display = "none";
Expand Down

0 comments on commit 47e312b

Please sign in to comment.