Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out Svelte's unknown data prop warnings #9510

Merged
merged 5 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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/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.indexOf("was created with unknown prop 'data-astro-cid") > 0;
bluwy marked this conversation as resolved.
Show resolved Hide resolved
if (isKnownSvelteError) return;
}
originalConsoleWarning(msg, ...rest);
Expand Down
Loading