mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Optimize element type checks for speed and size.
This commit is contained in:
parent
df077abfc2
commit
101a09d31f
31
ui/jquery.ui.autocomplete.js
vendored
31
ui/jquery.ui.autocomplete.js
vendored
@ -54,10 +54,21 @@ $.widget( "ui.autocomplete", {
|
|||||||
// so we use the suppressKeyPressRepeat flag to avoid handling keypress
|
// so we use the suppressKeyPressRepeat flag to avoid handling keypress
|
||||||
// events when we know the keydown event was used to modify the
|
// events when we know the keydown event was used to modify the
|
||||||
// search term. #7799
|
// search term. #7799
|
||||||
var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
|
var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
|
||||||
|
nodeName = this.element[0].nodeName.toLowerCase(),
|
||||||
|
isTextarea = nodeName === "textarea",
|
||||||
|
isInput = nodeName === "input";
|
||||||
|
|
||||||
this.isMultiLine = this._isMultiLine();
|
this.isMultiLine =
|
||||||
this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
|
// Textareas are always multi-line
|
||||||
|
isTextarea ? true :
|
||||||
|
// Inputs are always single-line, even if inside a contentEditable element
|
||||||
|
// IE also treats inputs as contentEditable
|
||||||
|
isInput ? false :
|
||||||
|
// All other element types are determined by whether or not they're contentEditable
|
||||||
|
this.element.prop( "isContentEditable" );
|
||||||
|
|
||||||
|
this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
|
||||||
this.isNewMenu = true;
|
this.isNewMenu = true;
|
||||||
|
|
||||||
this.element
|
this.element
|
||||||
@ -341,20 +352,6 @@ $.widget( "ui.autocomplete", {
|
|||||||
return element;
|
return element;
|
||||||
},
|
},
|
||||||
|
|
||||||
_isMultiLine: function() {
|
|
||||||
// Textareas are always multi-line
|
|
||||||
if ( this.element.is( "textarea" ) ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Inputs are always single-line, even if inside a contentEditable element
|
|
||||||
// IE also treats inputs as contentEditable
|
|
||||||
if ( this.element.is( "input" ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// All other element types are determined by whether or not they're contentEditable
|
|
||||||
return this.element.prop( "isContentEditable" );
|
|
||||||
},
|
|
||||||
|
|
||||||
_initSource: function() {
|
_initSource: function() {
|
||||||
var array, url,
|
var array, url,
|
||||||
that = this;
|
that = this;
|
||||||
|
Loading…
Reference in New Issue
Block a user