MCPcopy
hub / github.com/angular-ui/ui-grid / updateOptions

Function updateOptions

lib/test/angular/1.8.0/angular.js:32721–32789  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32719 }
32720
32721 function updateOptions() {
32722 var previousValue = options && selectCtrl.readValue();
32723
32724 // We must remove all current options, but cannot simply set innerHTML = null
32725 // since the providedEmptyOption might have an ngIf on it that inserts comments which we
32726 // must preserve.
32727 // Instead, iterate over the current option elements and remove them or their optgroup
32728 // parents
32729 if (options) {
32730
32731 for (var i = options.items.length - 1; i >= 0; i--) {
32732 var option = options.items[i];
32733 if (isDefined(option.group)) {
32734 jqLiteRemove(option.element.parentNode);
32735 } else {
32736 jqLiteRemove(option.element);
32737 }
32738 }
32739 }
32740
32741 options = ngOptions.getOptions();
32742
32743 var groupElementMap = {};
32744
32745 options.items.forEach(function addOption(option) {
32746 var groupElement;
32747
32748 if (isDefined(option.group)) {
32749
32750 // This option is to live in a group
32751 // See if we have already created this group
32752 groupElement = groupElementMap[option.group];
32753
32754 if (!groupElement) {
32755
32756 groupElement = optGroupTemplate.cloneNode(false);
32757 listFragment.appendChild(groupElement);
32758
32759 // Update the label on the group element
32760 // "null" is special cased because of Safari
32761 groupElement.label = option.group === null ? 'null' : option.group;
32762
32763 // Store it for use later
32764 groupElementMap[option.group] = groupElement;
32765 }
32766
32767 addOptionElement(option, groupElement);
32768
32769 } else {
32770
32771 // This option is not in a group
32772 addOptionElement(option, listFragment);
32773 }
32774 });
32775
32776 selectElement[0].appendChild(listFragment);
32777
32778 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