add form element comment

master
Kanezoh 2021-11-18 10:12:47 +09:00
parent a70e6eae90
commit fca04b29b9
5 changed files with 14 additions and 4 deletions

View File

@ -8,7 +8,7 @@ require "./form/button"
require "./form/select_list"
require "./utils/element_matcher"
# THis class represents the form tag of html.
# This class represents the form tag of html.
class Mechanize::Form
include Mechanize::ElementMatcher
@ -68,7 +68,7 @@ class Mechanize::Form
elements_with "checkbox", "checkboxes"
elements_with "button"
# Returns all fields of type Textarea
# Returns all fields of <input type="textarea">
def textareas
fields.select { |f| f.class == FormContent::Textarea }.map &.as(FormContent::Textarea)
end

View File

@ -1,7 +1,14 @@
# This class represents <input> elements in the form.
class Mechanize::FormContent::Field
# returns field's 'value' attribute
property value : String?
# returns field's 'name' attribute
getter name : String
# returns field's 'type' attribute
getter type : String
# returns field's 'value' attribute.
# value property is changeable, but this property stores raw value.
getter raw_value : String?
getter node : Node | Lexbor::Node
@ -17,12 +24,12 @@ class Mechanize::FormContent::Field
[@name, @value || ""]
end
# returns DOM 'id' value
# returns field's 'id' value
def dom_id
node.fetch("id", "")
end
# returns DOM 'class' value
# returns field's 'class' value
def dom_class
node.fetch("class", "")
end

View File

@ -1,2 +1,3 @@
# This class represents <input type="hidden">
class Mechanize::FormContent::Hidden < Mechanize::FormContent::Field
end

View File

@ -1,2 +1,3 @@
# This class represents <input type="text">
class Mechanize::FormContent::Text < Mechanize::FormContent::Field
end

View File

@ -1,2 +1,3 @@
# This class represents <input type="textarea">
class Mechanize::FormContent::Textarea < Mechanize::FormContent::Field
end