From d489916231779149e110183400e3e597b8ee02ba Mon Sep 17 00:00:00 2001 From: Slav Ivanov Date: Thu, 19 Jan 2023 11:07:28 +0200 Subject: [PATCH] fix: "ownPropertyOnly" not respected when passed via "renderOptions" --- src/context/context.ts | 4 +++- test/integration/liquid/{outputEscape.ts => output-escape.ts} | 0 2 files changed, 3 insertions(+), 1 deletion(-) rename test/integration/liquid/{outputEscape.ts => output-escape.ts} (100%) diff --git a/src/context/context.ts b/src/context/context.ts index 7339870be..91eb3c9f2 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -32,12 +32,14 @@ export class Context { * Throw when accessing undefined variable? */ public strictVariables: boolean; + public ownPropertyOnly: boolean; public constructor (env: object = {}, opts: NormalizedFullOptions = defaultOptions, renderOptions: RenderOptions = {}) { this.sync = !!renderOptions.sync this.opts = opts this.globals = renderOptions.globals ?? opts.globals this.environments = env this.strictVariables = renderOptions.strictVariables ?? this.opts.strictVariables + this.ownPropertyOnly = renderOptions.ownPropertyOnly ?? opts.ownPropertyOnly } public getRegister (key: string) { return (this.registers[key] = this.registers[key] || {}) @@ -74,7 +76,7 @@ export class Context { public * _getFromScope (scope: unknown, paths: PropertyKey[] | string): IterableIterator { if (isString(paths)) paths = paths.split('.') for (let i = 0; i < paths.length; i++) { - scope = yield readProperty(scope as object, paths[i], this.opts.ownPropertyOnly) + scope = yield readProperty(scope as object, paths[i], this.ownPropertyOnly) if (isNil(scope) && this.strictVariables) { throw new InternalUndefinedVariableError((paths as string[]).slice(0, i + 1).join!('.')) } diff --git a/test/integration/liquid/outputEscape.ts b/test/integration/liquid/output-escape.ts similarity index 100% rename from test/integration/liquid/outputEscape.ts rename to test/integration/liquid/output-escape.ts