mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
refactoring, work on environment
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import { init } from "../../../libs/snabbdom/src/snabbdom";
|
||||
import sdListeners from "../../../libs/snabbdom/src/modules/eventlisteners";
|
||||
import sdAttrs from "../../../libs/snabbdom/src/modules/attributes";
|
||||
import sdListeners from "../../../libs/snabbdom/src/modules/eventlisteners";
|
||||
import { init } from "../../../libs/snabbdom/src/snabbdom";
|
||||
import { VNode } from "../../../libs/snabbdom/src/vnode";
|
||||
import QWeb from "./qweb_vdom";
|
||||
|
||||
const patch = init([sdListeners, sdAttrs]);
|
||||
|
||||
export interface WidgetEnv {
|
||||
export interface WEnv {
|
||||
qweb: QWeb;
|
||||
}
|
||||
|
||||
export default class Widget<T extends WidgetEnv> {
|
||||
export default class Widget<T extends WEnv> {
|
||||
name: string = "widget";
|
||||
template: string = "<div></div>";
|
||||
vnode: VNode | null = null;
|
||||
@@ -49,7 +49,7 @@ export default class Widget<T extends WidgetEnv> {
|
||||
|
||||
async mount(target?: HTMLElement): Promise<VNode> {
|
||||
await this.willStart();
|
||||
this.env!.qweb.addTemplate(this.name, this.template);
|
||||
this.env.qweb.addTemplate(this.name, this.template);
|
||||
delete this.template;
|
||||
const vnode = await this.render();
|
||||
|
||||
|
||||
@@ -640,7 +640,7 @@ const forEachDirective: Directive = {
|
||||
const onDirective: Directive = {
|
||||
name: "on",
|
||||
priority: 90,
|
||||
atNodeCreation({ ctx, fullName, value, nodeID }) {
|
||||
atNodeCreation({ ctx, fullName, value, nodeID, qweb }) {
|
||||
const eventName = fullName.slice(5);
|
||||
let extraArgs;
|
||||
let handler = value.replace(/\(.*\)/, function(args) {
|
||||
@@ -649,7 +649,7 @@ const onDirective: Directive = {
|
||||
});
|
||||
ctx.addLine(
|
||||
`p${nodeID}.on = {${eventName}: context['${handler}'].bind(context${
|
||||
extraArgs ? ", " + extraArgs : ""
|
||||
extraArgs ? ", " + qweb._formatExpression(extraArgs) : ""
|
||||
})}`
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user