refactor: encapsulate Drop passthrough in createScope

This commit is contained in:
Yang Jun
2026-07-23 22:37:21 +08:00
parent 78915d1a2e
commit 33e455282d
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ export class Context {
return scope return scope
} }
public push (ctx: Scope): Scope { public push (ctx: Scope): Scope {
const scope = ctx instanceof Drop ? ctx : createScope(ctx) const scope = createScope(ctx)
this.scopes.push(scope) this.scopes.push(scope)
return scope return scope
} }
+2 -1
View File
@@ -6,6 +6,7 @@ export interface ScopeObject extends Record<string | number | symbol, any> {
export type Scope = ScopeObject | Drop export type Scope = ScopeObject | Drop
export function createScope (from?: ScopeObject): ScopeObject { export function createScope (from?: Scope): Scope {
if (from instanceof Drop) return from
return Object.assign(Object.create(null), from) return Object.assign(Object.create(null), from)
} }