Skip to content

Commit d74b255

Browse files
committed
updated JS code to use CONST and forEach
1 parent db25036 commit d74b255

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

content/patterns/disclosure/examples/js/disclosure-button.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DisclosureButton {
1919
this.buttonNode = buttonNode;
2020
this.controlledNode = false;
2121

22-
var id = this.buttonNode.getAttribute('aria-controls');
22+
const id = this.buttonNode.getAttribute('aria-controls');
2323

2424
if (id) {
2525
this.controlledNode = document.getElementById(id);
@@ -75,13 +75,13 @@ class DisclosureButton {
7575
window.addEventListener(
7676
'load',
7777
function () {
78-
var buttons = document.querySelectorAll(
78+
const buttons = document.querySelectorAll(
7979
'button[aria-expanded][aria-controls]'
8080
);
8181

82-
for (var i = 0; i < buttons.length; i++) {
83-
new DisclosureButton(buttons[i]);
84-
}
82+
buttons.forEach( (b) => {
83+
new DisclosureButton(b);
84+
});
8585
},
8686
false
8787
);

0 commit comments

Comments
 (0)