()
| 26620 | |
| 26621 | |
| 26622 | function updateOptions() { |
| 26623 | |
| 26624 | var previousValue = options && selectCtrl.readValue(); |
| 26625 | |
| 26626 | options = ngOptions.getOptions(); |
| 26627 | |
| 26628 | var groupMap = {}; |
| 26629 | var currentElement = selectElement[0].firstChild; |
| 26630 | |
| 26631 | // Ensure that the empty option is always there if it was explicitly provided |
| 26632 | if (providedEmptyOption) { |
| 26633 | selectElement.prepend(emptyOption); |
| 26634 | } |
| 26635 | |
| 26636 | currentElement = skipEmptyAndUnknownOptions(currentElement); |
| 26637 | |
| 26638 | options.items.forEach(function updateOption(option) { |
| 26639 | var group; |
| 26640 | var groupElement; |
| 26641 | var optionElement; |
| 26642 | |
| 26643 | if (option.group) { |
| 26644 | |
| 26645 | // This option is to live in a group |
| 26646 | // See if we have already created this group |
| 26647 | group = groupMap[option.group]; |
| 26648 | |
| 26649 | if (!group) { |
| 26650 | |
| 26651 | // We have not already created this group |
| 26652 | groupElement = addOrReuseElement(selectElement[0], |
| 26653 | currentElement, |
| 26654 | 'optgroup', |
| 26655 | optGroupTemplate); |
| 26656 | // Move to the next element |
| 26657 | currentElement = groupElement.nextSibling; |
| 26658 | |
| 26659 | // Update the label on the group element |
| 26660 | groupElement.label = option.group; |
| 26661 | |
| 26662 | // Store it for use later |
| 26663 | group = groupMap[option.group] = { |
| 26664 | groupElement: groupElement, |
| 26665 | currentOptionElement: groupElement.firstChild |
| 26666 | }; |
| 26667 | |
| 26668 | } |
| 26669 | |
| 26670 | // So now we have a group for this option we add the option to the group |
| 26671 | optionElement = addOrReuseElement(group.groupElement, |
| 26672 | group.currentOptionElement, |
| 26673 | 'option', |
| 26674 | optionTemplate); |
| 26675 | updateOptionElement(option, optionElement); |
| 26676 | // Move to the next element |
| 26677 | group.currentOptionElement = optionElement.nextSibling; |
| 26678 | |
| 26679 | } else { |
no test coverage detected