0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Filter out Svelte's unknown data prop warnings (#9510)

This commit is contained in:
Nikhil Kothari 2023-12-27 02:08:20 -08:00 committed by GitHub
parent 0ee255ae36
commit cf993bc263
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/svelte': patch
---
Filter out Svelte's unknown data prop warnings

View file

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