From cf993bc263b58502096f00d383266cd179f331af Mon Sep 17 00:00:00 2001 From: Nikhil Kothari Date: Wed, 27 Dec 2023 02:08:20 -0800 Subject: [PATCH] Filter out Svelte's unknown data prop warnings (#9510) --- .changeset/forty-actors-wash.md | 5 +++++ packages/integrations/svelte/client.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/forty-actors-wash.md diff --git a/.changeset/forty-actors-wash.md b/.changeset/forty-actors-wash.md new file mode 100644 index 0000000000..4a5d79d0a6 --- /dev/null +++ b/.changeset/forty-actors-wash.md @@ -0,0 +1,5 @@ +--- +'@astrojs/svelte': patch +--- + +Filter out Svelte's unknown data prop warnings diff --git a/packages/integrations/svelte/client.js b/packages/integrations/svelte/client.js index 9e3df40191..51d60ac8fc 100644 --- a/packages/integrations/svelte/client.js +++ b/packages/integrations/svelte/client.js @@ -104,9 +104,15 @@ function finishUsingConsoleFilter() { */ function filteredConsoleWarning(msg, ...rest) { if (consoleFilterRefs > 0 && typeof msg === 'string') { - // Astro passes a `class` prop to the Svelte component, which + // Astro passes `class` and `data-astro-cid` props to the Svelte component, which // outputs the following warning, which we can safely filter out. - const isKnownSvelteError = msg.endsWith("was created with unknown prop 'class'"); + + // NOTE: In practice data-astro-cid props have a hash suffix. Hence the use of a + // quoted prop name string without a closing quote. + + const isKnownSvelteError = + msg.endsWith("was created with unknown prop 'class'") || + msg.includes("was created with unknown prop 'data-astro-cid"); if (isKnownSvelteError) return; } originalConsoleWarning(msg, ...rest);