()
| 15741 | // Double-check for duplicates (defensive programming) |
| 15742 | const finalUniqueTags = []; |
| 15743 | const seenTags = new Set(); |
| 15744 | sortedTags.forEach(tag => { |
| 15745 | if (!seenTags.has(tag)) { |
| 15746 | seenTags.add(tag); |
| 15747 | finalUniqueTags.push(tag); |
| 15748 | } |
| 15749 | }); |
| 15750 | |
| 15751 | // Populate dropdown |
| 15752 | if (finalUniqueTags.length === 0) { |
| 15753 | const noTagsOption = document.createElement('option'); |
| 15754 | noTagsOption.value = ''; |
| 15755 | noTagsOption.textContent = 'No tags to remove'; |
| 15756 | noTagsOption.disabled = true; |
| 15757 | removeTagSelect.appendChild(noTagsOption); |
| 15758 | } else { |
| 15759 | finalUniqueTags.forEach(tagName => { |
| 15760 | // Additional check to prevent duplicate options in the DOM |
| 15761 | const existingOption = Array.from(removeTagSelect.options).find(opt => opt.value === tagName); |
| 15762 | if (!existingOption) { |
| 15763 | const option = document.createElement('option'); |
| 15764 | option.value = tagName; |
| 15765 | option.textContent = tagName; |
| 15766 | removeTagSelect.appendChild(option); |
| 15767 | } |
| 15768 | }); |
no outgoing calls
no test coverage detected