You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: runtime dev warn for mismatched @html (#12396)
* feat: runtime dev warn for mismatched `@html`
* fix: limit the length of the client value shown in the error
* put logic inside a helper
* remove $.hash, no longer needed
* fix
* tweak
* update changeset
* fix
---------
Co-authored-by: Rich Harris <[email protected]>
Copy file name to clipboardExpand all lines: packages/svelte/messages/client-warnings/warnings.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,12 @@
2
2
3
3
> The `%attribute%` attribute on `%html%` changed its value between server and client renders. The client value, `%value%`, will be ignored in favour of the server value
4
4
5
+
## hydration_html_changed
6
+
7
+
> The value of an `{@html ...}` block changed between server and client renders. The client value will be ignored in favour of the server value
8
+
9
+
> The value of an `{@html ...}` block %location% changed between server and client renders. The client value will be ignored in favour of the server value
10
+
5
11
## hydration_mismatch
6
12
7
13
> Hydration failed because the initial UI does not match what was rendered on the server
Copy file name to clipboardExpand all lines: packages/svelte/src/internal/client/warnings.js
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,19 @@ export function hydration_attribute_changed(attribute, html, value) {
20
20
}
21
21
}
22
22
23
+
/**
24
+
* The value of an `{@html ...}` block %location% changed between server and client renders. The client value will be ignored in favour of the server value
25
+
* @param {string | undefined | null} [location]
26
+
*/
27
+
exportfunctionhydration_html_changed(location){
28
+
if(DEV){
29
+
console.warn(`%c[svelte] hydration_html_changed\n%c${location ? `The value of an \`{@html ...}\` block ${location} changed between server and client renders. The client value will be ignored in favour of the server value` : "The value of an `{@html ...}` block changed between server and client renders. The client value will be ignored in favour of the server value"}`,bold,normal);
30
+
}else{
31
+
// TODO print a link to the documentation
32
+
console.warn("hydration_html_changed");
33
+
}
34
+
}
35
+
23
36
/**
24
37
* Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near %location%
'The value of an `{@html ...}` block in packages/svelte/tests/hydration/samples/html-tag-hydration-2/main.svelte changed between server and client renders. The client value will be ignored in favour of the server value'
0 commit comments