fix: render undefined html as the empty string (#13092)

Fix #13069

---------

Co-authored-by: adiGuba <frederic.martini@gmail.com>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/13085/head
Dominic Gannaway 3 weeks ago committed by GitHub
parent d776e522d2
commit b70d12c2e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: render undefined html as the empty string

@ -50,7 +50,7 @@ export function html(node, get_value, svg, mathml, skip_warning) {
var effect;
block(() => {
if (value === (value = get_value())) {
if (value === (value = get_value() ?? '')) {
if (hydrating) {
hydrate_next();
}

@ -5,6 +5,7 @@ import { hash } from '../../../utils.js';
* @param {string} value
*/
export function html(value) {
var open = DEV ? `<!--${hash(String(value ?? ''))}-->` : '<!---->';
return `${open}${value}<!---->`;
var html = String(value ?? '');
var open = DEV ? `<!--${hash(html)}-->` : '<!---->';
return open + html + '<!---->';
}

@ -15,7 +15,7 @@ export default test({
ssrHtml: `
<editor contenteditable="true"><b>world</b></editor>
<p>hello null</p>
<p>hello </p>
`,
async test({ assert, component, target, window }) {

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: ''
});
Loading…
Cancel
Save