(index, selectOptions)
| 1564 | } |
| 1565 | |
| 1566 | function addOptgroup (index, selectOptions) { |
| 1567 | var optgroup = selectOptions[index], |
| 1568 | // skip placeholder option |
| 1569 | previous = index - 1 < startIndex ? false : selectOptions[index - 1], |
| 1570 | next = selectOptions[index + 1], |
| 1571 | options = optgroup.querySelectorAll('option' + optionSelector); |
| 1572 | |
| 1573 | if (!options.length) return; |
| 1574 | |
| 1575 | var config = { |
| 1576 | display: htmlEscape(optgroup.label), |
| 1577 | subtext: optgroup.getAttribute('data-subtext'), |
| 1578 | icon: optgroup.getAttribute('data-icon'), |
| 1579 | type: 'optgroup-label', |
| 1580 | optgroupClass: ' ' + (optgroup.className || '') |
| 1581 | }, |
| 1582 | headerIndex, |
| 1583 | lastIndex; |
| 1584 | |
| 1585 | optID++; |
| 1586 | |
| 1587 | if (previous) { |
| 1588 | addDivider({ optID: optID }); |
| 1589 | } |
| 1590 | |
| 1591 | config.optID = optID; |
| 1592 | |
| 1593 | mainData.push(config); |
| 1594 | |
| 1595 | for (var j = 0, len = options.length; j < len; j++) { |
| 1596 | var option = options[j]; |
| 1597 | |
| 1598 | if (j === 0) { |
| 1599 | headerIndex = mainData.length - 1; |
| 1600 | lastIndex = headerIndex + len; |
| 1601 | } |
| 1602 | |
| 1603 | addOption(option, { |
| 1604 | headerIndex: headerIndex, |
| 1605 | lastIndex: lastIndex, |
| 1606 | optID: config.optID, |
| 1607 | optgroupClass: config.optgroupClass, |
| 1608 | disabled: optgroup.disabled |
| 1609 | }); |
| 1610 | } |
| 1611 | |
| 1612 | if (next) { |
| 1613 | addDivider({ optID: optID }); |
| 1614 | } |
| 1615 | } |
| 1616 | |
| 1617 | for (var len = selectOptions.length, i = startIndex; i < len; i++) { |
| 1618 | var item = selectOptions[i]; |
no test coverage detected