mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] env: env is now frozen, useSubEnv does not affect user env
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { Env } from "../app/app";
|
||||
import type { ComponentNode } from "./component_node";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -9,10 +10,10 @@ export class Component {
|
||||
static style: string = "";
|
||||
|
||||
props: any;
|
||||
env: any;
|
||||
env: Env;
|
||||
__owl__: ComponentNode;
|
||||
|
||||
constructor(props: any, env: any, node: ComponentNode) {
|
||||
constructor(props: any, env: Env, node: ComponentNode) {
|
||||
this.props = props;
|
||||
this.env = env;
|
||||
this.__owl__ = node;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { App } from "../app/app";
|
||||
import type { App, Env } from "../app/app";
|
||||
import { BDom, VNode } from "../blockdom";
|
||||
import { Component } from "./component";
|
||||
import {
|
||||
@@ -83,6 +83,7 @@ export class ComponentNode<T extends typeof Component = any> implements VNode<Co
|
||||
renderFn: Function;
|
||||
parent: ComponentNode | null;
|
||||
level: number;
|
||||
childEnv: Env;
|
||||
children: { [key: string]: ComponentNode } = Object.create(null);
|
||||
slots: any = {};
|
||||
refs: any = {};
|
||||
@@ -101,7 +102,9 @@ export class ComponentNode<T extends typeof Component = any> implements VNode<Co
|
||||
this.parent = parent || null;
|
||||
this.level = parent ? parent.level + 1 : 0;
|
||||
applyDefaultProps(props, C);
|
||||
this.component = new C(props, app.env, this) as any;
|
||||
const env = (parent && parent.childEnv) || app.env;
|
||||
this.childEnv = env;
|
||||
this.component = new C(props, env, this) as any;
|
||||
this.renderFn = app.getTemplate(C.template).bind(this.component, this.component, this);
|
||||
if (C.style) {
|
||||
applyStyles(C);
|
||||
|
||||
Reference in New Issue
Block a user