mirror of https://github.com/sveltejs/svelte
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 <rich.harris@vercel.com>pull/12397/head
parent
2cee6fb141
commit
4e8d1c8c52
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: warn in dev on `{@html ...}` block hydration mismatch
|
@ -0,0 +1,10 @@
|
||||
import { DEV } from 'esm-env';
|
||||
import { hash } from '../../../utils.js';
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
*/
|
||||
export function html(value) {
|
||||
var open = DEV ? `<!--${hash(String(value ?? ''))}-->` : '<!---->';
|
||||
return `${open}${value}<!---->`;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<script lang="ts">
|
||||
let { browser } = $props();
|
||||
</script>
|
||||
|
||||
{@html browser ? 'browser' : 'server'}
|
Loading…
Reference in new issue