mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: do not leak values in global context in rare cases
In some very rare cases (such as the use of the t-foreach directive), Owl did leak the values in the render context in the global context. This was due to the fact that the compiled template looked like this: let _3 = _4 = _5; instead of let _3 = _5; let _4 = _5;
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { QWeb } from "../../src/qweb/index";
|
||||
import { renderToString } from "../helpers";
|
||||
|
||||
describe("memory", () => {
|
||||
test("t-foreach does not leak stuff in global scope", () => {
|
||||
let qweb = new QWeb();
|
||||
const initialNumberOfGlobals = Object.keys(window).length;
|
||||
qweb.addTemplate(
|
||||
"test",
|
||||
`<p><t t-foreach="[3, 2, 1]" t-as="item"><t t-esc="item"/></t></p>`
|
||||
);
|
||||
const result = renderToString(qweb, "test");
|
||||
const expected = `<p>321</p>`;
|
||||
expect(result).toBe(expected);
|
||||
expect(Object.keys(window).length).toBe(initialNumberOfGlobals);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user