Skip to content

Commit a6ec8fc

Browse files
committed
Don't rely on :visible and :not(..., ...) selectors which only work with Sizzle.
1 parent b8fa72d commit a6ec8fc

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

select2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ the specific language governing permissions and limitations under the Apache Lic
264264

265265
/* make sure el received focus so we do not error out when trying to manipulate the caret.
266266
sometimes modals or others listeners may steal it after its set */
267-
if ($el.is(":visible") && el === document.activeElement) {
267+
var isVisible = (el.offsetWidth > 0 || el.offsetHeight > 0);
268+
if (isVisible && el === document.activeElement) {
268269

269270
/* after the focus is set move the caret to the end, necessary when we val()
270271
just before setting focus */
@@ -1431,7 +1432,7 @@ the specific language governing permissions and limitations under the Apache Lic
14311432

14321433
// abstract
14331434
findHighlightableChoices: function() {
1434-
return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)");
1435+
return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)");
14351436
},
14361437

14371438
// abstract

0 commit comments

Comments
 (0)