Skip to content

Commit

Permalink
Multiple Examples Code Quality: Use local index variables for loops (…
Browse files Browse the repository at this point in the history
…pull #1370)
  • Loading branch information
Vadim Makeev committed Jun 2, 2020
1 parent 6180a45 commit 81ab634
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 28 deletions.
1 change: 0 additions & 1 deletion examples/carousel/js/carousel.js
Expand Up @@ -222,4 +222,3 @@ window.addEventListener('load', function () {
carousel.init();
}
}, false);

2 changes: 0 additions & 2 deletions examples/dialog-modal/js/datepicker.js
Expand Up @@ -575,5 +575,3 @@ DatePicker.prototype.setMessage = function (str) {
this.lastMessage = str;
}
};


35 changes: 17 additions & 18 deletions examples/landmarks/js/visua11y.js
Expand Up @@ -27,11 +27,11 @@ function initHeadings() {

addPolyfills();

var targetList = [{ selector: "h1", color: "navy", label: "h1" },
{ selector: "h2", color: "olive", label: "h2" },
{ selector: "h3", color: "purple", label: "h3" },
{ selector: "h4", color: "green", label: "h4" },
{ selector: "h5", color: "gray", label: "h5" },
var targetList = [{ selector: "h1", color: "navy", label: "h1" },
{ selector: "h2", color: "olive", label: "h2" },
{ selector: "h3", color: "purple", label: "h3" },
{ selector: "h4", color: "green", label: "h4" },
{ selector: "h5", color: "gray", label: "h5" },
{ selector: "h6", color: "brown", label: "h6" }];

var selectors = targetList.map(function (tgt) {
Expand Down Expand Up @@ -84,16 +84,16 @@ function initLandmarks() {
return false;
}

var targetList = [{ selector: 'aside:not([role]), [role~="complementary"], [role~="COMPLEMENTARY"]', color: "maroon", label: "complementary" },
{ selector: 'form[aria-labelledby], form[aria-label], form[title], [role~="form"], [role~="form"]', color: "maroon", label: "form" },
{ selector: 'footer, [role~="contentinfo"], [role~="CONTENTINFO"]', filter: isContentinfo, color: "olive", label: "contentinfo" },
{ selector: '[role~="application"], [role~="APPLICATION"]', color: "black", label: "application" },
{ selector: 'nav, [role~="navigation"], [role~="NAVIGATION"]', color: "green", label: "navigation" },
{ selector: '[role~="region"][aria-labelledby], [role~="REGION"][aria-labelledby]', color: "teal", label: "region" },
{ selector: '[role~="region"][aria-label], [role~="REGION"][aria-label]', color: "teal", label: "region" },
{ selector: 'section[aria-labelledby], section[aria-label]', color: "teal", label: "region" },
{ selector: 'header, [role~="banner"], [role~="BANNER"]', filter: isBanner, color: "gray", label: "banner" },
{ selector: '[role~="search"], [role~="SEARCH"]', color: "purple", label: "search" },
var targetList = [{ selector: 'aside:not([role]), [role~="complementary"], [role~="COMPLEMENTARY"]', color: "maroon", label: "complementary" },
{ selector: 'form[aria-labelledby], form[aria-label], form[title], [role~="form"], [role~="form"]', color: "maroon", label: "form" },
{ selector: 'footer, [role~="contentinfo"], [role~="CONTENTINFO"]', filter: isContentinfo, color: "olive", label: "contentinfo" },
{ selector: '[role~="application"], [role~="APPLICATION"]', color: "black", label: "application" },
{ selector: 'nav, [role~="navigation"], [role~="NAVIGATION"]', color: "green", label: "navigation" },
{ selector: '[role~="region"][aria-labelledby], [role~="REGION"][aria-labelledby]', color: "teal", label: "region" },
{ selector: '[role~="region"][aria-label], [role~="REGION"][aria-label]', color: "teal", label: "region" },
{ selector: 'section[aria-labelledby], section[aria-label]', color: "teal", label: "region" },
{ selector: 'header, [role~="banner"], [role~="BANNER"]', filter: isBanner, color: "gray", label: "banner" },
{ selector: '[role~="search"], [role~="SEARCH"]', color: "purple", label: "search" },
{ selector: 'main, [role~="main"], [role~="MAIN"]', color: "navy", label: "main" }];

var selectors = targetList.map(function (tgt) {
Expand Down Expand Up @@ -817,15 +817,14 @@ function nameFromNativeSemantics(element, recFlag) {
function nameFromAttributeIdRefs(element, attribute) {
var value = getAttributeValue(element, attribute);
var idRefs,
i,
refElement,
accName,
arr = [];

if (value.length) {
idRefs = value.split(' ');

for (i = 0; i < idRefs.length; i++) {
for (var i = 0; i < idRefs.length; i++) {
refElement = document.getElementById(idRefs[i]);
if (refElement) {
accName = getAccessibleName(refElement, true);
Expand Down Expand Up @@ -1697,4 +1696,4 @@ function addPolyfills() {
}
};
}
}
}
8 changes: 4 additions & 4 deletions examples/tabs/tabs-1/js/tabs.js
Expand Up @@ -35,7 +35,7 @@
};

// Bind listeners
for (i = 0; i < tabs.length; ++i) {
for (var i = 0; i < tabs.length; ++i) {
addListeners(i);
}

Expand Down Expand Up @@ -124,7 +124,7 @@
function switchTabOnArrowPress (event) {
var pressed = event.keyCode;

for (x = 0; x < tabs.length; x++) {
for (var x = 0; x < tabs.length; x++) {
tabs[x].addEventListener('focus', focusEventHandler);
}

Expand Down Expand Up @@ -170,13 +170,13 @@

// Deactivate all tabs and tab panels
function deactivateTabs () {
for (t = 0; t < tabs.length; t++) {
for (var t = 0; t < tabs.length; t++) {
tabs[t].setAttribute('tabindex', '-1');
tabs[t].setAttribute('aria-selected', 'false');
tabs[t].removeEventListener('focus', focusEventHandler);
}

for (p = 0; p < panels.length; p++) {
for (var p = 0; p < panels.length; p++) {
panels[p].classList.add('is-hidden');
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/tabs/tabs-2/js/tabs.js
Expand Up @@ -36,7 +36,7 @@
};

// Bind listeners
for (i = 0; i < tabs.length; ++i) {
for (var i = 0; i < tabs.length; ++i) {
addListeners(i);
}

Expand Down Expand Up @@ -171,12 +171,12 @@

// Deactivate all tabs and tab panels
function deactivateTabs () {
for (t = 0; t < tabs.length; t++) {
for (var t = 0; t < tabs.length; t++) {
tabs[t].setAttribute('tabindex', '-1');
tabs[t].setAttribute('aria-selected', 'false');
}

for (p = 0; p < panels.length; p++) {
for (var p = 0; p < panels.length; p++) {
panels[p].classList.add('is-hidden');
}
}
Expand Down

0 comments on commit 81ab634

Please sign in to comment.