Skip to content

Commit 47e312b

Browse files
committed
Core: Only use mousedown to prevent text selection in browsers that don't support selectstart. Fixes #6080 - Core: disableSelection() disables select elements in Chrome.
1 parent f04a25f commit 47e312b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ui/jquery.ui.core.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ $.fn.extend({
118118
},
119119

120120
disableSelection: function() {
121-
return this.bind(
122-
"mousedown.ui-disableSelection selectstart.ui-disableSelection",
123-
function( event ) {
121+
return this.bind( $.support.selectstart ? "selectstart" : "mousedown" +
122+
".ui-disableSelection", function( event ) {
124123
event.preventDefault();
125124
});
126125
},
@@ -217,8 +216,8 @@ $.extend( $.expr[ ":" ], {
217216

218217
// support
219218
$(function() {
220-
var div = document.createElement( "div" ),
221-
body = document.body;
219+
var body = document.body,
220+
div = body.appendChild( div = document.createElement( "div" ) );
222221

223222
$.extend( div.style, {
224223
minHeight: "100px",
@@ -227,7 +226,9 @@ $(function() {
227226
borderWidth: 0
228227
});
229228

230-
$.support.minHeight = body.appendChild( div ).offsetHeight === 100;
229+
$.support.minHeight = div.offsetHeight === 100;
230+
$.support.selectstart = "onselectstart" in div;
231+
231232
// set display to none to avoid a layout bug in IE
232233
// http://dev.jquery.com/ticket/4014
233234
body.removeChild( div ).style.display = "none";

0 commit comments

Comments
 (0)