mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Revert "Always stringify properties in all array filters (#1936)"
This reverts commit aa1640035f.
This commit is contained in:
@@ -386,7 +386,6 @@ module Liquid
|
|||||||
end
|
end
|
||||||
elsif ary.all? { |el| el.respond_to?(:[]) }
|
elsif ary.all? { |el| el.respond_to?(:[]) }
|
||||||
begin
|
begin
|
||||||
property = Utils.to_s(property)
|
|
||||||
ary.sort { |a, b| nil_safe_compare(a[property], b[property]) }
|
ary.sort { |a, b| nil_safe_compare(a[property], b[property]) }
|
||||||
rescue TypeError
|
rescue TypeError
|
||||||
raise_property_error(property)
|
raise_property_error(property)
|
||||||
@@ -416,7 +415,6 @@ module Liquid
|
|||||||
end
|
end
|
||||||
elsif ary.all? { |el| el.respond_to?(:[]) }
|
elsif ary.all? { |el| el.respond_to?(:[]) }
|
||||||
begin
|
begin
|
||||||
property = Utils.to_s(property)
|
|
||||||
ary.sort { |a, b| nil_safe_casecmp(a[property], b[property]) }
|
ary.sort { |a, b| nil_safe_casecmp(a[property], b[property]) }
|
||||||
rescue TypeError
|
rescue TypeError
|
||||||
raise_property_error(property)
|
raise_property_error(property)
|
||||||
@@ -504,7 +502,6 @@ module Liquid
|
|||||||
elsif ary.empty? # The next two cases assume a non-empty array.
|
elsif ary.empty? # The next two cases assume a non-empty array.
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
property = Utils.to_s(property)
|
|
||||||
ary.uniq do |item|
|
ary.uniq do |item|
|
||||||
item[property]
|
item[property]
|
||||||
rescue TypeError
|
rescue TypeError
|
||||||
@@ -536,11 +533,6 @@ module Liquid
|
|||||||
# @liquid_syntax array | map: string
|
# @liquid_syntax array | map: string
|
||||||
# @liquid_return [array[untyped]]
|
# @liquid_return [array[untyped]]
|
||||||
def map(input, property)
|
def map(input, property)
|
||||||
property = Utils.to_s(property)
|
|
||||||
|
|
||||||
# Return the input array if property is empty (no-op)
|
|
||||||
return InputIterator.new(input, context).to_a if property.empty?
|
|
||||||
|
|
||||||
InputIterator.new(input, context).map do |e|
|
InputIterator.new(input, context).map do |e|
|
||||||
e = e.call if e.is_a?(Proc)
|
e = e.call if e.is_a?(Proc)
|
||||||
|
|
||||||
@@ -570,7 +562,6 @@ module Liquid
|
|||||||
elsif ary.empty? # The next two cases assume a non-empty array.
|
elsif ary.empty? # The next two cases assume a non-empty array.
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
property = Liquid::Utils.to_s(property)
|
|
||||||
ary.reject do |item|
|
ary.reject do |item|
|
||||||
item[property].nil?
|
item[property].nil?
|
||||||
rescue TypeError
|
rescue TypeError
|
||||||
@@ -960,8 +951,6 @@ module Liquid
|
|||||||
# @liquid_syntax array | sum
|
# @liquid_syntax array | sum
|
||||||
# @liquid_return [number]
|
# @liquid_return [number]
|
||||||
def sum(input, property = nil)
|
def sum(input, property = nil)
|
||||||
property = property.nil? ? nil : Utils.to_s(property)
|
|
||||||
|
|
||||||
ary = InputIterator.new(input, context)
|
ary = InputIterator.new(input, context)
|
||||||
return 0 if ary.empty?
|
return 0 if ary.empty?
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
VERSION = "5.8.4"
|
VERSION = "5.8.5"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user