Skip to content

Commit

Permalink
Merge pull request #75 from swup/fix/update-link-to-fragment-for-same…
Browse files Browse the repository at this point in the history
…-url
  • Loading branch information
hirasso committed May 21, 2024
2 parents 6f0f43d + 1c5101e commit 5d0b003
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/inc/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type Route = {
};

/** The interface for an augmented Fragment Element */
export interface FragmentElement extends Element {
export interface FragmentElement extends HTMLElement {
__swupFragment?: {
url?: string;
selector?: string;
Expand Down
3 changes: 1 addition & 2 deletions src/inc/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function handleLinksToFragments({ logger, swup }: FragmentPlugin): void {
if (isEqualUrl(fragmentUrl, swup.getCurrentUrl())) {
// prettier-ignore
if (__DEV__) logger?.warn(`The fragment URL of ${selector} is identical to the current URL. This could mean that [data-swup-fragment-url] needs to be provided by the server.`);
return;
}

el.href = fragmentUrl;
Expand Down Expand Up @@ -372,7 +371,7 @@ export function queryFragmentElement(
): FragmentElement | undefined {
for (const containerSelector of swup.options.containers) {
const container = document.querySelector(containerSelector);
if (container?.matches(fragmentSelector)) return container;
if (container?.matches(fragmentSelector)) return container as FragmentElement;

const fragment = container?.querySelector<FragmentElement>(fragmentSelector);
if (fragment) return fragment;
Expand Down

0 comments on commit 5d0b003

Please sign in to comment.