lib/glimmer/data_binding/observable_array.rb in glimmer-2.4.0 vs lib/glimmer/data_binding/observable_array.rb in glimmer-2.4.1

- old
+ new

@@ -50,10 +50,14 @@ element_properties = args element_properties = element_properties.flatten.compact.uniq return observer if has_observer?(observer) && has_observer_element_properties?(observer, element_properties) property_observer_list << observer observer_element_properties[observer] = element_properties_for(observer) + Concurrent::Set.new(element_properties) + if !options.empty? && options[:recursive].is_a?(Integer) + options = options.clone + options[:recursive] = options[:recursive] - 1 + end each { |element| add_element_observer(element, observer, options) } observer end def add_element_observers(element, options = {}) @@ -64,10 +68,12 @@ def add_element_observer(element, observer, options = {}) element_properties_for(observer).each do |property| observer.observe(element, property, options) end - ensure_array_object_observer(element, options) if options[:recursive] && element.is_a?(Array) + if element.is_a?(Array) && (options[:recursive] == true || (options[:recursive].is_a?(Integer) && options[:recursive] >= 0)) + ensure_array_object_observer(element, options) + end end def ensure_array_object_observer(object, options) return unless object&.is_a?(Array) array_object_observer = array_object_observer_for(object)