aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2016-02-16 10:22:45 -0500
committerScott González <scott.gonzalez@gmail.com>2016-02-16 12:22:10 -0500
commitcbceca7091b17e05c5a9ba887ef54761568bb70b (patch)
tree5b9da582ab44c488585dff99cc0b8ea06d56eeca
parent58d8b17fe3f718c43a6729b275d269793cd80840 (diff)
downloadjquery-ui-cbceca7091b17e05c5a9ba887ef54761568bb70b.tar.gz
jquery-ui-cbceca7091b17e05c5a9ba887ef54761568bb70b.zip
Autocomplete: Work around `isContentEditable` bug in Chrome
Fixes #14917 Closes gh-1673
-rw-r--r--ui/widgets/autocomplete.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js
index 060d8e94f..079b0dab0 100644
--- a/ui/widgets/autocomplete.js
+++ b/ui/widgets/autocomplete.js
@@ -82,7 +82,7 @@ $.widget( "ui.autocomplete", {
// Inputs are always single-line, even if inside a contentEditable element
// IE also treats inputs as contentEditable
// All other element types are determined by whether or not they're contentEditable
- this.isMultiLine = isTextarea || !isInput && this.element.prop( "isContentEditable" );
+ this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
this.isNewMenu = true;
@@ -614,6 +614,24 @@ $.widget( "ui.autocomplete", {
// Prevents moving cursor to beginning/end of the text field in some browsers
event.preventDefault();
}
+ },
+
+ // Support: Chrome <=50
+ // We should be able to just use this.element.prop( "isContentEditable" )
+ // but hidden elements always report false in Chrome.
+ // https://code.google.com/p/chromium/issues/detail?id=313082
+ _isContentEditable: function( element ) {
+ if ( !element.length ) {
+ return false;
+ }
+
+ var editable = element.prop( "contentEditable" );
+
+ if ( editable === "inherit" ) {
+ return this._isContentEditable( element.parent() );
+ }
+
+ return editable === "true";
}
} );