Skip to content

Commit 944d7c8

Browse files
committed
update docs
1 parent d8d5d9c commit 944d7c8

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

docs/dist/css/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @lordfriend/nya-bootstrap-select v2.1.9
2+
* @lordfriend/nya-bootstrap-select v2.1.10
33
* Copyright 2014 Nyasoft
44
* Licensed under MIT license
55
*/

docs/dist/css/nya-bs-select.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @lordfriend/nya-bootstrap-select v2.1.9
2+
* @lordfriend/nya-bootstrap-select v2.1.10
33
* Copyright 2014 Nyasoft
44
* Licensed under MIT license
55
*/

docs/dist/js/nya-bs-select.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @lordfriend/nya-bootstrap-select v2.1.9
2+
* @lordfriend/nya-bootstrap-select v2.1.10
33
* Copyright 2014 Nyasoft
44
* Licensed under MIT license
55
*/
@@ -1073,6 +1073,19 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', '$compi
10731073
}
10741074
}
10751075
}
1076+
1077+
function supportsSelector(selector) {
1078+
var el = document.createElement('div');
1079+
el.innerHTML = ['&shy;', '<style>', selector, '{}', '</style>'].join('');
1080+
el = document.body.appendChild(el);
1081+
var style = el.getElementsByTagName('style')[0];
1082+
if (style && style.sheet && style.sheet.rules && style.sheet.cssRules) {
1083+
var ret = !!(style.sheet.rules || style.sheet.cssRules)[0];
1084+
document.body.removeChild(el);
1085+
return ret;
1086+
}
1087+
return false;
1088+
}
10761089

10771090
function findFocus(fromFirst) {
10781091
var firstLiElement;
@@ -1083,10 +1096,18 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', '$compi
10831096
}
10841097

10851098
// focus on selected element
1086-
for(var i = 0; i < dropdownMenu.children().length; i++) {
1087-
var childElement = dropdownMenu.children().eq(i);
1088-
if (!childElement.hasClass('not-match') && childElement.hasClass('selected')) {
1089-
return dropdownMenu.children().eq(i)[0];
1099+
if (supportsSelector(".selected:not(.not-match)")) {
1100+
var match = dropdownMenu[0].querySelector('.selected:not(.not-match)');
1101+
if (match)
1102+
return match;
1103+
}
1104+
else {
1105+
// Fallback for IE8 users
1106+
for(var i = 0; i < dropdownMenu.children().length; i++) {
1107+
var childElement = dropdownMenu.children().eq(i);
1108+
if (!childElement.hasClass('not-match') && childElement.hasClass('selected')) {
1109+
return dropdownMenu.children().eq(i)[0];
1110+
}
10901111
}
10911112
}
10921113

0 commit comments

Comments
 (0)