mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
1ae9d514b9
With this commit, component only render child components if they have different props (shallow equality). Otherwise, we trust the reactivity system to make sure that all impacted components are updated
43 lines
955 B
TypeScript
43 lines
955 B
TypeScript
import type { ComponentNode } from "./component_node";
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Component Class
|
|
// -----------------------------------------------------------------------------
|
|
|
|
type Props = { [key: string]: any };
|
|
|
|
interface StaticComponentProperties {
|
|
template: string;
|
|
defaultProps?: any;
|
|
props?: any;
|
|
}
|
|
|
|
export type ComponentConstructor<P extends Props = any, E = any> = (new (
|
|
props: P,
|
|
env: E,
|
|
node: ComponentNode
|
|
) => Component<P, E>) &
|
|
StaticComponentProperties;
|
|
|
|
export class Component<Props = any, Env = any> {
|
|
static template: string = "";
|
|
static props?: any;
|
|
static defaultProps?: any;
|
|
|
|
props: Props;
|
|
env: Env;
|
|
__owl__: ComponentNode;
|
|
|
|
constructor(props: Props, env: Env, node: ComponentNode) {
|
|
this.props = props;
|
|
this.env = env;
|
|
this.__owl__ = node;
|
|
}
|
|
|
|
setup() {}
|
|
|
|
render(deep: boolean = false) {
|
|
this.__owl__.render(deep);
|
|
}
|
|
}
|