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