Use feature detection for bootstrap typeahead key handling

(imported from commit 1ce443d3e61920bf5842b31263141d4f175a6514)
This commit is contained in:
Leo Franchi 2014-02-12 14:13:17 -05:00
parent 2530009123
commit eaa777b612
1 changed files with 10 additions and 1 deletions

View File

@ -2002,7 +2002,7 @@
.on('keypress', $.proxy(this.keypress, this))
.on('keyup', $.proxy(this.keyup, this))
if ($.browser.webkit || $.browser.msie) {
if (this.eventSupported('keydown')) {
this.$element.on('keydown', $.proxy(this.keydown, this))
}
@ -2011,6 +2011,15 @@
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
}
, eventSupported: function(eventName) {
var isSupported = eventName in this.$element
if (!isSupported) {
this.$element.setAttribute(eventName, 'return;')
isSupported = typeof this.$element[eventName] === 'function'
}
return isSupported
}
, move: function (e) {
if (!this.shown) return