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
@@ -22,6 +22,12 @@ describe("attributes", () => {
|
||||
expect(renderToString(template)).toBe(`<div aria-label="Close"></div>`);
|
||||
});
|
||||
|
||||
test("static attributes with backticks", () => {
|
||||
const template = '<div foo="`bar`"></div>';
|
||||
const result = renderToString(template);
|
||||
expect(result).toBe('<div foo="`bar`"></div>');
|
||||
});
|
||||
|
||||
test("static attributes on void elements", () => {
|
||||
const template = `<img src="/test.skip.jpg" alt="Test"/>`;
|
||||
expect(renderToString(template)).toBe(`<img src="/test.skip.jpg" alt="Test">`);
|
||||
@@ -33,6 +39,12 @@ describe("attributes", () => {
|
||||
expect(result).toBe(`<div foo="bar"></div>`);
|
||||
});
|
||||
|
||||
test("dynamic attributes with backticks", () => {
|
||||
const template = '<div t-att-foo="`bar`"/>';
|
||||
const result = renderToString(template);
|
||||
expect(result).toBe(`<div foo="bar"></div>`);
|
||||
});
|
||||
|
||||
test("two dynamic attributes", () => {
|
||||
const template = `<div t-att-foo="'bar'" t-att-bar="'foo'"/>`;
|
||||
const result = renderToString(template);
|
||||
|
||||
Reference in New Issue
Block a user