Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tiny-pears-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Silence unknown prop warnings coming from SvelteKit
46 changes: 40 additions & 6 deletions packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,22 @@ export function create_client({ target, base, trailing_slash }) {
navigation_result.props.page.url = url;
}

root.$set(navigation_result.props);
if (import.meta.env.DEV) {
// Nasty hack to silence harmless warnings the user can do nothing about
const warn = console.warn;
console.warn = (...args) => {
if (
args.length !== 1 ||
!/<(Layout|Page)> was created with unknown prop '(data|errors)'/.test(args[0])
) {
warn(...args);
}
};
root.$set(navigation_result.props);
tick().then(() => (console.warn = warn));
} else {
root.$set(navigation_result.props);
}
} else {
initialize(navigation_result);
}
Expand Down Expand Up @@ -347,11 +362,30 @@ export function create_client({ target, base, trailing_slash }) {

page = result.props.page;

root = new Root({
target,
props: { ...result.props, stores },
hydrate: true
});
if (import.meta.env.DEV) {
// Nasty hack to silence harmless warnings the user can do nothing about
const warn = console.warn;
console.warn = (...args) => {
if (
args.length !== 1 ||
!/<(Layout|Page)> was created with unknown prop '(data|errors)'/.test(args[0])
) {
warn(...args);
}
};
root = new Root({
target,
props: { ...result.props, stores },
hydrate: true
});
console.warn = warn;
} else {
root = new Root({
target,
props: { ...result.props, stores },
hydrate: true
});
}

if (router_enabled) {
const navigation = { from: null, to: new URL(location.href) };
Expand Down