mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 05:10:40 -07:00
fix(context): use null-prototype scope and register objects
Add createScope(); use for bottom scope, spawn default, getAll merge, ctx.push frames, filter loops, include/layout blocks registers, and cycle groups. registers uses Object.create(null) and getRegister uses ??.
For-loop continue register defaults to 0 (not {}): Array.slice coerces plain {} but not null-prototype objects.
Export createScope from the package entry.
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -216,4 +216,12 @@ describe('Context', function () {
|
||||
expect(ctx.getSync(['foo'])).toEqual('zoo')
|
||||
})
|
||||
})
|
||||
describe('scope storage', function () {
|
||||
it('should use null prototype for bottom scope', function () {
|
||||
expect(Object.getPrototypeOf(new Context().bottom())).toBeNull()
|
||||
})
|
||||
it('should use null prototype for getAll() merge result', function () {
|
||||
expect(Object.getPrototypeOf(new Context({ a: 1 }).getAll())).toBeNull()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user