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());
|
console.info(DEV_MSG());
|
||||||
hasBeenLogged = true;
|
hasBeenLogged = true;
|
||||||
}
|
}
|
||||||
const descrs = Object.getOwnPropertyDescriptors(config.env || {});
|
const env = config.env || {};
|
||||||
this.env = Object.freeze(Object.defineProperties({}, descrs)) as E;
|
const descrs = Object.getOwnPropertyDescriptors(env);
|
||||||
|
this.env = Object.freeze(Object.create(Object.getPrototypeOf(env), descrs));
|
||||||
this.props = config.props || ({} as P);
|
this.props = config.props || ({} as P);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,5 +49,7 @@ describe("env handling", () => {
|
|||||||
|
|
||||||
await new App(Test, { env }).mount(fixture);
|
await new App(Test, { env }).mount(fixture);
|
||||||
expect(child.env).toEqual(env);
|
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