Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: options.js

Issue 8652024: Use new Option() instead of document.createElement("option") (Closed)
Patch Set: Created Oct. 22, 2012, 11:49 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « .hgsubstate ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: options.js
===================================================================
--- a/options.js
+++ b/options.js
@@ -145,17 +145,17 @@ function loadRecommendations()
var selectedPrefix = null;
var matchCount = 0;
var list = document.getElementById("subscriptionSelector");
var elements = request.responseXML.documentElement.getElementsByTagName("subscription");
for (var i = 0; i < elements.length; i++)
{
var element = elements[i];
- var option = document.createElement("option");
+ var option = new Option();
option.text = element.getAttribute("title") + " (" + element.getAttribute("specialization") + ")";
option._data = {
title: element.getAttribute("title"),
url: element.getAttribute("url"),
homepage: element.getAttribute("homepage")
};
var prefix = require("utils").Utils.checkLocalePrefixMatch(element.getAttribute("prefixes"));
@@ -183,17 +183,17 @@ function loadRecommendations()
selectedIndex = i;
selectedPrefix = prefix;
}
}
}
list.appendChild(option);
}
- var option = document.createElement("option");
+ var option = new Option();
option.text = i18n.getMessage("filters_addSubscriptionOther_label") + "\u2026";
option._data = null;
list.appendChild(option);
list.selectedIndex = selectedIndex;
if (delayedSubscriptionSelection)
startSubscriptionSelection.apply(null, delayedSubscriptionSelection);
@@ -414,38 +414,35 @@ function populateList(id, entries)
{
var list = document.getElementById(id);
while (list.lastChild)
list.removeChild(list.lastChild);
entries.sort();
for (var i = 0; i < entries.length; i++)
{
- var option = document.createElement("option");
+ var option = new Option();
option.text = entries[i];
option.value = entries[i];
list.appendChild(option);
}
}
// Add a filter string to the list box.
function appendToListBox(boxId, text)
{
- var elt = document.createElement("option");
+ var elt = new Option();
elt.text = text;
elt.value = text;
document.getElementById(boxId).appendChild(elt);
}
// Remove a filter string from a list box.
function removeFromListBox(boxId, text)
{
- var elt = document.createElement("option");
- elt.text = text;
- elt.value = text;
var list = document.getElementById(boxId);
for (var i = 0; i < list.length; i++)
if (list.options[i].value == text)
list.remove(i--);
}
function addWhitelistDomain(event)
{
« no previous file with comments | « .hgsubstate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld