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);