Skip to content

Commit

Permalink
getCollectionElements: Added 'previous' query
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiglesias93 committed Sep 29, 2021
1 parent 5e5157f commit a25bb3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@finsweet/ts-utils",
"version": "0.13.5",
"version": "0.13.6",
"description": "Typescript utils for custom Webflow projects.",
"main": "index.ts",
"module": "index.ts",
Expand Down
5 changes: 3 additions & 2 deletions webflow/getCollectionElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getCollectionElements(
): NodeListOf<HTMLDivElement>;
export function getCollectionElements(
reference: string | Element,
target: 'next',
target: 'next' | 'previous',
page?: Document
): HTMLAnchorElement | null | undefined;
export function getCollectionElements(
Expand All @@ -23,7 +23,7 @@ export function getCollectionElements(
): HTMLDivElement | null | undefined;
export function getCollectionElements(
reference: string | Element,
target: 'wrapper' | 'list' | 'items' | 'next',
target: 'wrapper' | 'list' | 'items' | 'next' | 'previous',
page: Document = document
): HTMLDivElement | NodeListOf<HTMLDivElement> | HTMLAnchorElement | null | undefined {
const referenceElement = typeof reference === 'string' ? page.querySelector<HTMLDivElement>(reference) : reference;
Expand All @@ -34,6 +34,7 @@ export function getCollectionElements(
if (target === 'items') return referenceElement.querySelectorAll<HTMLDivElement>('.w-dyn-item');

if (target === 'next') return referenceElement.querySelector<HTMLAnchorElement>('.w-pagination-next');
if (target === 'previous') return referenceElement.querySelector<HTMLAnchorElement>('.w-pagination-previous');

return (
referenceElement.querySelector<HTMLDivElement>(`.w-dyn-items`) ||
Expand Down

0 comments on commit a25bb3d

Please sign in to comment.