From eec62fade21c09146130ddfb861bbe4efd3e43e9 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Wed, 16 Jun 2021 23:30:34 +0900 Subject: [PATCH] add form property to checkbox --- src/mechanize/form.cr | 2 +- src/mechanize/form/check_box.cr | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mechanize/form.cr b/src/mechanize/form.cr index c5670fc..aebab19 100644 --- a/src/mechanize/form.cr +++ b/src/mechanize/form.cr @@ -61,7 +61,7 @@ class MechanizeCr::Form type = (html_node["type"] || "text").downcase case type when "checkbox" - @checkboxes << MechanizeCr::FormContent::CheckBox.new(html_node) + @checkboxes << MechanizeCr::FormContent::CheckBox.new(html_node, self) else @fields << MechanizeCr::FormContent::Field.new(html_node) end diff --git a/src/mechanize/form/check_box.cr b/src/mechanize/form/check_box.cr index fb5b897..c9607d6 100644 --- a/src/mechanize/form/check_box.cr +++ b/src/mechanize/form/check_box.cr @@ -1,9 +1,10 @@ class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field - property :checked + property :checked, :form - def initialize(node : Node | Myhtml::Node, value = nil) + def initialize(node : Node | Myhtml::Node, form : MechanizeCr::Form) @checked = !!node["checked"] - super(node, value) + @form = form + super(node) end def check