Skip to content

Commit 6b6d10d

Browse files
committed
Update code comments
1 parent 49c3963 commit 6b6d10d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/inc/functions.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function prepareFragmentElements({ parsedRules, swup, logger }: FragmentPlugin):
121121
*
122122
* A visit is being considered a reload, if one of these conditions apply:
123123
* - `route.from` equal to `route.to`
124-
* - all containers match the current url
124+
* - all containers match the current url and swup is set to navigate on `linkToSelf`
125125
*/
126126
export const getFragmentVisitContainers = (
127127
route: Route,
@@ -158,10 +158,14 @@ export const getFragmentVisitContainers = (
158158
const isLinkToSelf = fragments.every((fragment) =>
159159
elementMatchesFragmentUrl(fragment.el, route.to)
160160
);
161+
161162
const isReload =
162163
isEqualUrl(route.from, route.to) ||
163164
(isLinkToSelf && swup.options.linkToSelf === 'navigate');
164165

166+
/**
167+
* If this is NOT a reload, ignore fragments that already match `route.to`
168+
*/
165169
if (!isReload) {
166170
fragments = fragments.filter((fragment) => {
167171
if (elementMatchesFragmentUrl(fragment.el, route.to)) {

0 commit comments

Comments
 (0)