From 93b8151abdd2d5d14c22517fb398a2af02eeba7b Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Sat, 19 Jun 2021 06:42:44 +0900 Subject: [PATCH] fix raw_value --- spec/form/field_spec.cr | 4 +++- src/mechanize/form/field.cr | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/form/field_spec.cr b/spec/form/field_spec.cr index 7079e52..26365f1 100644 --- a/spec/form/field_spec.cr +++ b/spec/form/field_spec.cr @@ -8,7 +8,7 @@ WebMock.stub(:get, "example.com/form/fields").to_return(body:
- +
@@ -24,5 +24,7 @@ describe "Form Fields" do field = form.fields.first field.type.should eq "text" field.name.should eq "name" + field.value.should eq "kanezoh" + field.raw_value.should eq "kanezoh" end end diff --git a/src/mechanize/form/field.cr b/src/mechanize/form/field.cr index bcff113..7ecd22f 100644 --- a/src/mechanize/form/field.cr +++ b/src/mechanize/form/field.cr @@ -10,10 +10,20 @@ class MechanizeCr::FormContent::Field @name = node.fetch("name", "") @value = value || node.fetch("value", nil) @type = node.fetch("type", "") - @raw_value = value + @raw_value = @value end def query_value [@name, @value || ""] end + + # returns DOM 'id' value + def dom_id + node.fetch("id", "") + end + + # returns DOM 'class' value + def dom_class + node.fetch("class", "") + end end