mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
refactor: drop redundant typeof in blocked key check
Set.has already returns false for non-string PropertyKey values; widen BLOCKED_SCOPE_KEYS type so TypeScript accepts the direct has(key) call. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -155,10 +155,10 @@ export class Context {
|
||||
}
|
||||
}
|
||||
|
||||
const BLOCKED_SCOPE_KEYS = new Set(['__proto__', 'constructor', 'prototype'])
|
||||
const BLOCKED_SCOPE_KEYS: ReadonlySet<PropertyKey> = new Set(['__proto__', 'constructor', 'prototype'])
|
||||
|
||||
export function readJSProperty (obj: Scope, key: PropertyKey, ownPropertyOnly: boolean) {
|
||||
if (typeof key === 'string' && BLOCKED_SCOPE_KEYS.has(key)) {
|
||||
if (BLOCKED_SCOPE_KEYS.has(key)) {
|
||||
if (ownPropertyOnly || !hasOwnProperty.call(obj, key)) return undefined
|
||||
}
|
||||
if (ownPropertyOnly && !hasOwnProperty.call(obj, key) && !(obj instanceof Drop)) return undefined
|
||||
|
||||
Reference in New Issue
Block a user