mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 00:55:13 -07:00
refactor: encapsulate Drop passthrough in createScope
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user