-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
WebUI: Replace getElements & getChildren #22220
base: master
Are you sure you want to change the base?
Conversation
for (let i = 0; i < trs.length; ++i) { | ||
if (trs[i].rowId === rowId) | ||
return trs[i]; | ||
for (const tr of this.getTrs()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use Array.find()
instead. And with special handling to the undefined
case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Collection returned by getTrs is not an Array - it's a NodeList and we can't use Array.find() and others without for e.g converting it first. Should I do it in all reviewed cases or keep everything as is?
@@ -490,7 +490,9 @@ window.addEventListener("DOMContentLoaded", () => { | |||
const categoryList = document.getElementById("categoryFilterList"); | |||
if (!categoryList) | |||
return; | |||
categoryList.getChildren().each(c => c.destroy()); | |||
|
|||
for (const category of categoryList.querySelectorAll("li")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this be fragile? Also it looks like it will get grandchildren too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, totally forgot about subcategories - will fix to get only direct children.
Won't this be fragile?
for (let i = 0; i < columns.length; ++i) { | ||
if (columns[i].textContent === "Enabled") | ||
return i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be possible to use Array.findIndex()
.
for (const tr of this.getTrs()) { | ||
if (!tr.classList.contains("invisible") && (tr.style.display !== "none")) | ||
visibleRows.push(tr); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you can use Array.filter()
.
const visibleRows = []; | ||
for (const tr of this.getTrs()) { | ||
if (!tr.classList.contains("invisible") && (tr.style.display !== "none")) | ||
visibleRows.push(tr); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you can use Array.filter()
.
This PR further reduces Mootools usage.