()
| 31679 | } |
| 31680 | |
| 31681 | function updateOptions() { |
| 31682 | var previousValue = options && selectCtrl.readValue(); |
| 31683 | |
| 31684 | // We must remove all current options, but cannot simply set innerHTML = null |
| 31685 | // since the providedEmptyOption might have an ngIf on it that inserts comments which we |
| 31686 | // must preserve. |
| 31687 | // Instead, iterate over the current option elements and remove them or their optgroup |
| 31688 | // parents |
| 31689 | if (options) { |
| 31690 | |
| 31691 | for (var i = options.items.length - 1; i >= 0; i--) { |
| 31692 | var option = options.items[i]; |
| 31693 | if (isDefined(option.group)) { |
| 31694 | jqLiteRemove(option.element.parentNode); |
| 31695 | } else { |
| 31696 | jqLiteRemove(option.element); |
| 31697 | } |
| 31698 | } |
| 31699 | } |
| 31700 | |
| 31701 | options = ngOptions.getOptions(); |
| 31702 | |
| 31703 | var groupElementMap = {}; |
| 31704 | |
| 31705 | options.items.forEach(function addOption(option) { |
| 31706 | var groupElement; |
| 31707 | |
| 31708 | if (isDefined(option.group)) { |
| 31709 | |
| 31710 | // This option is to live in a group |
| 31711 | // See if we have already created this group |
| 31712 | groupElement = groupElementMap[option.group]; |
| 31713 | |
| 31714 | if (!groupElement) { |
| 31715 | |
| 31716 | groupElement = optGroupTemplate.cloneNode(false); |
| 31717 | listFragment.appendChild(groupElement); |
| 31718 | |
| 31719 | // Update the label on the group element |
| 31720 | // "null" is special cased because of Safari |
| 31721 | groupElement.label = option.group === null ? 'null' : option.group; |
| 31722 | |
| 31723 | // Store it for use later |
| 31724 | groupElementMap[option.group] = groupElement; |
| 31725 | } |
| 31726 | |
| 31727 | addOptionElement(option, groupElement); |
| 31728 | |
| 31729 | } else { |
| 31730 | |
| 31731 | // This option is not in a group |
| 31732 | addOptionElement(option, listFragment); |
| 31733 | } |
| 31734 | }); |
| 31735 | |
| 31736 | selectElement[0].appendChild(listFragment); |
| 31737 | |
| 31738 | ngModelCtrl.$render(); |
nothing calls this directly
no test coverage detected