From 92328eef1da121ab18037dd9254796d23c8c9458 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 17 Aug 2023 17:41:01 +0200 Subject: [PATCH] ref: Use Proxy to track client-side load event `route` accesses --- .changeset/weak-vans-change.md | 5 +++++ packages/kit/src/runtime/client/client.js | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/weak-vans-change.md diff --git a/.changeset/weak-vans-change.md b/.changeset/weak-vans-change.md new file mode 100644 index 000000000000..294e9a6296a4 --- /dev/null +++ b/.changeset/weak-vans-change.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: Use Proxy to track usage of client side load `event.route` diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 2eddc36d7b5d..310e5a87a447 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -449,12 +449,12 @@ export function create_client(app, target) { /** @type {import('@sveltejs/kit').LoadEvent} */ const load_input = { - route: { - get id() { + route: new Proxy(route, { + get: (target, key) => { uses.route = true; - return route.id; + return target[/** @type {'id'} */ (key)]; } - }, + }), params: new Proxy(params, { get: (target, key) => { uses.params.add(/** @type {string} */ (key));