Skip to content

Commit d489916

Browse files
slavivanovharttle
authored andcommitted
fix: "ownPropertyOnly" not respected when passed via "renderOptions"
1 parent 24c8a1e commit d489916

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/context/context.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ export class Context {
3232
* Throw when accessing undefined variable?
3333
*/
3434
public strictVariables: boolean;
35+
public ownPropertyOnly: boolean;
3536
public constructor (env: object = {}, opts: NormalizedFullOptions = defaultOptions, renderOptions: RenderOptions = {}) {
3637
this.sync = !!renderOptions.sync
3738
this.opts = opts
3839
this.globals = renderOptions.globals ?? opts.globals
3940
this.environments = env
4041
this.strictVariables = renderOptions.strictVariables ?? this.opts.strictVariables
42+
this.ownPropertyOnly = renderOptions.ownPropertyOnly ?? opts.ownPropertyOnly
4143
}
4244
public getRegister (key: string) {
4345
return (this.registers[key] = this.registers[key] || {})
@@ -74,7 +76,7 @@ export class Context {
7476
public * _getFromScope (scope: unknown, paths: PropertyKey[] | string): IterableIterator<unknown> {
7577
if (isString(paths)) paths = paths.split('.')
7678
for (let i = 0; i < paths.length; i++) {
77-
scope = yield readProperty(scope as object, paths[i], this.opts.ownPropertyOnly)
79+
scope = yield readProperty(scope as object, paths[i], this.ownPropertyOnly)
7880
if (isNil(scope) && this.strictVariables) {
7981
throw new InternalUndefinedVariableError((paths as string[]).slice(0, i + 1).join!('.'))
8082
}

0 commit comments

Comments
 (0)