Skip to content

Commit b5fc191

Browse files
committed
reduce indirection
1 parent 265e3f3 commit b5fc191

File tree

1 file changed

+7
-14
lines changed
  • packages/svelte/src/internal/server

1 file changed

+7
-14
lines changed

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

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

23-
/**
24-
* @param {import('#server').Payload} payload
25-
* @param {string} message
26-
*/
27-
function error_on_client(payload, message) {
28-
message =
29-
`${message}\n\n` +
30-
'This can cause content to shift around as the browser repairs the HTML, and will likely result in a `hydration_mismatch` warning.';
31-
// eslint-disable-next-line no-console
32-
console.error(message);
33-
payload.head.out += `<script>console.error(${JSON.stringify(message)})</script>`;
34-
}
35-
3623
/**
3724
* @param {Element} element
3825
*/
@@ -47,7 +34,13 @@ function stringify(element) {
4734
* @param {Element} child
4835
*/
4936
function print_error(payload, parent, child) {
50-
error_on_client(payload, `${stringify(child)} cannot contain ${stringify(parent)}`);
37+
var message =
38+
`${stringify(child)} cannot contain ${stringify(parent)}\n\n` +
39+
'This can cause content to shift around as the browser repairs the HTML, and will likely result in a `hydration_mismatch` warning.';
40+
41+
// eslint-disable-next-line no-console
42+
console.error(message);
43+
payload.head.out += `<script>console.error(${JSON.stringify(message)})</script>`;
5144
}
5245

5346
/**

0 commit comments

Comments
 (0)