MCPcopy Index your code
hub / github.com/angular-ui/ui-router / updateOptions

Function updateOptions

test/angular/1.7/angular.js:32656–32724  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32654 }
32655
32656 function updateOptions() {
32657 var previousValue = options && selectCtrl.readValue();
32658
32659 // We must remove all current options, but cannot simply set innerHTML = null
32660 // since the providedEmptyOption might have an ngIf on it that inserts comments which we
32661 // must preserve.
32662 // Instead, iterate over the current option elements and remove them or their optgroup
32663 // parents
32664 if (options) {
32665
32666 for (var i = options.items.length - 1; i >= 0; i--) {
32667 var option = options.items[i];
32668 if (isDefined(option.group)) {
32669 jqLiteRemove(option.element.parentNode);
32670 } else {
32671 jqLiteRemove(option.element);
32672 }
32673 }
32674 }
32675
32676 options = ngOptions.getOptions();
32677
32678 var groupElementMap = {};
32679
32680 options.items.forEach(function addOption(option) {
32681 var groupElement;
32682
32683 if (isDefined(option.group)) {
32684
32685 // This option is to live in a group
32686 // See if we have already created this group
32687 groupElement = groupElementMap[option.group];
32688
32689 if (!groupElement) {
32690
32691 groupElement = optGroupTemplate.cloneNode(false);
32692 listFragment.appendChild(groupElement);
32693
32694 // Update the label on the group element
32695 // "null" is special cased because of Safari
32696 groupElement.label = option.group === null ? 'null' : option.group;
32697
32698 // Store it for use later
32699 groupElementMap[option.group] = groupElement;
32700 }
32701
32702 addOptionElement(option, groupElement);
32703
32704 } else {
32705
32706 // This option is not in a group
32707 addOptionElement(option, listFragment);
32708 }
32709 });
32710
32711 selectElement[0].appendChild(listFragment);
32712
32713 ngModelCtrl.$render();

Callers

nothing calls this directly

Calls 4

isDefinedFunction · 0.70
jqLiteRemoveFunction · 0.70
addOptionElementFunction · 0.70
equalsFunction · 0.70

Tested by

no test coverage detected