diff --git a/.changeset/polite-elephants-care.md b/.changeset/polite-elephants-care.md
new file mode 100644
index 000000000000..7deda4c2e43c
--- /dev/null
+++ b/.changeset/polite-elephants-care.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+[fix] load function should not leak props to other components
diff --git a/packages/kit/src/runtime/client/renderer.js b/packages/kit/src/runtime/client/renderer.js
index 4f3de22b7da2..abf668120d1a 100644
--- a/packages/kit/src/runtime/client/renderer.js
+++ b/packages/kit/src/runtime/client/renderer.js
@@ -404,7 +404,7 @@ export class Renderer {
for (let i = 0; i < filtered.length; i += 1) {
const loaded = filtered[i].loaded;
- if (loaded) result.props[`props_${i}`] = await loaded.props;
+ result.props[`props_${i}`] = loaded ? await loaded.props : null;
}
if (
diff --git a/packages/kit/test/apps/basics/src/routes/load/_tests.js b/packages/kit/test/apps/basics/src/routes/load/_tests.js
index d97e030d5405..feab95b2f0c7 100644
--- a/packages/kit/test/apps/basics/src/routes/load/_tests.js
+++ b/packages/kit/test/apps/basics/src/routes/load/_tests.js
@@ -231,4 +231,12 @@ export default function (test, is_dev) {
assert.equal(await page.innerHTML('.parsed'), '{"oddly":{"formatted":"json"}}');
assert.equal(await page.innerHTML('.raw'), '{ "oddly" : { "formatted" : "json" } }');
});
+
+ test('does not leak props to other pages', '/load/props/about', async ({ page, clicknav }) => {
+ assert.equal(await page.textContent('p'), 'Data: undefined');
+ await clicknav('[href="/load/props/"]');
+ assert.equal(await page.textContent('p'), 'Data: Hello from Index!');
+ await clicknav('[href="/load/props/about"]');
+ assert.equal(await page.textContent('p'), 'Data: undefined');
+ });
}
diff --git a/packages/kit/test/apps/basics/src/routes/load/props/__layout.svelte b/packages/kit/test/apps/basics/src/routes/load/props/__layout.svelte
new file mode 100644
index 000000000000..9423a8777ee3
--- /dev/null
+++ b/packages/kit/test/apps/basics/src/routes/load/props/__layout.svelte
@@ -0,0 +1,10 @@
+
Data: {data}
diff --git a/packages/kit/test/apps/basics/src/routes/load/props/index.svelte b/packages/kit/test/apps/basics/src/routes/load/props/index.svelte new file mode 100644 index 000000000000..6619291fe88a --- /dev/null +++ b/packages/kit/test/apps/basics/src/routes/load/props/index.svelte @@ -0,0 +1,14 @@ + + + + +Data: {data}