From: Scott González Date: Mon, 9 Mar 2015 20:03:22 +0000 (-0400) Subject: Core: Add methods to work around IE active element bugs X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2256eeda45c0f52df87ee2241a88b3d70e83711e;p=jquery-ui.git Core: Add methods to work around IE active element bugs Closes gh-1478 (cherry picked from commit f33027840cdac5152599da66635981bbe68c6bda) --- diff --git a/ui/autocomplete.js b/ui/autocomplete.js index dc970b5c7..6e477bb41 100644 --- a/ui/autocomplete.js +++ b/ui/autocomplete.js @@ -278,7 +278,7 @@ $.widget( "ui.autocomplete", { previous = this.previous; // only trigger when focus was lost (click on menu) - if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) { + if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { this.element.focus(); this.previous = previous; // #6109 - IE triggers two focus events and the second diff --git a/ui/core.js b/ui/core.js index 0b2e03950..40703d73d 100644 --- a/ui/core.js +++ b/ui/core.js @@ -43,6 +43,31 @@ $.extend( $.ui, { SPACE: 32, TAB: 9, UP: 38 + }, + + // Internal use only + safeActiveElement: function( document ) { + var activeElement; + + // Support: IE 9 only + // IE9 throws an "Unspecified error" accessing document.activeElement from an