Skip to content

Commit 824d470

Browse files
committed
refactor: fix eslint warnings
1 parent 0abb648 commit 824d470

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

js/src/navigation.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ class Navigation extends BaseComponent {
9494
}
9595

9696
_setActiveLink() {
97-
Array.from(this._element.querySelectorAll(SELECTOR_NAV_LINK)).forEach(element => {
97+
for (const element of Array.from(this._element.querySelectorAll(SELECTOR_NAV_LINK))) {
9898
if (element.classList.contains(CLASS_NAME_NAV_GROUP_TOGGLE)) {
99-
return
99+
continue
100100
}
101101

102102
let currentUrl = String(window.location)
@@ -115,6 +115,7 @@ class Navigation extends BaseComponent {
115115

116116
if (this._config.activeLinksExact && element.href === currentUrl) {
117117
element.classList.add(CLASS_NAME_ACTIVE)
118+
// eslint-disable-next-line unicorn/no-array-for-each
118119
Array.from(this._getParents(element, SELECTOR_NAV_GROUP)).forEach(element => {
119120
element.classList.add(CLASS_NAME_SHOW)
120121
element.setAttribute('aria-expanded', true)
@@ -123,12 +124,13 @@ class Navigation extends BaseComponent {
123124

124125
if (!this._config.activeLinksExact && element.href.startsWith(currentUrl)) {
125126
element.classList.add(CLASS_NAME_ACTIVE)
127+
// eslint-disable-next-line unicorn/no-array-for-each
126128
Array.from(this._getParents(element, SELECTOR_NAV_GROUP)).forEach(element => {
127129
element.classList.add(CLASS_NAME_SHOW)
128130
element.setAttribute('aria-expanded', true)
129131
})
130132
}
131-
})
133+
}
132134
}
133135

134136
_getParents(element, selector) {
@@ -225,12 +227,12 @@ class Navigation extends BaseComponent {
225227

226228
// Close other groups
227229
if (this._config.groupsAutoCollapse === true) {
228-
this._getSiblings(toggler.parentNode, filter).forEach(element => {
230+
for (const element of this._getSiblings(toggler.parentNode, filter)) {
229231
this._slideUp(SelectorEngine.findOne(SELECTOR_NAV_GROUP_ITEMS, element), () => {
230232
element.classList.remove(CLASS_NAME_SHOW)
231233
element.setAttribute('aria-expanded', false)
232234
})
233-
})
235+
}
234236
}
235237

236238
if (toggler.parentNode.classList.contains(CLASS_NAME_SHOW)) {
@@ -280,9 +282,9 @@ class Navigation extends BaseComponent {
280282
* ------------------------------------------------------------------------
281283
*/
282284
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
283-
Array.from(document.querySelectorAll(SELECTOR_DATA_NAVIGATION)).forEach(element => {
285+
for (const element of Array.from(document.querySelectorAll(SELECTOR_DATA_NAVIGATION))) {
284286
Navigation.navigationInterface(element)
285-
})
287+
}
286288
})
287289

288290
/**

js/src/sidebar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ class Sidebar extends BaseComponent {
324324
*/
325325

326326
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
327-
Array.from(document.querySelectorAll(SELECTOR_SIDEBAR)).forEach(element => {
327+
for (const element of Array.from(document.querySelectorAll(SELECTOR_SIDEBAR))) {
328328
Sidebar.sidebarInterface(element)
329-
})
329+
}
330330
})
331331

332332
/**

0 commit comments

Comments
 (0)