Skip to content

Commit

Permalink
Merge pull request #123 from swup/version/automated
Browse files Browse the repository at this point in the history
Update package version (automated)
  • Loading branch information
daun authored Jan 29, 2024
2 parents d244c33 + 730ed4d commit bf2fe5b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

## [3.2.8] - 2023-10-20
## [3.2.9] - 2024-01-29

- Respect swup's link selector option
- Support preloading links in SVGs
- Create temporary visits for preload hooks

## [3.2.8] - 2024-01-26

- Ignore external links on hover

Expand Down Expand Up @@ -115,6 +121,7 @@

- Initial release

[3.2.9]: https://github.com/swup/preload-plugin/releases/tag/3.2.9
[3.2.8]: https://github.com/swup/preload-plugin/releases/tag/3.2.8
[3.2.7]: https://github.com/swup/preload-plugin/releases/tag/3.2.7
[3.2.6]: https://github.com/swup/preload-plugin/releases/tag/3.2.6
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@swup/preload-plugin",
"amdName": "SwupPreloadPlugin",
"version": "3.2.8",
"version": "3.2.9",
"description": "A swup plugin for preloading pages and faster navigation",
"type": "module",
"source": "src/index.ts",
Expand Down
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ export default class SwupPreloadPlugin extends Plugin {
const el = event.delegateTarget;
if (!isAnchorElement(el)) return;

this.swup.hooks.callSync('link:hover', undefined, { el, event });
// Create temporary visit object for link:hover hook
const { url: to, hash } = Location.fromElement(el);
// @ts-expect-error: createVisit is currently private, need to make this semi-public somehow
const visit = this.swup.createVisit({ to, hash, el, event });

this.swup.hooks.callSync('link:hover', visit, { el, event });
this.preload(el, { priority: true });
};

Expand Down Expand Up @@ -404,7 +409,12 @@ export default class SwupPreloadPlugin extends Plugin {
*/
protected async performPreload(href: string): Promise<PageData> {
const { url } = Location.fromUrl(href);
const page = await this.swup.hooks.call('page:preload', undefined, { url }, async (visit, args) => {

// Create temporary visit object for page:preload hook
// @ts-expect-error: createVisit is currently private, need to make this semi-public somehow
const visit = this.swup.createVisit({ to: url });

const page = await this.swup.hooks.call('page:preload', visit, { url }, async (visit, args) => {
args.page = await this.swup.fetchPage(href);
return args.page;
});
Expand Down

0 comments on commit bf2fe5b

Please sign in to comment.