From 976a8b80fb4fa9ac2e7938deb3ea248b2d54dfa1 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Wed, 14 Sep 2022 12:23:06 +0200 Subject: [PATCH] [fix] silence prop warnings Fixes #5980 This could result in false negatives but the probability for that is minimal and not seing the warning sometimes is better than seing the warning without being able to do anything about it --- .changeset/gorgeous-flowers-doubt.md | 5 ++++ packages/kit/src/runtime/client/client.js | 32 ++++++++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 .changeset/gorgeous-flowers-doubt.md diff --git a/.changeset/gorgeous-flowers-doubt.md b/.changeset/gorgeous-flowers-doubt.md new file mode 100644 index 000000000000..2bc67bc5dd5f --- /dev/null +++ b/.changeset/gorgeous-flowers-doubt.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[fix] silence prop warnings diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 09be6d707ab3..9824fc8def56 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -43,6 +43,7 @@ function update_scroll_positions(index) { scroll_positions[index] = scroll_state(); } +// TODO remove for 1.0 /** @type {Record} */ let warned_about_attributes = {}; @@ -1545,25 +1546,26 @@ function add_url_properties(type, target) { function pre_update() { if (__SVELTEKIT_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)(_[\w$]+)?> was created (with unknown|without expected) prop '(data|form)'/.test( - args[0] - ) - ) { - return; - } - warn(...args); - }; - return () => { - tick().then(() => (console.warn = warn)); check_for_removed_attributes(); }; } return () => {}; } + +if (__SVELTEKIT_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)(_[\w$]+)?> was created (with unknown|without expected) prop '(data|form)'/.test( + args[0] + ) + ) { + return; + } + warn(...args); + }; +}