Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local index variables for loops #1370

Merged
merged 7 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/carousel/js/carousel.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -575,5 +575,3 @@ DatePicker.prototype.setMessage = function (str) {
this.lastMessage = str;
}
};


34 changes: 17 additions & 17 deletions examples/landmarks/js/visua11y.js
Original file line number Diff line number Diff line change
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 @@ -825,7 +825,7 @@ function nameFromAttributeIdRefs(element, attribute) {
if (value.length) {
idRefs = value.split(' ');

for (i = 0; i < idRefs.length; i++) {
for (var i = 0; i < idRefs.length; i++) {
smhigley marked this conversation as resolved.
Show resolved Hide resolved
refElement = document.getElementById(idRefs[i]);
if (refElement) {
accName = getAccessibleName(refElement, true);
Expand Down Expand Up @@ -1697,4 +1697,4 @@ function addPolyfills() {
}
};
}
}
}
8 changes: 4 additions & 4 deletions examples/tabs/tabs-1/js/tabs.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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