MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / updateOptions

Function updateOptions

lib/test/angular/1.6.7/angular.js:30897–30965  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30895 }
30896
30897 function updateOptions() {
30898 var previousValue = options && selectCtrl.readValue();
30899
30900 // We must remove all current options, but cannot simply set innerHTML = null
30901 // since the providedEmptyOption might have an ngIf on it that inserts comments which we
30902 // must preserve.
30903 // Instead, iterate over the current option elements and remove them or their optgroup
30904 // parents
30905 if (options) {
30906
30907 for (var i = options.items.length - 1; i >= 0; i--) {
30908 var option = options.items[i];
30909 if (isDefined(option.group)) {
30910 jqLiteRemove(option.element.parentNode);
30911 } else {
30912 jqLiteRemove(option.element);
30913 }
30914 }
30915 }
30916
30917 options = ngOptions.getOptions();
30918
30919 var groupElementMap = {};
30920
30921 options.items.forEach(function addOption(option) {
30922 var groupElement;
30923
30924 if (isDefined(option.group)) {
30925
30926 // This option is to live in a group
30927 // See if we have already created this group
30928 groupElement = groupElementMap[option.group];
30929
30930 if (!groupElement) {
30931
30932 groupElement = optGroupTemplate.cloneNode(false);
30933 listFragment.appendChild(groupElement);
30934
30935 // Update the label on the group element
30936 // "null" is special cased because of Safari
30937 groupElement.label = option.group === null ? 'null' : option.group;
30938
30939 // Store it for use later
30940 groupElementMap[option.group] = groupElement;
30941 }
30942
30943 addOptionElement(option, groupElement);
30944
30945 } else {
30946
30947 // This option is not in a group
30948 addOptionElement(option, listFragment);
30949 }
30950 });
30951
30952 selectElement[0].appendChild(listFragment);
30953
30954 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