class Capybara::Result
def [](*args)
def [](*args) idx, length = args max_idx = case idx when Integer if idx.negative? nil else length.nil? ? idx : idx + length - 1 end when Range # idx.max is broken with beginless ranges # idx.end && idx.max # endless range will have end == nil max = idx.end max = nil if max&.negative? max -= 1 if max && idx.exclude_end? max end if max_idx.nil? full_results[*args] else load_up_to(max_idx + 1) @result_cache[*args] end end