mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] add browser bindings to standard environment
This could be done by each application, but it does cost only a few lines of code, and it helps standardizing the Owl ecosystem. For example, some library (such as o_spreadsheet) needs to mock side effects, and Odoo also needs to do that, so this prevents duplicated effort. closes #686
This commit is contained in:
@@ -7,6 +7,7 @@ import { Fiber } from "./fiber";
|
||||
import "./props_validation";
|
||||
import { Scheduler, scheduler } from "./scheduler";
|
||||
import { activateSheet } from "./styles";
|
||||
import { Browser, browser } from "../browser";
|
||||
|
||||
/**
|
||||
* Owl Component System
|
||||
@@ -34,6 +35,7 @@ import { activateSheet } from "./styles";
|
||||
*/
|
||||
export interface Env {
|
||||
qweb: QWeb;
|
||||
browser: Browser;
|
||||
}
|
||||
|
||||
export type MountPosition = "first-child" | "last-child" | "self";
|
||||
@@ -157,6 +159,9 @@ export class Component<Props extends {} = any, T extends Env = Env> {
|
||||
if (!this.env.qweb) {
|
||||
this.env.qweb = new QWeb();
|
||||
}
|
||||
if (!this.env.browser) {
|
||||
this.env.browser = browser;
|
||||
}
|
||||
this.env.qweb.on("update", this, () => {
|
||||
if (this.__owl__.isMounted) {
|
||||
this.render(true);
|
||||
|
||||
Reference in New Issue
Block a user