mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] owl: mount util now takes an AppConfig
This commit is contained in:
+2
-2
@@ -10,7 +10,7 @@ export interface Env {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Config {
|
export interface AppConfig {
|
||||||
dev?: boolean;
|
dev?: boolean;
|
||||||
env?: Env;
|
env?: Env;
|
||||||
translatableAttributes?: string[];
|
translatableAttributes?: string[];
|
||||||
@@ -35,7 +35,7 @@ export class App<T extends typeof Component = any> extends TemplateSet {
|
|||||||
this.props = props;
|
this.props = props;
|
||||||
}
|
}
|
||||||
|
|
||||||
configure(config: Config): App<T> {
|
configure(config: AppConfig): App<T> {
|
||||||
if (config.dev) {
|
if (config.dev) {
|
||||||
this.dev = config.dev;
|
this.dev = config.dev;
|
||||||
console.info(DEV_MSG);
|
console.info(DEV_MSG);
|
||||||
|
|||||||
+4
-2
@@ -31,6 +31,7 @@ export const blockDom = {
|
|||||||
html,
|
html,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
import type { AppConfig } from "./app/app";
|
||||||
import { App } from "./app/app";
|
import { App } from "./app/app";
|
||||||
import { Component } from "./component/component";
|
import { Component } from "./component/component";
|
||||||
import { getCurrent } from "./component/component_node";
|
import { getCurrent } from "./component/component_node";
|
||||||
@@ -39,10 +40,11 @@ export { App, Component };
|
|||||||
|
|
||||||
export async function mount<T extends typeof Component>(
|
export async function mount<T extends typeof Component>(
|
||||||
C: T,
|
C: T,
|
||||||
target: HTMLElement
|
target: HTMLElement,
|
||||||
|
config: AppConfig = {}
|
||||||
): Promise<InstanceType<T>> {
|
): Promise<InstanceType<T>> {
|
||||||
const app = new App(C);
|
const app = new App(C);
|
||||||
return app.mount(target);
|
return app.configure(config).mount(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useComponent(): Component {
|
export function useComponent(): Component {
|
||||||
|
|||||||
Reference in New Issue
Block a user