Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compatibility with swup 4.6.0 #72

Merged
merged 9 commits into from
Mar 26, 2024
Merged
4 changes: 2 additions & 2 deletions src/inc/ParsedRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type Options = {
* Represents a Rule
*/
export default class ParsedRule {
readonly matchesFrom;
readonly matchesTo;
readonly matchesFrom: ReturnType<typeof matchPath>;
readonly matchesTo: ReturnType<typeof matchPath>;

swup: Swup;
from: Path;
Expand Down
1 change: 0 additions & 1 deletion src/inc/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ export const cacheForeignFragmentElements = ({ swup, logger }: FragmentPlugin):

// Update the cache of the current page with the updated html
cache.update(currentUrl, {
...currentCache,
fragmentHtml: currentCachedDocument.documentElement.outerHTML
});

Expand Down
3 changes: 3 additions & 0 deletions src/inc/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export const beforeContentReplace: Handler<'content:replace'> = function (
const cache = this.swup.cache.get(visit.to.url);
if (!cache || !cache.fragmentHtml) return;

visit.to.document = new DOMParser().parseFromString(cache.fragmentHtml, 'text/html');
visit.to.html = cache.fragmentHtml;
args.page.html = cache.fragmentHtml;
hirasso marked this conversation as resolved.
Show resolved Hide resolved

if (__DEV__) this.logger?.log(`fragment cache used for ${highlight(visit.to.url!)}`);
};

Expand Down