diff --git a/packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-string.js b/packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-string.js index f83beb5392..cdd57f44fe 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-string.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-string.js @@ -14,33 +14,29 @@ export function template_to_string(items) { * @param {Node} node */ function stringify(node) { - switch (node.type) { - case 'element': { - let str = `<${node.name}`; - - for (const key in node.attributes) { - const value = node.attributes[key]; + if (node.type === 'text') { + return node.nodes.map((node) => node.raw).join(''); + } - str += ` ${key}`; - if (value !== undefined) str += `="${escape_html(value, true)}"`; - } + if (node.type === 'anchor') { + return node.data ? `` : ''; + } - str += `>`; - str += node.children.map(stringify).join(''); + let str = `<${node.name}`; - if (!is_void(node.name)) { - str += ``; - } + for (const key in node.attributes) { + const value = node.attributes[key]; - return str; - } + str += ` ${key}`; + if (value !== undefined) str += `="${escape_html(value, true)}"`; + } - case 'text': { - return node.nodes.map((node) => node.raw).join(''); - } + str += `>`; + str += node.children.map(stringify).join(''); - case 'anchor': { - return node.data ? `` : ''; - } + if (!is_void(node.name)) { + str += ``; } + + return str; }