diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts
index 63ac828b..ebe5f0e4 100644
--- a/src/compiler/parser.ts
+++ b/src/compiler/parser.ts
@@ -298,6 +298,7 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
if (tagName === "t" && !dynamicTag) {
return null;
}
+ ctx = Object.assign({}, ctx);
const children: AST[] = [];
if (tagName === "pre") {
ctx.inPreTag = true;
diff --git a/tests/compiler/__snapshots__/white_space.test.ts.snap b/tests/compiler/__snapshots__/white_space.test.ts.snap
index 9f5a8249..974e8adc 100644
--- a/tests/compiler/__snapshots__/white_space.test.ts.snap
+++ b/tests/compiler/__snapshots__/white_space.test.ts.snap
@@ -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(\`
\`);
+
+ 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
) {
diff --git a/tests/compiler/parser.test.ts b/tests/compiler/parser.test.ts
index 9f1d102a..366d044b 100644
--- a/tests/compiler/parser.test.ts
+++ b/tests/compiler/parser.test.ts
@@ -255,6 +255,32 @@ describe("qweb parser", () => {
});
});
+ test("pre dom node with new line", async () => {
+ expect(parse(``)).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
// ---------------------------------------------------------------------------
diff --git a/tests/compiler/white_space.test.ts b/tests/compiler/white_space.test.ts
index 1fdf096d..44f2b95e 100644
--- a/tests/compiler/white_space.test.ts
+++ b/tests/compiler/white_space.test.ts
@@ -39,4 +39,10 @@ describe("white space handling", () => {
`;
expect(renderToString(template3)).toBe(template3);
});
+
+ test("pre inside a div with a new line", () => {
+ expect(renderToString(``)).toBe(
+ ""
+ );
+ });
});