mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
ce9c2f8613
This commit is a significant refactoring of the internal of QWeb. It simplifies the way variables/scoping and slots interact together. The main idea is that we use a simple scope object instead of a context/var/scope object. This commit also implement the actual correct QWeb semantic for the t-call directive with a sub body. Before, we simply extracted the variables from the body and injected them at the top of the sub template. We now simply compile the body before the sub template. This is a joint work with Lucas (lpe). closes #541 closes #544 closes #545 closes #557 closes #556
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
/**
|
|
* We can only make one test per file, since the debug tool modify in place
|
|
* the owl object in a way that is difficult to undo.
|
|
*/
|
|
|
|
import { debugOwl } from "../../tools/debug";
|
|
import * as owl from "../../src/index";
|
|
|
|
import { Component, Env } from "../../src/component/component";
|
|
import { xml } from "../../src/tags";
|
|
import { makeTestFixture, makeTestEnv } from "../helpers";
|
|
|
|
let fixture: HTMLElement = makeTestFixture();
|
|
let env: Env = makeTestEnv();
|
|
Component.env = env;
|
|
|
|
debugOwl(owl, { logScheduler: true });
|
|
|
|
test("log a specific message for render method calls if component is not mounted", async () => {
|
|
const steps: string[] = [];
|
|
const log = console.log;
|
|
console.log = arg => steps.push(arg);
|
|
|
|
class Parent extends Component<any, any> {
|
|
static template = xml`<div><t t-esc="state.value"/></div>`;
|
|
state = owl.hooks.useState({ value: 1 });
|
|
}
|
|
|
|
const parent = new Parent(null, {});
|
|
await parent.mount(fixture);
|
|
parent.unmount();
|
|
parent.state.value = 2;
|
|
|
|
expect(steps).toEqual([
|
|
"[OWL_DEBUG] Parent<id=1> constructor, props={}",
|
|
"[OWL_DEBUG] Parent<id=1> mount",
|
|
"[OWL_DEBUG] Parent<id=1> willStart",
|
|
"[OWL_DEBUG] scheduler: start running tasks queue",
|
|
"[OWL_DEBUG] Parent<id=1> rendering template",
|
|
"[OWL_DEBUG] Parent<id=1> mounted",
|
|
"[OWL_DEBUG] scheduler: stop running tasks queue",
|
|
"[OWL_DEBUG] Parent<id=1> willUnmount",
|
|
"[OWL_DEBUG] Parent<id=1> render (warning: component is not mounted, this render has no effect)"
|
|
]);
|
|
console.log = log;
|
|
});
|