refactor: wrap plain scopes in Context.push()

Centralize null-prototype scope creation in push() so callers pass plain objects; Drop instances and existing null-proto frames are pushed as-is. Remove sanitizeScope in favor of createScope via Object.assign.
This commit is contained in:
Yang Jun
2026-07-19 23:42:09 +08:00
parent 812af67022
commit 90ab891c29
9 changed files with 37 additions and 30 deletions
+1 -11
View File
@@ -24,15 +24,5 @@ export function shouldBlockScopeKeyWrite (key: PropertyKey, ownPropertyOnly: boo
}
export function createScope (from?: ScopeObject): ScopeObject {
return from ? sanitizeScope(from) : Object.create(null)
}
export function sanitizeScope (obj: ScopeObject): ScopeObject {
const scope = Object.create(null)
for (const key of Object.keys(obj)) {
if (hasOwnProperty.call(obj, key)) {
scope[key] = obj[key]
}
}
return scope
return Object.assign(Object.create(null), from)
}