Skip to content

Commit

Permalink
Swup 4.6.0 compatibility for caching fragments in history visits
Browse files Browse the repository at this point in the history
  • Loading branch information
hirasso committed Mar 26, 2024
1 parent e0093cc commit a87f597
Showing 1 changed file with 3 additions and 0 deletions.
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;

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

Expand Down

0 comments on commit a87f597

Please sign in to comment.