mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
snapshot all qweb templates
This commit is contained in:
@@ -224,7 +224,7 @@ export class QWeb {
|
||||
throw new Error(`Template ${name} does not exist`);
|
||||
}
|
||||
const template = this.templates[name] || this._compile(name);
|
||||
return template(context, extra);
|
||||
return template.call(this, context, extra);
|
||||
}
|
||||
|
||||
_compile(name: string): CompiledTemplate<VNode> {
|
||||
@@ -261,7 +261,6 @@ export class QWeb {
|
||||
}\nCompiled code:\n` + template.toString()
|
||||
);
|
||||
}
|
||||
template = template.bind(this);
|
||||
this.templates[name] = template;
|
||||
return template;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,11 @@ function renderToDOM(
|
||||
context: EvalContext = {}
|
||||
): HTMLElement | Text {
|
||||
const vnode = qweb.render(template, context);
|
||||
|
||||
// we snapshot here the compiled code. This is useful to prevent unwanted code
|
||||
// change.
|
||||
expect(qweb.templates[template].toString()).toMatchSnapshot();
|
||||
|
||||
if (vnode.sel === undefined) {
|
||||
return document.createTextNode(vnode.text!);
|
||||
}
|
||||
@@ -647,7 +652,7 @@ describe("t-on", () => {
|
||||
});
|
||||
|
||||
test("can bind handlers with loop variable as argument", () => {
|
||||
expect.assertions(1);
|
||||
expect.assertions(2);
|
||||
qweb.addTemplate(
|
||||
"test",
|
||||
`
|
||||
@@ -664,7 +669,7 @@ describe("t-on", () => {
|
||||
});
|
||||
|
||||
test("handler is bound to proper owner", () => {
|
||||
expect.assertions(1);
|
||||
expect.assertions(2);
|
||||
qweb.addTemplate("test", `<button t-on-click="add">Click</button>`);
|
||||
let owner = {
|
||||
add() {
|
||||
|
||||
Reference in New Issue
Block a user