[FIX] parser: correctly parse pre node within a div with new lines

This commit is contained in:
Lucas Perais (lpe)
2021-12-02 18:06:03 +01:00
committed by Aaron Bohy
parent c1a973a4d8
commit 3c12519277
4 changed files with 46 additions and 0 deletions
@@ -56,6 +56,19 @@ exports[`white space handling nothing is done in pre tags 3`] = `
}"
`;
exports[`white space handling pre inside a div with a new line 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let block1 = createBlock(\`<div><pre>SomeText</pre></div>\`);
return function template(ctx, node, key = \\"\\") {
return block1();
}
}"
`;
exports[`white space handling white space only text nodes are condensed into a single space 1`] = `
"function anonymous(bdom, helpers
) {
+26
View File
@@ -255,6 +255,32 @@ describe("qweb parser", () => {
});
});
test("pre dom node with new line", async () => {
expect(parse(`<div><pre />\n</div>`)).toEqual({
type: 2,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
ref: null,
content: [
{
type: 2,
tag: "pre",
dynamicTag: null,
attrs: {},
on: {},
ref: null,
content: [],
model: null,
ns: null,
},
],
model: null,
ns: null,
});
});
// ---------------------------------------------------------------------------
// t-esc
// ---------------------------------------------------------------------------
+6
View File
@@ -39,4 +39,10 @@ describe("white space handling", () => {
</pre>`;
expect(renderToString(template3)).toBe(template3);
});
test("pre inside a div with a new line", () => {
expect(renderToString(`<div><pre>SomeText</pre>\n</div>`)).toBe(
"<div><pre>SomeText</pre></div>"
);
});
});