Skip to content

Commit

Permalink
I forgor
Browse files Browse the repository at this point in the history
  • Loading branch information
WallSoGB committed Nov 18, 2024
1 parent bebf6d6 commit ef9aad3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ function createRightSidebar() {
const fragment = document.createDocumentFragment();

for (const section of sections) {
// Get and sort elements once per section
// Get only direct children and sort them
const elements = [
...section.querySelectorAll('.card, .expander-top')
].sort((a, b) =>
...section.children
].filter(el =>
(el.classList.contains('card') || el.classList.contains('expander-top')) &&
el.parentNode === section
).sort((a, b) =>
a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1
);

Expand Down

0 comments on commit ef9aad3

Please sign in to comment.