mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] compiler: properly handle <t> tags in some cases
The problem was that the compiler is based on the assumption that the multi block received by the parser only occurs in some cases where the structure of the template require a multi block, and it does not work when we have random multiblock elsewhere. We could fix the issue by modifying the code generator code to support these usecases, or by simply removing these cases in the parser. Since this seems more efficient, this is the approach taken by this commit. Note that it was a good opportunity to simplify the parser.
This commit is contained in:
committed by
Mathieu Duckerts-Antoine
parent
424bc480e2
commit
d7de25e867
@@ -149,6 +149,93 @@ describe("qweb parser", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("dom node with t multi inside", async () => {
|
||||
const template = `<div><t>Loading<t t-esc="abc"/></t></div>`;
|
||||
expect(parse(template)).toEqual({
|
||||
type: ASTType.DomNode,
|
||||
tag: "div",
|
||||
dynamicTag: null,
|
||||
attrs: {},
|
||||
on: {},
|
||||
ref: null,
|
||||
model: null,
|
||||
ns: null,
|
||||
content: [
|
||||
{ type: ASTType.Text, value: "Loading" },
|
||||
{ type: ASTType.TEsc, expr: "abc", defaultValue: "" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test("dom node with multiple t multi inside", async () => {
|
||||
const template = `
|
||||
<div>
|
||||
<t t-esc="a"/>
|
||||
<t>
|
||||
<t t-esc="b"/>
|
||||
<t>Loading<t t-esc="c"/></t>
|
||||
</t>
|
||||
</div>`;
|
||||
expect(parse(template)).toEqual({
|
||||
type: ASTType.DomNode,
|
||||
tag: "div",
|
||||
dynamicTag: null,
|
||||
attrs: {},
|
||||
on: {},
|
||||
ref: null,
|
||||
model: null,
|
||||
ns: null,
|
||||
content: [
|
||||
{ type: ASTType.TEsc, expr: "a", defaultValue: "" },
|
||||
{ type: ASTType.TEsc, expr: "b", defaultValue: "" },
|
||||
{ type: ASTType.Text, value: "Loading" },
|
||||
{ type: ASTType.TEsc, expr: "c", defaultValue: "" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test("dom node with t multi inside", async () => {
|
||||
const template = `<div><t><t>Loading<t t-esc="abc"/></t></t></div>`;
|
||||
expect(parse(template)).toEqual({
|
||||
type: ASTType.DomNode,
|
||||
tag: "div",
|
||||
dynamicTag: null,
|
||||
attrs: {},
|
||||
on: {},
|
||||
ref: null,
|
||||
model: null,
|
||||
ns: null,
|
||||
content: [
|
||||
{ type: ASTType.Text, value: "Loading" },
|
||||
{ type: ASTType.TEsc, expr: "abc", defaultValue: "" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test("dom node with two t multi inside", async () => {
|
||||
const template = `
|
||||
<div>
|
||||
<t><t t-esc="a"/><t t-esc="b"/></t>
|
||||
<t><t t-esc="c"/><t t-esc="d"/></t>
|
||||
</div>`;
|
||||
expect(parse(template)).toEqual({
|
||||
type: ASTType.DomNode,
|
||||
tag: "div",
|
||||
dynamicTag: null,
|
||||
attrs: {},
|
||||
on: {},
|
||||
ref: null,
|
||||
model: null,
|
||||
ns: null,
|
||||
content: [
|
||||
{ type: ASTType.TEsc, expr: "a", defaultValue: "" },
|
||||
{ type: ASTType.TEsc, expr: "b", defaultValue: "" },
|
||||
{ type: ASTType.TEsc, expr: "c", defaultValue: "" },
|
||||
{ type: ASTType.TEsc, expr: "d", defaultValue: "" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test("dom node next to text node", async () => {
|
||||
expect(parse("some text<span></span>")).toEqual({
|
||||
type: ASTType.Multi,
|
||||
|
||||
Reference in New Issue
Block a user