lib/watir-webdriver/attribute_helper.rb in watir-webdriver-0.0.9 vs lib/watir-webdriver/attribute_helper.rb in watir-webdriver-0.1.0
- old
+ new
@@ -1,17 +1,17 @@
module Watir
-
+
#
# @private
- #
+ #
# Extended by Element, provides methods for defining attributes on the element classes.
- #
-
+ #
+
module AttributeHelper
-
+
IGNORED_ATTRIBUTES = [:text, :hash]
-
+
def typed_attributes
@typed_attributes ||= Hash.new { |hash, type| hash[type] = [] }
end
def attribute_list
@@ -72,22 +72,23 @@
end
def define_int_attribute(mname, aname)
define_method mname do
assert_exists
- @element.attribute(aname).to_i
+ value = @element.attribute(aname)
+ value && Integer(value)
end
end
def add_attributes(attributes)
attributes.each do |type, attr_list|
typed_attributes[type] += attr_list
end
end
def method_name_for(type, attribute)
- # TODO: rethink this - this list could get pretty long...
+ # http://github.com/jarib/watir-webdriver/issues/issue/26
name = case attribute
when :html_for
'for'
when :col_span
'colspan'
@@ -101,21 +102,27 @@
name
end
def attribute_for_method(method)
+ # http://github.com/jarib/watir-webdriver/issues/issue/26
+
case method.to_sym
when :class_name
'class'
when :html_for
'for'
when :read_only
'readonly'
when :http_equiv
'http-equiv'
+ when :col_span
+ 'colspan'
+ when :row_span
+ 'rowspan'
else
method.to_s
end
end
-
+
end # AttributeHelper
-end # Watir
\ No newline at end of file
+end # Watir