From f1e15481b5b41b3c3926c1b9cee37208b91ffe64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 Mar 2015 16:03:22 -0400 Subject: [PATCH 1/2] Core: Add methods to work around IE active element bugs --- ui/autocomplete.js | 2 +- ui/core.js | 23 +++++++++++++++++++++++ ui/dialog.js | 26 +++++++------------------- ui/draggable.js | 15 ++------------- ui/menu.js | 4 ++-- ui/spinner.js | 4 ++-- ui/tabs.js | 2 +- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ui/autocomplete.js b/ui/autocomplete.js index 60d69307edb..af3975d6e5a 100644 --- a/ui/autocomplete.js +++ b/ui/autocomplete.js @@ -286,7 +286,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 a7d10fe40d7..4fccfeab36d 100644 --- a/ui/core.js +++ b/ui/core.js @@ -49,6 +49,29 @@ $.extend( $.ui, { SPACE: 32, TAB: 9, UP: 38 + }, + + safeActiveElement: function( document ) { + var activeElement; + + // Support: IE 9 only + // IE9 throws an "Unspecified error" accessing document.activeElement from an