()
| 27701 | |
| 27702 | |
| 27703 | function updateOptions() { |
| 27704 | |
| 27705 | var previousValue = options && selectCtrl.readValue(); |
| 27706 | |
| 27707 | options = ngOptions.getOptions(); |
| 27708 | |
| 27709 | var groupMap = {}; |
| 27710 | var currentElement = selectElement[0].firstChild; |
| 27711 | |
| 27712 | // Ensure that the empty option is always there if it was explicitly provided |
| 27713 | if (providedEmptyOption) { |
| 27714 | selectElement.prepend(emptyOption); |
| 27715 | } |
| 27716 | |
| 27717 | currentElement = skipEmptyAndUnknownOptions(currentElement); |
| 27718 | |
| 27719 | options.items.forEach(function updateOption(option) { |
| 27720 | var group; |
| 27721 | var groupElement; |
| 27722 | var optionElement; |
| 27723 | |
| 27724 | if (isDefined(option.group)) { |
| 27725 | |
| 27726 | // This option is to live in a group |
| 27727 | // See if we have already created this group |
| 27728 | group = groupMap[option.group]; |
| 27729 | |
| 27730 | if (!group) { |
| 27731 | |
| 27732 | // We have not already created this group |
| 27733 | groupElement = addOrReuseElement(selectElement[0], |
| 27734 | currentElement, |
| 27735 | 'optgroup', |
| 27736 | optGroupTemplate); |
| 27737 | // Move to the next element |
| 27738 | currentElement = groupElement.nextSibling; |
| 27739 | |
| 27740 | // Update the label on the group element |
| 27741 | groupElement.label = option.group; |
| 27742 | |
| 27743 | // Store it for use later |
| 27744 | group = groupMap[option.group] = { |
| 27745 | groupElement: groupElement, |
| 27746 | currentOptionElement: groupElement.firstChild |
| 27747 | }; |
| 27748 | |
| 27749 | } |
| 27750 | |
| 27751 | // So now we have a group for this option we add the option to the group |
| 27752 | optionElement = addOrReuseElement(group.groupElement, |
| 27753 | group.currentOptionElement, |
| 27754 | 'option', |
| 27755 | optionTemplate); |
| 27756 | updateOptionElement(option, optionElement); |
| 27757 | // Move to the next element |
| 27758 | group.currentOptionElement = optionElement.nextSibling; |
| 27759 | |
| 27760 | } else { |
no test coverage detected