From 5f04e341087c706f7666b8b41a7cd18bec163650 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 17 Jun 2022 18:40:07 +0200 Subject: [PATCH] lib: fix TODO in `freeze_intrinsics` --- lib/internal/freeze_intrinsics.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index cb1d28f4b0feb4..508b071c7c0f88 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -428,16 +428,8 @@ module.exports = function() { const descs = ObjectGetOwnPropertyDescriptors(obj); enqueue(proto); ArrayPrototypeForEach(ReflectOwnKeys(descs), (name) => { - // TODO: Uncurried form - // TODO: getOwnPropertyDescriptors is guaranteed to return well-formed - // descriptors, but they still inherit from Object.prototype. If - // someone has poisoned Object.prototype to add 'value' or 'get' - // properties, then a simple 'if ("value" in desc)' or 'desc.value' - // test could be confused. We use hasOwnProperty to be sure about - // whether 'value' is present or not, which tells us for sure that - // this is a data property. const desc = descs[name]; - if ('value' in desc) { + if (ObjectPrototypeHasOwnProperty(desc, 'value')) { // todo uncurried form enqueue(desc.value); } else { @@ -489,7 +481,7 @@ module.exports = function() { * objects succeed if otherwise possible. */ function enableDerivedOverride(obj, prop, desc) { - if ('value' in desc && desc.configurable) { + if (ObjectPrototypeHasOwnProperty(desc, 'value') && desc.configurable) { const value = desc.value; function getter() {