Permalink
Browse files

Collection#[] returns always an object, even if the index is out of b…

…ounds
  • Loading branch information...
1 parent 3c0f218 commit d3d05792b5211fcdcc579dbd02930595476af5d7 @jarmo jarmo committed Jan 7, 2012
Showing with 1 addition and 6 deletions.
  1. +1 −6 watir/lib/watir/element_collections.rb
@@ -37,12 +37,7 @@ def each
def [](n)
number = n - Watir::IE.base_index
offset = Watir::IE.zero_based_indexing ? (length - 1) : length
-
- unless number.abs.between?(0, offset)
- raise Exception::MissingWayOfFindingObjectException,
- "Can't find #{element_tag.downcase} with :index #{n} from #{self.class} with size of #{length}"
- end
- return iterator_object(number)
+ iterator_object(number) || element_class.new(@container, :index, n)
end
def first

0 comments on commit d3d0579

Please sign in to comment.