From ad06ce8dd673d5289127c50307a2e128fef73b73 Mon Sep 17 00:00:00 2001 From: daun Date: Mon, 29 Jan 2024 17:11:56 +0000 Subject: [PATCH 1/3] Update package version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e4b1aa..ec14cea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@swup/preload-plugin", - "version": "3.2.8", + "version": "3.2.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@swup/preload-plugin", - "version": "3.2.8", + "version": "3.2.9", "license": "MIT", "dependencies": { "@swup/plugin": "^4.0.0" diff --git a/package.json b/package.json index 0112695..2168f8b 100755 --- a/package.json +++ b/package.json @@ -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", From 3d76932ac1a5ccce1ec850b40916435c9540971c Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Mon, 29 Jan 2024 18:35:42 +0100 Subject: [PATCH 2/3] Fix missing temporary visit objects --- src/index.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0c085b6..847fa00 100755 --- a/src/index.ts +++ b/src/index.ts @@ -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 }); }; @@ -404,7 +409,12 @@ export default class SwupPreloadPlugin extends Plugin { */ protected async performPreload(href: string): Promise { 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; }); From 730ed4d9f7322022a7b430c2a43533b79c84fd40 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Mon, 29 Jan 2024 18:35:52 +0100 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe763f9..22f2dd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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