diff --git a/package-lock.json b/package-lock.json index 0013b8fe88..b77955c235 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2586,9 +2586,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001335", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001335.tgz", - "integrity": "sha512-ddP1Tgm7z2iIxu6QTtbZUv6HJxSaV/PZeSrWFZtbY4JZ69tOeNhBCl3HyRQgeNZKE5AOn1kpV7fhljigy0Ty3w==", + "version": "1.0.30001431", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz", + "integrity": "sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==", "dev": true }, "cardinal": { diff --git a/src/context/context.ts b/src/context/context.ts index 0be465e8a4..2b75496c70 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -103,19 +103,19 @@ export class Context { } export function readProperty (obj: Scope, key: PropertyKey, ownPropertyOnly: boolean) { - if (isNil(obj)) return obj obj = toLiquid(obj) + if (isNil(obj)) return obj if (isArray(obj) && key < 0) return obj[obj.length + +key] - const jsProperty = readJSProperty(obj, key, ownPropertyOnly) - if (jsProperty === undefined && obj instanceof Drop) return obj.liquidMethodMissing(key) - if (isFunction(jsProperty)) return jsProperty.call(obj) + const value = readJSProperty(obj, key, ownPropertyOnly) + if (value === undefined && obj instanceof Drop) return obj.liquidMethodMissing(key) + if (isFunction(value)) return value.call(obj) if (key === 'size') return readSize(obj) else if (key === 'first') return readFirst(obj) else if (key === 'last') return readLast(obj) - return jsProperty + return value } export function readJSProperty (obj: Scope, key: PropertyKey, ownPropertyOnly: boolean) { - if (ownPropertyOnly && !Object.hasOwnProperty.call(obj, key)) return undefined + if (ownPropertyOnly && !Object.hasOwnProperty.call(obj, key) && !(obj instanceof Drop)) return undefined return obj[key] } diff --git a/src/liquid-options.ts b/src/liquid-options.ts index 88a16f639d..1be99d6b42 100644 --- a/src/liquid-options.ts +++ b/src/liquid-options.ts @@ -153,7 +153,7 @@ export const defaultOptions: NormalizedFullOptions = { preserveTimezones: false, strictFilters: false, strictVariables: false, - ownPropertyOnly: false, + ownPropertyOnly: true, lenientIf: false, globals: {}, keepOutputType: false,