mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] hooks: useSubEnv supports arbitrary descriptors in env
Before this commit, when defining a getter in the env passed to useSubEnv, the value was read, losing the definition of the property. After this commit, declaring a getter in the env works as expected: the property stays a getter.
This commit is contained in:
committed by
Aaron Bohy
parent
b66d5231d3
commit
463eb4bb86
+3
-1
@@ -38,7 +38,9 @@ export function useEnv<E extends Env>(): E {
|
||||
*/
|
||||
export function useSubEnv(envExtension: Env) {
|
||||
const node = getCurrent()!;
|
||||
node.childEnv = Object.freeze(Object.assign({}, node.childEnv, envExtension));
|
||||
const env = Object.create(node.childEnv);
|
||||
const descrs = Object.getOwnPropertyDescriptors(envExtension);
|
||||
node.childEnv = Object.freeze(Object.defineProperties(env, descrs));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user