mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 05:10:40 -07:00
refactor: remove createScope helper
Drop the exported helper and finish migrating call sites. Revert incidental context/for/include/layout churn so behavior matches mainline aside from the removal. Trim duplicate e2e and heavy Object.prototype loops in registry tests. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -61,19 +61,9 @@ describe('liquid#registerFilter()', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('filter registry storage', () => {
|
||||
it('should use a null-prototype map for filters', () => {
|
||||
expect(Object.getPrototypeOf(liquid.filters)).toBeNull()
|
||||
})
|
||||
it('should treat Object.prototype keys as unregistered unless explicitly registered', async () => {
|
||||
const registered = new Set(Object.keys(liquid.filters))
|
||||
const strict = new Liquid({ strictFilters: true })
|
||||
for (const name of Object.getOwnPropertyNames(Object.prototype)) {
|
||||
if (registered.has(name)) continue
|
||||
const out = await liquid.parseAndRender(`{{ x | ${name} }}`, { x: 42 })
|
||||
expect(out).toBe('42')
|
||||
await expect(strict.parseAndRender(`{{ 1 | ${name} }}`)).rejects.toThrow('undefined filter')
|
||||
}
|
||||
})
|
||||
it('should not treat Object.prototype names as registered filters', async () => {
|
||||
expect(Object.getPrototypeOf(liquid.filters)).toBeNull()
|
||||
await expect(liquid.parseAndRender('{{ x | constructor }}', { x: 42 })).resolves.toBe('42')
|
||||
await expect(new Liquid({ strictFilters: true }).parseAndRender('{{ 1 | constructor }}')).rejects.toThrow('undefined filter')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -39,17 +39,9 @@ describe('liquid#registerTag()', function () {
|
||||
return expect(html).toBe('ABC')
|
||||
})
|
||||
|
||||
describe('tag registry storage', () => {
|
||||
it('should use a null-prototype map for tags', () => {
|
||||
expect(Object.getPrototypeOf(new Liquid().tags)).toBeNull()
|
||||
})
|
||||
it('should not resolve names that exist only on Object.prototype', () => {
|
||||
const l = new Liquid()
|
||||
const registered = new Set(Object.keys(l.tags))
|
||||
for (const name of Object.getOwnPropertyNames(Object.prototype)) {
|
||||
if (registered.has(name)) continue
|
||||
expect(() => l.parse(`{% ${name} %}`)).toThrow(`tag "${name}" not found`)
|
||||
}
|
||||
})
|
||||
it('should not treat Object.prototype names as registered tags', () => {
|
||||
const l = new Liquid()
|
||||
expect(Object.getPrototypeOf(l.tags)).toBeNull()
|
||||
expect(() => l.parse('{% constructor %}')).toThrow('tag "constructor" not found')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user