diff --git a/src/compiler/code_generator.ts b/src/compiler/code_generator.ts index 479a6c0f..b401ff5d 100644 --- a/src/compiler/code_generator.ts +++ b/src/compiler/code_generator.ts @@ -294,7 +294,7 @@ export class CodeGenerator { for (let block of this.blocks) { if (block.dom) { let xmlString = block.asXmlString(); - xmlString = xmlString.replace(/`/g, "\\`"); + xmlString = xmlString.replace(/\\/g, "\\\\").replace(/`/g, "\\`"); if (block.dynamicTagName) { xmlString = xmlString.replace(/^<\w+/, `<\${tag || '${block.dom.nodeName}'}`); xmlString = xmlString.replace(/\w+>$/, `\${tag || '${block.dom.nodeName}'}>`); diff --git a/tests/compiler/__snapshots__/attributes.test.ts.snap b/tests/compiler/__snapshots__/attributes.test.ts.snap index c536cefd..6fc68183 100644 --- a/tests/compiler/__snapshots__/attributes.test.ts.snap +++ b/tests/compiler/__snapshots__/attributes.test.ts.snap @@ -430,6 +430,19 @@ exports[`attributes static attributes on void elements 1`] = ` }" `; +exports[`attributes static attributes with backslash or backtick 1`] = ` +"function anonymous(app, bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, comment } = bdom; + + let block1 = createBlock(\`