Skip to content

Commit 8c5e8d6

Browse files
committed
only print message once
1 parent b5fc191 commit 8c5e8d6

File tree

1 file changed

+6
-0
lines changed
  • packages/svelte/src/internal/server

1 file changed

+6
-0
lines changed

packages/svelte/src/internal/server/dev.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import { current_component } from './context.js';
2020
*/
2121
let parent = null;
2222

23+
/** @type {Set<string>} */
24+
let seen;
25+
2326
/**
2427
* @param {Element} element
2528
*/
@@ -38,6 +41,9 @@ function print_error(payload, parent, child) {
3841
`${stringify(child)} cannot contain ${stringify(parent)}\n\n` +
3942
'This can cause content to shift around as the browser repairs the HTML, and will likely result in a `hydration_mismatch` warning.';
4043

44+
if ((seen ??= new Set()).has(message)) return;
45+
seen.add(message);
46+
4147
// eslint-disable-next-line no-console
4248
console.error(message);
4349
payload.head.out += `<script>console.error(${JSON.stringify(message)})</script>`;

0 commit comments

Comments
 (0)