allow nil to field value
parent
6c2a942809
commit
601a12f1ee
|
@ -1,7 +1,7 @@
|
|||
class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field
|
||||
property :checked
|
||||
|
||||
def initialize(node : Node | Myhtml::Node, value = "")
|
||||
def initialize(node : Node | Myhtml::Node, value = nil)
|
||||
@checked = !!node["checked"]
|
||||
super(node, value)
|
||||
end
|
||||
|
@ -22,4 +22,8 @@ class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field
|
|||
def click
|
||||
checked ? uncheck : check
|
||||
end
|
||||
|
||||
def query_value
|
||||
[@name, @value || "on"]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
class MechanizeCr::FormContent::Field
|
||||
getter :node
|
||||
property value : String
|
||||
property value : String?
|
||||
getter name : String
|
||||
getter type : String
|
||||
getter raw_value : String
|
||||
getter raw_value : String?
|
||||
|
||||
def initialize(node : Node | Myhtml::Node, value = "")
|
||||
def initialize(node : Node | Myhtml::Node, value=nil)
|
||||
@node = node
|
||||
@name = node.fetch("name", "")
|
||||
@value = value || node.fetch("value", "")
|
||||
@value = value || node.fetch("value", nil)
|
||||
@type = node.fetch("type", "")
|
||||
@raw_value = value
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue