fix: clarify blocked key checks in readJSProperty

Split the OR condition into two explicit checks so inherited proto keys are always blocked and own proto keys are blocked only when ownPropertyOnly is true.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Yang Jun
2026-07-23 22:50:10 +08:00
co-authored by Cursor
parent 071c4a3619
commit d32da49925
+2 -1
View File
@@ -159,7 +159,8 @@ const BLOCKED_SCOPE_KEYS: ReadonlySet<PropertyKey> = new Set(['__proto__', 'cons
export function readJSProperty (obj: Scope, key: PropertyKey, ownPropertyOnly: boolean) { export function readJSProperty (obj: Scope, key: PropertyKey, ownPropertyOnly: boolean) {
if (BLOCKED_SCOPE_KEYS.has(key)) { if (BLOCKED_SCOPE_KEYS.has(key)) {
if (ownPropertyOnly || !hasOwnProperty.call(obj, key)) return undefined if (!hasOwnProperty.call(obj, key)) return undefined
if (ownPropertyOnly) return undefined
} }
if (ownPropertyOnly && !hasOwnProperty.call(obj, key) && !(obj instanceof Drop)) return undefined if (ownPropertyOnly && !hasOwnProperty.call(obj, key) && !(obj instanceof Drop)) return undefined
return obj[key] return obj[key]