mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-18 13:39:57 -04:00
Refactor JS
Based on these comments on the associated pull request: - add area/areas condition to the array used to build the label prefixe2af2f63a4 (r55831534)- use a for loop instead of while when looping through nodese2af2f63a4 (r55831693)
This commit is contained in:
@@ -46,13 +46,11 @@
|
||||
function addAriaLabel (mapElement) {
|
||||
|
||||
function getLabelPrefix (areas) {
|
||||
var labelPrefix = ['Map of the United Kingdom, showing the ', ' for'];
|
||||
|
||||
if (areas.length === 1) {
|
||||
return labelPrefix[0] + 'area' + labelPrefix[1];
|
||||
} else {
|
||||
return labelPrefix[0] + 'areas' + labelPrefix[1];
|
||||
}
|
||||
return [
|
||||
'Map of the United Kingdom, showing the ',
|
||||
(areas.length === 1) ? 'area' : 'areas',
|
||||
' for'
|
||||
].join('');
|
||||
};
|
||||
|
||||
function getStringOfAreas (areas) {
|
||||
@@ -63,10 +61,11 @@
|
||||
function getAreaName (area) {
|
||||
var areaString = '';
|
||||
var childNodesLen = area.childNodes.length;
|
||||
var idx;
|
||||
var childNode;
|
||||
|
||||
while (childNodesLen--) {
|
||||
childNode = area.childNodes[childNodesLen];
|
||||
for (idx = 0; idx < childNodesLen; idx++) {
|
||||
childNode = area.childNodes[idx];
|
||||
if (childNode.nodeType === 3) { areaString += childNode.nodeValue; } // only use text nodes
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user