Skip to content

Commit

Permalink
Filter out Svelte's unknown data prop warnings (#9510)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilk authored Dec 27, 2023
1 parent 0ee255a commit cf993bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-actors-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/svelte': patch
---

Filter out Svelte's unknown data prop warnings
10 changes: 8 additions & 2 deletions packages/integrations/svelte/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cf993bc

Please sign in to comment.