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:
parent
0ee255ae36
commit
cf993bc263
2 changed files with 13 additions and 2 deletions
5
.changeset/forty-actors-wash.md
Normal file
5
.changeset/forty-actors-wash.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/svelte': patch
|
||||
---
|
||||
|
||||
Filter out Svelte's unknown data prop warnings
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue