Skip to content

Commit

Permalink
feat(esl-utils): add findNextLooped and findPrevLooped common tra…
Browse files Browse the repository at this point in the history
…versing utility
  • Loading branch information
ala-n committed May 18, 2023
1 parent 3a93887 commit 80a4e67
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/modules/esl-utils/dom/traversing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ export const findClosestBy = (node: Node | null, predicate: (node: Node) => bool
return null;
};

/**
* Find looped next element within parent circle
*/
export const findNextLooped =
createSequenceFinder((el) => el.nextElementSibling || (el.parentElement && el.parentElement.firstElementChild));

/**
* Find looped previous element within parent circle (looped)
*/
export const findPrevLooped =
createSequenceFinder((el) => el.previousElementSibling || (el.parentElement && el.parentElement.lastElementChild));

/** @deprecated Cumulative traversing utility set */
export abstract class TraversingUtils {
static isRelative = isRelativeNode;
Expand Down

0 comments on commit 80a4e67

Please # to comment.