Skip to content
Snippets Groups Projects
Commit 39f3d34b authored by catch's avatar catch
Browse files

Issue #1660952 by Jelle_S, RobLoach, seutje: Replace all jQuery.each() with filtered for loop.

parent 6fa50c64
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -96,12 +96,14 @@ jQuery.fn.fieldUIPopulateOptions = function (options, selected) {
var previousSelectedText = this.options[this.selectedIndex].text;
var html = '';
jQuery.each(options, function (value, text) {
// Figure out which value should be selected. The 'selected' param
// takes precedence.
var is_selected = ((typeof selected !== 'undefined' && value === selected) || (typeof selected === 'undefined' && text === previousSelectedText));
html += '<option value="' + value + '"' + (is_selected ? ' selected="selected"' : '') + '>' + text + '</option>';
});
for (var value in options) {
if (options.hasOwnProperty(value)) {
// Figure out which value should be selected. The 'selected' param
// takes precedence.
var is_selected = ((typeof selected !== 'undefined' && value === selected) || (typeof selected === 'undefined' && options[value] === previousSelectedText));
html += '<option value="' + value + '"' + (is_selected ? ' selected="selected"' : '') + '>' + options[value] + '</option>';
}
}
$(this).html(html).prop('disabled', disabled);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment