diff --git a/packages/compartment-mapper/src/policy.js b/packages/compartment-mapper/src/policy.js index ee2a8fb52d..7306ae7496 100644 --- a/packages/compartment-mapper/src/policy.js +++ b/packages/compartment-mapper/src/policy.js @@ -10,7 +10,9 @@ import { policyLookupHelper, } from './policy-format.js'; -const { create, entries, values, assign, keys, freeze } = Object; +const { create, entries, values, assign, freeze, getOwnPropertyDescriptors } = + Object; +const { ownKeys } = Reflect; const q = JSON.stringify; /** @@ -19,7 +21,9 @@ const q = JSON.stringify; export const ATTENUATORS_COMPARTMENT = ''; /** - * Copies properties (optionally limited to a specific list) from one object to another. + * Copies properties (optionally limited to a specific list) from one object + * to another. By default, copies all enumerable, own, string- and + * symbol-named properties. * * @param {object} from * @param {object} to @@ -28,7 +32,12 @@ export const ATTENUATORS_COMPARTMENT = ''; */ const selectiveCopy = (from, to, list) => { if (!list) { - list = keys(from); + const descs = getOwnPropertyDescriptors(from); + list = ownKeys(from).filter( + key => + // @ts-expect-error TypeScript still confused about a symbol as index + descs[key].enumerable, + ); } for (let index = 0; index < list.length; index += 1) { const key = list[index];