From a6ec8fc4e17e9622202b61ca1b1b6e044bf9fa1a Mon Sep 17 00:00:00 2001 From: Arend van Beelen Date: Mon, 30 Dec 2013 15:33:46 +0100 Subject: [PATCH] Don't rely on :visible and :not(..., ...) selectors which only work with Sizzle. --- select2.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index 67f6b85e..b4b67efc 100644 --- a/select2.js +++ b/select2.js @@ -264,7 +264,8 @@ the specific language governing permissions and limitations under the Apache Lic /* make sure el received focus so we do not error out when trying to manipulate the caret. sometimes modals or others listeners may steal it after its set */ - if ($el.is(":visible") && el === document.activeElement) { + var isVisible = (el.offsetWidth > 0 || el.offsetHeight > 0); + if (isVisible && el === document.activeElement) { /* after the focus is set move the caret to the end, necessary when we val() just before setting focus */ @@ -1431,7 +1432,7 @@ the specific language governing permissions and limitations under the Apache Lic // abstract findHighlightableChoices: function() { - return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)"); + return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)"); }, // abstract