mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
fix: comparison for empty/nil, fixes #321
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { Drop } from './drop'
|
||||
import { Comparable } from './comparable'
|
||||
import { isObject, isString, isArray } from '../util/underscore'
|
||||
import { isObject, isString, isArray, toValue } from '../util/underscore'
|
||||
|
||||
export class EmptyDrop extends Drop implements Comparable {
|
||||
public equals (value: any) {
|
||||
if (value instanceof EmptyDrop) return false
|
||||
value = toValue(value)
|
||||
if (isString(value) || isArray(value)) return value.length === 0
|
||||
if (isObject(value)) return Object.keys(value).length === 0
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user