From a2bfdee1c8588a9042af6b4f49279d0c12b228fb Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Mon, 5 Jul 2021 14:15:05 +0900 Subject: [PATCH] add @mech to page --- src/mechanize.cr | 2 +- src/mechanize/http/agent.cr | 2 +- src/mechanize/page.cr | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mechanize.cr b/src/mechanize.cr index 1b0c3aa..b888b4d 100644 --- a/src/mechanize.cr +++ b/src/mechanize.cr @@ -83,7 +83,7 @@ class Mechanize def parse(uri, response, body) code = response.not_nil!.status_code - MechanizeCr::Page.new(uri, response, body, code) + MechanizeCr::Page.new(uri, response, body, code, self) end def history diff --git a/src/mechanize/http/agent.cr b/src/mechanize/http/agent.cr index 036d6da..6bc12be 100644 --- a/src/mechanize/http/agent.cr +++ b/src/mechanize/http/agent.cr @@ -78,7 +78,7 @@ module MechanizeCr end private def response_parse(response, body, uri) - @context.not_nil!.parse uri, response, body + @context.not_nil!.parse(uri, response, body) end private def add_response_cookies(response, uri, page) diff --git a/src/mechanize/page.cr b/src/mechanize/page.cr index 5ff6760..d4feb97 100644 --- a/src/mechanize/page.cr +++ b/src/mechanize/page.cr @@ -5,7 +5,10 @@ class MechanizeCr::Page < MechanizeCr::File include MechanzeCr::ElementMatcher delegate :css, to: parser - def initialize(uri, response, body, code) + property mech : Mechanize? + + def initialize(uri, response, body, code, mech=nil) + @mech = mech super(uri, response, body, code) end