mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] compiler: escape backticks in attributes
Before this commit, the generated code crashed if an attribute in the template contained backticks. The compiler output something like ```js let block1 = createBlock(`<div foo="`bar`"/>`); ``` The backticks are now properly escaped.
This commit is contained in:
committed by
Sam Degueldre
parent
9c4c3e3b83
commit
c16d7d52b1
@@ -282,6 +282,7 @@ export class CodeGenerator {
|
||||
for (let block of this.blocks) {
|
||||
if (block.dom) {
|
||||
let xmlString = block.asXmlString();
|
||||
xmlString = xmlString.replace(/`/g, "\\`");
|
||||
if (block.dynamicTagName) {
|
||||
xmlString = xmlString.replace(/^<\w+/, `<\${tag || '${block.dom.nodeName}'}`);
|
||||
xmlString = xmlString.replace(/\w+>$/, `\${tag || '${block.dom.nodeName}'}>`);
|
||||
|
||||
Reference in New Issue
Block a user