Skip to content

Commit

Permalink
fix: "ownPropertyOnly" not respected when passed via "renderOptions"
Browse files Browse the repository at this point in the history
  • Loading branch information
slavivanov authored and harttle committed Feb 14, 2023
1 parent 24c8a1e commit d489916
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] || {})
Expand Down Expand Up @@ -74,7 +76,7 @@ export class Context {
public * _getFromScope (scope: unknown, paths: PropertyKey[] | string): IterableIterator<unknown> {
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!('.'))
}
Expand Down
File renamed without changes.

0 comments on commit d489916

Please sign in to comment.