mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] parser: correctly parse pre node within a div with new lines
This commit is contained in:
committed by
Géry Debongnie
parent
247200194f
commit
c8db663869
@@ -298,6 +298,7 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
if (tagName === "t" && !dynamicTag) {
|
if (tagName === "t" && !dynamicTag) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
ctx = Object.assign({}, ctx);
|
||||||
const children: AST[] = [];
|
const children: AST[] = [];
|
||||||
if (tagName === "pre") {
|
if (tagName === "pre") {
|
||||||
ctx.inPreTag = true;
|
ctx.inPreTag = true;
|
||||||
|
|||||||
@@ -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`] = `
|
exports[`white space handling white space only text nodes are condensed into a single space 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -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
|
// t-esc
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -39,4 +39,10 @@ describe("white space handling", () => {
|
|||||||
</pre>`;
|
</pre>`;
|
||||||
expect(renderToString(template3)).toBe(template3);
|
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>"
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user