diff --git a/src/vdom/html_to_vdom.ts b/src/vdom/html_to_vdom.ts index a7a56209..c8a3c17a 100644 --- a/src/vdom/html_to_vdom.ts +++ b/src/vdom/html_to_vdom.ts @@ -13,6 +13,9 @@ export function htmlToVDOM(html: string): VNode[] { function htmlToVNode(node: ChildNode): VNode { if (!(node instanceof Element)) { + if (node instanceof Comment) { + return h("!", node.textContent); + } return { text: node.textContent! } as VNode; } const attrs = {}; diff --git a/tests/qweb/__snapshots__/qweb.test.ts.snap b/tests/qweb/__snapshots__/qweb.test.ts.snap index f355c401..cf4009a7 100644 --- a/tests/qweb/__snapshots__/qweb.test.ts.snap +++ b/tests/qweb/__snapshots__/qweb.test.ts.snap @@ -3148,6 +3148,23 @@ exports[`t-raw t-raw and another sibling node 1`] = ` }" `; +exports[`t-raw t-raw with comment 1`] = ` +"function anonymous(context, extra +) { + // Template name: \\"test\\" + let utils = this.constructor.utils; + let scope = Object.create(context); + let h = this.h; + let c1 = [], p1 = {key:1}; + let vn1 = h('span', p1, c1); + let _2 = scope['var']; + if (_2 != null) { + c1.push(...utils.htmlToVDOM(_2)); + } + return vn1; +}" +`; + exports[`t-raw variable 1`] = ` "function anonymous(context, extra ) { diff --git a/tests/qweb/qweb.test.ts b/tests/qweb/qweb.test.ts index 9d3e591a..95c0d2c6 100644 --- a/tests/qweb/qweb.test.ts +++ b/tests/qweb/qweb.test.ts @@ -238,6 +238,13 @@ describe("t-raw", () => { "helloworld" ); }); + + test("t-raw with comment", () => { + qweb.addTemplate("test", ``); + expect(renderToString(qweb, "test", { var: "

text

" })).toBe( + "

text

" + ); + }); }); describe("t-set", () => {