mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] app: make sure we maintain the correct prototype chain in env
This commit is contained in:
+3
-2
@@ -52,8 +52,9 @@ export class App<
|
||||
console.info(DEV_MSG());
|
||||
hasBeenLogged = true;
|
||||
}
|
||||
const descrs = Object.getOwnPropertyDescriptors(config.env || {});
|
||||
this.env = Object.freeze(Object.defineProperties({}, descrs)) as E;
|
||||
const env = config.env || {};
|
||||
const descrs = Object.getOwnPropertyDescriptors(env);
|
||||
this.env = Object.freeze(Object.create(Object.getPrototypeOf(env), descrs));
|
||||
this.props = config.props || ({} as P);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,5 +49,7 @@ describe("env handling", () => {
|
||||
|
||||
await new App(Test, { env }).mount(fixture);
|
||||
expect(child.env).toEqual(env);
|
||||
// we check that the frozen env maintain the same prototype chain
|
||||
expect(Object.getPrototypeOf(child.env)).toBe(Object.getPrototypeOf(env));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user