Skip to content

Commit bf2fe5b

Browse files
authored
Merge pull request #123 from swup/version/automated
Update package version (automated)
2 parents d244c33 + 730ed4d commit bf2fe5b

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22

3-
## [3.2.8] - 2023-10-20
3+
## [3.2.9] - 2024-01-29
4+
5+
- Respect swup's link selector option
6+
- Support preloading links in SVGs
7+
- Create temporary visits for preload hooks
8+
9+
## [3.2.8] - 2024-01-26
410

511
- Ignore external links on hover
612

@@ -115,6 +121,7 @@
115121

116122
- Initial release
117123

124+
[3.2.9]: https://github.com/swup/preload-plugin/releases/tag/3.2.9
118125
[3.2.8]: https://github.com/swup/preload-plugin/releases/tag/3.2.8
119126
[3.2.7]: https://github.com/swup/preload-plugin/releases/tag/3.2.7
120127
[3.2.6]: https://github.com/swup/preload-plugin/releases/tag/3.2.6

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@swup/preload-plugin",
33
"amdName": "SwupPreloadPlugin",
4-
"version": "3.2.8",
4+
"version": "3.2.9",
55
"description": "A swup plugin for preloading pages and faster navigation",
66
"type": "module",
77
"source": "src/index.ts",

src/index.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,12 @@ export default class SwupPreloadPlugin extends Plugin {
198198
const el = event.delegateTarget;
199199
if (!isAnchorElement(el)) return;
200200

201-
this.swup.hooks.callSync('link:hover', undefined, { el, event });
201+
// Create temporary visit object for link:hover hook
202+
const { url: to, hash } = Location.fromElement(el);
203+
// @ts-expect-error: createVisit is currently private, need to make this semi-public somehow
204+
const visit = this.swup.createVisit({ to, hash, el, event });
205+
206+
this.swup.hooks.callSync('link:hover', visit, { el, event });
202207
this.preload(el, { priority: true });
203208
};
204209

@@ -404,7 +409,12 @@ export default class SwupPreloadPlugin extends Plugin {
404409
*/
405410
protected async performPreload(href: string): Promise<PageData> {
406411
const { url } = Location.fromUrl(href);
407-
const page = await this.swup.hooks.call('page:preload', undefined, { url }, async (visit, args) => {
412+
413+
// Create temporary visit object for page:preload hook
414+
// @ts-expect-error: createVisit is currently private, need to make this semi-public somehow
415+
const visit = this.swup.createVisit({ to: url });
416+
417+
const page = await this.swup.hooks.call('page:preload', visit, { url }, async (visit, args) => {
408418
args.page = await this.swup.fetchPage(href);
409419
return args.page;
410420
});

0 commit comments

Comments
 (0)