mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
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:
@@ -94,8 +94,14 @@ export class Context {
|
||||
}
|
||||
return scope
|
||||
}
|
||||
public push (ctx: object) {
|
||||
return this.scopes.push(ctx)
|
||||
public push (ctx: Scope): Scope {
|
||||
const scope = ctx instanceof Drop
|
||||
? ctx
|
||||
: Object.getPrototypeOf(ctx) === null
|
||||
? ctx
|
||||
: createScope(ctx)
|
||||
this.scopes.push(scope)
|
||||
return scope
|
||||
}
|
||||
public pop () {
|
||||
return this.scopes.pop()
|
||||
|
||||
Reference in New Issue
Block a user