mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] qweb: add support for event capture
In this commit, we uses the "!" as suffix to designate an event that should be captured. This is inspired by the Vue source code. This solves the issue of communicating additional information to the underlying virtual dom. However, this will most likely disappear when we rewrite the vdom as a virtual block system. closes #650
This commit is contained in:
@@ -2192,6 +2192,30 @@ describe("other directives with t-component", () => {
|
||||
expect(steps).toEqual(["click"]);
|
||||
});
|
||||
|
||||
test("t-on with .capture modifier", async () => {
|
||||
const steps: string[] = [];
|
||||
|
||||
class Child extends Component {
|
||||
static template = xml`<div><span t-on-click="click">hey</span></div>`;
|
||||
click() {
|
||||
steps.push("click");
|
||||
}
|
||||
}
|
||||
class ParentWidget extends Component {
|
||||
static components = { Child };
|
||||
static template = xml`<div><Child t-on-click.capture="capture"/></div>`;
|
||||
capture() {
|
||||
steps.push("captured");
|
||||
}
|
||||
}
|
||||
const widget = new ParentWidget();
|
||||
await widget.mount(fixture);
|
||||
|
||||
fixture.querySelector("span")!.click();
|
||||
expect(env.qweb.templates[ParentWidget.template].fn.toString()).toMatchSnapshot();
|
||||
expect(steps).toEqual(["captured", "click"]);
|
||||
});
|
||||
|
||||
test("t-on on destroyed components", async () => {
|
||||
const steps: string[] = [];
|
||||
let child;
|
||||
|
||||
Reference in New Issue
Block a user